---
title: "Apps"
description: "REST endpoints for apps. Bearer-auth required."
section: "API"
group: "REST"
order: 17
---

## POST /api/app-preview-sessions

Start (or wake) a live preview session

Declarative create. Pass `appVersionId` in the body to start a preview for that version. Reuses an existing session if one is still warm.

**Request body**

```json
{
  "appVersionId": "string"
}
```

**Response**

```json
{
  "id": "string",
  "workspaceId": "string",
  "appId": "string",
  "versionId": "string",
  "status": "hydrating | installing | starting | ready",
  "previewUrl": "string",
  "error": "string",
  "metadata": {},
  "lastHeartbeatAt": "string",
  "createdBy": "string",
  "startedAt": "string",
  "readyAt": "string",
  "stoppedAt": "string",
  "createdAt": "string"
}
```

## GET /api/app-versions/{id}/files

List files in a specific app version

**Path parameters**

- `id` (required): The app version's prefixed ID (e.g. `appver_...`).

**Query parameters**

- `path` (optional): Directory path to list (omit for the app root).

**Response**

```json
{
  "data": [
    {
      "name": "<...>",
      "path": "<...>",
      "isDirectory": "<...>",
      "size": "<...>"
    }
  ]
}
```

## POST /api/app-versions/{id}/files

Create a file in a specific app version

**Path parameters**

- `id` (required): The app version's prefixed ID (e.g. `appver_...`).

**Request body**

```json
{
  "path": "string",
  "content": "string"
}
```

**Response**

```json
{
  "success": "boolean"
}
```

## PATCH /api/app-versions/{id}/files

Update a file in a specific app version

**Path parameters**

- `id` (required): The app version's prefixed ID (e.g. `appver_...`).

**Request body**

```json
{
  "path": "string",
  "content": "string"
}
```

**Response**

```json
{
  "success": "boolean"
}
```

## DELETE /api/app-versions/{id}/files

Delete a file from a specific app version

**Path parameters**

- `id` (required): The app version's prefixed ID (e.g. `appver_...`).

**Query parameters**

- `path` (required): File path to delete, relative to the app root.

**Response**

```json
{
  "success": "boolean"
}
```

## GET /api/app-versions/{id}/files/read

Read a file's content from a specific app version

**Path parameters**

- `id` (required): The app version's prefixed ID (e.g. `appver_...`).

**Query parameters**

- `path` (required): File path to read, relative to the app root.

**Response**

```json
{
  "content": "string",
  "contentType": "string"
}
```

## GET /api/apps

List apps with pagination and optional filtering.

**Query parameters**

- `limit` (optional): Page size (1–100, default 100).
- `after` (optional): Keyset cursor — return the page after this row (next page).
- `before` (optional): Keyset cursor — return the page before this row (prev page).
- `ids` (optional): Comma-separated list of IDs. Narrows results to these IDs within the caller's accessible scope (does not bypass access checks).
- `filter` (optional): Nested filter expression (`<Entity>Filter`): AND/OR/NOT + per-field comparison operators + relation traversal. JSON-encoded on the query string.
- `orderBy` (optional): Multi-key sort (`<Entity>OrderBy[]`): array of `{ field: direction }` applied in order. Directions: asc/desc plus the four explicit nulls variants. JSON-encoded on the query string.
- `workspace_id` (optional): Filter to apps in this workspace. When omitted, returns apps across every workspace the caller is a member of (admins see all).
- `include_deleted` (optional): Soft-deleted app visibility. `false` (default) — active rows only. `true` — active plus soft-deleted. `only` — soft-deleted only.
- `name` (optional): Case-insensitive substring match on name.
- `source` (optional): Narrow by source. `workspace` = this workspace's rows plus those visible via installed integrations; `integration` = only rows made visible by installed integrations; omit = union.
- `default_version_id` (optional): Shorthand: filter where `defaultVersionId` equals this value.
- `status` (optional): Shorthand: filter where `status` equals this value.
- `public_access` (optional): Shorthand: filter where `publicAccess` equals this value.
- `api_key_id` (optional): Shorthand: filter where `apiKeyId` equals this value.
- `created_by` (optional): Shorthand: filter where `createdBy` equals this value.
- `retention_tier` (optional): Shorthand: filter where `retentionTier` equals this value.

