Attach promo code
Attach promo code
Description
Attaches a promotion code to a profile.
If a "code"
parameter is specified, it will be used for promo code matching.
- If the code is already attached and its multiple usage is restricted, an error will occur.
- If a code is found unattached — it will be attached.
- If a code is not found — it will be imported and attached.
With no "code"
parameter loyalty program ID will be used for matching.
- If there are promo codes available in a loyalty program — one will be attached.
Request URL
Method: POST
https://example.com/api/v1.1/promocodes/attach
Request parameters
Parameter | Type | Example | Required | Description |
---|---|---|---|---|
token | string | "abcdefghijklmnqrstuvwxyz" | Yes | API token |
code | string | "CODE-12345" | No | Promo code |
db_id | int | 1 | Yes | Database ID |
string | "john@example.com" | No | Email address | |
format | string | "json" | No | Response data format. By default – json |
field_name | string | No | Custom database field for profile matching | |
field_value | string | No | Custom field value | |
matching | string | "profile_id" "email" "phone" "custom" | No | Profiles matching mode |
loyalty_id | int | 1 | Yes | Loyalty program ID |
phone | string | "+79000000000" | No | Phone number |
profile_id | string | "abcdefghijklmnqrstuvwxyz" | No | Profile ID |
Request example
- JSON
- XML
{
"token": "abcdefghijklmnqrstuvwxyz",
"db_id": 1,
"matching": "profile_id",
"profile_id": "abcdefghijklmnqrstuvwxyz",
"loyalty_id": 5,
"code": "CODE-1"
}
<xml>
<token>abcdefghijklmnqrstuvwxyz</token>
<db_id>1</db_id>
<matching>profile_id</matching>
<profile_id>abcdefghijklmnqrstuvwxyz</profile_id>
<loyalty_id>5</loyalty_id>
<code>CODE-1</code>
</xml>
Response example
- JSON
- XML
{
"data": null,
"error": 0,
"error_text": "Successful operation"
}
<xml>
<data></data>
<error>0</error>
<error_text>Successful operation</error_text>
</xml>
Response parameters
Parameter | Type | Description |
---|---|---|
error | int | Error code |
error_text | string | Error text |