Skip to main content
Everything the Waniwani SDK and chat widget do goes through a JSON API over HTTPS, and you can call it yourself from any language. This page covers what every route has in common, then sends events end to end. The Server API and Chat API sections list each route with its full request and response schema.

Base URL

Use the URL of the region your organization was created in. A key from one region gets a 401 from the other.

Authentication

Every request carries a key as a bearer token:
The events route takes either key. Data lands in the environment the key belongs to.

Requests and responses

Send JSON with Content-Type: application/json. Each endpoint page shows its method, its fields and which of them are required. Most routes answer inside an envelope, with the route’s own result in data. Searching the knowledge base, for example:
Three routes answer with their result directly, without the envelope: the events route (shown below) and the two WebMCP routes. Their endpoint pages show the exact body.

Errors

A failed request answers with a 4xx or 5xx status. The body carries the error code in error, and errorId identifies the failure if you contact support:
The events route answers errors as { "error": "INVALID_API_KEY", "requestId": "ingest_req_..." }.

Send events

POST /api/mcp/events/v2/batch takes a batch of events and stores each one that passes the checks. This is the route the SDK’s track() calls.

The batch

Put your channel’s id in properties.channelId. Waniwani files each event under a channel, and without an id it tries to match source to a channel’s label. An event that matches no channel is rejected. Neither the batch nor an event takes other keys. An unknown key in the batch fails the whole request with a 400, and one in an event rejects that event alone.

The response

Each event is checked on its own, so a 200 can list events that were not stored:
accepted counts the events that passed. rejected lists the others and is absent when there are none. Send a rejected event again later when its retryable is true. When it is false, fix the event first.

Retries

Waniwani stores an event id once. When a request times out and you can’t tell whether it arrived, send the same batch again with the same ids, and the events already stored are skipped. They still count in accepted, so count delivered events by their ids, not by adding up accepted. The SDK sends up to 20 events per batch.