Agents & webhooks

Create an agent

triggertype: manual, schedule (put the schedule in triggerconfig; preview it with POST /api/agents/schedule-preview/), keyword, webhook. Delivery goes to whichever of whatsappinstance/whatsappnumber, discordchannelid, emailaddress or webhookurl you set.

Run now: POST /api/agents/{id}/run/ · History: GET /api/agents/{id}/runs/ · Templates: GET /api/agents/templates/, POST …/{id}/install/.

Trigger it from your system

GET /api/agents/{id}/webhook-info/ gives the trigger URL (/api/agents/<webhooktoken/trigger/) and the secret. Each call needs three headers:

| Header | Value | |---|---| | X-Timestamp | Unix seconds — must be within 5 minutes of now | | X-Signature | sha256= + hex HMAC-SHA256 of "{timestamp}.{raw body}" with the webhook secret | | X-Idempotency-Key | Unique per event — a repeat returns 409 for 24 h |

secret = b"your-webhook-secret" body = json.dumps({"orderid": 42}) ts = str(int(time.time())) sig = "sha256=" + hmac.new(secret, f"{ts}.{body}".encode(), hashlib.sha256).hexdigest()

r = requests.post("https://ai.thimitech.com/api/agents/<webhooktoken/trigger/", data=body, headers={ "Content-Type": "application/json", "X-Timestamp": ts, "X-Signature": sig, "X-Idempotency-Key": str(uuid.uuid4()), }) print(r.statuscode, r.json()) 202 {"runid": ...}

The body you send is passed to the agent as its payload. Responses: 202 queued, 403 bad signature/timestamp/disabled, 409 duplicate, 429 over 60/min. Rotate the secret with POST /api/agents/{id}/regenerate-webhook/.