Skip to content
🎉 Bem-vindo! Sinfonia by 27Devs é uma plataforma completa de orquestração de robôs, solicite já seu acesso.
Completion webhook

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_url

Payload

FieldTypeDescription
exec_idintegerExecution number. Use it to fetch the log.
statusstringExecution result: success or error.
{
  "status": "success",
  "exec_id": 4512
}

Delivery

  • Sinfonia sends a POST with Content-Type: application/json to the provided URL.
  • If the call fails, it is retried up to 3 times.
  • Respond with a 2xx status 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 "", 204
Last updated on