Authentication
Every request carries an API key as a bearer token. Live and test keys, budgets, and how requests are made.
Every request to the API and to the MCP server carries an API key in the Authorization header.
curl https://api.won.dev/v1/account \
-H "Authorization: Bearer $WON_API_KEY"API keys
Create keys in the console, on the API keys page. A key is shown once, right after you create it: keep it in an environment variable or a secret manager, never in code that runs in a browser. Members of an organization can see its keys; owners and admins can create, edit and revoke them. An organization can have 20 keys at a time: revoke one you no longer use to make room.
| Prefix | What it does |
|---|---|
won_live_ | Returns real data and spends the organization's balance. |
won_test_ | Returns fixed sample data from every trade data and enrichment endpoint and runs cold email in a sandbox that sends nothing. It is never charged. |
A test key has the same parameters, validation, response shapes and rate limit as a live key, so code written against one works with the other.
Budgets
Give each program or agent a key of its own, with a budget: the most that key may ever spend, whatever the code or the agent asks for. A call that could go past it fails with budget_exceeded before anything is charged. GET /account shows what is left in data.key.remaining.
max_cost caps a single call in the same way. See Billing by result.
When a key is refused
| Status | Code | Why |
|---|---|---|
| 401 | unauthorized | The header is missing, or the key is unknown or revoked. |
| 402 | budget_exceeded | The call could cost more than max_cost or what is left of the key's budget. |
| 402 | insufficient_balance | The balance cannot cover the most the call can cost. |
| 429 | rate_limited | The key sent too many requests in a row. See Rate limits. |
The MCP server also answers a 401 with WWW-Authenticate: Bearer realm="won.dev". A refused request does nothing and costs nothing.
Making requests
- The base URL is
https://api.won.dev/v1. Every endpoint answers with JSON. GETandDELETEtake their parameters in the path and the query string, with lists comma-separated:include=partners,contacts.POSTandPATCHtake a JSON body, sent withContent-Type: application/json.- A parameter the endpoint does not know is an error, never silently ignored. One
invalid_inputanswer lists every parameter that needs fixing, see Errors. POST,PATCHandDELETEtake anIdempotency-Keyheader, so that a retry does not do the same thing twice. See Idempotency.- The OpenAPI 3.1 document is at
https://api.won.dev/v1/openapi.json. - Every page of these docs is also Markdown: add
.mdto its URL, or sendAccept: text/markdown.