Two credentials open the API from outside the app. A project token reads one design system; an account token acts on one account. Neither is a session: a bearer token carries no cookie and gets no page.
How to use it
Project token. One per project, shown and rotated in the workbench's Project settings. Send it as Authorization: Bearer <project token> to the project routes. The Figma plugin's iframe sends it in an x-figma-sync-token header to the three Figma routes instead, since the iframe has no origin for a bearer flow.
curl -H "Authorization: Bearer $DS_SYNC_TOKEN" https://designsource.app/api/projectAccount token. Minted by the device authorization flow that designsource login runs; it starts with dsa_. Send it as Authorization: Bearer <account token> to the agent routes only; every other route ignores it. It holds three scopes, projects:read, projects:create and screens:create, and no scope that deletes or edits.
How it works
Every project-token route runs one contract: the token, an optional check of the request (the starter's, kit's and snapshot's query), one lookup, then the plan gate on the project's owner. A missing or unknown token is 401, never 404, so a guess cannot tell a wrong token from a missing project. The gate answers 402 with code: "plan_required" when the owner's account is on the free plan, since every export is a Pro feature. Every answer, refusals included, is Cache-Control: no-store: each depends on the token's owner and plan.
Every agent route runs the matching contract: the token's shape (dsa_ and 43 base64url characters), one lookup by its SHA-256, refused with 401 and code: "agent_token_invalid" when unknown, revoked, expired, or minted before the account changed its password or unlinked a sign-in method, and 403 with code: "agent_scope_missing" when the scope is not held. Every invalid cause answers the same body. A used token has its last use recorded at most once a minute and its 90-day expiry slid forward at most once a day.
Tokens are stored hashed. The project token is the one secret the app hands out; the account token is minted once and shown to the command line alone, never to the browser.
Rotating a project token in Project settings signs every holder out at once. Revoking an account token happens from designsource logout or the profile page's Coding apps card; a password change, unlinking a sign-in method or deleting the account revokes every account token.
What can go wrong
401 { "error": "Invalid sync token" }: the project token was regenerated, or mistyped.402 { "code": "plan_required" }: the project owner's account is on Free.401 { "code": "agent_token_invalid" }: rundesignsource loginagain.- A cookie-authenticated route called with a bearer token answers as if signed out: those routes are the app's own.
Related
- Project routes, Agent routes, Device authorization.
- Error codes.
- Tokens and credentials: the same credentials in the command line.