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

> Hämta status för det senaste publiceringsförsöket för en chatt

Hämtar status för det senaste publiceringsförsöket för en chatt, eller för det försök som `deploymentId` anger. Det senaste försöket kan fortfarande byggas, eller kan ha misslyckats medan en äldre version fortfarande är live. Använd `liveUrl` för URL:en till den version som är live just nu. Om driftsättningen inte har nått ett slutläge synkar endpointen statusen med Vercel innan den svarar.

## Anrop

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

### Headers

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

### Sökvägsparametrar

| Parameter | Typ | Beskrivning |
| - | - | - |
| `chatId` | string | Chatt-ID |

### Frågeparametrar

| Parameter | Obligatorisk | Beskrivning |
| - | - | - |
| `deploymentId` | Nej | Det `id` eller `deploymentId` som [`POST /deploy`](/docs/sv/api/deploy) returnerade. Utan den returnerar endpointen chattens senaste publiceringsförsök. |

### Exempelanrop

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

## Svar

### Driftsättningen är klar

```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"
}
```

### Ingen driftsättning

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

### Driftsättningen misslyckades

En misslyckad ompublicering behåller den tidigare versionen live, så `liveUrl` är fortfarande satt.

```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"
}
```

### Svarsfält

| Fält | Typ | Beskrivning |
| - | - | - |
| `id` | string \| null | Driftsättningens ID i databasen (null om den aldrig publicerats) |
| `url` | string \| null | Driftsättningens URL |
| `status` | string \| null | Driftsättningsstatus hos Vercel (se nedan) |
| `deploymentId` | string \| null | Driftsättningens ID hos Vercel |
| `createdAt` | string \| null | ISO-tidsstämpel för när driftsättningen skapades |
| `error` | string\[] \| null | Felmeddelanden om driftsättningen misslyckades |
| `domain` | string \| null | Driftsättningens primära domän |
| `domains` | array | Alla anslutna domäner |
| `domains[].domain` | string | Domännamn |
| `domains[].verified` | boolean | Om domänen är verifierad |
| `domains[].isCustomDomain` | boolean | Om det är en egen domän |
| `liveUrl` | string \| null | URL till den version som är live (null om inget är live) |

### Statusvärden för driftsättning

| Status | Beskrivning |
| - | - |
| `QUEUED` | Driftsättningen står i kö |
| `BUILDING` | Bygget pågår |
| `READY` | Driftsättningen lyckades |
| `ERROR` | Driftsättningen misslyckades |
| `CANCELED` | Driftsättningen avbröts |
| `UNPUBLISHED` | Driftsättningen avpublicerades |

## Statuskoder

| Status | Beskrivning |
| - | - |
| 200 | Lyckades (även om ingen driftsättning finns returneras fälten som null) |
| 401 | Ogiltig eller saknad API-nyckel |
| 403 | Chatten tillhör inte ditt team |
| 404 | Chatten hittades inte, eller `deploymentId` matchar ingen driftsättning i den här chatten |

## Mönster för upprepad kontroll

Skicka det `id` som `POST /deploy` returnerade som `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.