Pular para o conteúdo principal

Listar Templates

GET /backend/templates

Filtros (Query Parameters)

ParâmetroTipoDescrição
gupshup_app_idstringFiltrar por app Gupshup
statusstringFiltrar por status (APPROVED, PENDING, REJECTED)
categorystringFiltrar por categoria (MARKETING, UTILITY, AUTHENTICATION)
languagestringFiltrar por idioma (ex: pt_BR, en)

Exemplo

curl -X GET "https://api.leavo.ai/backend/templates?status=APPROVED&language=pt_BR" \
  -H "Authorization: Bearer sua_chave_aqui"
Resposta (200):
[
  {
    "id": "uuid",
    "tenant_id": "uuid",
    "gupshup_app_id": "app_12345",
    "template_name": "boas_vindas_v1",
    "template_id": "gupshup_id",
    "language": "pt_BR",
    "status": "APPROVED",
    "category": "MARKETING",
    "components": [...],
    "last_synced_at": "2024-01-15T10:00:00Z"
  }
]

Obter Template

GET /backend/templates/{id}
Retorna os detalhes completos de um template, incluindo todos os componentes.

Excluir Template

DELETE /backend/templates/{id}
Ao excluir um template, todas as associações com cadências são removidas automaticamente.
Resposta: 204 No Content

Sincronizar Templates

POST /backend/templates/sync
Endpoint chamado pelo meta-service para sincronizar templates do Gupshup. Body:
{
  "app_id": "app_12345",
  "templates": [
    {
      "id": "gupshup_template_id",
      "name": "boas_vindas_v1",
      "language": "pt_BR",
      "status": "APPROVED",
      "category": "MARKETING",
      "components": [
        {
          "type": "BODY",
          "text": "Olá {{1}}, bem-vindo à {{2}}!"
        }
      ]
    }
  ]
}
Resposta (200):
{
  "synced_count": 5,
  "app_id": "app_12345"
}
Templates existentes são atualizados (upsert). Templates novos são criados automaticamente. A chave de unicidade é (tenant_id, gupshup_app_id, template_name, language).