Deploy with the API

Deploy and manage functions from CI, scripts and tools with the management API.

The dashboard uses the same API you can call with an access token (Account → Access tokens). A read-only token can list functions, read code, logs and stats; deploying, changing settings and secrets needs a read-write token. Tokens limited to some projects only see those.

Terminal
# Deploy (creates the function, or a new version when the code changed)
curl -X POST 'https://stitchdb.com/platform/v1/projects/<project-ref>/functions' \
  -H "Authorization: Bearer $STITCHDB_TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{
    "slug": "hello-world",
    "verify_jwt": true,
    "files": [{ "name": "index.ts", "content": "'"$(base64 -w0 index.ts)"'" }]
  }'

File contents are base64 (or pass "encoding": "utf8" on a file and send plain text). The entrypoint is index.ts (or the only code file) unless you pass "entrypoint"; a deno.json or import_map.json among the files is used as the import map. Deploying the same code again keeps the current version.

#Endpoints

All under https://stitchdb.com/platform/v1/projects/<project-ref>:

Method and pathDoes
GET /functionsList functions
POST /functionsDeploy: { slug, name?, verify_jwt?, entrypoint?, import_map?, files: [{ name, content }] }
GET /functions/<slug>One function
PATCH /functions/<slug>{ name?, verify_jwt?, version? }: settings, or make an earlier version live
DELETE /functions/<slug>Delete the function, its versions and logs
GET /functions/<slug>/bodySource files of the live version (?version= for another)
GET /functions/<slug>/versionsThe last 20 versions
GET /functions/<slug>/logsLog lines: ?level=error|warn|info|debug&search=&since=&limit=
GET /functions/<slug>/statsInvocations, errors, median and 95th percentile time, hourly series (?hours=, up to 168)
GET /functions/logsLogs of all functions
GET /functions/usageInvocations this month and your plan's limits
GET /secrets, POST /secrets, DELETE /secretsSecrets (names and digests; values are write-only)

Function names (slug) use letters, digits, - and _, up to 63 characters; logs and usage are reserved.