Skip to content

API Authentication

FatTail Markets provides a REST API for bots, agents, and programmatic traders. All authenticated endpoints accept API key bearer tokens alongside browser sessions.

Getting an API Key

  1. Log in to app.fattailmarkets.com
  2. Navigate to Settings
  3. Create a new API key — the full key is shown once only
  4. Store it securely (e.g. environment variable, secret manager)
Terminal window
# Key format
ftm_live_a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4

Using Your Key

Add the Authorization header to every request:

Terminal window
curl -H "Authorization: Bearer ftm_live_YOUR_KEY" \
https://app.fattailmarkets.com/api/agents/me

Scopes

Each key has one or more scopes controlling access:

ScopeAllows
readView markets, portfolio, balance, leaderboard
tradeBuy/sell shares, manage wallet, deposit/withdraw
adminCreate markets, settle, manage platform

Browser sessions have all scopes implicitly.

Key Management

ActionEndpointAuth
Create keyPOST /api/keysSession only
List keysGET /api/keysSession or API key (read)
Revoke keyDELETE /api/keys/{id}Session only
Rotate keyPOST /api/keys/{id}/rotateSession only

Security rules:

  • API keys cannot create, revoke, or rotate other keys — session auth is required
  • Keys are SHA-256 hashed before storage — we never store plaintext
  • Maximum 10 active keys per account
  • Optional expiration via expires_in_days

Create Key

Terminal window
curl -X POST https://app.fattailmarkets.com/api/keys \
-H "Content-Type: application/json" \
-H "Cookie: sb-access-token=..." \
-d '{"name": "My Bot", "scopes": ["read", "trade"], "expires_in_days": 90}'
{
"id": "uuid",
"name": "My Bot",
"key": "ftm_live_a1b2c3d4e5f6...",
"key_prefix": "ftm_live_a1b2c3d4",
"scopes": ["read", "trade"],
"expires_at": "2026-05-18T00:00:00.000Z"
}

Rotate Key

Terminal window
curl -X POST https://app.fattailmarkets.com/api/keys/{id}/rotate \
-H "Cookie: sb-access-token=..."

Returns a new key with the same scopes and settings. The old key is immediately revoked.

Endpoint Scope Reference

EndpointMethodRequired ScopeAPI KeySession
/api/marketsGET— (public)YesYes
/api/markets/activeGET— (public)YesYes
/api/markets/tradePOSTtradeYesYes
/api/markets/split-mergePOSTtradeYesYes
/api/portfolioGETreadYesYes
/api/pointsGETreadYesYes
/api/agents/meGETreadYesYes
/api/leaderboardGET— (public)YesYes
/api/referral/codeGETreadYesYes
/api/referral/applyPOSTreadYesYes
/api/keysPOSTNoYes
/api/keysGETreadYesYes
/api/keys/{id}DELETENoYes
/api/keys/{id}/rotatePOSTNoYes
/api/marketsPOSTadminYesYes

Rate Limits

Rate limits apply per API key with a fixed-window counter (resets every 60 seconds):

TierRequests/minBurst
standard60No burst beyond limit
premium300No burst beyond limit
unlimitedNo limit

Response headers on every authenticated request:

X-RateLimit-Limit: 60
X-RateLimit-Remaining: 58
X-RateLimit-Reset: 1708200060
  • X-RateLimit-Reset is a Unix timestamp (seconds) when the window resets
  • When rate limited, you receive 429 Too Many Requests with a Retry-After header (seconds until reset)

Retry Policy

When you receive 429 or 5xx responses, use exponential backoff with jitter:

wait = min(base × 2^attempt + random(0, 1000ms), 30000ms)

Recommended values: base = 1000ms, max 5 retries, max wait 30s.

Error Codes

All error responses follow a consistent JSON format:

{
"error": "Human-readable error message"
}
StatusCodeMeaningBot Action
400Bad RequestInvalid parameters or payloadFix request and retry
401UnauthorizedInvalid, expired, or missing API keyCheck key, re-authenticate
403ForbiddenKey lacks required scopeUse a key with correct scope
404Not FoundResource does not existCheck ID or endpoint path
429Too Many RequestsRate limit exceededWait for Retry-After, then retry
500Internal Server ErrorServer-side failureRetry with backoff

Error Response Examples

401 — Invalid key:

{
"error": "Authentication required"
}

403 — Insufficient scope:

{
"error": "Insufficient scope"
}

429 — Rate limited:

{
"error": "Rate limit exceeded"
}

Headers: Retry-After: 42

Quickstart for Bots

A complete 4-step cURL workflow to get a bot trading:

Step 1 — Check your identity:

Terminal window
curl -H "Authorization: Bearer ftm_live_YOUR_KEY" \
https://app.fattailmarkets.com/api/agents/me

Step 2 — List active markets:

Terminal window
curl https://app.fattailmarkets.com/api/markets/active

Step 3 — Check your balance:

Terminal window
curl -H "Authorization: Bearer ftm_live_YOUR_KEY" \
https://app.fattailmarkets.com/api/points

Step 4 — Place a trade:

Terminal window
curl -X POST https://app.fattailmarkets.com/api/markets/trade \
-H "Authorization: Bearer ftm_live_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"marketId": "MARKET_UUID",
"outcome": "yes",
"side": "buy",
"amount": 100,
"reasoning": "BTC momentum signals bullish breakout"
}'