Services
Deploy
Every deployment sends every file, and a broken one never serves.
http
POST /api/services/<name>/deploymentsjson
{
"main": "src/index.js",
"files": {
"src/index.js": "export default { … }",
"src/page.html": "<!doctype html>…",
"logo.png": { "base64": "iVBORw0KGgo…" }
},
"bindings": { "DB": "db", "UPLOADS": "files", "JOBS": "jobs", "LIVE": "realtime" },
"crons": [{ "schedule": "0 * * * *", "payload": { "task": "cleanup" } }],
"vars": { "GREETING": "hello" }
}| Field | |
|---|---|
<name> | 1 to 40 lowercase letters, digits and hyphens. The first deployment creates the service, at https://<name>.<domain>. |
files | Path to content: a string, or {"base64": "…"}. Every deployment sends every file: up to 2000 files, 50 MB. |
main | Defaults to index.js, src/index.js, worker.js or main.js. |
bindings | Env name to db, files, jobs, realtime, assets or service:<name>. |
crons | Schedules that queue a job: see jobs. |
vars | Plain strings in env. Use secrets for credentials. |
Data belongs to the service and the binding's name: renaming a binding starts it empty, and removing one keeps its data until you empty it.
The answer
201:{"deployment": {...}, "url": "..."}. The new version serves every request from now on; the old one finishes the requests it has.422: the deployment withstatus: "failed"and itserror: a syntax error, a missing import, an exception at the top level. The previous version keeps serving.400: the request itself is invalid.
Versions
Each service keeps its last 10 deployments. Roll back, or forward, to any ready one:
http
POST /api/services/<name>/deployments/<id>/activatehttp
GET /api/services/<name>/deployments # newest first
GET /api/services/<name>/deployments/<id>/source # {main, files} as deployed
GET /api/services/<name>/deployments/<id>/bundle # the body that deploys it againA bundle deploys the same version here or on another runner.