Docs
Contact

Order and read codes

Order a batch of access codes, read them with their links, and block one.

A batch is one order of codes: how many, what access each grants, and until when they can be redeemed. Your backend orders a batch with the scope access_codes:write, and reads its codes with access_codes:read or access_codes:write.

Order a batch

curl https://api.youth-platform.io/v1/access-code-batches \  --header "Authorization: Bearer $YOUTH_ACCESS_TOKEN" \  --header "Content-Type: application/json" \  --header "Idempotency-Key: 5f2b6f0e-3a51-4c58-9a57-2a1f6f1d3c11" \  --data '{    "count": 1000,    "label": "december-2026",    "redeem_by": "2027-12-31T23:59:59Z",    "access": { "term": "until_ended" }  }'
FieldMeans
countHow many codes, at most 20,000 in one order and within your daily limit
labelA name of yours for the batch, such as the month or your order number. It is never shown to a customer
redeem_byThe last moment a code of this batch can be redeemed, still to come and at most five years ahead. Optional
accessWhat a redeemed code grants: see below
access.termA redeemed code grants
until_endedAccess until you end it: for a service you bill by period
fixed_daysAccess for access.days days from the redemption, then it ends by itself

The answer is 201 once every code can be read and redeemed, with the batch ready and its address in Location:

{  "id": "0193b1c0-11aa-7e02-8c55-9d3f0a7b6c21",  "label": "december-2026",  "status": "ready",  "count": 1000,  "redeem_by": "2027-12-31T23:59:59.000Z",  "access": { "term": "until_ended" },  "created_at": "2026-12-01T10:00:00.000Z"}

An order must carry an Idempotency-Key header of your own, a UUID for example, of at most 255 characters. The same key with the same body answers the first order again, within 24 hours of the latest attempt, so a request you repeat after a timeout never orders twice.

AnswercodeMeans
400idempotency_key_requiredThe order has no Idempotency-Key
400idempotency_key_invalidThe key is empty, or longer than 255 characters
409idempotency_conflictThe key was already used with another body: use a new key
409idempotency_in_progressAn order with the key runs now: send it again after Retry-After seconds
409app_not_set_upYour organization isn't in the YOU(th) app yet, so no code could be redeemed: ask your YOU(th) contact
422invalid_requestA field is missing or not valid, or the order doesn't take it, such as a misspelt one
422redeem_by_passedredeem_by has passed
422redeem_by_too_farredeem_by is more than five years ahead
422count_over_limitThe order would take you past your daily limit: nothing was made
503temporarily_unavailableNot now: send the same order again after Retry-After seconds

Making thousands of codes takes a few seconds. When an order can't be finished now, it answers 503 with Retry-After: repeat it, or one that timed out, with the same key and body, and it goes on with the same batch, never a second one. Every refusal has the body Errors and rate limits describes.

The daily limit

Your organization's batches ordered in one day, from 00:00 UTC, hold at most 1,000 codes together, whatever became of them since. An order that would pass it answers 422 count_over_limit and makes nothing: order fewer, with a new Idempotency-Key (the refused key answers another body 409), or wait for the next day. A repeat of an order with the same key goes on with its batch and isn't counted again. Need more? Ask your YOU(th) contact to raise your organization's limit.

Read a batch

curl https://api.youth-platform.io/v1/access-code-batches/0193b1c0-11aa-7e02-8c55-9d3f0a7b6c21 \  --header "Authorization: Bearer $YOUTH_ACCESS_TOKEN"
statusMeans
readyEvery code can be read and redeemed
creatingAn order answered 503 and hasn't been sent again yet: send it again with the same key
failedNo order went on with it for a day: none of its codes is listed or billed. Order again, with a new key

Read the codes

