Pular para o conteúdo

Desenvolvedores

Rode Pixmates a partir do seu sistema: enfileire briefs com uma chave de API, busque o resultado e receba avisos por webhook.

1 · Autenticação

Gere uma chave "po_…" em Perfil → Chaves de API (só o dono do escritório). Envie no cabeçalho X-API-Key a cada requisição — a chave aparece UMA ÚNICA VEZ, na criação.

Abrir no perfil →

2 · Colocar um brief na fila

POST /api/v1/runs — retorna 202; a execução é assíncrona. Campos: pixmate_slug, brief (≤20.000 caracteres), locale (tr|en).

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

3 · Buscar o resultado

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

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

4 · Limites de taxa

60 requisições por minuto por chave. Ao exceder, retorna 429 + Retry-After; toda resposta traz os headers X-RateLimit-Limit / X-RateLimit-Remaining.

5 · Webhooks

Cadastre um endpoint HTTPS em Perfil → Webhooks. Quando um run chega a um estado final (completed/failed/cancelled), chega um POST assinado; 3 tentativas (0/5/25 s). Assinatura: HMAC-SHA256("{timestamp}.{gövde}").

Abrir no perfil →

Você também pode se inscrever com uma chave de API (Zapier/Make “REST hook”): POST /api/v1/webhooks {"url": "https://…"} devolve a chave de assinatura uma única vez; GET /api/v1/webhooks lista; DELETE /api/v1/webhooks/{id} cancela a inscrição.

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

Verificação (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

A superfície da API é um contrato v1: mudanças incompatíveis chegam numa nova versão. Dúvidas? Página de suporte →