> ## Documentation Index
> Fetch the complete documentation index at: https://docs.whaapy.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Obtener Template

> Obtén los detalles de un template específico

## Parámetros de Path

<ParamField path="id" type="string" required>
  UUID del template
</ParamField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X GET "https://api.whaapy.com/templates/v1/tmpl-uuid" \
    -H "Authorization: Bearer wha_xxxxx"
  ```

  ```javascript Node.js theme={null}
  const templateId = 'tmpl-uuid';
  const response = await fetch(
    `https://api.whaapy.com/templates/v1/${templateId}`,
    {
      headers: { 'Authorization': 'Bearer wha_xxxxx' }
    }
  );
  const data = await response.json();
  ```

  ```python Python theme={null}
  import requests

  template_id = 'tmpl-uuid'
  response = requests.get(
      f'https://api.whaapy.com/templates/v1/{template_id}',
      headers={'Authorization': 'Bearer wha_xxxxx'}
  )
  data = response.json()
  ```
</RequestExample>

<ResponseExample>
  ```json 200 OK theme={null}
  {
    "data": {
      "id": "tmpl-uuid-1",
      "name": "order_confirmation",
      "category": "UTILITY",
      "language": "es_MX",
      "status": "APPROVED",
      "content": "Hola {{1}}, tu pedido #{{2}} ha sido confirmado. Te avisaremos cuando esté en camino.",
      "variables": ["{{1}}", "{{2}}"],
      "components": [
        {
          "type": "HEADER",
          "format": "IMAGE"
        },
        {
          "type": "BODY",
          "text": "Hola {{1}}, tu pedido #{{2}} ha sido confirmado. Te avisaremos cuando esté en camino.",
          "example": {
            "body_text": [["Juan", "12345"]]
          }
        },
        {
          "type": "FOOTER",
          "text": "Gracias por tu compra"
        },
        {
          "type": "BUTTONS",
          "buttons": [
            {
              "type": "URL",
              "text": "Rastrear pedido",
              "url": "https://ejemplo.com/track/{{1}}"
            }
          ]
        }
      ],
      "createdAt": "2026-01-15T10:00:00Z",
      "updatedAt": "2026-01-15T10:00:00Z"
    }
  }
  ```
</ResponseExample>

## Errores

<ResponseExample>
  ```json 404 Not Found theme={null}
  {
    "error": "Template not found"
  }
  ```
</ResponseExample>

## Campos de respuesta

| Campo        | Tipo   | Descripción                              |
| ------------ | ------ | ---------------------------------------- |
| `id`         | string | UUID interno de Whaapy                   |
| `name`       | string | Nombre del template (usado para enviar)  |
| `category`   | string | `MARKETING`, `UTILITY`, `AUTHENTICATION` |
| `language`   | string | Código de idioma                         |
| `status`     | string | Estado de aprobación                     |
| `content`    | string | Texto del body (para preview)            |
| `variables`  | array  | Variables posicionales detectadas        |
| `components` | array  | Estructura completa del template         |

## Usar el template

Una vez que tienes los detalles del template, puedes usarlo para enviar un mensaje:

```javascript theme={null}
const template = response.data;

// Enviar el template
await fetch('https://api.whaapy.com/messages/v1', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer wha_xxxxx',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    to: '+5215512345678',
    type: 'template',
    template: {
      name: template.name,
      language: template.language,
      components: [
        {
          type: 'header',
          parameters: [
            { type: 'image', image: { link: 'https://ejemplo.com/logo.png' } }
          ]
        },
        {
          type: 'body',
          parameters: template.variables.map((_, i) => ({
            type: 'text',
            text: i === 0 ? 'Juan' : '12345'  // Reemplazar con valores reales
          }))
        },
        {
          type: 'button',
          sub_type: 'url',
          index: 0,
          parameters: [
            { type: 'text', text: '12345' }  // Valor para {{1}} en la URL
          ]
        }
      ]
    }
  })
});
```
