Deploy to altengine
Publish an altengine.json manifest at any https URL and hand out a link. Whoever opens it signs in, picks an organization, sees every instance the app will create or change, and clicks Deploy. Opening the link again later updates the same app.
https://console.altengine.net/deploy?manifest=https%3A%2F%2Fexample.com%2Faltengine.jsonNothing is created before the click. The deploy runs as the person who clicks, within their role.
The button
[](https://console.altengine.net/deploy?manifest=https%3A%2F%2Fexample.com%2Faltengine.json)Link parameters
| Parameter | Meaning |
|---|---|
manifest | Required. The manifest's https URL, URL-encoded. |
name | App name. Defaults to the manifest's name. |
var.<name> | A value for one of the manifest's vars. Repeat for each. |
A var can also ride in the manifest URL's own query string: altengine.json?board=acme. A var. parameter wins. Every value can be edited on the page before deploying.
A manifest
{
"altengine": 1,
"name": "guestbook-{{board}}",
"title": "Guestbook",
"version": "1.4.0",
"homepage": "https://example.com",
"vars": {
"board": { "description": "Board id", "pattern": "[a-z0-9-]{1,24}" }
},
"instances": {
"datastore": {
"service": "datastore",
"indexes": [{ "collection": "entries", "fields": ["status", "createdAt:desc"] }],
"config": { "triggers": [{ "match": { "collection": "entries", "ops": ["create"] }, "queue": "${jobs}/notify" }] }
},
"auth": {
"service": "auth",
"config": { "access": { "datastore:${datastore}": { "level": "write" } } }
},
"jobs": {
"service": "tasks",
"queues": { "notify": { "target": { "function": "${functions}/notify" } } }
},
"functions": {
"service": "functions",
"env": { "DB": "${datastore}", "QUEUE": "${jobs}" },
"secrets": { "RESEND_KEY": { "description": "Resend API key" } },
"config": { "allowedHosts": ["api.resend.com"] },
"functions": {
"web": {
"module": { "url": "./dist/web.mjs", "sha256": "9f2c…" },
"grants": { "datastore:${datastore}": "write", "tasks:${jobs}": "write" }
},
"notify": {
"module": { "url": "./dist/notify.mjs", "sha256": "41b0…" },
"grants": { "datastore:${datastore}": "read" },
"schedules": ["*/15 * * * *"]
}
}
},
"static": {
"service": "static",
"config": { "spa": true },
"site": {
"base": "./dist/site/",
"files": { "/index.html": { "hash": "ab12…", "size": 1820 } }
},
"runtimeConfig": { "path": "/altengine.json", "expose": ["datastore", "auth", "functions"] }
}
}
}Relative URLs resolve against the manifest's URL. title, description, version and homepage are shown on the deploy page.
Instance names
Each key under instances becomes one instance, named from the app name:
| Key | Name, for app guestbook-acme |
|---|---|
Equal to its service: "datastore": { "service": "datastore" } | guestbook-acme |
Anything else: "jobs": { "service": "tasks" } | guestbook-acme-jobs |
Any key with "suffix": "auth" | guestbook-acme-auth |
Services: search, datastore, channel, auth, functions, static, tasks, blob. Up to 12 instances.
References
Wherever config names another instance, write ${key}. It becomes that instance's real name. A literal name in these places is refused, and ${…} anywhere else is refused.
| Field | Form |
|---|---|
Function grants keys | "<service>:${key}": "read" | "write" | "full" |
Auth config.access keys | "datastore:${key}", "channel:${key}" |
Datastore or blob config.triggers[].queue | "${key}/<queue>" |
Datastore config.live.channelInstance | "${key}" |
Tasks queues.*.target | { "function": "${key}/<fn>" }, { "channel": "${key}/<channel>" } |
Functions env values | ${key}, ${key:url}, ${key:origin} anywhere in the string |
Auth config.settings.allowedOrigins, functions config.corsOrigins | "${key:origin}" as one list item |
${key:url} is a static, functions or blob instance's public URL, such as https://guestbook-acme-web.altengine.app/; ${key:origin} is the same without the trailing slash. In the two origin lists it stands for every address the instance is served at when the deploy runs: its altengine.app origin and each active custom domain. A domain attached later is added on the next deploy.
Instance fields
| Field | Services | What it does |
|---|---|---|
service | all | Required. |
region | auth, blob, static, tasks | Set when the instance is created; fixed after. |
suffix | all | Name the instance <app>-<suffix> instead of by its key. |
config | all | The instance's settings, as in patch_instance_config, applied on every deploy (see merging). Not allowed: region, functions functions and secretsBlob, static activeDeployment. |
initialConfig | all | Like config, applied only by the deploy that creates the instance — for defaults an owner may change, such as auth settings.allowSignup. |
indexes | datastore | [{ collection, fields, unique?, namespace? }], up to 128. Added if missing. |
queues | tasks | { name: settings }, as in queue settings; up to 20. Created or updated. |
functions | functions | See Functions. |
env | functions | { NAME: value }, read by code as env.NAME. Written on every deploy. |
secrets | functions | { NAME: { description, required?, egress?, hosts? } }. The person enters the value on the page; a blank field keeps the stored one. |
site, runtimeConfig | static | See Static sites. |
How config merges
A top-level key is set. A key whose value is an object (auth settings, access, signup; datastore live) is merged one level: its own keys are set and the rest are kept. Lists are replaced, except auth settings.allowedOrigins and functions corsOrigins, which are added to, so origins an owner added survive updates.
env and secrets names are A-Z0-9_. DATASTORE, SEARCH, AUTH and CHANNEL are reserved. At most 32 per instance, together.
Functions
A module is one pre-bundled ES module of at most 5 MiB, named by URL and pinned by the hex sha256 of its bytes. A file that does not match is refused. Bundle first, for example with esbuild --bundle --format=esm --platform=neutral.
Instance names depend on the app name, so never write one into code. Pass them in through env:
"env": { "DB": "${datastore}", "QUEUE": "${jobs}" }export default {
async fetch(request, env) {
const open = await env.datastore.query({ instance: env.DB }, "entries", {
where: [{ field: "status", op: "=", value: "open" }],
});
await env.tasks.add({ instance: env.QUEUE }, "notify", { payload: { count: open.documents.length } });
return Response.json(open.documents);
},
};cpuMs (1–30,000) and subRequests (0–1,000) set a function's per-request CPU and outbound-call limits. Grants must use ${key} and cannot exceed the deploying person's role. schedules takes up to 5 cron expressions; leaving the field out clears them. Reserved function names: api, admin, v1, assets, healthz, robots, favicon, site, well-known.
On an update, a function whose code, grants and schedules have not changed is left alone. Changed ones get a new version, and an instance's functions switch over together after all of them are stored.
Static sites
site.files lists every file of the built site with the hex sha256 and size of its bytes; each is fetched from base + its path. Up to 5,000 files, 1 GiB, and 25 MiB per file. An update fetches only files whose hash changed. The site goes live last; if a deploy stops part way, the previous site keeps serving.
import { createHash } from "node:crypto";
import { readFileSync, readdirSync, statSync } from "node:fs";
import { join, relative } from "node:path";
function walk(dir, root = dir, out = {}) {
for (const name of readdirSync(dir)) {
const p = join(dir, name);
if (statSync(p).isDirectory()) walk(p, root, out);
else {
const bytes = readFileSync(p);
out["/" + relative(root, p).split("\\").join("/")] = {
hash: createHash("sha256").update(bytes).digest("hex"),
size: bytes.length,
};
}
}
return out;
}
console.log(JSON.stringify(walk("dist/site"), null, 2));runtimeConfig adds a generated file to the site so one build serves every install. Only the keys in expose are included:
{
"app": "guestbook-acme",
"version": "1.4.0",
"api": "https://api.altengine.net",
"vars": { "board": "acme" },
"instances": {
"datastore": { "service": "datastore", "name": "guestbook-acme", "id": "…", "url": null },
"functions": { "service": "functions", "name": "guestbook-acme", "id": "…", "url": "https://guestbook-acme-fn.altengine.app/" }
}
}const config = await fetch("/altengine.json").then((r) => r.json());Vars
"vars": {
"board": { "description": "Board id", "pattern": "[a-z0-9-]{1,24}" },
"color": { "default": "blue" }
}{{board}} is replaced in every string and key of the manifest, name included. A var without a default is required, and the page asks for it. Values are up to 200 characters, without $ { } " \ or control characters; pattern must match the whole value. An install keeps its values, and a redeploy reuses them.
A var in name makes each value its own app: "name": "guestbook-{{board}}" deployed with var.board=acme and var.board=zeta creates two apps with separate instances, and each redeploy updates its own.
Using existing instances
An app can ask for access to an instance the person already has:
"uses": {
"orders": { "service": "datastore", "level": "read", "why": "Shows each customer's orders", "suggest": "orders" }
}The person picks the instance (suggest preselects one by that name), and the page names it and the level. Refer to it with ${orders} in grants, auth access and env; each use needs at most the declared level. The app never configures, renames or deletes it. An update that adds a uses entry, raises a level, binds another instance or adds a use must be confirmed before it deploys.
Updates
Open the link again, or use Deployed apps → Redeploy in the console. The page lists what will change before anything does.
| Part | On update |
|---|---|
| Instances | Kept. New keys are created. |
config | Merged at the top level; keys the manifest sets are set again. |
| Indexes, queues | Added or updated, never removed. |
env | Written again. |
| Secrets | Kept unless a new value is entered. |
| Functions, site | New versions only for what changed. |
| A key removed from the manifest | Shown as no longer managed. The instance is kept and no longer changed. |
A deploy that stops part way continues from where it stopped when retried. A manifest URL on the same host as the install's, such as a newer release's folder, is an ordinary update; another host must be confirmed as a change of source. Check for updates fetches the URL last deployed, so a stable URL (…/latest/altengine.json) is the one to hand out.
Existing instances with the app's names
If an instance already exists with a name the app would create, and no deployed app manages it, the page offers to adopt it. It lists what will change on the instance and asks the person to confirm the takeover; adopting needs full on that instance. From then on the app manages it, and later deploys are ordinary updates. An app set up before it had a manifest moves over this way: deploy the manifest under the same app name and adopt.
An instance another deployed app manages is never adopted; choose a different app name.
Deployed apps has Check for updates on each app and Check all for updates above the list. A check fetches the manifest and compares it with the one last applied, and changes nothing; Update opens the review page. An owner can Unlink an app: its instances stay, and it is no longer checked or updated from its manifest. Deploying its link again offers to adopt them.
Limits
Manifest: 2 MiB, 12 instances, 8 uses, 20 vars, 128 indexes per datastore. Mailbox, automation and container instances cannot be deployed from a manifest, and site files are listed one by one; archives are not read.