The agent routes are what designsource login unlocks: an account token lists the account's design systems, creates one from a recipe, reads a linked one's kit or snapshot, generates a screen in one, and revokes itself. Every one lives under /api/agent/ and takes Authorization: Bearer dsa_….
How to use it
| Route | Scope | Answers |
|---|---|---|
GET /api/agent/token |
any | { "scopes": [...] } of the calling token; designsource login reads it. |
GET /api/agent/projects |
projects:read |
{ "projects": [{ "id", "name", "updatedAt", "url" }] }, newest first. |
POST /api/agent/projects |
projects:create |
201 { "id", "name", "url", "account": { "email" }, "score", "failing", "changes" }. |
GET /api/agent/projects/<id>/kit |
projects:read |
The kit manifest of that project; takes screens and pages as the project routes do. |
GET /api/agent/projects/<id>/snapshot |
projects:read |
The snapshot of that project; takes pages. |
POST /api/agent/projects/<id>/screens/generate |
screens:create |
A stream of JSON lines ending in { "type": "result", "data": { "screen", "screens", "url" } }. |
DELETE /api/agent/token |
any | { "revoked": true }; the calling token is dead from here on. |
The create body is { "name", "recipe", "mockupSpec"?, "radiusStrategy"?, "icons"? }: the name up to 60 characters, the recipe in the compact shape on Recipe shape (ramps as hue and chroma), an optional page spec, a corner strategy (concentric by default), and an icon set ({ "set", "style", "weight"?, "filledWhenSelected"? }, Lucide by default; a set, style or weight that set does not offer answers 400 invalid_icons). The body is capped at 64 KB.
curl -X POST -H "Authorization: Bearer $DSA" -H "Content-Type: application/json" \
-d '{"name":"Acme","recipe":{...}}' https://designsource.app/api/agent/projectsThe screen body is { "prompt", "screen"?, "dataModel"?, "pages"?, "modelId"?, "operationId"? }: what to make or change, up to 500 characters; the file name of a screen to change, or none for a new one; pages: true to let it make or change a marketing page (without it a new one is an app screen and a change to a page is refused); and the app's own records, { "records": [{ "name", "fields": [{ "key", "label", "type" }] }] }, at most three records of twelve fields, names in PascalCase, keys in camelCase, labels up to 32 characters, types those of a screen field. The body is capped at 16 KB.
How it works
Creating runs what the app's own creation does, plus a repair the wizard has already done by the time it posts: the recipe is validated, control and bidi characters are refused in the name and the page spec (an agent's text can reach a terminal), the contrast repair runs with primary, accent and background left alone so the agent's brand stays where it put it, any web font is checked against Google Fonts and replaced by system on a miss, a taken name gets a number, and the full token set is seeded under the chosen strategy. The answer's changes lists every repair and font fallback in words, failing the required rows the protected colours left failing, and score the system's score. The account's project cap and a creation throttle apply; no project token is ever handed out this way.
Reading a project through the account is the same build as the project routes, after an ownership check: a project not in the account is 404, never 403. The owner's plan gate applies, so reading needs Pro while creating is free.
Generating a screen is the workbench's own screen generator: the same price, funding (the account's key for the model's provider, else its credits), metering and saved versions. A data model reaches the model as data, so the screen's records take the app's names, keys and types while the sample rows stay invented; the plan the model writes is checked like any other. The result names the screen (its slug and title) and links the project in the workbench; it carries no source. Generating is on any plan.
Revoking takes any valid token and ends it; the command line calls it from logout. The profile page's Coding apps card revokes from the browser instead, through the app's own session routes.
Every answer is no-store, and none carries a project token or the account token.
What can go wrong
401 agent_token_invalid: the token is unknown, revoked, expired, or older than a password change or a sign-in unlink.403 agent_scope_missing: a token minted with fewer scopes than this route needs.404on a per-project route: the id is not in this account.402 plan_requiredon kit or snapshot: the account is on Free.402 credits_requiredorprovider_key_requiredon a screen: the account has neither the credits nor a key to run it.404on a screen: no screen of that file name in the project.409: the project already holds 50 screens, the screen's current version cannot be read, or the screen is a page andpageswas not sent.- An
errorline in the stream withcodepage_kind_taken(the project already has a page of that kind) orplan_family_changed(a screen cannot turn into a page or back): nothing was saved or charged. 400with the first validation issue, or413past 64 KB (16 KB for a screen).
Related
- Letting an agent create design systems: the same flow from the agent's side.
- Device authorization: where the token comes from.
- Error codes.