Skip to main content

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

ParameterTypeExampleRequiredDescription
tokenstring"abcdefghijklmnqrstuvwxyz"YesAPI token
codestring"CODE-12345"NoPromo code
db_idint1YesDatabase ID
emailstring"john@example.com"NoEmail address
formatstring"json"NoResponse data format.
By default – json
field_namestring
NoCustom database field for profile matching
field_valuestring
NoCustom field value
matchingstring"profile_id"
"email"
"phone"
"custom"
NoProfiles matching mode
loyalty_idint1YesLoyalty program ID
phonestring"+79000000000"NoPhone number
profile_idstring"abcdefghijklmnqrstuvwxyz"NoProfile ID

Request example

{
"code": "CODE-12345",
"db_id": 1,
"loyalty_id": 1,
"profile_id": "abcdefghijklmnqrstuvwxyz",
"token": "abcdefghijklmnqrstuvwxyz"
}

Response example

{
"data": null,
"error": 0,
"error_text": "Successful operation"
}

Response parameters

ParameterTypeDescription
errorintError code
error_textstringError text