**Response**

```json
{
  "data": [
    {
      "id": "<...>",
      "workspaceId": "<...>",
      "name": "<...>",
      "description": "<...>",
      "handle": "<...>",
      "defaultVersionId": "<...>",
      "status": "<...>",
      "publicAccess": "<...>",
      "pagesProjectId": "<...>",
      "apiKeyId": "<...>",
      "config": "<...>",
      "createdBy": "<...>",
      "deletedAt": "<...>",
      "retentionTier": "<...>",
      "createdAt": "<...>",
      "updatedAt": "<...>"
    }
  ],
  "pageInfo": {
    "total": "number",
    "hasNextPage": "boolean",
    "hasPreviousPage": "boolean",
    "startCursor": "string",
    "endCursor": "string"
  }
}
```

## POST /api/apps

Create app

**Request body**

```json
{
  "workspaceId": "string",
  "name": "string",
  "description?": "string",
  "handle?": "string",
  "publicAccess?": "boolean"
}
```

**Response**

```json
{
  "id": "string",
  "workspaceId": "string",
  "name": "string",
  "description": "string",
  "handle": "string",
  "defaultVersionId": "string",
  "status": "draft | live",
  "publicAccess": "boolean",
  "pagesProjectId": "string",
  "apiKeyId": "string",
  "config": {
    "nodeVersion?": "<...>",
    "env?": "<...>"
  },
  "createdBy": "string",
  "deletedAt": "string",
  "retentionTier": "any",
  "createdAt": "string",
  "updatedAt": "string"
}
```

## GET /api/apps/{id}

Get a single app by ID.

**Path parameters**

- `id` (required): App to retrieve.

**Response**

```json
{
  "id": "string",
  "workspaceId": "string",
  "name": "string",
  "description": "string",
  "handle": "string",
  "defaultVersionId": "string",
  "status": "draft | live",
  "publicAccess": "boolean",
  "pagesProjectId": "string",
  "apiKeyId": "string",
  "config": {
    "nodeVersion?": "<...>",
    "env?": "<...>"
  },
  "createdBy": "string",
  "deletedAt": "string",
  "retentionTier": "any",
  "createdAt": "string",
  "updatedAt": "string"
}
```

## PATCH /api/apps/{id}

Update app

**Path parameters**

- `id` (required): The app's prefixed ID (e.g. `app_...`).

**Request body**

```json
{
  "name?": "string",
  "description?": "string",
  "handle?": "string",
  "publicAccess?": "boolean",
  "defaultVersionId?": "string",
  "config?": "any"
}
```

**Response**

```json
{
  "id": "string",
  "workspaceId": "string",
  "name": "string",
  "description": "string",
  "handle": "string",
  "defaultVersionId": "string",
  "status": "draft | live",
  "publicAccess": "boolean",
  "pagesProjectId": "string",
  "apiKeyId": "string",
  "config": {
    "nodeVersion?": "<...>",
    "env?": "<...>"
  },
  "createdBy": "string",
  "deletedAt": "string",
  "retentionTier": "any",
  "createdAt": "string",
  "updatedAt": "string"
}
```

## DELETE /api/apps/{id}

Soft-delete an app.

**Path parameters**

- `id` (required): App to soft-delete.

**Response**

```json
{
  "success": "boolean"
}
```

## POST /api/apps/{id}/deploy

Deploy app (latest successful build of default version)

Deploy the most recent successful build of the app's default version. Use POST /api/apps/{id}/builds/{buildId}/deploy to deploy a specific build. Returns the freshly-created deploy row.

**Path parameters**

- `id` (required): The app's prefixed ID (e.g. `app_...`).

**Response**

```json
{
  "id": "string",
  "workspaceId": "string",
  "entityId": "string",
  "sequenceNumber": "integer",
  "buildId": "string",
  "status": "pending | running | completed | failed",
  "trigger": "auto | manual | rollback",
  "sourceEventId": "string",
  "productionUrl": "string",
  "previewUrl": "string",
  "error": "string",
  "metadata": {},
  "createdBy": "string",
  "startedAt": "string",
  "completedAt": "string",
  "createdAt": "string"
}
```

