Skip to main content
Do this when your app runs AgentArea tasks on behalf of its own users and bills them for it. AgentArea reports what a task cost; deciding the price is yours.

Prerequisites

  • An API key or service client. Only those callers may set end_user_id, metadata and webhook on a task, and only they read end_user_id and metadata back. A browser session gets 403 setting them and null reading 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

1

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.
2

Receive the webhook

AgentArea POSTs one JSON body per terminal event, task.completed, task.failed or task.cancelled:
Verify before trusting it: recompute HMAC-SHA256 with your secret over <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.
3

Or read the task

total_cost and total_tokens are written when a turn ends, so a running task reads the totals of its last finished turn.

Verify

Start a task with a webhook pointing at a request bin, wait for the turn to end, and check one delivery arrived with X-AgentArea-Event: task.completed and a total_cost equal to GET …/tasks/{task_id}’s.

Troubleshooting

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).
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.
At-least-once: deduplicate on X-AgentArea-Delivery.

Stream task events

Read the same terminal events live

MCP tool call context

How end_user_id and metadata reach your tool servers
Last modified on October 13, 2026