# Publishing

> Move the development version to production.

Every prompt changes the **development preview** only. **Publishing** builds the current version, applies its pending database migrations to the **live database**, and puts it on the live address (`<projectId>.totalum-project.com` and the custom domain). Publishing is asynchronous: start it, then poll [Get Deployment Status](#get-deployment-status) every 10–15 seconds.

## Deploy to Production

```endpoint
method: POST
path: /api/v1/vcaas/projects/:projectId/deployments/deploy
cost: 0.5 credits
```

Publish the project's current version. It takes about 2 to 5 minutes. If the build or a migration fails, Totalum's agent tries to repair it once or twice before the publish ends in `error`; the live site keeps serving the previous version until a publish succeeds.

**Migrations that delete data.** A migration that drops a table or column, or deletes or overwrites existing live rows, runs only when the prompt that made it asked for it, or when you publish with `confirmDestructive: true`. Otherwise the publish ends in `error` with `DESTRUCTIVE_MIGRATION_NEEDS_CONFIRMATION` and nothing changes on live. Rows already in the live database that break a new rule end the publish with the list of those rows; Totalum never changes production data on its own.

**Path parameters**

| Parameter | Type | Description |
|---|---|---|
| `projectId` | string | The project id |

**Body parameters**

| Field | Type | Required | Description |
|---|---|---|---|
| `confirmDestructive` | boolean | No | `true` = run the pending migrations that drop columns or tables or delete/overwrite live rows |

**Response fields**

| Field | Type | Description |
|---|---|---|
| `data.projectId` | string | Project id |
| `data.status` | string | `"deploying"` |
| `data.deploymentId` | string | This publish |
| `data.message` | string | How to follow it |

**Example request**

```bash
curl -X POST -H "api-key: tlm_sk_your_key" \
  https://builder-api.totalum.app/api/v1/vcaas/projects/barber-bookings/deployments/deploy
```

:::success Success · 200 OK
```json
{
  "errors": null,
  "data": {
    "projectId": "barber-bookings",
    "status": "deploying",
    "message": "Deployment started. It will take from 2 to 5 minutes depending on project size. Fetch GET /api/v1/vcaas/projects/barber-bookings/deployments/status every 10-15 seconds to track progress.",
    "deploymentId": "dep_01k6xf3a9b"
  }
}
```
:::

**Error codes**

| Code | HTTP | Meaning |
|---|---|---|
| `AGENT_RUNNING` | 409 | A prompt is running; publish when it is done |
| `DEPLOYMENT_RUNNING` | 409 | A publish is already running |
| `OPERATION_IN_PROGRESS` | 409 | A restore, import or other long operation holds the project, or it is still being set up |
| `INSUFFICIENT_CREDITS` | 402 | Not enough credits |
| `PROJECT_CREDIT_LIMIT_REACHED` | 403 | The project's monthly development cap is reached |

## Get Deployment Status

```endpoint
method: GET
path: /api/v1/vcaas/projects/:projectId/deployments/status
cost: Free
```

The newest publish and where it is. Poll every 10–15 seconds until `status` is `"success"` or `"error"`.

**Path parameters**

| Parameter | Type | Description |
|---|---|---|
| `projectId` | string | The project id |

**Response fields**

| Field | Type | Description |
|---|---|---|
| `data.status` | string \| null | `"deploying"`, `"success"`, `"error"`, or `null` if never published |
| `data.createdAt` | string \| null | When the publish started |
| `data.deploymentId` | string \| undefined | The publish |
| `data.step` | string \| undefined | `"build"`, `"migration"`, `"upload"`, `"probe"`, `"fixing"` (the agent is repairing a failed step) or `"done"` |
| `data.progress` | object \| undefined | While `step` is `"fixing"`: `{ stage: "fixing", failedStage, fixAttempt, fixAttempts }` |
| `data.errorDetails` | object \| undefined | On `"error"`: `{ stage, title, message, logExcerpt, versionId, deploymentId?, migrationName?, fixSummary?, at }`: `fixSummary` says what the repair tried and what you need to do |
| `data.liveUrl` | string | The live address |

**Example request**

```bash
curl -H "api-key: tlm_sk_your_key" \
  https://builder-api.totalum.app/api/v1/vcaas/projects/barber-bookings/deployments/status
```

:::success Success · 200 OK
```json
{
  "errors": null,
  "data": {
    "status": "success",
    "createdAt": "2026-10-08T11:20:00.000Z",
    "deploymentId": "dep_01k6xf3a9b",
    "step": "done",
    "liveUrl": "https://barber-bookings.totalum-project.com"
  }
}
```
:::

When it is `"success"`, the address to show is `productionProjectUrl` on [Get Project](https://www.totalum.app/docs/api/projects#get-project) (the custom domain once active).

## Unpublish

```endpoint
method: POST
path: /api/v1/vcaas/projects/:projectId/deployments/unpublish
cost: Free
```

Take the published site offline and remove the project's custom domain. The preview, the code, the databases and the versions stay. Publish again with [Deploy to Production](#deploy-to-production); a custom domain has to be added again. Free, at any balance.

**Path parameters**

| Parameter | Type | Description |
|---|---|---|
| `projectId` | string | The project id |

**Response fields**

| Field | Type | Description |
|---|---|---|
| `data.projectId` | string | Project id |
| `data.status` | string | `"unpublished"` |
| `data.customDomainsRemoved` | string[] | Domains removed |
| `data.customDomainsFailed` | string[] | Domains that could not be removed (they serve nothing; call again to retry) |
| `data.warnings` | string[] | Non-fatal problems |
| `data.message` | string | What happened |

**Example request**

```bash
curl -X POST -H "api-key: tlm_sk_your_key" \
  https://builder-api.totalum.app/api/v1/vcaas/projects/barber-bookings/deployments/unpublish
```

:::success Success · 200 OK
```json
{
  "errors": null,
  "data": {
    "projectId": "barber-bookings",
    "status": "unpublished",
    "customDomainsRemoved": [],
    "customDomainsFailed": [],
    "warnings": [],
    "message": "The project is offline: its published site, preview snapshot and custom domains were removed. Deploy again to publish it; custom domains have to be added again."
  }
}
```
:::

**Error codes**

| Code | HTTP | Meaning |
|---|---|---|
| `DEPLOYMENT_RUNNING` | 409 | A publish is running and would put the site back; wait until it ends, then retry |
