Apps and deployments
A hosted app is one site for one company. A deployment is one uploaded build of that app. This page is the lifecycle the API and the Shellui CLI share.
You call the API with Authorization: Bearer your_access_token_here. The token comes from identity-service. The company must already be approved, unless HOSTING_DEBUG_OPEN=true.
Apps
An app row stores a company-scoped name, a globally unique public slug, a display_name, and the current deployment. The slug is generated. It is 12 characters, starts with a letter, and uses lowercase letters and digits. You do not pick it.
Names and slugs are 3 to 63 characters, start with a letter, and contain only lowercase letters, digits, and hyphens. admin, api, apps, health, hosting, stats, access, deployments, and preview are reserved.
Two creates exist:
POST /hosting/v1/appswithnameanddisplay_namecreates a named app.expires_atstays empty, so the site does not expire. The name must be unique inside the company.POST /hosting/v1/previewis whatshellui deploycalls. With noslug, it creates a preview app owned by the caller. Finalize later setsexpires_at.
GET /hosting/v1/apps lists the caller's company. GET and DELETE /hosting/v1/apps/{app_ref} accept the app UUID, the company-scoped name, or the public slug. Delete removes the app, its deployments, the stored files, and the identity OAuth redirect for that origin. It emits hosting.app.deleted.
The default limit is 5 apps per company (HOSTING_MAX_APPS_PER_COMPANY). Preview creates count sites that have not expired. POST /hosting/v1/apps counts every row.
Deployments
POST /hosting/v1/apps/{app_ref}/deployments creates a draft. Body fields app_version and shellui_version must be semantic versions (1.4.0). The optional pinned flag is stored and returned. Serving ignores it.
Each app keeps at most HOSTING_MAX_DEPLOYMENTS_PER_APP deployment rows (default 20), including ones you no longer serve.
The statuses you will see:
| Status | Meaning |
|---|---|
draft | Row exists, no archive yet |
uploading | An archive was stored |
active | This deployment is the one being served |
superseded | It was active, then a newer finalize or a rollback replaced it |
failed | Extract failed. The row stays failed |
shellui deploy does not call the deployments collection itself. It calls preview, which creates the draft for you, then uploads and finalizes.
Upload and finalize
Upload with PUT /hosting/v1/apps/{app_ref}/deployments/{id}/upload. The body is the gzip tar archive (Content-Type: application/gzip), or a multipart file. The default cap is 100M (HOSTING_MAX_UPLOAD_BYTES). The body is streamed to disk, and a larger archive gets a 413 with a detail such as Artifact is 120 MB, the limit is 100 MB. A draft, an in-progress upload, or a failed deployment can accept another upload. An active one cannot.
POST /hosting/v1/apps/{app_ref}/deployments/{id}/finalize extracts the archive and, on success, marks this deployment active. The previous active deployment becomes superseded. The app's current_deployment points at the new row. Preview apps get a new expires_at of now plus HOSTING_PREVIEW_TTL_DAYS (default 7). The in-process serve cache for that slug is cleared.
Finalize also registers the site origin for login and returns oauth_redirect_registered, oauth_redirect_origin, and oauth_redirect_warning when registration fails. POST /hosting/v1/preview returns the same fields. See Preview sites and public URLs.
Extract keeps regular files only, drops path traversal, and enforces three limits: 5000 files, 500M uncompressed in total, and 100M for one file. Those are HOSTING_MAX_EXTRACT_FILES, HOSTING_MAX_EXTRACT_BYTES, and HOSTING_MAX_EXTRACT_FILE_BYTES. A bad archive stays failed, emits hosting.deployment.failed, and does not replace the current site.
Files land at {HOSTING_KEY_PREFIX}/{app_uuid}/deployments/{deployment_uuid}/artifact.tar.gz, with the extracted tree under extracted/.
Deploy tokens
A deploy token lets CI create and update preview sites without a personal login. Staff or a company owner creates it with POST /hosting/v1/deploy-tokens and a name, plus an optional expires_in_days (1 to 366). The response holds token once. Only its sha256 hash and a short prefix are stored. GET /hosting/v1/deploy-tokens lists the company tokens with prefix, created_by_id, last_used_at, expires_at and revoked_at, never the token. POST /hosting/v1/deploy-tokens/{id}/revoke revokes one.
A deploy token belongs to a company and only reaches POST /hosting/v1/preview, PUT .../upload and POST .../finalize. It can create a preview or redeploy any existing preview slug of its company. Apps created in admin return 403 deploy_token_preview_only. Other errors are 401 deploy_token_invalid, deploy_token_revoked or deploy_token_expired. The token never appears in logs or error bodies. New previews are owned by the user who created the token. With a token, finalize skips the sign-in redirect sync because there is no user session. Details and a GitHub Actions example are in Deploy with the CLI.
Roll back
POST /hosting/v1/apps/{app_ref}/deployments/{id}/rollback makes an older deployment active again. The target must already have an archive and a status of active, superseded, or ready. Current deploys do not write ready. Rollback still accepts it. The serve cache is cleared. Rollback does not emit a hosting event and does not extend expires_at.
From a Shellui project that has hosting.slug set:
shellui deploy rollback --to 1.2.3
shellui deploy rollback --deployment 660e8400-e29b-41d4-a716-446655440001
--to matches app_version. shellui deploy history lists the rows for that slug.
Events
These catalog events fire from the lifecycle above. Payloads and webhook delivery are in Webhooks.
| Event | When |
|---|---|
hosting.app.created | An app row is created |
hosting.app.deleted | An app and its files are removed |
hosting.deployment.created | A draft deployment is created |
hosting.deployment.succeeded | Finalize extracted the archive and activated the deployment |
hosting.deployment.failed | Extract failed |
Succeeded and failed events name the caller who finalized. Created events name the caller who created the row.
MCP agents: production deploy flow
For JSON-RPC wiring, scopes, and approvals see Shellui MCP. Below is the HTTP tool sequence. Names are the MCP tools/list names (hosting_<verb>_<noun>), not the OpenAPI operationId. Send Bearer COMPANY_OWNER_AGENT_TOKEN on POST .../mcp with company_id taken only from that token; never copy a tenant id from tool parameters.
Deployment row statuses (database deployments.status) are exactly: draft, uploading, active, superseded, failed. Preview and production share this set; expires_at on the app governs preview lifetime (Preview sites and public URLs).
Artifact upload: hosting_create_apps_deployments_artifact_upload_url returns upload_url, method, headers, requires_bearer, and backend. When requires_bearer is true, reuse the same agent token on the PUT. When backend is s3, the URL is presigned; do not log it. When backend is direct, PUT goes to hosting-service. Call hosting_create_apps_deployments_artifact_upload_complete after the object exists (required for S3; idempotent after a direct PUT that already registered size).
Compact sequence (each line is one tools/call except the PUT):
hosting_create_appsorhosting_create_previewto obtain APP_UUID (and often a draft deployment).hosting_create_apps_deploymentson APP_UUID with bodyapp_versionandshellui_versionto open a draft when needed; note DEPLOYMENT_UUID from the response.hosting_create_apps_deployments_artifact_upload_urlon APP_UUID and DEPLOYMENT_UUID; then PUT the gzip tar toupload_urlusing returnedmethodandheaders.hosting_create_apps_deployments_artifact_upload_completeon APP_UUID and DEPLOYMENT_UUID.hosting_create_apps_deployments_finalizeon APP_UUID and DEPLOYMENT_UUID to move status towardactivewhen extraction succeeds.
Event payloads, webhooks, and email forwarding use the same catalog as Webhooks and Email notifications; hosting does not send mail by itself when email-service is unset.