> ## Documentation Index
> Fetch the complete documentation index at: https://www.macaly.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Deploy

> Deploy a chat to production

Deploy a chat to production. Starts a deployment to Vercel and returns immediately.

## Request

```
POST /api/chat/{chatId}/deploy
```

### Headers

| Header          | Required | Description         |
| --------------- | -------- | ------------------- |
| `Authorization` | Yes      | `Bearer macaly_...` |

### Path Parameters

| Parameter | Type   | Description           |
| --------- | ------ | --------------------- |
| `chatId`  | string | The chat ID to deploy |

### Example Request

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://www.macaly.com/api/chat/abc123/deploy \
    -H "Authorization: Bearer macaly_abc123..."
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    `https://www.macaly.com/api/chat/${chatId}/deploy`,
    {
      method: 'POST',
      headers: {
        'Authorization': 'Bearer macaly_abc123...',
      },
    }
  );

  const data = await response.json();
  console.log(data.url);
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      f'https://www.macaly.com/api/chat/{chat_id}/deploy',
      headers={
          'Authorization': 'Bearer macaly_abc123...',
      },
  )

  data = response.json()
  print(data['url'])
  ```
</CodeGroup>

## Response

```json theme={null}
{
  "id": "jzga0sttml37v6mbizb8tk1x",
  "url": "https://macaly-staging-abc123.macaly.app",
  "status": "QUEUED",
  "deploymentId": "dpl_HKLBd2QDTwq58AMUJiaMyUzk8WUw"
}
```

### Response Fields

| Field          | Type                       | Description            |
| -------------- | -------------------------- | ---------------------- |
| `id`           | string                     | Database deployment ID |
| `url`          | string                     | The deployment URL     |
| `status`       | `"QUEUED"` \| `"BUILDING"` | Initial status         |
| `deploymentId` | string                     | Vercel deployment ID   |

## Status Codes

| Status | Description                                            |
| ------ | ------------------------------------------------------ |
| 200    | Deployment started                                     |
| 400    | Bad request (e.g., no messages in chat)                |
| 401    | Invalid or missing API key                             |
| 403    | No permission to deploy OR chat doesn't belong to team |
| 404    | Chat not found                                         |
| 500    | Internal server error                                  |

## Notes

<Info>
  This endpoint returns immediately after starting the deployment. The deployment happens asynchronously on Vercel.
</Info>

* Use [`GET /api/chat/{chatId}/deployment`](/en/api/get-deployment) to poll for completion
* Requires the `hosting.publish_macaly` permission

## Next Steps

After starting a deployment:

1. **Poll for completion** using [`GET /api/chat/{chatId}/deployment`](/en/api/get-deployment)
2. Wait for `status` to become `READY`