curl "https://api.youth-platform.io/v1/access-codes?batch_id=0193b1c0-11aa-7e02-8c55-9d3f0a7b6c21" \  --header "Authorization: Bearer $YOUTH_ACCESS_TOKEN"
{  "items": [    {      "id": "0193b1c2-7a4e-7c1d-9f0a-2b6d5e8f1a34",      "batch_id": "0193b1c0-11aa-7e02-8c55-9d3f0a7b6c21",      "code": "482957362845",      "redeem_url": "https://youthai.app.link/?~channel=partners&~feature=access_code&$partner_configuration_system_name=coopvoce&$access_code=482957362845",      "status": "available",      "redeemed_at": null,      "access": { "term": "until_ended", "ends_at": null }    }  ],  "next": "0193b1c2-7a4e-7c1d-9f0a-2b6d5e8f1a34"}
FieldMeans
idThe code's id: what events and the other routes name. Store it beside the code
codeWhat the customer types. An opaque string: store and show it exactly as it is, without spaces
redeem_urlThe link that redeems it, or null when your members redeem in an app of your own: see How the customer redeems
statusWhere the code is in its life
redeemed_atWhen it was redeemed, or null
access.ends_atWhen its access ends or ended, or null while no end is set
  • The list holds the codes of ready batches alone, in a stable order.
  • As JSON, the list comes a page at a time, 100 codes unless limit says otherwise (at most 1,000). Pass a page's next as after to read the next page; the last page has no next.
  • next is for one pass through the list, not a feed of what is new: a batch that becomes ready later can sort before codes you have already read. Read a new batch's codes with batch_id.
  • Send Accept: text/csv for one CSV file of every matching code, one code per line. The file is not paged: it takes no after or limit, and holds every code the filters keep, up to 50,000. More answer 422 too_many_codes: filter by batch_id or a time range, or read pages as JSON.
  • An after that isn't an id, or an after or limit sent for a CSV file, answers 422 invalid_request.
  • GET /v1/access-codes/{access_code_id} reads one code. Another organization's code, or one that doesn't exist, answers 404 not_found.
  • The code and its link are secrets until redeemed: whoever has one can redeem it. Keep them out of logs, and hand each to one customer only.
  • Use redeem_url exactly as it is: do not build it from the code.

As a CSV file

curl "https://api.youth-platform.io/v1/access-codes?batch_id=0193b1c0-11aa-7e02-8c55-9d3f0a7b6c21" \  --header "Authorization: Bearer $YOUTH_ACCESS_TOKEN" \  --header "Accept: text/csv" \  --output december-2026.csv

The file starts with a header line, and an empty field means null:

id,batch_id,code,redeem_url,status,redeemed_at,access_term,access_ends_at0193b1c2-7a4e-7c1d-9f0a-2b6d5e8f1a34,0193b1c0-11aa-7e02-8c55-9d3f0a7b6c21,482957362845,https://youthai.app.link/?~channel=partners&~feature=access_code&$partner_configuration_system_name=coopvoce&$access_code=482957362845,available,,until_ended,

Opening the file in a spreadsheet such as Excel, import the code column as text: read as a number, a code of twelve digits is shown as 4.82957E+11, not as the code to give your customer.

Block a code you will not use

A code you handed to nobody, or to the wrong person, can be blocked while nobody has redeemed it, available or expired:

curl --request POST \  https://api.youth-platform.io/v1/access-codes/0193b1c2-7a4e-7c1d-9f0a-2b6d5e8f1a34/deactivate \  --header "Authorization: Bearer $YOUTH_ACCESS_TOKEN"

It becomes deactivated and can never be redeemed; the answer is the code. Blocking it again changes nothing and answers the same, so repeat it safely after a timeout. It needs the scope access_codes:write.

AnswercodeMeans
404not_foundNo code of yours has this id
409already_redeemedSomeone redeemed the code: end its access instead
409redemption_in_progressSomeone is redeeming the code this moment: send the same call again after Retry-After seconds
422invalid_requestThe code's id in the address isn't an id
503temporarily_unavailableNot now: send the same call again after Retry-After seconds

Last updated