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

> Verifica dello stato dell'ultimo tentativo di pubblicazione di una chat

Recupera lo stato dell'ultimo tentativo di pubblicazione di una chat, o del tentativo indicato da `deploymentId`. L'ultimo tentativo può essere ancora in build, oppure può essere fallito mentre una versione precedente resta online. Usa `liveUrl` per ottenere l'URL della versione attualmente online. Se il deployment non è in uno stato finale, questo endpoint sincronizza lo stato con Vercel prima di rispondere.

## Richiesta

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

### Header

| Header | Obbligatorio | Descrizione |
| - | - | - |
| `Authorization` | Sì | `Bearer macaly_...` |

### Parametri del percorso

| Parametro | Tipo | Descrizione |
| - | - | - |
| `chatId` | string | L'ID della chat |

### Parametri della query

| Parametro | Obbligatorio | Descrizione |
| - | - | - |
| `deploymentId` | No | L'`id` o il `deploymentId` restituito da [`POST /deploy`](/docs/it/api/deploy). Senza questo parametro, l'endpoint restituisce l'ultimo tentativo di pubblicazione della chat. |

### Esempio di richiesta

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

## Risposta

### Deployment pronto

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

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

Una ripubblicazione fallita lascia online la versione precedente, quindi `liveUrl` resta valorizzato.

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

### Campi della risposta

| Campo | Tipo | Descrizione |
| - | - | - |
| `id` | string \| null | ID del deployment nel database (null se non è mai stato effettuato un deployment) |
| `url` | string \| null | La URL del deployment |
| `status` | string \| null | Stato del deployment su Vercel (vedi sotto) |
| `deploymentId` | string \| null | ID del deployment su Vercel |
| `createdAt` | string \| null | Data e ora ISO di creazione del deployment |
| `error` | string\[] \| null | Messaggi di errore se il deployment è fallito |
| `domain` | string \| null | Dominio principale del deployment |
| `domains` | array | Tutti i domini collegati |
| `domains[].domain` | string | Nome del dominio |
| `domains[].verified` | boolean | Indica se il dominio è verificato |
| `domains[].isCustomDomain` | boolean | Indica se si tratta di un dominio personalizzato |
| `liveUrl` | string \| null | URL della versione online (null se nulla è online) |

### Valori dello stato del deployment

| Stato | Descrizione |
| - | - |
| `QUEUED` | Deployment in coda |
| `BUILDING` | Build in corso |
| `READY` | Deployment riuscito |
| `ERROR` | Deployment fallito |
| `CANCELED` | Deployment annullato |
| `UNPUBLISHED` | Deployment rimosso dalla produzione |

## Codici di stato

| Codice | Descrizione |
| - | - |
| 200 | Operazione riuscita (anche se non esiste alcun deployment, restituisce campi null) |
| 401 | Chiave API non valida o mancante |
| 403 | La chat non appartiene al tuo team |
| 404 | Chat non trovata, oppure `deploymentId` non corrisponde ad alcun deployment di questa chat |

## Come seguire l'avanzamento

Passa come `deploymentId` l'`id` restituito da `POST /deploy`.

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