Quickstart
Get credentials, configure your OAuth library, call the API, then receive and verify a delivery.
This walks through an integration end to end. The first three steps get your backend talking to the API: get credentials, configure your OAuth library, make a first call. The rest registers your receiver's address, checks that a delivery is from YOU(th), and reads what the delivery names.
1. Get credentials
An administrator of your organization creates an integration in the console, with the scopes
webhooks:write and access_codes:read, and downloads its credentials file: see
Get API credentials. The file holds four values. Keep them on your server:
| Value | In the samples |
|---|---|
| The token URL | TOKEN_URL |
| The client id | YOUTH_CLIENT_ID |
| The key id | YOUTH_KEY_ID |
| The private key | YOUTH_PRIVATE_KEY |
You hold the private key, and YOU(th) holds only its public half. There is no client secret.
2. Configure your OAuth library
Give your language's OAuth2 library the four values, with the grant client_credentials, the
client authentication private_key_jwt, and your two scopes as scope:
webhooks:write access_codes:read. Authentication has the
settings, and samples for Node, Python and Java. The library signs with your key and gets a token,
valid for about five minutes.
3. Call the API
Send the token with a first call, which answers your organization and your integration:
curl https://api.youth-platform.io/v1/organization \ --header "Authorization: Bearer $YOUTH_ACCESS_TOKEN"4. Create a webhook endpoint
Register your receiver's HTTPS address, and the events it takes, with
POST /v1/webhook-endpoints: see Manage your endpoints. The answer
shows the endpoint's signing secret, once. Keep it as YOUTH_WEBHOOK_SECRET. That page is a
preview: the request's fields are not final, so create your first endpoint with your YOU(th)
contact.
5. Receive and verify a delivery
import { createServer } from "node:http";import { verifyDelivery } from "./verify-delivery";createServer((request, response) => { const chunks: Buffer[] = []; request.on("data", (chunk: Buffer) => chunks.push(chunk)); request.on("end", () => { const body = Buffer.concat(chunks); const signed = verifyDelivery(process.env.YOUTH_WEBHOOK_SECRET ?? "", request.headers, body); response.writeHead(signed ? 200 : 401).end(); if (signed) console.log(JSON.parse(body.toString("utf8")).event_type); });}).listen(8080);verifyDelivery is on Verify a delivery. It checks the signature over the
raw body, exactly as it arrived, and refuses a delivery more than five minutes old. A
Standard Webhooks library does the same, if you prefer one.
Test the check before a real event arrives, with the signed request on
Verify a delivery. For a real delivery, have a tester redeem a code
in your sandbox: your receiver logs AccessCode.redeemed.
6. Read what it names
A delivery carries ids and a resource_url, never the resource. Read it with your token:
curl https://api.youth-platform.io/v1/access-codes/0193b1c2-7a4e-7c1d-9f0a-2b6d5e8f1a34 \ --header "Authorization: Bearer $YOUTH_ACCESS_TOKEN"An AccessCode.redeemed names the code, which the scope access_codes:read reads.
Next
- Answer fast and take each delivery once: Retries and duplicates.
- Know every event and what it carries: Events.
- Sell access to your own customers: Sell access with codes.
- List what you missed while your receiver was down: access codes.
- Test with your own testers before a customer is involved: Sandbox.