> ## 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

> Publica um chat em produção

Publica um chat em produção. Inicia um deployment na Vercel e retorna imediatamente.

## Requisição

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

### Cabeçalhos

| Cabeçalho | Obrigatório | Descrição |
| - | - | - |
| `Authorization` | Sim | `Bearer macaly_...` |

### Parâmetros de caminho

| Parâmetro | Tipo | Descrição |
| - | - | - |
| `chatId` | string | O ID do chat a ser publicado |

### Exemplo de requisição

<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>

## Resposta

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

### Campos da resposta

| Campo | Tipo | Descrição |
| - | - | - |
| `id` | string | ID da publicação no banco de dados |
| `url` | string | URL da publicação |
| `status` | `"QUEUED"` \| `"BUILDING"` | Status inicial |
| `deploymentId` | string | ID do deployment na Vercel |

## Códigos de status

| Código | Descrição |
| - | - |
| 200 | Publicação iniciada |
| 400 | Requisição inválida (por exemplo, o chat não tem mensagens) |
| 401 | Chave de API inválida ou ausente |
| 403 | Sem permissão para publicar OU o chat não pertence ao workspace |
| 404 | Chat não encontrado |
| 500 | Erro interno do servidor |

## Observações

<Info>
  Este endpoint retorna imediatamente após iniciar a publicação. O deployment acontece de forma assíncrona na Vercel.
</Info>

* Use [`GET /api/chat/{chatId}/deployment`](/docs/pt-BR/api/get-deployment) com o `id` retornado como `deploymentId` para acompanhar até a conclusão
* Exige a permissão `hosting.publish_macaly`

## Próximos passos

Depois de iniciar uma publicação:

1. **Acompanhe a conclusão** com [`GET /api/chat/{chatId}/deployment`](/docs/pt-BR/api/get-deployment), passando o `id` retornado como `deploymentId`
2. Aguarde até que `status` seja `READY`


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.