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

> Publicera en chatt i produktion

Publicerar en chatt i produktion. Startar en driftsättning på Vercel och svarar direkt.

## Anrop

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

### Headers

| Header | Obligatorisk | Beskrivning |
| - | - | - |
| `Authorization` | Ja | `Bearer macaly_...` |

### Sökvägsparametrar

| Parameter | Typ | Beskrivning |
| - | - | - |
| `chatId` | string | ID för chatten som ska publiceras |

### Exempelanrop

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

## Svar

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

### Svarsfält

| Fält | Typ | Beskrivning |
| - | - | - |
| `id` | string | Driftsättningens ID i databasen |
| `url` | string | Driftsättningens URL |
| `status` | `"QUEUED"` \| `"BUILDING"` | Inledande status |
| `deploymentId` | string | Driftsättningens ID hos Vercel |

## Statuskoder

| Status | Beskrivning |
| - | - |
| 200 | Driftsättningen startades |
| 400 | Felaktigt anrop (till exempel att chatten saknar meddelanden) |
| 401 | Ogiltig eller saknad API-nyckel |
| 403 | Behörighet att publicera saknas ELLER så tillhör chatten inte teamet |
| 404 | Chatten hittades inte |
| 500 | Internt serverfel |

## Anmärkningar

<Info>
  Endpointen svarar direkt efter att driftsättningen har startat. Själva driftsättningen sker asynkront på Vercel.
</Info>

* Använd [`GET /api/chat/{chatId}/deployment`](/docs/sv/api/get-deployment) med `deploymentId` satt till det returnerade `id` för att kontrollera när den är klar
* Kräver behörigheten `hosting.publish_macaly`

## Nästa steg

Efter att du har startat en driftsättning:

1. **Kontrollera tills den är klar** med [`GET /api/chat/{chatId}/deployment`](/docs/sv/api/get-deployment) och `deploymentId` satt till det returnerade `id`
2. Vänta tills `status` blir `READY`


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