Platform API (access tokens)
Everything the builder does goes through a JSON API under /api. With a personal access token a script, a CI job or an AI agent can call the same routes: list projects, read and edit files, run checks, inspect pages, change data and publish.
This page covers tokens, scopes, limits and errors, OAuth apps for integrations that sign people in, then lists the routes a token can reach, grouped by task. If your agent speaks the Model Context Protocol, use the MCP server instead: it wraps the same routes as tools (tool reference). For the built-in AI and an overview, see Agents & MCP.
https://devmachinist.com as the host and a token in the shell variable DM_TOKEN.Personal access tokens #
A token looks like dm_pat_ followed by 43 random characters. Only its SHA-256 hash is stored, so the full token is shown once, when you create it. The first 14 characters (the prefix) are kept so you can tell tokens apart in the list.
A token acts as you: it sees your own projects and the projects your teams share with you, and it is billed and limited like you. It never reaches account settings, billing, admin, Shop selling, team management or token management.
Creating a token #
Go to Account → Access tokens (/#/account?tab=tokens) and press New token. Choose:
- Name, up to 60 characters, e.g. "Claude on my laptop".
- Scopes: any of read, write, preview, publish (see below).
- Projects: all your projects, or only the ones you tick.
- Expires in: 7, 30 or 90 days, or 1 year.
After you create it, the page shows the token and a ready-made MCP client config. Copy the token then; it can't be shown again. You can have up to 25 active tokens. Revoke stops a token at once.
Managing tokens from a signed-in session #
The token routes work only from a signed-in browser session. A request that carries an access token gets 403 Access tokens can't use this endpoint, so a token can never create or revoke tokens. Like every state-changing /api call from a browser, they must come from the app's own origin (see CSRF below).
GET /api/tokens{
"ok": true,
"tokens": [
{
"id": "9c41e07b2fd35a18",
"name": "Claude on my laptop",
"prefix": "dm_pat_Xk2Lq9W",
"scopes": ["read", "write", "preview"],
"project_ids": null,
"expires_at": "2027-02-11T09:12:40.512Z",
"last_used_at": "2026-11-13T08:02:11Z",
"created_at": "2026-11-13T09:12:40Z"
}
],
"scopes": {
"read": "Read projects, files, components, pages, issues and comments",
"write": "Create and edit files, components, pages, issues and comments; AI generation",
"preview": "Start and stop live previews",
"publish": "Publish and unpublish sites, export apps"
}
}POST /api/tokens
Content-Type: application/json
{ "name": "CI deploy", "scopes": ["read", "preview", "publish"], "projectIds": ["Vq3xT8mKp2Lw"], "expiresInDays": 30 }{
"ok": true,
"token": "dm_pat_…",
"id": "4be2a9d01c7f3e66",
"prefix": "dm_pat_R7tVb0e",
"scopes": ["read", "preview", "publish"],
"projectIds": ["Vq3xT8mKp2Lw"],
"expiresAt": "2026-12-13T10:01:05.330Z"
}| Field | Meaning |
|---|---|
name | Required, trimmed to 60 characters. |
scopes | Unknown names are dropped. Defaults to ["read"]; at least one valid scope is required. |
projectIds | Optional. An empty or missing list means all projects. Up to 50 ids; each must be a project you can open (400 Unknown project … otherwise). |
expiresInDays | Defaults to 90 and is capped at 365. 0 also means the default 90 days. A negative number creates a token that never expires. |
DELETE /api/tokens/<id> revokes a token. Creating and revoking are recorded in the audit log, and every use updates last_used_at.
Using a token #
Send it in the Authorization header on every request:
export DM_TOKEN='dm_pat_…'
curl -s https://devmachinist.com/api/projects \
-H "Authorization: Bearer $DM_TOKEN"Tokens are read only from that header, never from cookies. /api sends no CORS headers (except the MCP endpoint, /api/mcp), so a web page on another site can't call the REST routes from the browser: use tokens from servers, scripts, CLIs and agents.
A token that is unknown or revoked gets 401 Invalid or revoked access token; an expired one 401 This access token has expired; a token whose account is suspended or gone 401 The account behind this token is unavailable.
Scopes #
| Scope | Grants |
|---|---|
| read | Every GET and HEAD the token can reach, plus two read-only POSTs: project search (/search) and queries on connected databases (/connections/<id>/query). |
| write | Every other change: files, components, pages, brand, packages, git (except push), data, issues, comments, AI generation. |
| preview | Building and running: start, stop, restart, scaffold, journeys, experiment/check, check/build, check/page. |
| publish | publish and everything under it (also GET and DELETE), android, desktop, apps/build, experiment/approve, git/push. |
Before any route runs, the server decides which scope a request needs, in this order:
- A path matching the publish list needs publish, whatever the method. So reading
GET /api/projects/<id>/publishand unpublishing withDELETEneed publish too. - A path matching the preview list needs preview, whatever the method.
POST …/tools/<name>needs the scope of that chat tool (read for tools that only look, write for the rest; see The chat's tools).GET,HEAD,POST …/searchandPOST …/connections/<id>/queryneed read.- Anything else needs write.
A missing scope answers 403 This token lacks the "<scope>" scope. Scopes don't include each other: a token with only write can't read files, so most agents want read and write together.
One route checks more inside: POST /api/projects/<id>/git/do needs write, and with "action": "push" it also needs publish (403 Pushing needs a token with the publish scope).
What a token can reach #
Only these path prefixes accept a token. Anything else answers 403 Access tokens can't use this endpoint before routing.
| Path | Notes |
|---|---|
/api/projects and everything under it | Projects, files, previews, checks, data, git, publishing. |
/api/library and everything under it | Your component library and the shared one. |
/api/ai/status, /api/ai/component, /api/ai/jobs | The AI that applies to you or a project, one-off component generation, and AI builds running now or finished in the last hour. |
/api/templates | The project templates. |
/api/launcher, /api/launcher/updates | What the Android launcher shows, and new versions of the launcher and the Devmachinist app (read scope). |
/api/agent, /api/agent/changelog | Self-description, and what changed in the tools by version (need no token at all). |
/api/mcp | The MCP server. |
/api/system | Server versions and your running previews. |
/api/notifications, /api/notifications/read, /api/events | Your notifications, marking them read (read scope is enough) and the live stream of new ones (Server-Sent Events). |
Even inside those paths, some actions need a person in a signed-in browser and refuse tokens with 403: adding or removing a database or app connection, seeing a webhook address, allowing changes on a connection, approving or undoing a change to a connected database, starting a transfer, and downloading an app's signing key.
Account state still applies. Starting previews, running checks, publishing and other building routes answer 402 with upgradeRequired: true when your account has no active plan or trial, and publishing needs a verified email address.
Project limits #
A token created for specific projects:
- gets
404 Not foundfor any other project under/api/projects/<id>, as if it didn't exist; - sees only its projects in
GET /api/projects; - can't create projects (
403 A project-limited token can't create projects); - can call
POST /api/ai/componentonly with theprojectIdof one of its projects (404 otherwise).
Library, system and notification routes are not project-specific, so the project list doesn't narrow them.
OAuth apps #
An app that works for other Devmachinist users, like an MCP client, an IDE plugin or a hosted integration, shouldn't ask people to paste a token. It signs them in with OAuth 2.1 instead. The person approves it on a Devmachinist page and chooses its scopes and projects, and the app gets tokens that work everywhere a personal access token does: the REST routes on this page and the MCP server.
| Item | Value |
|---|---|
| Authorization server metadata | GET /.well-known/oauth-authorization-server (RFC 8414; also at /.well-known/openid-configuration) |
| Protected resource metadata | GET /.well-known/oauth-protected-resource/api/mcp (RFC 9728) |
| Registration | POST /oauth/register (dynamic client registration, RFC 7591) |
| Authorization | GET /oauth/authorize (authorization code with PKCE S256, required) |
| Token | POST /oauth/token (authorization_code, refresh_token) |
| Revocation | POST /oauth/revoke (RFC 7009) |
| Scopes | read, write, preview, publish (the same as token scopes) |
| Resource | https://devmachinist.com/api/mcp (optional resource parameter, RFC 8707) |
Most MCP clients do all of this by themselves from the address alone. The steps below are for writing your own.
1. Register the app #
curl -s https://devmachinist.com/oauth/register \
-H "Content-Type: application/json" \
-d '{"client_name": "My integration", "redirect_uris": ["https://example.com/oauth/callback"], "client_uri": "https://example.com"}'{ "client_id": "dmc_…", "client_id_issued_at": 1763078400, "client_name": "My integration",
"redirect_uris": ["https://example.com/oauth/callback"], "grant_types": ["authorization_code", "refresh_token"],
"response_types": ["code"], "token_endpoint_auth_method": "none" }redirect_uris: up to 10.httpsaddresses anywhere;httponly onlocalhost,127.0.0.1or[::1], where any port matches (an app that opens a random local port registers it without one); or a native app's own scheme likemyapp://callback. The redirect sent later must match one exactly (apart from the loopback port).token_endpoint_auth_method:none(a public client, the default: a CLI, desktop or browser app), orclient_secret_post/client_secret_basicfor a server that can keep a secret. Then the answer also has aclient_secret, shown only this once.client_name(≤ 80 characters) andclient_uriare shown to the person on the consent page. Registration is limited to 20 an hour per address. A client that never gets used is removed after 30 days.
2. Send the person to the authorization page #
Make a PKCE pair (a random code_verifier of 43 to 128 characters, and code_challenge = base64url of its SHA-256), then open:
https://devmachinist.com/oauth/authorize?response_type=code
&client_id=dmc_…
&redirect_uri=https%3A%2F%2Fexample.com%2Foauth%2Fcallback
&code_challenge=<challenge>&code_challenge_method=S256
&scope=read%20write%20preview
&state=<random>The person signs in if needed and sees your app's name, where it sends them back to and the scopes you asked for. They can untick scopes and limit the app to some of their projects before pressing Allow. Without scope the app asks for read, write and preview.
- Allow sends the browser to
redirect_uri?code=…&state=…&iss=https://devmachinist.com. The code works once, within 60 seconds. - Cancel sends it back with
error=access_denied. - A request with an unknown
client_idor aredirect_urithat isn't registered is shown as an error on Devmachinist's own page and never redirected. Other mistakes (no PKCE,plaininstead ofS256, a badresponse_type) come back to yourredirect_uriaserroranderror_description.
Check that state is the one you sent, and that iss is the server you expected.
3. Exchange the code #
curl -s https://devmachinist.com/oauth/token \
-d grant_type=authorization_code \
-d code=<code> \
-d redirect_uri=https://example.com/oauth/callback \
-d client_id=dmc_… \
-d code_verifier=<verifier>{ "access_token": "dm_oat_…", "token_type": "Bearer", "expires_in": 3600,
"refresh_token": "dm_ort_…", "scope": "read write preview" }The body is application/x-www-form-urlencoded. A confidential client adds client_secret, or sends it with HTTP Basic. The scope in the answer is what the person allowed, which can be less than you asked for.
4. Call the API #
curl -s https://devmachinist.com/api/projects -H "Authorization: Bearer dm_oat_…"An OAuth access token acts exactly like a personal access token with the same scopes and projects: everything on this page about scopes, what a token can reach, project limits, rate limits and errors applies. When it's expired or withdrawn the answer is 401 Invalid or expired access token.
5. Refresh #
Access tokens last an hour. Get a new pair with the refresh token:
curl -s https://devmachinist.com/oauth/token \
-d grant_type=refresh_token -d refresh_token=dm_ort_… -d client_id=dmc_…Every refresh returns a new refresh token and retires the old one, and the old access token stops working. Keep only the newest pair. Using a retired refresh token again is treated as theft: the whole connection is withdrawn and the person has to allow the app again. A refresh token that isn't used for 60 days expires.
Disconnecting #
The person sees every app they allowed under Account → Access tokens → Connected apps and can Disconnect one; its tokens stop working at once. Your app can disconnect itself too:
curl -s https://devmachinist.com/oauth/revoke -d token=dm_ort_… -d client_id=dmc_…Revoking the refresh token ends the whole connection; revoking an access token ends only that token. The answer is 200 either way, as the spec asks.
Token errors follow RFC 6749: 400 with {"error": "invalid_grant", "error_description": "…"} (or invalid_client, invalid_request, unsupported_grant_type, invalid_target). The token endpoint allows 120 requests a minute per address.
CSRF and cookies #
The CSRF guard rejects cross-site state changes made with the session cookie: it checks Origin (and Sec-Fetch-Site) and answers 403 Cross-site request blocked. Any request with an Authorization: Bearer … header skips that check, because another site can't make a browser attach your token. You don't need any CSRF token or extra header with a personal access token.
Rate limits #
Limits are fixed windows. Going over answers 429 with a Retry-After header and {"ok": false, "error": "Too many requests — try again in 42s"}.
| Limit | Applies to |
|---|---|
| 1,200 a minute per IP address | Every request. |
| 600 per 10 minutes per client | /api/mcp and /api/agent. |
| 600 a minute per account | Writes under /api/projects. |
| 30 per 10 minutes per account | Preview start and restart. |
| 30 per 10 minutes per account | Package installs, removals and updates, and typescript. |
| 40 per 10 minutes per account | git/push, git/pull, git/fetch, git/clone. |
| 20 per 10 minutes per account | Publishing writes (publish, rollback, unpublish). |
| 10 an hour per account | android and desktop exports. |
| 40 a minute per account | POST /api/ai/.... |
| 120 per 10 minutes per account | Writes to issues and comments. |
AI work also counts against your AI allowance: 60 generations an hour on the site's AI keys and 300 with your own key, and calls on the site's keys need AI credits (402 when you have none). The server's operator can tune any limit with RATE_<NAME>=max/seconds. If the server restricts access by country, requests from elsewhere get 451.
Responses and errors #
Every JSON response has an ok flag:
{ "ok": true, "path": "src/components/Hero.jsx" }{ "ok": false, "error": "old_text appears more than once — include more surrounding text so it is unique" }Errors are plain sentences meant to be shown to a person or read by a model. Some routes add fields, such as locked and by on a 423 or upgradeRequired on a 402.
| Status | When |
|---|---|
| 400 | Invalid input: a bad id or name, a missing field, a path outside the project, an edit that doesn't apply. |
| 401 | No credentials, or the token is invalid, revoked or expired. |
| 402 | No active plan or trial, a project or site limit reached, or no AI credits. |
| 403 | Missing scope, a route tokens can't use, a protected path (.git/, node_modules/, .npmrc), or an action only a person can take. |
| 404 | No such project (or not in the token's list), file, page, component or staged change. |
| 409 | Conflicts: the file or page already exists, a staged change isn't pending, an experiment is running and blocks publishing or git. |
| 413 | A file or body is too large. |
| 422 | Publishing: the build failed (the response has a log). |
| 423 | The file, API or whole project is held by an AI answer or build that is running now. |
| 429 | Rate limit. |
ok, not only the status. A few routes report a failed operation with HTTP 200 and "ok": false: check/build when the site doesn't build, package installs when npm fails, and git/push when git refuses.Locks (423) #
While an AI Chat answer or a site build is changing a project, people and agents can read everything but can't write what it holds:
{
"ok": false,
"locked": true,
"file": "src/pages/Home.jsx",
"by": { "kind": "chat", "user": { "name": "Dana" }, "goal": "Add a pricing section", "files": ["src/pages/Home.jsx"], "whole": false },
"error": "src/pages/Home.jsx is being changed by Dana's AI — working on “Add a pricing section”. You can watch it — it opens for editing when the AI is done."
}by is abbreviated here; it also carries the work's id, thread, planned files, held APIs and start time.
A build holds the whole project: files, components, pages, brand, packages, git and publishing answer 423 until it ends. Git changes and project-wide replace also wait while any AI holds files (git/fetch, git/summary and git/message still work). Wait and retry.
Reference #
Routes written as /projects/… are under https://devmachinist.com/api, so /projects/<id>/files means https://devmachinist.com/api/projects/<id>/files. <id> is a project id, 12 letters and digits such as Vq3xT8mKp2Lw. The scope each route needs follows from the rules above and is shown in each table.
Discover the API #
GET /api/agent describes every MCP tool with its scope, input schema and the REST route it calls, plus the scopes, the MCP address, limits (the size, quota and guarantee notes the built-in AI works with), the tools' version and fingerprint, and the changelog. It needs no token. GET /api/agent/changelog?since=1.2.0 gives only the changes after a version, as text and entries.
curl -s https://devmachinist.com/api/agent | jq '.tools[] | {name, scope, rest}'{ "name": "read_lines", "scope": "read", "rest": "GET /api/projects/%7BprojectId%7D/lines/%7Bpath%7D?from=%7Bfrom%7D&to=%7Bto%7D" }The rest strings fill each argument with a URL-encoded {name} placeholder.
Projects #
| Route | Scope | What it does |
|---|---|---|
GET /api/projects | read | Your projects and team-shared ones: id, name, updatedAt, componentCount, pageCount, running, url, template, icon, isTemplate, and shared for team projects. |
POST /api/projects | write | Create a project: name (≤ 80), optional template (blank, ecommerce, blog, library), auth (sign-in for blank), or from (copy one of your projects). |
GET /api/projects/<id> | read | The manifest (pages, components without code, packages) and preview state. |
PUT /api/projects/<id> | write | {"project": {…}} with any of name, description, settings, theme, activePage, isTemplate. |
DELETE /api/projects/<id> | write | Archive it (owner only). ?permanent=1 deletes it for good. |
GET /api/projects/<id>/symbols | read | Components with their tag, export and props; library components; installed packages. |
curl -s https://devmachinist.com/api/projects \
-H "Authorization: Bearer $DM_TOKEN" \
-H 'Content-Type: application/json' \
-d '{"name": "Corner Bakery", "template": "blank"}'Creating a project can answer 402 when you are at your plan's project limit; on Pay as you go it adds the project's price to your next invoice.
Files #
Paths are relative to the project workspace (a Vite + React + Tailwind v4 app), e.g. src/pages/Home.jsx. Paths can't leave the workspace, symbolic links that point outside are refused, and .git/, node_modules/ and .npmrc can be read but never written.
| Route | Scope | What it does |
|---|---|---|
GET /projects/<id>/files | read | The file tree (node_modules, .git, dist, .cache left out). |
GET /projects/<id>/files/<path> | read | {type: "file", content, path, size} (≤ 5 MB), or {type: "dir", children}. |
PUT /projects/<id>/files/<path> | write | {"content": "…"} creates or overwrites a file (≤ 5 MB). A component or page file keeps the project's manifest in step. |
POST /projects/<id>/files | write | {"path", "type": "file" or "dir", "content"} creates; 409 if it exists. |
PATCH /projects/<id>/files/<path> | write | {"newPath"} renames or moves. |
DELETE /projects/<id>/files/<path> | write | Deletes a file or a folder. |
PUT /projects/<id>/upload?path=<path> | write | Raw bytes, streamed (≤ 25 MB by default). 409 if the file exists unless &overwrite=1. |
POST /projects/<id>/import-url | write | Save a file from the web without passing it through a model (see the import_url tool). |
# Read a file
curl -s https://devmachinist.com/api/projects/Vq3xT8mKp2Lw/files/src/pages/Home.jsx \
-H "Authorization: Bearer $DM_TOKEN" | jq -r .content
# Write a file
curl -s -X PUT https://devmachinist.com/api/projects/Vq3xT8mKp2Lw/files/src/data/hours.json \
-H "Authorization: Bearer $DM_TOKEN" -H 'Content-Type: application/json' \
-d '{"content": "{\"open\": \"7:00\", \"close\": \"15:00\"}\n"}'
# Upload a picture
curl -s -X PUT 'https://devmachinist.com/api/projects/Vq3xT8mKp2Lw/upload?path=public/media/croissant.jpg' \
-H "Authorization: Bearer $DM_TOKEN" --data-binary @croissant.jpgFiles the builder generates (src/site.js, src/App.jsx, src/main.jsx, src/api/) are rebuilt from the project when pages, brand or data change. The Files routes will write them, but the change won't last; the line-editing routes below refuse them.
Components and pages #
| Route | Scope | What it does |
|---|---|---|
GET /projects/<id>/components | read | Components without code. |
GET /projects/<id>/components/<Name>/code | read | {name, code}. |
POST /projects/<id>/components | write | {"name", "code"} adds src/components/<Name>.jsx (≤ 1 MB); 409 if it exists. |
PUT /projects/<id>/components/<Name> | write | {"code", "newName"} replaces the source, optionally renaming. |
DELETE /projects/<id>/components/<Name> | write | Removes the component and its file. Pages that import it are not rewritten. |
GET /projects/<id>/pages | read | Pages without code: name, slug, hidden, roles, description. |
GET /projects/<id>/pages/<Name>/code | read | The page's source, read from its file. |
POST /projects/<id>/pages | write | {"name", "slug"}: a JavaScript identifier such as AboutUs; the slug is a–z, 0–9 and dashes. |
PUT /projects/<id>/pages/<Name> | write | Any of code, newName, slug, listed, roles, description (≤ 300). |
DELETE /projects/<id>/pages/<Name or slug> | write | Deletes the page: its file, route and menu entry (not the last one). It leaves the live site at the next publish. Deleting src/pages/<Name>.jsx through the files routes does the same. |
GET /projects/<id>/brand | read | Brand, theme, colour families, fonts and options. |
PUT /projects/<id>/brand | write | Change brand and theme; rewrites src/site.js, index.html and the managed CSS block. |
curl -s -X PUT https://devmachinist.com/api/projects/Vq3xT8mKp2Lw/pages/Menu \
-H "Authorization: Bearer $DM_TOKEN" -H 'Content-Type: application/json' \
-d '{"description": "Breads, pastries and coffee, baked every morning.", "listed": true}'Line editing #
These are the cheapest way for an agent to read and change code: number-addressed reads and small, checked edits. They work on index.html and text files under src/ (.jsx .tsx .js .ts .css .json .glsl .vert .frag), never on generated files, and only on files that exist. Files can be up to 512 KB.
GET /projects/<id>/lines/<path>?from=&to= (read) returns numbered lines, at most 2,000 per call and about 100,000 characters, always whole lines:
curl -s 'https://devmachinist.com/api/projects/Vq3xT8mKp2Lw/lines/src/components/Hero.jsx?from=1&to=20' \
-H "Authorization: Bearer $DM_TOKEN"{
"ok": true,
"path": "src/components/Hero.jsx",
"text": " 1│import React from 'react'\n 2│\n 3│export default function Hero() {\n…",
"from": 1,
"to": 20,
"total": 34
}When a read stops early the text ends with … (stopped at line N to keep the result small — continue with from: N+1).
POST /projects/<id>/edit (write) makes one small change. Every reply carries problems: syntax errors the change caused in that file, so you can fix them before building.
op | Fields | Does |
|---|---|---|
insert | path, after, text | Inserts text after line after (0 = the top). |
replace_lines | path, from, to, text | Replaces lines from to to (1-based, inclusive). |
replace_text | path, old_text, new_text | Replaces one exact snippet, which must appear exactly once. |
edits | path, edits | A list of up to 40 {old_text, new_text} replacements, applied in order, all or nothing. |
curl -s https://devmachinist.com/api/projects/Vq3xT8mKp2Lw/edit \
-H "Authorization: Bearer $DM_TOKEN" -H 'Content-Type: application/json' \
-d '{
"op": "edits",
"path": "src/components/Hero.jsx",
"edits": [
{ "old_text": "Fresh bread daily", "new_text": "Baked before sunrise" },
{ "old_text": "bg-amber-600", "new_text": "bg-brand-600" }
]
}'{ "ok": true, "message": "Made 2 changes to src/components/Hero.jsx", "problems": [] }If any snippet isn't found or isn't unique, nothing changes and the error says which edit failed, e.g. Edit 2 of 2: old_text was not found — read the file again and copy the text exactly (nothing was changed).
Search and replace #
POST /projects/<id>/search (read) searches text files under src/ and index.html (each ≤ 512 KB). Body: q, and optionally regex, case (case-sensitive) and word (whole words). Patterns run with a 4-second limit.
curl -s https://devmachinist.com/api/projects/Vq3xT8mKp2Lw/search \
-H "Authorization: Bearer $DM_TOKEN" -H 'Content-Type: application/json' \
-d '{"q": "useCart\\(", "regex": true}'The reply has total, truncated (more than 2,000 matches) and files, each with its matches (line, col, pre, text, post) and managed: true for generated files.
POST /projects/<id>/replace (write) takes the same fields plus replacement (≤ 5,000 characters), and optionally paths (only these files) and exclude (skip these). With regex, the replacement can use $&, $1 and $<name>. Generated files are never changed. It returns total and the files it changed with their count.
Preview #
| Route | Scope | What it does |
|---|---|---|
POST /projects/<id>/start | preview | Starts the sandboxed Vite preview, installing packages on the first run. Returns running, url, ready (and already: true if it was running). |
POST /projects/<id>/restart | preview | Stops and starts it. |
POST /projects/<id>/stop | preview | Stops it: {stopped}. |
POST /projects/<id>/scaffold | preview | Writes any missing workspace files (never overwrites). |
GET /projects/<id>/status | read | running, ready, starting, url. |
GET /projects/<id>/logs | read | The last 100 lines of the preview's output. |
curl -s -X POST https://devmachinist.com/api/projects/Vq3xT8mKp2Lw/start -H "Authorization: Bearer $DM_TOKEN"
curl -s https://devmachinist.com/api/projects/Vq3xT8mKp2Lw/logs -H "Authorization: Bearer $DM_TOKEN" | jq -r '.logs[]'The preview address is for the builder's frames; to look at a page from a script, use page inspection below.
Build check and page inspection #
POST /projects/<id>/check/build (preview) builds the site both ways it runs: the preview (Vite, development mode) and the published site (Next.js static export). A failing build answers HTTP 200 with ok: false, the file and an error text with line, column and the lines around it.
curl -s -X POST https://devmachinist.com/api/projects/Vq3xT8mKp2Lw/check/build -H "Authorization: Bearer $DM_TOKEN"{ "ok": true, "text": "The site builds: the preview (Vite, 3.4 s) and the published site (Next.js, 38.9 s)." }{ "ok": false, "file": "src/components/Hero.jsx", "text": "Build failed in src/components/Hero.jsx:14:9:\nExpected corresponding JSX closing tag for <section>\n 12 | <h1 …" }POST /projects/<id>/check/page (preview) builds the site, opens one page in a headless browser and reports what happened. Body:
| Field | Meaning |
|---|---|
page | A page name or slug (default: the first page). With published, an item address such as product/3. |
actions | Up to 25 steps, 5 s each, 90 s per call: {"text": "Order"} or {"selector": "#buy"} clicks; {"selector": "input[name=email]", "value": "a@b.co"} fills; {"press": "Enter"}; {"wait": 800}; {"goto": "menu"}. |
viewport | desktop (1280×900, default) or phone (390×844). |
selector | Limit the outline and screenshot to one element. |
published | true opens the Next.js export at its real address instead of the preview build. |
curl -s https://devmachinist.com/api/projects/Vq3xT8mKp2Lw/check/page \
-H "Authorization: Bearer $DM_TOKEN" -H 'Content-Type: application/json' \
-d '{"page": "menu", "viewport": "phone", "actions": [{"text": "Pastries"}]}'{
"ok": true,
"clean": true,
"text": "#menu (phone 390×844) — “Corner Bakery”\nSteps:\n ✓ click “Pastries”\nErrors: none\nConsole: empty\nHeadings: Our menu | Pastries\nButtons: Breads | Pastries | Coffee\n…",
"shot": "shot_mhx2k9a1f03c2b.png",
"screenshot": "/api/projects/Vq3xT8mKp2Lw/ai/shots/shot_mhx2k9a1f03c2b.png"
}clean is false when the page had errors. Writes to the data API are answered with 204 and change nothing. Fetch the screenshot with GET on its address (read scope); the newest 30 per project are kept.
POST /projects/<id>/journeys (preview) runs customer journeys: the site as a visitor, a signed-in user, an admin and each custom role, on throwaway copies of its data ({"roles": [...]} narrows it). See the simulate_journeys tool.
Publishing #
| Route | Scope | What it does |
|---|---|---|
POST /projects/<id>/publish | publish | Builds and publishes a snapshot. Optional {"slug"} sets the site address (a–z, 0–9, dashes, ≤ 48). |
GET /projects/<id>/publish | publish | published, slug, version, publishedAt, size, url, versions. |
POST /projects/<id>/publish/rollback | publish | {"version": "v…"} points the site at an earlier snapshot (the last 3 are kept). |
DELETE /projects/<id>/publish | publish | Unpublishes. |
curl -s -X POST https://devmachinist.com/api/projects/Vq3xT8mKp2Lw/publish \
-H "Authorization: Bearer $DM_TOKEN" -H 'Content-Type: application/json' -d '{}'{ "ok": true, "slug": "corner-bakery", "version": "vmhx3b1q2", "primary": true, "url": "https://sites.devmachinist.com/@dana/corner-bakery/", "size": 812044 }Publishing can fail with 402 (no free site slot on your plan, for a project not yet published), 403 with needsVerification (verify your email first), 409 (an experiment is running), 400 (choose a username first, or a bad slug) and 422 with error: "Build failed" and the build log. A build takes from a few seconds to about a minute, so use a generous client timeout.
Packages #
| Route | Scope | What it does |
|---|---|---|
GET /projects/<id>/packages | read | installed, declared (package.json), tracked, healthy and base (React, Vite, Tailwind versions). |
GET /projects/<id>/packages/scan | read | Every package the code imports, and which are missing. |
POST /projects/<id>/packages/install | write | {"packages": ["framer-motion", "date-fns@4"]}. |
POST /projects/<id>/packages/install-missing | write | Installs every imported package that isn't installed. |
POST /projects/<id>/packages/uninstall | write | {"packages": [...]}. |
POST /projects/<id>/packages/update | write | {"packages": [...]}, or everything when empty. |
POST /projects/<id>/packages/reinstall | write | Deletes node_modules and the lockfile and installs again. |
POST /projects/<id>/packages/upgrade-base | write | Moves the project to the current React, Vite and Tailwind and restarts its preview. |
npm runs in the project's sandbox against the public registry with install scripts turned off. When npm fails, the reply is HTTP 200 with ok: false, error and npm's output.
curl -s https://devmachinist.com/api/projects/Vq3xT8mKp2Lw/packages/install \
-H "Authorization: Bearer $DM_TOKEN" -H 'Content-Type: application/json' \
-d '{"packages": ["framer-motion"]}'Git #
GET /projects/<id>/git/summary (read) returns a plain-text overview: branch, upstream with ahead and behind, remotes, local branches, staged, changed and new files, and recent commits. Add ?diff=1 for the diff (≤ 50,000 characters) and &file=<path> for one file.
curl -s 'https://devmachinist.com/api/projects/Vq3xT8mKp2Lw/git/summary?diff=1' \
-H "Authorization: Bearer $DM_TOKEN" | jq -r .textPOST /projects/<id>/git/do (write) runs one operation and returns {ok, text}:
action | Fields |
|---|---|
init | message (first commit, default "Initial commit"). Starts on main. |
commit | message (required), files (default: everything). |
push | remote (default origin), branch, remote_branch, set_upstream. Needs the publish scope too. Never forced. |
pull | remote, branch, rebase (default fast-forward only). |
fetch | remote. |
branch | name, checkout (default true). |
checkout | name. |
remote_add, remote_set_url | remote, url. |
remote_remove | remote. |
curl -s https://devmachinist.com/api/projects/Vq3xT8mKp2Lw/git/do \
-H "Authorization: Bearer $DM_TOKEN" -H 'Content-Type: application/json' \
-d '{"action": "commit", "message": "Add opening hours to the footer"}'Also available: GET /git/remotes (read), POST /git/message (write: a commit message written by your AI from the diff, optional files), and POST /git/push (publish: remote, localBranch, remoteBranch, setUpstream; force: true uses --force-with-lease). Push, pull and fetch refuse a remote that doesn't exist, and credentials come from More → Git in the builder. While an experiment runs, everything except fetch answers 409.
Data #
The project's data API (models, rules, sign-in) and its rows. Data API explains the models and runtime; these routes are the agent's side. Most return a text summary written for people and models.
| Route | Scope | What it does |
|---|---|---|
GET /projects/<id>/data-api?apiId= | read | Models, fields, access rules, sign-in and the generated hooks. |
POST /projects/<id>/data-api | write | Change it like the API designer saves it (add_models, add_fields, change_fields, remove_fields, remove_models, rules, roles, sign_in, uploads, sample_rows, api_id). Creates and connects an API if there is none. |
GET /projects/<id>/data/inspect?model=&apiId= | read | Fields and rules, row counts, recent rows, references, sources, access problems. |
GET /projects/<id>/data/query | read | Exactly the rows you need (below). |
POST /projects/<id>/data/stage | write | Preview adding or updating up to 5,000 rows. Nothing is written. |
GET /projects/<id>/data/staged | read | Recent staged changes (?thread= for one chat). |
GET /projects/<id>/data/staged/<sid> | read | One staged change; ?full=1 for every row. |
POST /projects/<id>/data/staged/<sid>/commit | write | Save a pending change: one transaction, every row read back, undo kept for 30 days. |
GET /projects/<id>/widgets | read | The project's launcher widgets with their pages and addresses. |
POST /projects/<id>/widgets | write | {"name", "w", "h", "page", "refresh"} adds one (a new hidden page when page is left out). |
PUT / DELETE /projects/<id>/widgets/<wid> | write | Change or remove a widget (its page stays). |
GET /launcher | read | What the Android launcher shows: your projects (with the Android app ids built for them and where they're published), every widget, and your builder home layout. |
POST /projects/<id>/data/staged/<sid>/discard | write | Drop a pending change. |
POST /projects/<id>/data/staged/<sid>/undo | write | Delete the rows it added and restore the rows it updated. |
GET /projects/<id>/data/staged/<sid>/verify | read | Re-read a committed import: how many rows still match. |
GET /projects/<id>/data/imports?staged=&offset=&limit= | read | Recent imports, or one with every unsaved row and its reason. |
POST /projects/<id>/data/staged/<sid>/retry | write | {"fixes": {"<row>": {field: value}}} stages a saved import's failed rows again. |
Query parameters for data/query: model (required), where (a JSON list of {field, op, value}; ops eq ne lt lte gt gte contains starts in null notnull orphan), sort, order, limit (≤ 250), offset, fields (comma-separated), groupBy, duplicatesOn (comma-separated), apiId.
curl -s -G https://devmachinist.com/api/projects/Vq3xT8mKp2Lw/data/query \
-H "Authorization: Bearer $DM_TOKEN" \
--data-urlencode 'model=Product' \
--data-urlencode 'where=[{"field":"price","op":"gt","value":10}]' \
--data-urlencode 'fields=id,name,price' --data-urlencode 'limit=20'Staging, reviewing and committing an import:
curl -s https://devmachinist.com/api/projects/Vq3xT8mKp2Lw/data/stage \
-H "Authorization: Bearer $DM_TOKEN" -H 'Content-Type: application/json' \
-d '{
"model": "Product",
"csv": "Name,Price\nSourdough,8.50\nCroissant,3.20",
"mapping_json": "{\"name\": \"Name\", \"price\": \"Price\"}",
"match_on": ["name"]
}'{
"ok": true,
"text": "Staged stg_4f1c9a0b7e2d6c35 — Product: 2 new, 0 updated, 0 unchanged. Matched existing rows on name.\nWaiting for the person's approval — …",
"staged": { "id": "stg_4f1c9a0b7e2d6c35", "status": "pending", "model": "Product", "summary": "Product: 2 new, 0 updated, 0 unchanged", "matchOn": ["name"], "total": 2, "preview": ["…"] }
}curl -s -X POST https://devmachinist.com/api/projects/Vq3xT8mKp2Lw/data/staged/stg_4f1c9a0b7e2d6c35/commit \
-H "Authorization: Bearer $DM_TOKEN"A stage takes its rows from one of rows_json (a JSON string), csv, file_path (a CSV or JSON file in the workspace, ≤ 10 MB), source_url (a JSON or CSV file on the web), source_id (a collected source) or connection_id + resource (a linked app). mapping_json maps model fields to source keys, defaults_json fills empty fields, and match_on makes re-runs update instead of duplicating. Pending stages expire after a day. Committing answers 409 if the change isn't pending or its API is no longer connected.
Connected PostgreSQL and MySQL databases and linked apps live under /projects/<id>/connections. Tokens can list, inspect, query (read) and stage or plan (write); a person approves in the builder. See Connections and the tool reference.
AI map and context #
GET /projects/<id>/ai/map (read) returns a compact map of the project (pages with access, components, modules, data models with row counts, sign-in and roles, theme, generated files, connections, a running experiment) with a version hash that changes when any of them does. Add ?topic= for detail: components (with &names=Hero,MenuList), design, data, auth, structure, modules, files, connections, graphics or tools.
curl -s 'https://devmachinist.com/api/projects/Vq3xT8mKp2Lw/ai/map?topic=components&names=Hero' \
-H "Authorization: Bearer $DM_TOKEN" | jq -r '.map, .context'POST /api/ai/component (write) asks the AI that applies to you and the project to write one component: {"projectId", "prompt", "name", "mode": "component"}. It returns code, name, props and warnings and saves nothing; add the result with POST /projects/<id>/components. GET /api/ai/status?projectId= (read) says which provider and model apply.
App files #
The file storage of the app's data API (the files your site's visitors upload; see Data API).
| Route | Scope | What it does |
|---|---|---|
GET /projects/<id>/app-files?api_id=&access= | read | api (who may upload, access words), files (url, access, type, size, uploader), used and quota. |
POST /projects/<id>/app-files | write | {"path", "access", "api_id"} copies a workspace file into storage and returns its url. access is public (default), private, users or a custom role. Needs sign-in on the API. |
curl -s https://devmachinist.com/api/projects/Vq3xT8mKp2Lw/app-files \
-H "Authorization: Bearer $DM_TOKEN" -H 'Content-Type: application/json' \
-d '{"path": "public/media/menu.pdf", "access": "users"}'The chat's tools #
Every tool the builder's AI chat uses runs for a token too, with the same code: POST /api/projects/<id>/tools/<name> with the tool's arguments as the body. It answers {"ok": true, "tool": "<name>", "result": "<text>"}, or {"ok": false, "error": "…"} with the tool's status (423 when another AI or agent holds a file it would change). The routes on this page cover most of them; the ones without a route of their own are: search, get_context, get_api, read_url, check_access, ai_activity, find_sources, inspect_connection (read) and create_file, rename_file, install_package, remove_package, change_api, remember, ask_question, declare_plan, set_page_access, connect_database, connect_app, run_database_migration (write).
curl -s https://devmachinist.com/api/projects/Vq3xT8mKp2Lw/tools/declare_plan \
-H "Authorization: Bearer $DM_TOKEN" -H 'Content-Type: application/json' \
-d '{"summary": "Add a featured row to Home", "files": ["src/pages/Home.jsx"]}'Every file an agent writes is held for it as well, like a chat answer's: people watch it change live and can't edit it, and other AIs and agents are refused it, until the agent has made no call for 3 minutes (15 with a declared plan) or calls DELETE /api/projects/<id>/tools/plan (MCP release_plan). The agent's own writes pass its own holds. A plan declared with declare_plan holds its files for this token until DELETE /api/projects/<id>/tools/plan or 15 minutes without a call: people and other AIs get 423 on those files, while the token's own writes go through. See AI chat tools and the MCP tool reference.
Starting projects, instructions, analytics and uploads #
| Route | Scope | What it does |
|---|---|---|
GET /templates | read | The project templates. |
POST /projects | write | {"name", "template", "auth"} or {"name", "from": "<your project id>"} creates a project (not with a project-limited token; 402 at the plan's limit). |
POST /projects/<id>/ai/build | write | {"prompt", "ask": false} has Devmachinist's AI build the whole site in the background; it shows as a chat in the builder. |
GET /ai/jobs | read | AI builds running now or finished in the last hour, with steps done of total. |
GET /projects/<id>/knowledge | read | {project, account, text}: the project's instructions and yours. |
PUT /projects/<id>/knowledge | write | {"project"} and/or {"account"} (≤ 20,000 characters each; empty clears). |
GET /projects/<id>/analytics?days= | read | The published site's views, visitors, bounce rate, series, pages, sources, devices, browsers, countries and crawlers, plus a text summary. |
POST /projects/<id>/upload-url | write | {"path", "overwrite"} → a one-time url for 15 minutes. |
PUT /uploads/<token> | none | The file's bytes (≤ 25 MB) to that address, once; no Authorization header (the address is the credential). → {ok, path, size}. |
POST /projects/<id>/data/staged/<sid>/discard | write | Throws away a pending staged change (a data preview or a database change); nothing is written. |
# Upload a picture without putting it in a JSON body
URL=$(curl -s -X POST https://devmachinist.com/api/projects/Vq3xT8mKp2Lw/upload-url \
-H "Authorization: Bearer $DM_TOKEN" -H 'Content-Type: application/json' \
-d '{"path": "public/media/hero.jpg"}' | jq -r .url)
curl -T ./hero.jpg "$URL"More routes a token can use #
Tokens reach every other route under /api/projects/<id> with the scope the rules above give it, including issues and comments, project memory, experiments, the evidence graph and sources. The MCP tool reference lists each one an agent is expected to use, with its route, arguments and results.