Prerequisites
- An API key or service client. Only those callers may set
end_user_id,metadataandwebhookon a task, and only they readend_user_idandmetadataback. A browser session gets 403 setting them andnullreading them. - For the webhook: an HTTPS endpoint the deployment’s outbound policy lets the worker reach, and a secret of 32 to 512 characters.
The numbers
A task that takes follow-ups ends every turn with
task.completed
(data.execution_status: "waiting"), and each turn’s total_cost and
tokens_used are the running totals of the task. Charge the difference
from the last value you processed for that task.
Steps
Tag the task with your end user and ask for a webhook
webhook.secret is write-only: it goes to the secret manager and is never
returned. Without it deliveries are unsigned.Receive the webhook
AgentArea POSTs one JSON body per terminal event, Verify before trusting it: recompute HMAC-SHA256 with your secret over
task.completed,
task.failed or task.cancelled:<t>.<raw body>, compare with v1 in constant time, and reject a t more
than five minutes old. Deduplicate on X-AgentArea-Delivery (the event id):
a delivery that got a 5xx, a 429 or no answer is retried, a 4xx is not.Verify
Start a task with a webhook pointing at a request bin, wait for the turn to end, and check one delivery arrived withX-AgentArea-Event: task.completed
and a total_cost equal to GET …/tasks/{task_id}’s.
Troubleshooting
The task is created with 422 webhook.url
The task is created with 422 webhook.url
The URL is not http(s), or it resolves to an address the deployment’s
outbound policy refuses (private and metadata addresses, unless the
operator allows them).
No delivery arrives
No delivery arrives
Deliveries go through the worker’s channel delivery stream, so the worker’s
channel delivery consumer must be running. A 4xx from your endpoint is not
retried.
Two deliveries for one turn
Two deliveries for one turn
At-least-once: deduplicate on
X-AgentArea-Delivery.Related
Stream task events
Read the same terminal events live
MCP tool call context
How end_user_id and metadata reach your tool servers