Upload coupon codes
const url = 'https://api.keliplay.com/v1/game-instances/example/reward-coupons';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"tierId":"0192f3a1-0000-7000-8000-000000071001","codes":["COFFEE-7K2M","COFFEE-9P4X","COFFEE-3B8D"],"issueLimit":1}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.keliplay.com/v1/game-instances/example/reward-coupons \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "tierId": "0192f3a1-0000-7000-8000-000000071001", "codes": [ "COFFEE-7K2M", "COFFEE-9P4X", "COFFEE-3B8D" ], "issueLimit": 1 }'Adds your own codes to a prize, up to 5,000 per request. Codes already
stored are skipped and counted in duplicates. Without tierId, codes
go to the first prize.
Send either codes (plain codes) or coupons (each code with your own
ref and name), not both. A ref names one coupon in a campaign: one
the campaign already has is refused with 409, and the same ref twice
in one request with 400. The reward_granted webhook carries the
ref and name of the coupon a player was given. The request body may
be up to 3 MB.
Permission: rewards.codes.manage. Plan feature: Rewards. Plan limit:
stored coupon codes. Rate limit: 10 requests per minute.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”The campaign’s id.
Request Bodyrequired
Section titled “Request Bodyrequired”object
The prize these codes belong to. Defaults to the first prize.
object
Your own ID for this coupon, unique within the campaign. Sent in the
reward_granted webhook. Blank is the same as none.
Your own name for this coupon. Players see it only on a reward page
whose coupon block has show set to name or both.
How many times each code can be given out. Null means no limit.
object
The prize these codes belong to. Defaults to the first prize.
object
Your own ID for this coupon, unique within the campaign. Sent in the
reward_granted webhook. Blank is the same as none.
Your own name for this coupon. Players see it only on a reward page
whose coupon block has show set to name or both.
How many times each code can be given out. Null means no limit.
Examples
Plain codes
{ "tierId": "0192f3a1-0000-7000-8000-000000071001", "codes": [ "COFFEE-7K2M", "COFFEE-9P4X", "COFFEE-3B8D" ], "issueLimit": 1}Codes with your own reference
{ "tierId": "0192f3a1-0000-7000-8000-000000071001", "coupons": [ { "code": "COFFEE-7K2M", "ref": "CRM-00417", "name": "Free coffee" }, { "code": "COFFEE-9P4X", "ref": "CRM-00418", "name": "Free coffee" } ], "issueLimit": 1}Responses
Section titled “Responses”What was stored.
object
Example
{ "submitted": 3, "accepted": 3, "duplicates": 0}Headers
Section titled “Headers”Requests allowed in the current window.
Requests left in the current window.
The request is not valid. details lists each field that failed, where there is one.
object
object
Stable and safe to branch on.
invalid_request(400): the request is not valid.unauthorized(401): missing, malformed or revoked API key.upgrade_required(402): not in your plan, or a plan limit is reached.forbidden(403): the key lacks a permission, or the action is not allowed.not_found(404): nothing with that id in your account.conflict(409): clashes with the current state.confirmation_required(409): repeat withconfirm=true. Folder deletion only.rate_limited(429): wait forRetry-Afterseconds.internal_error(500) andservice_unavailable(503): try again later.
Written for a person. May change; do not parse it.
object
The failing field, dot separated, such as prize.label.
object
Example
{ "error": { "code": "invalid_request", "message": "Invalid request json.", "details": [ { "path": "name", "message": "Too small, expected string to have >=1 characters" } ] }}The API key is missing, malformed or revoked.
object
object
Stable and safe to branch on.
invalid_request(400): the request is not valid.unauthorized(401): missing, malformed or revoked API key.upgrade_required(402): not in your plan, or a plan limit is reached.forbidden(403): the key lacks a permission, or the action is not allowed.not_found(404): nothing with that id in your account.conflict(409): clashes with the current state.confirmation_required(409): repeat withconfirm=true. Folder deletion only.rate_limited(429): wait forRetry-Afterseconds.internal_error(500) andservice_unavailable(503): try again later.
Written for a person. May change; do not parse it.
object
The failing field, dot separated, such as prize.label.
object
Example
{ "error": { "code": "unauthorized", "message": "Invalid or revoked API key." }}Your plan does not include this feature, or you have reached a plan limit.
object
object
Stable and safe to branch on.
invalid_request(400): the request is not valid.unauthorized(401): missing, malformed or revoked API key.upgrade_required(402): not in your plan, or a plan limit is reached.forbidden(403): the key lacks a permission, or the action is not allowed.not_found(404): nothing with that id in your account.conflict(409): clashes with the current state.confirmation_required(409): repeat withconfirm=true. Folder deletion only.rate_limited(429): wait forRetry-Afterseconds.internal_error(500) andservice_unavailable(503): try again later.
Written for a person. May change; do not parse it.
object
The failing field, dot separated, such as prize.label.
object
Example
{ "error": { "code": "upgrade_required", "message": "Rewards is not included in your plan. Ask whoever manages your account to add it." }}The API key does not carry the permission this needs, or the request is not allowed.
object
object
Stable and safe to branch on.
invalid_request(400): the request is not valid.unauthorized(401): missing, malformed or revoked API key.upgrade_required(402): not in your plan, or a plan limit is reached.forbidden(403): the key lacks a permission, or the action is not allowed.not_found(404): nothing with that id in your account.conflict(409): clashes with the current state.confirmation_required(409): repeat withconfirm=true. Folder deletion only.rate_limited(429): wait forRetry-Afterseconds.internal_error(500) andservice_unavailable(503): try again later.
Written for a person. May change; do not parse it.
object
The failing field, dot separated, such as prize.label.
object
Example
{ "error": { "code": "forbidden", "message": "Your role does not allow this (draws.run)." }}Nothing with that id exists in your account.
object
object
Stable and safe to branch on.
invalid_request(400): the request is not valid.unauthorized(401): missing, malformed or revoked API key.upgrade_required(402): not in your plan, or a plan limit is reached.forbidden(403): the key lacks a permission, or the action is not allowed.not_found(404): nothing with that id in your account.conflict(409): clashes with the current state.confirmation_required(409): repeat withconfirm=true. Folder deletion only.rate_limited(429): wait forRetry-Afterseconds.internal_error(500) andservice_unavailable(503): try again later.
Written for a person. May change; do not parse it.
object
The failing field, dot separated, such as prize.label.
object
Example
{ "error": { "code": "not_found", "message": "Channel 0192f3a1-0000-7000-8000-00000000c009 not found." }}The request clashes with the current state. The message says what to change.
object
object
Stable and safe to branch on.
invalid_request(400): the request is not valid.unauthorized(401): missing, malformed or revoked API key.upgrade_required(402): not in your plan, or a plan limit is reached.forbidden(403): the key lacks a permission, or the action is not allowed.not_found(404): nothing with that id in your account.conflict(409): clashes with the current state.confirmation_required(409): repeat withconfirm=true. Folder deletion only.rate_limited(429): wait forRetry-Afterseconds.internal_error(500) andservice_unavailable(503): try again later.
Written for a person. May change; do not parse it.
object
The failing field, dot separated, such as prize.label.
object
Example
{ "error": { "code": "conflict", "message": "An archived campaign cannot be edited. Restore it first, then make the change." }}Rate limit exceeded. Wait for Retry-After seconds.
object
object
Stable and safe to branch on.
invalid_request(400): the request is not valid.unauthorized(401): missing, malformed or revoked API key.upgrade_required(402): not in your plan, or a plan limit is reached.forbidden(403): the key lacks a permission, or the action is not allowed.not_found(404): nothing with that id in your account.conflict(409): clashes with the current state.confirmation_required(409): repeat withconfirm=true. Folder deletion only.rate_limited(429): wait forRetry-Afterseconds.internal_error(500) andservice_unavailable(503): try again later.
Written for a person. May change; do not parse it.
object
The failing field, dot separated, such as prize.label.
object
Example
{ "error": { "code": "rate_limited", "message": "Rate limit exceeded: 30 requests per 60s." }}Headers
Section titled “Headers”Seconds to wait before trying again.