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

# Get deployment

> Ruft den Status des neuesten Veröffentlichungsversuchs für einen Chat ab

Ruft den Status des neuesten Veröffentlichungsversuchs für einen Chat ab, oder des Versuchs, den `deploymentId` angibt. Der neueste Versuch kann noch im Build sein oder fehlgeschlagen sein, während eine ältere Version live bleibt. Die URL der Version, die gerade live ist, steht in `liveUrl`. Befindet sich das Deployment nicht in einem finalen Status, synchronisiert dieser Endpoint den Status zunächst mit Vercel, bevor er antwortet.

## Anfrage

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

### Header

| Header | Erforderlich | Beschreibung |
| - | - | - |
| `Authorization` | Ja | `Bearer macaly_...` |

### Pfadparameter

| Parameter | Typ | Beschreibung |
| - | - | - |
| `chatId` | string | Die Chat-ID |

### Query-Parameter

| Parameter | Erforderlich | Beschreibung |
| - | - | - |
| `deploymentId` | Nein | Die `id` oder `deploymentId`, die [`POST /deploy`](/docs/de/api/deploy) zurückgegeben hat. Ohne sie liefert der Endpoint den neuesten Veröffentlichungsversuch des Chats. |

### Beispielanfrage

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

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

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

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

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

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

## Antwort

### Deployment bereit

```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
    }
  ],
  "liveUrl": "https://macaly-staging-abc123.macaly.app"
}
```

### Kein Deployment

```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
    }
  ],
  "liveUrl": null
}
```

### Deployment fehlgeschlagen

Eine fehlgeschlagene erneute Veröffentlichung lässt die vorherige Version live, daher bleibt `liveUrl` gesetzt.

```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": [],
  "liveUrl": "https://macaly-staging-abc123.macaly.app"
}
```

### Antwortfelder

| Feld | Typ | Beschreibung |
| - | - | - |
| `id` | string \| null | Datenbank-ID des Deployments (null, wenn nie deployt) |
| `url` | string \| null | Die Deployment-URL |
| `status` | string \| null | Vercel-Deployment-Status (siehe unten) |
| `deploymentId` | string \| null | Vercel-Deployment-ID |
| `createdAt` | string \| null | ISO-Zeitstempel der Deployment-Erstellung |
| `error` | string\[] \| null | Fehlermeldungen, falls das Deployment fehlgeschlagen ist |
| `domain` | string \| null | Primäre Domain für das Deployment |
| `domains` | array | Alle verbundenen Domains |
| `domains[].domain` | string | Domainname |
| `domains[].verified` | boolean | Ob die Domain verifiziert ist |
| `domains[].isCustomDomain` | boolean | Ob es sich um eine eigene Domain handelt |
| `liveUrl` | string \| null | URL der Live-Version (null, wenn nichts live ist) |

### Deployment-Statuswerte

| Status | Beschreibung |
| - | - |
| `QUEUED` | Deployment ist in der Warteschlange |
| `BUILDING` | Build läuft |
| `READY` | Deployment erfolgreich |
| `ERROR` | Deployment fehlgeschlagen |
| `CANCELED` | Deployment wurde abgebrochen |
| `UNPUBLISHED` | Aus der Produktion entfernt |

## Statuscodes

| Status | Beschreibung |
| - | - |
| 200 | Erfolgreich (auch wenn kein Deployment existiert, werden null-Felder zurückgegeben) |
| 401 | Ungültiger oder fehlender API-Schlüssel |
| 403 | Chat gehört nicht zu deinem Team |
| 404 | Chat nicht gefunden, oder `deploymentId` passt zu keinem Deployment dieses Chats |

## Polling-Muster

Übergib die `id`, die `POST /deploy` zurückgegeben hat, als `deploymentId`.

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

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

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

  sleep 3
done
```


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