traction.day

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.

EndpointPOST /api/v1/events
AuthBearer API key
Price1 credit a signup, 3 a purchase

Authentication

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.

Keys are secrets. Keep them on your server: never put one in a web page or an app, since anyone holding it can spend the owner’s credits. The API sends no CORS headers, so browsers can’t call it.

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.

Request

curl -X POST https://traction.day/api/v1/events \
  -H "Authorization: Bearer td_live_…" \
  -d '{"type":"test","eventId":"test_1"}'
200 · test_received
{
  "status": "test_received",
  "received": {
    "type": "test",
    "eventId": "test_1"
  },
  "balance": 500
}

Report an event

POSThttps://traction.day/api/v1/events

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

Request

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.

FieldValue
type"signup" or "purchase", or "test" to test your connection.
eventIdYour 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.
201 · recorded
{
  "status": "recorded",
  "eventId": "0193a4c2-7b1e-7c3d-8e4f-5a6b7c8d9e0f",
  "balance": 499,
  "score": 1
}
A refused request: 402 · insufficient_credits
{
  "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.

HTTPStatusWhen
201recordedCharged and scored. Also returns eventId (our id for the event), balance (the owner’s credits left) and score (the product’s score today).
200duplicateThis eventId was already recorded for the product with the same type. Nothing was charged. Returns eventId, our id for the original event.
200test_receivedA test event arrived. Nothing was recorded or charged. Returns received (the type and eventId we read) and balance (the owner’s credits).
400invalid_requestThe body isn’t a JSON object, type is unknown, or eventId is missing or malformed.
401invalid_api_keyNo key, an unknown or revoked key, or a product that isn’t active.
402insufficient_creditsThe owner’s wallet can’t cover the event. Nothing was recorded, so the same request works after a top-up.
403wallet_frozenThe owner’s wallet is frozen. Nothing was recorded.
409type_conflictThis 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.
500internal_errorSomething failed on our side. Retry with the same eventId.
503day_closedThe 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.

  1. 503 day_closedWait Retry-After seconds (1) and send the same request again. It lands on the new day’s board.
  2. 500 internal_errorRetry with the same eventId. It can’t charge twice.
  3. A network errorSend the same request again. If the first one was recorded, the retry answers duplicate.
  4. 402 insufficient_creditsThe owner tops up the wallet, then the same request succeeds.
  5. 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.

1credit per signup
3credits per purchase
1¢per credit

Listing is free. Buy credits in packs from $5.