Endpoints

Implementatie ophalen

Haal de status op van de nieuwste publicatiepoging voor een chat

GET/api/chat/{chatId}/deployment

Haalt de status op van de nieuwste publicatiepoging voor een chat, of van de poging die deploymentId aanwijst. De nieuwste poging kan nog bezig zijn met bouwen, of kan mislukt zijn terwijl een oudere versie live blijft. Gebruik liveUrl voor de URL van de versie die nu live is. 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

HeaderVereistBeschrijving
AuthorizationJaBearer macaly_...

Padparameters

ParameterTypeBeschrijving
chatIdstringDe chat-ID

Queryparameters

ParameterVereistBeschrijving
deploymentIdNeeDe id of deploymentId die POST /deploy heeft geretourneerd. Zonder deze parameter retourneert het endpoint de nieuwste publicatiepoging van de chat.

Voorbeeldverzoek

curl "https://www.macaly.com/api/chat/abc123/deployment?deploymentId=jzga0sttml37v6mbizb8tk1x" \
  -H "Authorization: Bearer macaly_abc123..."

Respons

Implementatie gereed

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

Geen implementatie

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

Implementatie mislukt

Een mislukte herpublicatie laat de vorige versie live staan, dus liveUrl blijft ingevuld.

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

Responsvelden

VeldTypeBeschrijving
idstring | nullDatabase-implementatie-ID (null als nooit geïmplementeerd)
urlstring | nullDe implementatie-URL
statusstring | nullVercel-implementatiestatus (zie hieronder)
deploymentIdstring | nullVercel-implementatie-ID
createdAtstring | nullISO-tijdstempel van de implementatiecreatie
errorstring[] | nullFoutmeldingen als de implementatie is mislukt
domainstring | nullPrimair domein voor de implementatie
domainsarrayAlle gekoppelde domeinen
domains[].domainstringDomeinnaam
domains[].verifiedbooleanOf het domein is geverifieerd
domains[].isCustomDomainbooleanOf dit een aangepast domein is
liveUrlstring | nullURL van de live versie (null als er niets live is)

Implementatiestatuswaarden

StatusBeschrijving
QUEUEDImplementatie staat in de wachtrij
BUILDINGBuild is bezig
READYImplementatie geslaagd
ERRORImplementatie mislukt
CANCELEDImplementatie geannuleerd
UNPUBLISHEDImplementatie gedepubliceerd

Statuscodes

StatusBeschrijving
200Succes (zelfs als er geen implementatie bestaat, retourneert null-velden)
401Ongeldige of ontbrekende API-sleutel
403Chat behoort niet tot uw team
404Chat niet gevonden, of deploymentId komt niet overeen met een implementatie van deze chat

Pollingpatroon

Geef de id die POST /deploy heeft geretourneerd door als deploymentId.

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