Completion webhook
When you run a bot through the API with the webhook_url field, Sinfonia notifies your system as soon as the execution finishes. That way you don’t need to keep polling the platform for the result.
POST
{webhook_url}Sent by Sinfonia to the address provided in
webhook_urlPayload
| Field | Type | Description |
|---|---|---|
exec_id | integer | Execution number. Use it to fetch the log. |
status | string | Execution result: success or error. |
{
"status": "success",
"exec_id": 4512
}Delivery
- Sinfonia sends a
POSTwithContent-Type: application/jsonto the provided URL. - If the call fails, it is retried up to 3 times.
- Respond with a
2xxstatus as quickly as possible. If processing takes a while, do it after responding. - The address must be reachable from the internet. Use
https.
Tip
The webhook doesn’t carry a token. To make sure the call came from Sinfonia, include a secret in the URL itself (for example https://mysystem.com/webhooks/sinfonia?key=a-long-secret) and check it on your server. Then confirm the result by fetching the execution log through the API.
Sample receiver
# pip install flask requests
import os
import requests
from flask import Flask, request, abort
app = Flask(__name__)
SINFONIA_TOKEN = os.environ["SINFONIA_TOKEN"]
WEBHOOK_KEY = os.environ["WEBHOOK_KEY"]
@app.post("/webhooks/sinfonia")
def sinfonia_webhook():
if request.args.get("key") != WEBHOOK_KEY:
abort(401)
event = request.get_json()
exec_id, status = event["exec_id"], event["status"]
log = requests.get(
f"https://sinfonia.live/api/v1/execlog/{exec_id}",
headers={"token": SINFONIA_TOKEN},
).json()
print(f"Execution {exec_id} finished with {status}")
print(log)
return "", 204Last updated on