Sviluppatori

Avvia i Pixmate dal tuo sistema: metti in coda i brief con una chiave API, recupera il risultato, ricevi notifiche via webhook.

1 · Autenticazione

Genera una chiave "po_…" da Profilo → Chiavi API (solo il proprietario dell'ufficio). Inviala in ogni richiesta con l'header X-API-Key — la chiave viene mostrata UNA SOLA VOLTA alla creazione.

2 · Metti un brief in coda

POST /api/v1/runs restituisce 202; l'esecuzione è asincrona. Campi: pixmate_slug, brief (≤20.000 caratteri), locale (tr|en).

curl -X POST https://api.pixel-office.app/api/v1/runs \
  -H "X-API-Key: po_XXXXXXXXXXXXXXXX" \
  -H "Content-Type: application/json" \
  -d '{
    "pixmate_slug": "mira-marketing",
    "brief": "Yeni single için 6 sosyal medya postu yaz",
    "locale": "tr"
  }'
# → 202 Accepted
# { "id": "…", "status": "queued", "pixmate_slug": "mira-marketing", … }

3 · Recupera il risultato

GET /api/v1/runs (liste) · GET /api/v1/runs/{id}

curl https://api.pixel-office.app/api/v1/runs/RUN_ID \
  -H "X-API-Key: po_XXXXXXXXXXXXXXXX"
# status: queued → running → completed | failed

4 · Limiti di frequenza

60 richieste al minuto per chiave. Oltre il limite: 429 + Retry-After; ogni risposta include gli header X-RateLimit-Limit / X-RateLimit-Remaining.

5 · Webhooks

Registra un endpoint HTTPS da Profilo → Webhook. Quando un run arriva a uno stato finale (completed/failed/cancelled) ricevi una POST firmata; 3 tentativi (0/5/25 s). Firma: HMAC-SHA256("{timestamp}.{body}").

{
  "event": "run.completed",          // ya da run.failed / run.cancelled
  "run": {
    "id": "…", "status": "completed",
    "pixmate_slug": "mira-marketing", "kind": "chat",
    "cost_usd": 0.0213, "tokens_consumed": 3,
    "error_message": null, "session_id": "…",
    "created_at": "…", "finished_at": "…"
  },
  "sent_at": "…"
}

Verifica (Python):

import hashlib, hmac

def verify(secret: str, ts: str, raw_body: bytes, signature: str) -> bool:
    expected = hmac.new(
        secret.encode(), f"{ts}.".encode() + raw_body, hashlib.sha256
    ).hexdigest()
    return hmac.compare_digest(f"sha256={expected}", signature)

# headers: X-Webhook-Timestamp / X-Webhook-Signature

Per domande: l'email di supporto è nella pagina del profilo. La superficie API è un contratto v1 — le modifiche incompatibili escono in una nuova versione.