Skip to main content

List Templates

GET /backend/templates

Filters (Query Parameters)

ParameterTypeDescription
gupshup_app_idstringFilter by Gupshup app
statusstringFilter by status (APPROVED, PENDING, REJECTED)
categorystringFilter by category (MARKETING, UTILITY, AUTHENTICATION)
languagestringFilter by language (e.g., pt_BR, en)

Example

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

Get Template

GET /backend/templates/{id}
Returns complete template details including all components.

Delete Template

DELETE /backend/templates/{id}
Deleting a template automatically removes all cadence associations.
Response: 204 No Content

Sync Templates

POST /backend/templates/sync
Endpoint called by meta-service to sync templates from Gupshup. Body:
{
  "app_id": "app_12345",
  "templates": [
    {
      "id": "gupshup_template_id",
      "name": "welcome_v1",
      "language": "en",
      "status": "APPROVED",
      "category": "MARKETING",
      "components": [
        {
          "type": "BODY",
          "text": "Hello {{1}}, welcome to {{2}}!"
        }
      ]
    }
  ]
}
Response (200):
{
  "synced_count": 5,
  "app_id": "app_12345"
}
Existing templates are updated (upsert). New templates are created automatically. The uniqueness key is (tenant_id, gupshup_app_id, template_name, language).