Atteny API

API REST pública e versionada para integrar o Atteny à sua aplicação: enviar e ler mensagens, gerenciar contatos e conversas.

Base URL
https://api.atteny.ai/api/v1

Crie sua chave no dashboard em app.atteny.ai/api-tokens e comece em 1 minuto.

Autenticação

Toda requisição usa uma API key por organização no header Authorization:

curl https://api.atteny.ai/api/v1/me \
  -H "Authorization: Bearer sk_live_xxxxxxxx"

Limites & quota

TipoPadrãoHeadersExcedeu
Rate limit por key120 req/minX-RateLimit-*429 rate_limit_exceeded
Quota mensal (por plano)configurávelX-Api-Quota-*402 quota_exceeded

Escopos

EscopoPermite
messages:sendEnviar mensagens
messages:readLer mensagens
conversations:readLer conversas
contacts:readLer contatos
contacts:writeCriar/editar contatos
webhooks:manageGerenciar webhooks

Respostas & erros

// sucesso
{ "success": true, "data": { ... }, "meta": { "total": 0, "page": 1, "limit": 20 } }
// erro
{ "success": false, "code": "invalid_api_key", "error": "Mensagem amigável." }
HTTPcodeQuando
401unauthorized / invalid_api_keySem chave / chave inválida
403API_FEATURE_DISABLED / insufficient_scopePlano sem API / falta escopo
402quota_exceededCota mensal atingida
429rate_limit_exceededRate limit por key

GET /me

GET /v1/me qualquer escopo

Identidade da chave: organização, plano e a própria key.

{
  "success": true,
  "data": {
    "organization": { "id": "...", "name": "Minha Empresa", "slug": "minha-empresa" },
    "plan": { "name": "Business", "hasAPI": true, "hasWebhooks": true },
    "apiKey": { "name": "Integração loja", "prefix": "sk_live_a1b2", "scopes": ["messages:send"] }
  }
}

Contatos

GET /v1/contacts contacts:read

Lista contatos (paginado). Query: page, limit (1–100), search.

POST /v1/contacts contacts:write

Cria um contato. 409 contact_exists se o telefone já existir na org.

curl -X POST https://api.atteny.ai/api/v1/contacts \
  -H "Authorization: Bearer sk_live_..." \
  -H "Content-Type: application/json" \
  -d '{ "phoneNumber": "+5511999990000", "name": "Maria" }'

Conversas

GET /v1/conversations conversations:read

Lista conversas (paginado). Query: page, limit, status. Cada item traz contact + lastMessage.

GET /v1/conversations/:id/messages messages:read

Mensagens da conversa (paginado). 404 se a conversa não for da sua org.

Enviar mensagem

POST /v1/conversations/:id/messages messages:send
curl -X POST https://api.atteny.ai/api/v1/conversations/CONV_ID/messages \
  -H "Authorization: Bearer sk_live_..." \
  -H "Content-Type: application/json" \
  -d '{ "content": "Olá! Tudo bem?" }'

Body: content (obrigatório), type (TEXT|IMAGE|VIDEO|AUDIO|DOCUMENT), mediaUrl, mediaType.

Webhooks de saída

Receba eventos no seu servidor em tempo real. Cadastre endpoints no dashboard em app.atteny.ai/api-tokens (seção Webhooks de saída) — escolha a URL (https) e os eventos.

EventoQuando
message.createdMensagem recebida de um contato
message.sentMensagem enviada pela sua org

Cada entrega é um POST assinado por HMAC SHA-256. Verifique a autenticidade recomputando a assinatura sobre o corpo cru com o secret do endpoint (mostrado uma vez na criação):

// header recebido
X-Atteny-Signature: sha256=<hex>
X-Atteny-Event: message.created
X-Atteny-Delivery: <id>

// Node.js — verificar
const crypto = require('crypto')
const expected = 'sha256=' + crypto.createHmac('sha256', SECRET)
  .update(rawBody, 'utf8').digest('hex')
const ok = crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(req.headers['x-atteny-signature']))

Entregas com falha são reentregues com backoff (até 5 tentativas); o endpoint é desativado após falhas consecutivas. Use o botão Testar no dashboard para validar seu receptor.

Segurança