## GET /api/apps/{id}/domain

Get the custom domain attached to an app

**Path parameters**

- `id` (required): The app's prefixed ID (e.g. `app_...`).

**Response**

```json
"any"
```

## PUT /api/apps/{id}/domain

Attach (or replace) the app's custom domain

**Path parameters**

- `id` (required): The app's prefixed ID (e.g. `app_...`).

**Request body**

```json
{
  "hostname": "string"
}
```

**Response**

```json
{
  "id": "string",
  "appId": "string",
  "hostname": "string",
  "status": "pending | active | failed",
  "lastError": "string",
  "createdBy": "string",
  "createdAt": "string",
  "updatedAt": "string"
}
```

## DELETE /api/apps/{id}/domain

Detach the app's custom domain

**Path parameters**

- `id` (required): The app's prefixed ID (e.g. `app_...`).

**Response**

```json
{
  "success": "boolean"
}
```

## GET /api/apps/{id}/env

List env vars

List build-time environment variables (vite embeds these into the bundle at `import.meta.env.VITE_*`).

**Path parameters**

- `id` (required): The app's prefixed ID (e.g. `app_...`).

**Response**

```json
{
  "data": [
    {
      "name": "string",
      "type": "string",
      "value": "string"
    }
  ]
}
```

## PUT /api/apps/{id}/env

Set env var

Create or update a build-time env var. Takes effect on the next build.

**Path parameters**

- `id` (required): The app's prefixed ID (e.g. `app_...`).

**Request body**

```json
{
  "name": "string",
  "value": "string"
}
```

**Response**

```json
{
  "success": "boolean"
}
```

## DELETE /api/apps/{id}/env

Delete env var

Remove a build-time env var. Takes effect on the next build.

**Path parameters**

- `id` (required): The app's prefixed ID (e.g. `app_...`).

**Query parameters**

- `name` (required): The env var name to delete.

**Response**

```json
{
  "success": "boolean"
}
```

## DELETE /api/apps/{id}/purge

Permanently delete a soft-deleted app.

**Path parameters**

- `id` (required): Soft-deleted app to permanently delete.

**Response**

```json
{
  "success": "boolean"
}
```

## POST /api/apps/{id}/restore

Restore a soft-deleted app.

**Path parameters**

- `id` (required): Soft-deleted app to restore.

**Response**

```json
{
  "id": "string",
  "workspaceId": "string",
  "name": "string",
  "description": "string",
  "handle": "string",
  "defaultVersionId": "string",
  "status": "draft | live",
  "publicAccess": "boolean",
  "pagesProjectId": "string",
  "apiKeyId": "string",
  "config": {
    "nodeVersion?": "<...>",
    "env?": "<...>"
  },
  "createdBy": "string",
  "deletedAt": "string",
  "retentionTier": "any",
  "createdAt": "string",
  "updatedAt": "string"
}
```

## GET /api/apps/preview/{sessionId}

Get current state of a preview session

**Path parameters**

- `sessionId` (required): The preview session's prefixed ID (e.g. `appprv_...`).

**Response**

```json
{
  "id": "string",
  "workspaceId": "string",
  "appId": "string",
  "versionId": "string",
  "status": "hydrating | installing | starting | ready",
  "previewUrl": "string",
  "error": "string",
  "metadata": {},
  "lastHeartbeatAt": "string",
  "createdBy": "string",
  "startedAt": "string",
  "readyAt": "string",
  "stoppedAt": "string",
  "createdAt": "string"
}
```

## DELETE /api/apps/preview/{sessionId}

Stop a preview session

**Path parameters**

- `sessionId` (required): The preview session's prefixed ID (e.g. `appprv_...`).

**Response**

```json
{
  "success": "boolean"
}
```

## POST /api/apps/preview/{sessionId}/keepalive

Keep a preview session alive (called by the client every ~30s)

**Path parameters**

- `sessionId` (required): The preview session's prefixed ID (e.g. `appprv_...`).

**Response**

```json
{
  "id": "string",
  "status": "string"
}
```
