# DPoP, tokens bound to a key

> Make a token useless to anyone who steals it, by binding it to the caller's private key with DPoP (RFC 9449).

Applies to: the Sypnia engine (open source, self-hosted) and Sypnia Cloud (paid service).  
Source: https://data.docs.sypnia.com/machines/dpop/

For agents: DPoP (RFC 9449) in Sypnia Data: the client sends a DPoP proof JWT (typ dpop+jwt, jwk header, htm, htu, iat, jti; ath on resource calls) to /oauth/token; the engine issues token_type DPoP with cnf.jkt (JWK thumbprint). Resource calls need Authorization: DPoP <token> plus a fresh proof (iat within 60 s, jti single-use for 5 minutes). DPoP-Nonce supported. Per client: optional or required (dpop_bound_access_tokens). Refresh tokens of public clients are bound to the same key.

A normal access token is a **bearer** token: whoever holds it can use it. A **DPoP** token is bound to a key pair, and every request must carry a fresh proof signed with the private key. A stolen token, from a log, a proxy or a leaked file, does nothing on its own.

## How it works

1. The client generates a key pair (Ed25519 or P-256) and keeps the private key.
2. When it asks for a token, it adds a header `DPoP:` with a small signed JWT: the method, the address, the time and a random id, plus the public key.
3. The engine issues the token with `"token_type": "DPoP"` and the key's thumbprint in `cnf.jkt`.
4. On every call, the client sends `Authorization: DPoP <token>` and a **new** proof for that method and address, including `ath`, the hash of the token.
5. The engine checks the proof's signature, that its key matches `cnf.jkt`, that it is less than 60 seconds old and that its id was never seen in the last 5 minutes.

```text
GET /rest/v1/orders?select=id HTTP/1.1
Host: <ref>.data.sypnia.com
Authorization: DPoP eyJhbGciOiJFZERTQSJ9…
DPoP: eyJ0eXAiOiJkcG9wK2p3dCIsImFsZyI6IkVkRFNBIiwiandrIjp7Imt0eSI6Ik9LUCIsImNydiI6IkVkMjU1MTkiLCJ4IjoiLi4uIn19…
```

## Optional or required

Per client, `dpop_bound_access_tokens`:

- **off**: DPoP is used if the client sends a proof, ignored otherwise;
- **on**: the token endpoint refuses requests without a proof.

Clients created by `npx @sypnia/data login` (the device flow) always use DPoP. When a public client (no secret) gets a refresh token with DPoP, the refresh token is bound to the same key.

The engine may answer `401` with a `DPoP-Nonce` header; the client then repeats the request with that nonce in the proof. `@sypnia/data` handles proofs and nonces for you.
