Sell access with codes
Order codes, hand one to each customer, hear when it is redeemed, and end the access with one call.
An access code gives one person access to YOU(th) for as long as you say. You order codes in batches, hand one to each customer, and YOU(th) tells your system when it is redeemed. This is how a company sells YOU(th) beside its own product: a mobile operator, an insurer, a gym.
YOU(th) and your system exchange codes and dates only. No name, email address, phone number or health data crosses in either direction.
How it fits together
- You order a batch of codes with the API, and read them.
- You hand a code to a customer, as a link or as text, wherever you sell: your app, your shop, an email.
- The customer redeems it in the YOU(th) app, where they create their account and accept YOU(th)'s terms.
- YOU(th) sends your receiver
AccessCode.redeemed, with the code's id and the time. You bill from that time, if you bill by period. - You end the access with one call when the customer cancels or stops paying. Until then it continues: you send nothing for a renewal.
- YOU(th) sends
Access.endedwhen the access has stopped.
| Step | Who | With |
|---|---|---|
| Order a batch | You | POST /v1/access-code-batches |
| Receive the codes | You | GET /v1/access-codes, as JSON or one CSV file |
| Hand out a code | You | Your own systems |
| Redeem it | Customer | The YOU(th) app |
| Learn it was redeemed | YOU(th) | The AccessCode.redeemed event |
| End the access | You | PUT /v1/access-codes/{access_code_id}/access |
| Learn it has ended | YOU(th) | The Access.ended event |
| Check a month | You | GET /v1/access-codes?status= |
What you build
Three things, each small:
- A call that orders a batch and reads its codes, as JSON or as one CSV file: see Order and read codes.
- A webhook receiver that verifies a delivery and stores the time of each
AccessCode.redeemed: see Manage your endpoints, Verify a delivery and Retries and duplicates. - A call that ends an access: see End a customer's access.
Every call takes a token your backend gets with its integration's key: see
Authentication. An integration with the scopes access_codes:write and
webhooks:write does all three.
What you do not build
- No exchange of customer data. The code is the only thing both sides know. The customer gives YOU(th) their details themselves, when they register.
- No renewal calls. Access continues until you end it.
- No polling. YOU(th) tells you about a redemption as it happens.
- No API of yours for YOU(th) to call. You expose one HTTPS address that takes deliveries.
A code's life
status | Means | Next |
|---|---|---|
available | Nobody has redeemed it | redeemed, deactivated or expired |
redeemed | A person redeemed it and has access | ended |
ended | The access it started has stopped | None |
deactivated | You blocked it before anyone redeemed it | None |
expired | Nobody redeemed it before its batch's redeem_by | None |
- A code is used once. A customer who comes back after their access ended gets a new code.
- A code can wait. A customer can redeem it weeks after you handed it over, until the batch's
redeem_by. - A code names no person. The API speaks of the access a code started, never of who redeemed it.
How the customer redeems
A code comes with a redeem_url, the link that redeems it in the YOU(th) app. Offer the link where
you can:
- The link. It opens the YOU(th) app, or its store page when the app is not installed, with your organization and the code filled in. The customer types nothing. If the app doesn't open on your organization, the customer chooses it from the app's list of organizations when they first open it, then types the code.
- The code as text. The customer installs the YOU(th) app, chooses your organization from its list, creates an account and types the code, twelve digits, as you show it: without spaces.
When your organization's members redeem in an app of its own, not the YOU(th) app, redeem_url is
null: no YOU(th) link opens your app, so hand out the code as text, which the customer types in
your app.
A code is redeemed with an account created under your organization. The link fills in your organization and the code only in a YOU(th) app that has no organization yet. A YOU(th) app already set up for your organization opens as it is, and the customer types the code. One set up for another organization, YOU(th)'s own included, can't redeem it.
Try it first
A sandbox is a second organization of yours, which only your own testers join. Your backend orders codes there, a tester redeems one in the app, and your receiver and your billing are tested end to end before a customer is involved.
Build it with an assistant
Use the docs with AI has a prompt that builds the receiver and the call that ends an access, in your stack.