Events API
One endpoint. Report each real signup and purchase from your product’s server. Each one is paid for with credits from the owner’s wallet and adds points to the product’s score on today’s board.
POST /api/v1/eventsAuthentication
Send your product’s API key in the Authorization header as a bearer token: Authorization: Bearer <key>. Each API key belongs to one product, and its events are charged to that product’s owner.
You see each key once, when it’s made. If one is lost or leaks, revoke it on the dashboard’s Integration page and create another, and give your server the new one. Regenerating on the product’s edit page replaces every key of the product with one.
Test your connection
Send a test event to check your key and your request before you report real ones. A test is free, never reaches the board and is never recorded as an event. It echoes back what we read, so you can check your JSON came through. The reply also includes the owner’s credit balance.
curl -X POST https://traction.day/api/v1/events \ -H "Authorization: Bearer td_live_…" \ -d '{"type":"test","eventId":"test_1"}'
{ "status": "test_received", "received": { "type": "test", "eventId": "test_1" }, "balance": 500 }
Report an event
https://traction.day/api/v1/eventsSend one request for each signup or purchase, from your server, when it happens. The example reads your API key from the TRACTIONDAY_API_KEY environment variable.
curl https://traction.day/api/v1/events \ -H "Authorization: Bearer $TRACTIONDAY_API_KEY" \ -H "Content-Type: application/json" \ -d '{"type": "signup", "eventId": "user_8412"}'
The body is a JSON object of at most 8 KiB, encoded as UTF-8, with two fields. Other fields are ignored.
| Field | Value |
|---|---|
type | "signup" or "purchase", or "test" to test your connection. |
eventId | Your own id for this signup or purchase: 1 to 128 printable ASCII characters (space included), unique within your product across both types. See Event IDs. |
{ "status": "recorded", "eventId": "0193a4c2-7b1e-7c3d-8e4f-5a6b7c8d9e0f", "balance": 499, "score": 1 }
{ "status": "insufficient_credits", "error": "The owner's wallet doesn't have enough credits. Nothing was recorded: top up, then send the same request again." }
Event IDs
An eventId is unique within your product across both types, so prefix it with the kind of id, as in user_8412 for a signup and order_1093 for a purchase. A repeat is spotted by eventId alone, so a user and an order with the same number would otherwise collide, and the second would be refused.
An eventId is recorded once, so retries are safe. Sending it again with the same type answers duplicate; sending it with the other type answers type_conflict.
traction.day keeps only a keyed hash of each eventId, which is enough to spot a repeat. The id itself is never stored or logged.
Responses
Every response is JSON with a status. A failed request also carries error, a message for people. Branch on status, which stays stable. We check the request body before the key, so a request with a bad body gets 400 even when its key is unknown or revoked.
| HTTP | Status | When |
|---|---|---|
| 201 | recorded | Charged and scored. Also returns eventId (our id for the event), balance (the owner’s credits left) and score (the product’s score today). |
| 200 | duplicate | This eventId was already recorded for the product with the same type. Nothing was charged. Returns eventId, our id for the original event. |
| 200 | test_received | A test event arrived. Nothing was recorded or charged. Returns received (the type and eventId we read) and balance (the owner’s credits). |
| 400 | invalid_request | The body isn’t a JSON object, type is unknown, or eventId is missing or malformed. |
| 401 | invalid_api_key | No key, an unknown or revoked key, or a product that isn’t active. |
| 402 | insufficient_credits | The owner’s wallet can’t cover the event. Nothing was recorded, so the same request works after a top-up. |
| 403 | wallet_frozen | The owner’s wallet is frozen. Nothing was recorded. |
| 409 | type_conflict | This eventId was already recorded with the other type, so this event was not recorded or charged. Your ids collide across signups and purchases: prefix them (user_8412, order_1093) and send this event again under its prefixed id. Never send an event that was already recorded under a new id: it would be recorded and charged again. |
| 500 | internal_error | Something failed on our side. Retry with the same eventId. |
| 503 | day_closed | The board closed for the day mid-request. Nothing was recorded. Retry after Retry-After seconds (1) and the event lands on the new day. |
Retries
An eventId is recorded once per product. Sending it again answers duplicate and charges nothing, so a retry is always safe.
- 503
day_closedWaitRetry-Afterseconds (1) and send the same request again. It lands on the new day’s board. - 500
internal_errorRetry with the sameeventId. It can’t charge twice. - A network errorSend the same request again. If the first one was recorded, the retry answers
duplicate. - 402
insufficient_creditsThe owner tops up the wallet, then the same request succeeds. - 400, 401, 403, 409These fail the same way until something changes.
Prices
Each recorded event is paid for with credits from the product owner’s wallet and adds points to the product’s score for the current UTC day: a signup costs 1 credit and adds 1 point, a purchase costs 3 credits and adds 3 points. A duplicate, or a request that fails, costs nothing.
Listing is free. Buy credits in packs from $5.