Create Promotion Codes
Makes a batch of codes on a code promotion: each code is the prefix and a random suffix, with its own limit of uses.
What the request needs
- The account comes from the
X-Account-Codeheader. The promotion must belong to that account. Without the header the answer is400 INVALID_PARAMETERS. X-Idempotency-Keyis required. It is any text of 1 to 64 characters. The same key on the same promotion returns the first batch with201, and Yuno does not compare the body.- The promotion id is a UUID v4 in the path. An id that is not one answers
400 INVALID_PARAMETERS. An id that is not on the account answers404 PROMOTION_NOT_FOUND. quantityis required, a whole number from 1 to 1000.prefixis required, 1 to 8 letters or digits.uses_per_codeis optional, a whole number from 1 to 1000000, and each code accepts one payment without it.- A full code is refused. A body with a
codeanswers400 INVALID_REQUESTwithcode: NOT_ALLOWED. Yuno makes every code of the batch. - The body is at most 256 KiB. A larger body answers
413 REQUEST_ENTITY_TOO_LARGE.
What the answer holds
201 returns the batch: batch_id, promotion_id, quantity and codes. Each entry of codes holds the code and its uses_per_code. The suffix of each code is 5 characters for up to 28 codes, 6 characters for 29 to 887 codes, and 7 characters for 888 to 1000 codes.
The codes come back only in this answer and in List Promotion Codes. Keep them secret. Yuno does not write them to its logs.
Errors
Two kinds of400 exist, as for Create Promotion. INVALID_PARAMETERS comes from the headers, the path and the check of the body as an object. INVALID_REQUEST comes from the rules of the batch: quantity, uses_per_code, prefix and code, with one path: RULE message for each failed path. A promotion that can’t hold a batch answers 422 PROMOTION_NOT_APPLICABLE with a reason. Promotion Error Codes lists every answer.Authorizations
Headers
The account_id found in your Yuno Dashboard (UUID). Required. A promotion belongs to one account, and this header names it. Omitting it returns 400 INVALID_PARAMETERS ("x-account-code header is required.").
Path Parameters
Body
Required. 1 to 8 letters or digits (A-Z, 0-9), in any case. Yuno converts it to upper case and builds each code from it: the prefix, then a random suffix. A missing or blank prefix answers prefix: REQUIRED. A body with a code is refused with code: NOT_ALLOWED.
1 - 8Response
- The batch, with its codes. The same key on the same promotion returns the same batch with
201.