Status ophalen
curl --request GET \
--url https://macaly.com/api/chat/{chatId}/status \
--header 'Authorization: Bearer <token>'import requests
url = "https://macaly.com/api/chat/{chatId}/status"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://macaly.com/api/chat/{chatId}/status', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://macaly.com/api/chat/{chatId}/status",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://macaly.com/api/chat/{chatId}/status"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://macaly.com/api/chat/{chatId}/status")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://macaly.com/api/chat/{chatId}/status")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_bodyEndpoints
Status ophalen
Vraag de status van een chatworkflow op
GET
/
api
/
chat
/
{chatId}
/
status
Status ophalen
curl --request GET \
--url https://macaly.com/api/chat/{chatId}/status \
--header 'Authorization: Bearer <token>'import requests
url = "https://macaly.com/api/chat/{chatId}/status"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://macaly.com/api/chat/{chatId}/status', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://macaly.com/api/chat/{chatId}/status",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://macaly.com/api/chat/{chatId}/status"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://macaly.com/api/chat/{chatId}/status")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://macaly.com/api/chat/{chatId}/status")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_bodyVraagt de status van een chatworkflow op. Handig om te controleren of een chat klaar is met verwerken zonder een streamingverbinding te onderhouden.
Verzoek
GET /api/chat/{chatId}/status
Headers
| Header | Vereist | Beschrijving |
|---|---|---|
Authorization | Ja | Bearer macaly_... |
Padparameters
| Parameter | Type | Beschrijving |
|---|---|---|
chatId | string | De chat-ID die is geretourneerd door POST /api/chat |
Voorbeeldverzoek
curl https://www.macaly.com/api/chat/abc123/status \
-H "Authorization: Bearer macaly_abc123..."
const response = await fetch(
`https://www.macaly.com/api/chat/${chatId}/status`,
{
headers: {
'Authorization': 'Bearer macaly_abc123...',
},
}
);
const data = await response.json();
console.log(data.status);
import requests
response = requests.get(
f'https://www.macaly.com/api/chat/{chat_id}/status',
headers={
'Authorization': 'Bearer macaly_abc123...',
},
)
data = response.json()
print(data['status'])
Respons
{
"chatId": "abc123",
"url": "https://www.macaly.com/chat/abc123",
"status": "completed",
"result": {
"content": "Here's what I built for you..."
}
}
Responsvelden
| Veld | Type | Beschrijving |
|---|---|---|
chatId | string | De chat-ID |
url | string | URL om de chat in de browser te bekijken |
status | string | Huidige workflowstatus (zie hieronder) |
result.content | string | Laatste assistentbericht (alleen bij completed) |
error.message | string | Foutbeschrijving (alleen bij failed) |
Statuswaarden
| Status | Beschrijving |
|---|---|
running | Workflow wordt momenteel uitgevoerd |
completed | Succesvol afgerond |
failed | Er is een fout opgetreden |
cancelled | Workflow is handmatig geannuleerd |
no_active_workflow | Geen workflow gevonden voor deze chat |
Statuscodes
| Status | Beschrijving |
|---|---|
| 200 | Succes |
| 401 | Ongeldige of ontbrekende API-sleutel |
| 403 | Chat behoort niet tot uw team |
| 404 | Chat niet gevonden |
Pollingpatroon
while true; do
STATUS=$(curl -s https://www.macaly.com/api/chat/$CHAT_ID/status \
-H "Authorization: Bearer macaly_...")
echo "Status: $(echo $STATUS | jq -r .status)"
if echo "$STATUS" | grep -q '"status":"completed"'; then
echo "Done!"
break
fi
sleep 2
done
Volgende stappen
Zodra de statuscompleted is, kunt u:
- De app implementeren met
POST /api/chat/{chatId}/deploy
Was deze pagina nuttig?