Developer API

Everything your agent does over MCP, as plain HTTP: create a project, write its files, check and apply, run verify, deploy, roll back and operate the running app. Use it from scripts and CI, or from any language. The CLI is a thin client of it.

When you would use it

  • A CI job that applies, verifies and deploys on every merge.
  • A script that sets up projects for clients from a template.
  • Your own tools around Appbricx, in any language.

Your app's own API (its tables, actions and queries) is a different surface: see the data API.

Base URL and auth

https://appbricx.com/api/dev/v1          # self-hosted: https://<your platform host>/dev/v1
Authorization: Bearer apx_pat_…
  • A personal access token for one workspace, with the scopes it needs: read (reads, checks, dry runs), apply (dev writes, secrets), deploy (production writes, deploys, rollbacks, restores, domains). See access tokens.
  • JSON in and out. A project outside the token's reach answers 404.
  • Every write is in the workspace's audit log with the token as the actor.

From files to production

API=https://appbricx.com/api/dev/v1
H=(-H "Authorization: Bearer $APPBRICX_TOKEN" -H 'content-type: application/json')

# 1. a project from the code-first starter, built in dev
curl -sS -X POST "$API/templates/team-outings/use" "${H[@]}" \
  -d '{"name": "Offsite Co", "params": {"brand_name": "Offsite Co"}}'
PROJECT=3b7e…

# 2. change files in the draft (rev from the last answer refuses a concurrent edit)
curl -sS -X POST "$API/projects/$PROJECT/files" "${H[@]}" \
  -d '{"files": {"db/queries/bookings-by-status.sql": "-- @param status text\n-- @roles ops\nselect count(*)::int as n from booking where status = :status;"}}'

# 3. check, then apply to dev
curl -sS -X POST "$API/projects/$PROJECT/files/check" "${H[@]}"
curl -sS -X POST "$API/projects/$PROJECT/files/apply" "${H[@]}"

# 4. verify (a 202 "running" answer means: call again to join the run)
curl -sS -X POST "$API/projects/$PROJECT/verify" "${H[@]}" -d '{}'

# 5. read the plan, then deploy
curl -sS -X POST "$API/projects/$PROJECT/deploy/plan" "${H[@]}" -d '{"subdomain": "offsite"}'
curl -sS -X POST "$API/projects/$PROJECT/deploy" "${H[@]}" -d '{"subdomain": "offsite"}'

Push a whole folder

If your client has a shell, push the tree with one request instead of sending files one by one (or pasting them into tool calls): stream a tar.gz (or a zip) of the folder that holds app.config.ts to PUT …/files/archive. The dev draft becomes exactly that tree in one edit; nothing is live until you apply.

tar -czf - --exclude=node_modules --exclude=.git -C ./myapp . \
  | curl -sS -X PUT "$API/projects/$PROJECT/files/archive?then=check" \
      -H "Authorization: Bearer $APPBRICX_TOKEN" -H 'content-type: application/gzip' --data-binary @-

