Docs
Contact

End a customer's access

Set when the access a code started ends, and what YOU(th) sends when it has.

Access that a code started with the term until_ended continues until you end it. You end it with one call, when your customer cancels or stops paying. It needs the scope access_codes:write.

End it

Get a token, then set when the access ends:

curl --request PUT \  https://api.youth-platform.io/v1/access-codes/0193b1c2-7a4e-7c1d-9f0a-2b6d5e8f1a34/access \  --header "Authorization: Bearer $YOUTH_ACCESS_TOKEN" \  --header "Content-Type: application/json" \  --data '{ "ends_at": "2027-01-12T00:00:00Z" }'

The answer is the code, with the end you set:

{  "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": "redeemed",  "redeemed_at": "2026-12-12T09:30:00.375Z",  "access": { "term": "until_ended", "ends_at": "2027-01-12T00:00:00.000Z" }}
ends_atDoes
A time to comeAccess ends then: the end of the paid period, or of your grace period
Left outAccess ends now
A time that has passedAccess ends now, as if left out
nullRemoves an end that has not passed yet: the customer changed their mind
  • Call when you know. Send the end as soon as the customer cancels, with the date to come, or on the day itself. Both work.
  • Repeat it safely. The same call twice leaves the same end, and a call that ends an access already ended answers 200 with the code as it is. Try again after a timeout without checking first. A later call replaces the end while it has not passed.
  • A redemption takes a minute to arrive. The API hears of a redemption within about a minute. A 409 not_redeemed for a code your customer has just redeemed is worth repeating a minute later.
  • Your rules stay yours. Billing periods, renewals and grace periods are in your system. YOU(th) keeps one date per code: the end you sent.
  • An end that has passed is final. The code is ended: a call that sets a later end, or null, answers 409. A customer who returns gets a new code.

What happens then

When ends_at passes, the code answers ended. Within about 10 minutes the person can no longer use what the code gave them in the YOU(th) app, and YOU(th) sends your receiver Access.ended with the reason ended_by_partner and your end as its occurred_at; later if YOU(th) can't reach the app then. Stop billing on your own date; the event confirms it.

Access.ended can also come without a call of yours:

reasonMeans
ended_by_partnerThe ends_at you set has passed
term_overA code with the term fixed_days reached its last day

When the call is refused

AnswercodeMeans
404not_foundNo code of yours has this id
409not_redeemedNobody has redeemed the code: block it instead
409access_endedIts access has already ended, and the call asks for a later end or for none
422invalid_requestends_at is not a time, the body holds a field the call doesn't take, or the code's id isn't an id
422ends_at_beyond_termends_at is later than the code's own term: a fixed_days code cannot be extended past its days
503temporarily_unavailableNot now: send the same call again after Retry-After seconds

Every refusal has the body Errors and rate limits describes.

Last updated