ServicesDeploy
Services

Deploy

Every deployment sends every file, and a broken one never serves.

http
POST /api/services/<name>/deployments
json
{
  "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>.
filesPath to content: a string, or {"base64": "…"}. Every deployment sends every file: up to 2000 files, 50 MB.
mainDefaults to index.js, src/index.js, worker.js or main.js.
bindingsEnv name to db, files, jobs, realtime, assets or service:<name>.
cronsSchedules that queue a job: see jobs.
varsPlain 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 with status: "failed" and its error: 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>/activate
http
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 again

A bundle deploys the same version here or on another runner.