# Use the docs with AI

> Hand a page or the whole docs to an assistant or a coding agent, with prompts to start from.

These docs are written to be read by people and by assistants alike. Hand an assistant or a coding
agent what it needs, and ask it to build your integration from there.

## One page

Every page has the same row under its title:

| Action          | Does                                                                        |
| --------------- | --------------------------------------------------------------------------- |
| Copy page       | Puts the page on your clipboard as Markdown, to paste into any assistant    |
| Markdown        | Opens the page as Markdown: its address is the page's with `.md` at the end |
| Open in ChatGPT | Starts a chat that asks ChatGPT to read the page's Markdown                 |
| Open in Claude  | Starts a chat that asks Claude to read the page's Markdown                  |

## The whole docs

| File                               | Holds                                                                  |
| ---------------------------------- | ---------------------------------------------------------------------- |
| [`/llms.txt`](/llms.txt)           | An index of every page's Markdown, by section, as llmstxt.org proposes |
| [`/llms-full.txt`](/llms-full.txt) | Every page in one Markdown file                                        |

Give a coding agent `/llms-full.txt` for the whole picture.

## Prompts to start from

In each prompt, put this site's address in place of `<this site's address>`, and your stack in
place of the other placeholder. The prompts name the variables the docs' samples use:
`YOUTH_CLIENT_ID`, `YOUTH_KEY_ID` and `YOUTH_PRIVATE_KEY` for your
[integration](/docs/credentials), and `YOUTH_WEBHOOK_SECRET` for your endpoint's signing secret.

### Receive checkups

> **Preview:** the checkup events and the read API are not available yet.

```text
Read <this site's address>/llms-full.txt, the docs of the YOU(th) webhook and read API.
Build a webhook receiver for my backend in <your language and framework> that:
- verifies each delivery's Standard Webhooks signature (webhook-id, webhook-timestamp,
  webhook-signature) with the secret in YOUTH_WEBHOOK_SECRET, over the raw body, and refuses one
  older than five minutes;
- skips an event_id it has already handled, and answers 200 within ten seconds;
- for Checkup.completed, reads the bundle at resource_url with an access token for the scope
  checkups:read, reusing the token until it expires;
- gets that token as the Authentication page describes: OAuth2 client credentials with
  private_key_jwt, a client assertion signed for each token request with the key in
  YOUTH_PRIVATE_KEY (its id in YOUTH_KEY_ID, the client id in YOUTH_CLIENT_ID), and scope in every
  request. There is no client secret.
Write tests for each of these, and keep every secret and key out of the code.
```

### Sell access with codes

```text
Read <this site's address>/llms-full.txt, the docs of the YOU(th) API and webhook.
I sell YOU(th) access to my customers with access codes. In <your language and framework>, build:
1. A webhook receiver that verifies each delivery's Standard Webhooks signature with the secret in
   YOUTH_WEBHOOK_SECRET, over the raw body, refuses one older than five minutes, skips an event_id
   it has already handled, and answers 200 within ten seconds.
2. For AccessCode.redeemed: store access_code_id and occurred_at as the activation my billing
   starts from. For Access.ended: mark that code as ended, with its reason.
3. A function endAccess(accessCodeId, endsAt) that calls
   PUT /v1/access-codes/{access_code_id}/access with an access token for the scope
   access_codes:write, reuses the token until it expires, and treats a repeated call as success.
4. The token client the Authentication page describes: OAuth2 client credentials with
   private_key_jwt, a client assertion signed for each token request with the key in
   YOUTH_PRIVATE_KEY (its id in YOUTH_KEY_ID, the client id in YOUTH_CLIENT_ID), and scope in every
   request. There is no client secret.
Take nothing about a person from YOU(th): the code's id is the only key.
Write tests for each of these, and keep every secret and key out of the code.
```

### Reconcile and catch up

```text
Read <this site's address>/docs/access-codes/reconcile.md and <this site's address>/docs/errors.md.
In <your language and framework>, write a job that runs once a day and:
- lists GET /v1/access-codes with redeemed_from set to one hour before the newest activation I
  have stored, passing each page's next as after until a page has none;
- stores every redeemed code I do not have yet, exactly as the webhook receiver would;
- lists the same route with status=ended and ended_from set to the same time, and marks each code
  I still hold as active as ended;
- reports each code that is cancelled in my system and redeemed at YOU(th) with no access.ends_at,
  and sends its end again;
- waits for Retry-After on a 429 or a 503, and stops with the request_id on any other refusal.
Write tests with a fake of the API.
```

### Test in the sandbox

```text
Read <this site's address>/docs/sandbox.md and <this site's address>/docs/access-codes/order.md.
Write an end-to-end test for my integration that runs against my YOU(th) sandbox organization,
with the sandbox integration in YOUTH_CLIENT_ID, YOUTH_KEY_ID and YOUTH_PRIVATE_KEY:
- check that GET /v1/organization names the organization in YOUTH_SANDBOX_ORGANIZATION, and stop
  if it does not;
- order a batch of 3 codes with an Idempotency-Key, and wait until it is ready;
- print one code's redeem_url for a tester to redeem in the YOU(th) app, and wait until my
  receiver has stored AccessCode.redeemed for it;
- end its access with ends_at left out, and wait for Access.ended.
Never run it with live credentials.
```

### Review what you built

```text
Read <this site's address>/llms-full.txt. Review my YOU(th) integration in this repository against
it, and list every place where it: parses the body before verifying the signature, handles an
event twice, does work before answering the delivery, gets a token for every request, asks for a
token without scope, reuses a client assertion, logs a secret, a private key, a token or an access
code, or fails on a field, event type or error code it does not know.
For each, name the file and the page of the docs it goes against.
```

Check an assistant's work against these pages, and against your [sandbox](/docs/sandbox).
