Traffic Lights
All resources

Developer guide

SDKs & REST API

Tell Traffic Lights what happened in your process — from Python, from Node, or from anything that can send an HTTPS request.

REST is the contract. The Python and Node SDKs are thin clients over the same endpoint: they validate the event before it leaves your process, add the headers for you, and turn a refusal into a typed error.

Choose your path

PathInstallGuide
Pythonpip install traffic-lights-eventsPython SDK
Nodenpm install @traffic-lights/eventsNode SDK
RESTNothing — one HTTPS POSTThis page, below
AI agentsAdd a connector — no codeConnect over MCP

Configuration

Both SDKs read two environment variables. With either missing they refuse to send, and say which one.

export TL_API_BASE_URL="https://api.traffic-lights.io"
export TL_API_KEY="<your API key>"

TL_API_BASE_URL is the bare origin — the SDK adds the path. Keep TL_API_KEY on the server: it travels in a header on every request, so it must never ship to a browser.

The REST API

One request. No SDK required.

curl -X POST https://api.traffic-lights.io/api/v1/events \
  -H "X-Api-Key: $TL_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
        "source": "sai.tl.billing",
        "detail-type": "FLOW_CALLBACK",
        "detail": {
          "runID": "run-2026-09-28-001",
          "taskID": "20006510",
          "status": "SUCCESS"
        }
      }'

Headers

HeaderRequiredWhat it does
X-Api-KeyYesYour API key. The account is taken from the key, never from the body.
Idempotency-KeyYesA unique value per event. Resending the same key returns the original eventId instead of creating a second event — so a retried timeout is safe.
Content-TypeYesapplication/json

Body

FieldWhat it is
sourceThe system reporting the event. Use the prefix shown in the examples.
detail-typeWhat happened — for example FLOW_CALLBACK, the result of a task in a run.
detailThe event itself. It must carry runID — the run you are reporting on. Traffic Lights never invents one for you.

Responses

  • 202 with {"eventId": "…"} — the event was accepted. This is the only success.
  • 4xx — refused, with the server's reason. Fix the request; retrying the same one will not help.
  • 5xx or timeout — delivery failed. Retry with the same Idempotency-Key.

Treat anything other than a 202 as not delivered — including a 200. A 200 means something other than the events endpoint answered.