# a zip works too
(cd myapp && zip -qr - . -x 'node_modules/*' '.git/*') \
  | curl -sS -X PUT "$API/projects/$PROJECT/files/archive?then=apply" \
      -H "Authorization: Bearer $APPBRICX_TOKEN" -H 'content-type: application/zip' --data-binary @-
  • mode=replace (default) deletes draft files the archive doesn't have, except package.json and package-lock.json when the archive has neither (the answer lists them in kept); mode=merge only adds and replaces files.
  • delete=path1,path2 deletes those draft files in the same edit, in either mode (paths the draft doesn't have come back in not_in_draft). A .appbricx-delete file at the archive's root, one path a line, does the same.
  • then=check answers the check report (errors at file and line); then=apply builds dev; rev= refuses the push if someone wrote the draft since.
  • Dot-files and folders (.env, .git), node_modules and binary files are left out and listed in skipped; files whose text didn't change aren't rewritten. A tree inside one folder (tar czf - myapp) works as well. Limits: 32 MiB compressed, 8 MiB of source, 2,000 files.
  • An agent signed in over MCP has no token in its shell: it calls project_files { action: "upload_url" }, which answers a token (apx_upl_…) that works for 30 minutes on this route of this one project, and the ready-made command. See upload tokens.

Routes by task

Paths below are under the base URL; … is /projects/:id. Each has the same scope and answer as the MCP tool next to it. Bodies, answers and errors are in the build and operate references.

TaskRoutesMCP tool
Tokens and youGET /me · POST, GET /tokens · DELETE /tokens/:idwhoami
ProjectsGET, POST /projects · GET /projects/:idlist_projects, create_project, get_project
Files (the dev draft)GET /projects/:id/files (?content=1) · GET, PUT, DELETE …/files/<path> · POST, PUT …/files · PUT …/files/archive (a tar.gz or zip of the tree) · POST …/files/move, /resetproject_files, code
Check and applyPOST …/files/check · POST …/files/apply · POST …/check, /apply {files} · POST …/plancheck_contract, apply_contract
VersionsGET …/versions · …/versions/:n · …/versions/diff · …/versions/compare · POST …/versions/:n/restore · PUT …/versions/:n/labelversions
PreviewsPOST, GET …/previews · DELETE …/previews/:name(appbricx push --preview)
TemplatesGET /templates · GET /templates/:slug · POST /templates/:slug/use · POST /templates · DELETE /templates/:slugsearch_templates, get_template, use_template, save_template
TestPOST …/verify · POST …/screenshot · POST …/check-code · POST …/workflows/:wid/run · GET …/runs/:runIdverify, screenshot, check_code, run
ShipPOST …/deploy/plan · POST …/deploy · GET …/deploys · POST …/deploys/:did/rollbackdeploy, deploys
DataPOST …/data/query · POST …/sql · POST …/rows · GET …/schema · POST …/data/export, /import, /copy · GET …/data/exportsquery_data, sql, edit_rows, describe_schema, data_transfer
SnapshotsGET, POST …/snapshots · POST …/snapshots/:sid/restore · POST …/snapshots/:sid/downloadsnapshots
OperateGET …/logs · GET …/tail · GET …/dead-letters · POST …/dead-letters/replaylogs, tail, run
SettingsGET …/secrets · PUT, DELETE …/secrets/:name · GET, POST …/sign-in · POST …/app-users · GET …/rolessecrets, sign_in_providers, app_users, roles
AddressesGET …/routing · GET, PUT …/routing/subdomain · POST …/domains · POST …/domains/:d/verify · PATCH, DELETE …/domains/:drouting, domains

In CI

# .github/workflows/appbricx.yml (a step)
- name: Apply and verify
  env:
    APPBRICX_API: https://appbricx.com/api/dev/v1
    APPBRICX_TOKEN: ${{ secrets.APPBRICX_TOKEN }}
  run: |
    appbricx push "$PROJECT" . --apply | tee apply.json
    jq -e '.report.ok' apply.json
    curl -sS -X POST "$APPBRICX_API/projects/$PROJECT/verify" \
      -H "Authorization: Bearer $APPBRICX_TOKEN" -H 'content-type: application/json' -d '{}'

On pull requests, appbricx push "$PROJECT" . --preview gives each branch its own preview instead of touching the dev draft.

Errors

StatusCodeWhat to do
401UNAUTHENTICATEDNo token, or an expired or revoked one.
403FORBIDDEN_SCOPEThe token lacks the scope; mint one with it.
404The project doesn't exist or is outside the token's workspace.
400BAD_ARCHIVEThe upload isn't a tar.gz, tar or zip, a path leaves the tree, or it has no project files.
409DRAFT_CHANGEDSomeone wrote the draft since your rev: read it again.
409PROJECT_BUSYAn apply is running: retry.
422CONTRACT_INVALIDThe files don't check; the answer's report has each error at its file and line.
428CONFIRM_REQUIREDA production change needs dry_run: false (or confirm); the answer previews it.

Every code the platform answers, with its fix, is in the guide's error catalogue: get_guide { section: "errors" }, or explain { about: "error", code } over MCP.

Related