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

> Bir sohbetin en son yayınlama denemesinin durumunu alın

Bir sohbetin en son yayınlama denemesinin ya da `deploymentId` ile belirtilen denemenin durumunu alın. En son deneme hâlâ derleniyor olabilir ya da daha eski bir sürüm canlıda kalırken başarısız olmuş olabilir. Şu anda canlı olan sürümün URL'si için `liveUrl` kullanın. Dağıtım nihai bir durumda değilse, bu endpoint yanıt dönmeden önce durumu Vercel ile eşitler.

## İstek

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

### Başlıklar

| Header | Zorunlu | Açıklama |
| - | - | - |
| `Authorization` | Evet | `Bearer macaly_...` |

### Yol parametreleri

| Parametre | Tür | Açıklama |
| - | - | - |
| `chatId` | string | Sohbet kimliği |

### Sorgu parametreleri

| Parametre | Zorunlu | Açıklama |
| - | - | - |
| `deploymentId` | Hayır | [`POST /deploy`](/docs/tr/api/deploy) yanıtında dönen `id` veya `deploymentId`. Verilmezse endpoint, sohbetin en son yayınlama denemesini döndürür. |

### Örnek istek

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

## Yanıt

### Dağıtım hazır

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

### Dağıtım yok

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

### Dağıtım başarısız

Başarısız bir yeniden yayınlama önceki sürümü canlıda tutar, bu yüzden `liveUrl` dolu kalır.

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

### Yanıt alanları

| Alan | Tür | Açıklama |
| - | - | - |
| `id` | string \| null | Veritabanındaki dağıtım kimliği (hiç dağıtılmadıysa null) |
| `url` | string \| null | Dağıtım URL'si |
| `status` | string \| null | Vercel dağıtım durumu (aşağıya bakın) |
| `deploymentId` | string \| null | Vercel dağıtım kimliği |
| `createdAt` | string \| null | Dağıtımın oluşturulma zamanı (ISO formatında) |
| `error` | string\[] \| null | Dağıtım başarısız olduysa hata mesajları |
| `domain` | string \| null | Dağıtımın birincil alan adı |
| `domains` | array | Bağlı tüm alan adları |
| `domains[].domain` | string | Alan adı |
| `domains[].verified` | boolean | Alan adının doğrulanıp doğrulanmadığı |
| `domains[].isCustomDomain` | boolean | Bunun özel bir alan adı olup olmadığı |
| `liveUrl` | string \| null | Canlı sürümün URL'si (canlıda bir şey yoksa null) |

### Dağıtım durumu değerleri

| Durum | Açıklama |
| - | - |
| `QUEUED` | Dağıtım sıraya alındı |
| `BUILDING` | Derleme sürüyor |
| `READY` | Dağıtım başarılı |
| `ERROR` | Dağıtım başarısız oldu |
| `CANCELED` | Dağıtım iptal edildi |
| `UNPUBLISHED` | Dağıtım yayından kaldırıldı |

## Durum kodları

| Durum | Açıklama |
| - | - |
| 200 | Başarılı (dağıtım olmasa bile null alanlarla yanıt döner) |
| 401 | Geçersiz veya eksik API anahtarı |
| 403 | Sohbet ekibinize ait değil |
| 404 | Sohbet bulunamadı veya `deploymentId` bu sohbetin hiçbir dağıtımıyla eşleşmiyor |

## Durum takibi deseni

`POST /deploy` yanıtında dönen `id` değerini `deploymentId` olarak iletin.

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