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.
# 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 path | Does |
|---|---|
GET /functions | List functions |
POST /functions | Deploy: { 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>/body | Source files of the live version (?version= for another) |
GET /functions/<slug>/versions | The last 20 versions |
GET /functions/<slug>/logs | Log lines: ?level=error|warn|info|debug&search=&since=&limit= |
GET /functions/<slug>/stats | Invocations, errors, median and 95th percentile time, hourly series (?hours=, up to 168) |
GET /functions/logs | Logs of all functions |
GET /functions/usage | Invocations this month and your plan's limits |
GET /secrets, POST /secrets, DELETE /secrets | Secrets (names and digests; values are write-only) |
Function names (slug) use letters, digits, - and _, up to 63 characters; logs and usage are reserved.