Open an outcome

An outcome is a live instance of an agent for one customer. The first event for a key opens it.

Before sending the first event, you need a customer and an agent. The customer must have a rate card assigned with an entry for that agent.

What is an outcome?

An outcome tracks whether a real-world event happened and whether it met the conditions for billing. It opens when you send the first event for a new key and resolves to confirmed or missed after the settlement window closes.

Examples of when an outcome opens: a support ticket is created, a document is sent for signature, a job is posted, a task is started.

The outcome key

Every outcome has a key. You choose this string. It must be globally unique across all accounts and between 8 and 255 characters.

You use the key in every event submission for that outcome. Pick something that includes your own system identifiers:

support:ticket:1001
contract:acme:2024-01
job:hire:req-4821

The key cannot be changed after the outcome is created. It must be globally unique across all accounts, not just your own.

Opening an outcome

Send the first event. witn creates the outcome automatically.

curl -X POST https://api.thewitn.com/v1/events \
  -H "Authorization: Bearer $WITN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "key": "support:ticket:1001",
    "action": "ticket_created",
    "customer_key": "acme",
    "agent_key": "support"
  }'

Returns 202 Accepted. witn records the event, snapshots the agent contract for this customer, and starts evaluating the billable condition.

customer_key is the customer's key, not an ID.

agent_key is the key of the agent. Find it in the dashboard.

What happens next

After the outcome opens, send events as things happen in your system. witn evaluates the billable condition after each event and resets the settlement timer.

When the timer expires, the outcome resolves:

  • Confirmed: condition was met. You receive a notification and an invoice line is created.
  • Missed: condition was not met. You receive a notification.

See Notifications to set up a webhook for these events.

Errors

CodeStatusWhen
VALIDATION_ERROR400key, action, or customer_key is missing or invalid.
TOKEN_INVALID401Token missing or not recognised.
PAYLOAD_TOO_LARGE413Request body exceeded the 256 KiB limit.

On this page