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

# Implementatie ophalen

> Haal de huidige implementatiestatus op voor een chat

Haalt de huidige implementatiestatus op voor een chat. Als de implementatie niet in een eindstatus is, synchroniseert dit endpoint de status met Vercel voordat het antwoordt.

## Verzoek

```
GET /api/chat/{chatId}/deployment
```

### Headers

| Header          | Vereist | Beschrijving        |
| --------------- | ------- | ------------------- |
| `Authorization` | Ja      | `Bearer macaly_...` |

### Padparameters

| Parameter | Type   | Beschrijving |
| --------- | ------ | ------------ |
| `chatId`  | string | De chat-ID   |

### Voorbeeldverzoek

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

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

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

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

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

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

## Respons

### Implementatie gereed

```json theme={null}
{
  "id": "jzga0sttml37v6mbizb8tk1x",
  "url": "https://macaly-staging-abc123.macaly.app",
  "status": "READY",
  "deploymentId": "dpl_HKLBd2QDTwq58AMUJiaMyUzk8WUw",
  "createdAt": "2025-01-12T21:18:54.906Z",
  "error": null,
  "domain": "macaly-staging-abc123.macaly.app",
  "domains": [
    {
      "domain": "macaly-staging-abc123.macaly.app",
      "verified": true,
      "isCustomDomain": false
    }
  ]
}
```

### Geen implementatie

```json theme={null}
{
  "id": null,
  "url": null,
  "status": null,
  "deploymentId": null,
  "createdAt": null,
  "error": null,
  "domain": null,
  "domains": [
    {
      "domain": "macaly-staging-abc123.macaly.app",
      "verified": true,
      "isCustomDomain": false
    }
  ]
}
```

### Implementatie mislukt

```json theme={null}
{
  "id": "jzga0sttml37v6mbizb8tk1x",
  "url": "https://macaly-staging-abc123.macaly.app",
  "status": "ERROR",
  "deploymentId": "dpl_HKLBd2QDTwq58AMUJiaMyUzk8WUw",
  "createdAt": "2025-01-12T21:18:54.906Z",
  "error": ["Build failed: Module not found"],
  "domain": "macaly-staging-abc123.macaly.app",
  "domains": []
}
```

### Responsvelden

| Veld                       | Type              | Beschrijving                                               |
| -------------------------- | ----------------- | ---------------------------------------------------------- |
| `id`                       | string \| null    | Database-implementatie-ID (null als nooit geïmplementeerd) |
| `url`                      | string \| null    | De implementatie-URL                                       |
| `status`                   | string \| null    | Vercel-implementatiestatus (zie hieronder)                 |
| `deploymentId`             | string \| null    | Vercel-implementatie-ID                                    |
| `createdAt`                | string \| null    | ISO-tijdstempel van de implementatiecreatie                |
| `error`                    | string\[] \| null | Foutmeldingen als de implementatie is mislukt              |
| `domain`                   | string \| null    | Primair domein voor de implementatie                       |
| `domains`                  | array             | Alle gekoppelde domeinen                                   |
| `domains[].domain`         | string            | Domeinnaam                                                 |
| `domains[].verified`       | boolean           | Of het domein is geverifieerd                              |
| `domains[].isCustomDomain` | boolean           | Of dit een aangepast domein is                             |

### Implementatiestatuswaarden

| Status        | Beschrijving                       |
| ------------- | ---------------------------------- |
| `QUEUED`      | Implementatie staat in de wachtrij |
| `BUILDING`    | Build is bezig                     |
| `READY`       | Implementatie geslaagd             |
| `ERROR`       | Implementatie mislukt              |
| `CANCELED`    | Implementatie geannuleerd          |
| `UNPUBLISHED` | Implementatie gedepubliceerd       |

## Statuscodes

| Status | Beschrijving                                                              |
| ------ | ------------------------------------------------------------------------- |
| 200    | Succes (zelfs als er geen implementatie bestaat, retourneert null-velden) |
| 401    | Ongeldige of ontbrekende API-sleutel                                      |
| 403    | Chat behoort niet tot uw team                                             |
| 404    | Chat niet gevonden                                                        |

## Pollingpatroon

```bash theme={null}
while true; do
  DEPLOYMENT=$(curl -s https://www.macaly.com/api/chat/$CHAT_ID/deployment \
    -H "Authorization: Bearer macaly_...")

  STATUS=$(echo $DEPLOYMENT | jq -r '.status')
  echo "Status: $STATUS"

  if [[ $STATUS == "READY" ]]; then
    echo "Deployed: $(echo $DEPLOYMENT | jq -r '.url')"
    break
  elif [[ $STATUS == "ERROR" ]]; then
    echo "Failed: $(echo $DEPLOYMENT | jq -r '.error')"
    break
  fi

  sleep 3
done
```
