Referencja API

Wszystkie endpointy public API. Base URL: https://api.affily.pl

Authentication
Authorization: Bearer aff_pk_live_xxx
Rate limit
1000 req/min/key
Content type
application/json

Endpointy

POST/v1/conversions

Rejestruje konwersję

Request body
{
  "click_id": "click_xxx",
  "offer_id": "off_xxx",
  "order_id": "ORDER-001",
  "amount": 250.00,
  "currency": "PLN",
  "metadata": {...}
}
Response
{
  "id": "conv_xxx",
  "status": "pending",
  "commission": 25.00,
  "hold_until": "2026-..."
}
GET/v1/conversions

Lista konwersji (cursor pagination, limit 500)

Query params
?status=approved&from=2026-01-01&cursor=conv_xxx
Response
{
  "data": [...],
  "next_cursor": "conv_yyy",
  "has_more": true
}
PATCH/v1/conversions/:id

Approve / reject / dispute konwersji

Request body
{
  "status": "approved" | "rejected",
  "rejection_reason": "returned" | "chargeback" | "duplicate" | "offer_terms_violation" | "fraud" | "other",
  "rejection_note": "string"
}
GET/v1/account

Info o koncie + statystyki MTD

Response
{
  "advertiser": { "id": "...", "company_name": "..." },
  "deposit_balance": 4250.00,
  "stats_mtd": {
    "clicks": 1234,
    "conversions": 56,
    "commission_paid": 1234.50
  }
}
GET/v1/offers

Lista własnych ofert

POST/v1/deposits

Tworzy depozyt (Stripe / Sunrise Pay / proforma)

Request body
{
  "amount": 1000,
  "currency": "PLN",
  "method": "stripe" | "sunrise_pay" | "transfer" | "proforma",
  "return_url": "https://your-app.com/success"
}
Response
{
  "id": "dep_xxx",
  "status": "pending_payment",
  "payment_url": "https://checkout.stripe.com/...",
  "expires_at": "..."
}

Kody błędów

StatusKodOpis
400validation_errorNieprawidłowe dane wejściowe
401invalid_api_keyBrak lub niepoprawny klucz API
402insufficient_depositNiewystarczający depozyt reklamodawcy
403forbiddenBrak uprawnień do zasobu
404not_foundZasób nie istnieje
409duplicate_order_idorder_id już użyty
410click_expiredCookie window minęło
422validation_errorBody schema validation failed
429rate_limitPrzekroczony rate limit
500internal_errorBłąd serwera

Format błędu

{
  "error": {
    "code": "validation_error",
    "message": "Invalid body",
    "details": { ... }
  }
}