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

# Get Templates

> Retrieve and manage your WhatsApp message templates

<Tip>
  Templates are pre-approved message formats that ensure your WhatsApp communications comply with WhatsApp Business policies while maintaining consistent messaging with your audience.
</Tip>

WhatsApp templates are essential for business messaging, enabling you to send structured communications to customers while complying with WhatsApp's policies. This guide covers how to retrieve your templates using our API.

## Overview

Templates serve as the foundation for all non-session messages on WhatsApp Business. Each template:

* Must be pre-approved by WhatsApp before use
* Belongs to a specific category (Marketing, Utility, Authentication)
* Can include variables that personalize messages for each recipient
* Supports multiple languages and formats (text, media, interactive components)

<Card title="Try it in the API Reference" icon="arrow-right" href="https://docs.whatsable.app/api-reference/notifier-system/templates/get-templates">
  Experiment with the Get Templates API and view responses in real-time
</Card>

## Get Templates

Retrieve all WhatsApp templates associated with your account, including approval status, variables, and other key properties.

### Endpoint

```
GET https://api.insightssystem.com/api:AFRA_QCy/get_templates
```

### Authentication

<Warning>
  All API requests require authentication using your API key. Never share your API keys in client-side code.
</Warning>

Include your API key in all requests using Bearer authentication:

<CodeGroup>
  ```bash theme={null}
  Authorization: Bearer YOUR_API_KEY
  ```

  ```javascript theme={null}
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json'
  }
  ```
</CodeGroup>

### Response

The API returns an array of template objects, each containing detailed information about your WhatsApp templates.

<ResponseField name="id" type="integer">
  Unique identifier for the template
</ResponseField>

<ResponseField name="user_id" type="string">
  UUID of the account that owns the template
</ResponseField>

<ResponseField name="name" type="string">
  Unique name identifier of the template
</ResponseField>

<ResponseField name="category" type="string">
  <Expandable title="category options">
    <ResponseField name="MARKETING" type="string">
      Promotional content and offers
    </ResponseField>

    <ResponseField name="UTILITY" type="string">
      Transactional messages like order confirmations
    </ResponseField>

    <ResponseField name="AUTHENTICATION" type="string">
      Security codes and verification messages
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="type" type="string">
  Format type of the template (text, media, etc.)
</ResponseField>

<ResponseField name="language" type="string">
  Language code (e.g., "en", "en\_US")
</ResponseField>

<ResponseField name="status" type="string">
  <Expandable title="status options">
    <ResponseField name="APPROVED" type="string">
      Template is ready to use
    </ResponseField>

    <ResponseField name="PENDING" type="string">
      Template is awaiting WhatsApp review
    </ResponseField>

    <ResponseField name="REJECTED" type="string">
      Template was rejected by WhatsApp
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="variable_counts" type="integer">
  Number of variable placeholders in the template
</ResponseField>

<ResponseField name="template_formate" type="string">
  Format string showing variable placement (e.g., "\[b:7]")
</ResponseField>

<ResponseField name="template_id" type="string">
  UUID of the template in our system
</ResponseField>

### Example Request

<CodeGroup>
  ```bash cURL theme={null}
  curl -X GET \
    https://api.insightssystem.com/api:AFRA_QCy/get_templates \
    -H 'Content-Type: application/json' \
    -H 'Authorization: Bearer YOUR_API_KEY'
  ```

  ```javascript Node.js theme={null}
  const axios = require('axios');

  async function getTemplates() {
    try {
      const response = await axios.get(
        'https://api.insightssystem.com/api:AFRA_QCy/get_templates',
        {
          headers: {
            'Content-Type': 'application/json',
            'Authorization': 'Bearer YOUR_API_KEY'
          }
        }
      );
      console.log(response.data);
      return response.data;
    } catch (error) {
      console.error('Error fetching templates:', error);
    }
  }

  getTemplates();
  ```

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

  url = "https://api.insightssystem.com/api:AFRA_QCy/get_templates"

  headers = {
      "Content-Type": "application/json",
      "Authorization": "Bearer YOUR_API_KEY"
  }

  response = requests.get(url, headers=headers)
  print(response.json())
  ```
</CodeGroup>

### Example Response

<CodeGroup>
  ```json Response theme={null}
  [
    {
      "id": 300,
      "user_id": "a9d7c221-62d2-43b5-810a-8a1a71c7820c",
      "name": "exclusive_offer_alert",
      "category": "MARKETING",
      "type": "text",
      "language": "en",
      "status": "APPROVED",
      "variable_counts": 7,
      "template_formate": "[b:7]",
      "template_id": "6f6e4113-cc8a-4fbe-b98d-2c631d299c6b"
    },
    {
      "id": 150,
      "user_id": "a9d7c221-62d2-43b5-810a-8a1a71c7820c",
      "name": "general_communication_message",
      "category": "UTILITY",
      "type": "text",
      "language": "en",
      "status": "REJECTED",
      "variable_counts": 0,
      "template_formate": "[]",
      "template_id": "75521873-72cd-4c33-9072-c8b901d6f687"
    }
  ]
  ```
</CodeGroup>

## Response Codes

<AccordionGroup>
  <Accordion title="200: Success">
    Your request was successful and the templates have been returned.
  </Accordion>

  <Accordion title="401: Unauthorized">
    Authentication failed. Check that you're using a valid API key.

    ```json theme={null}
    {
      "error": {
        "code": "unauthorized",
        "message": "Invalid API key provided"
      }
    }
    ```
  </Accordion>

  <Accordion title="403: Forbidden">
    Your account doesn't have permission to access templates.
  </Accordion>

  <Accordion title="429: Too Many Requests">
    You've exceeded the rate limit. Implement exponential backoff in your requests.
  </Accordion>

  <Accordion title="500: Server Error">
    Something went wrong on our end. Please contact support if the issue persists.

    ```json theme={null}
    {
      "error": {
        "code": "server_error",
        "message": "An internal server error occurred"
      }
    }
    ```
  </Accordion>
</AccordionGroup>

## Working with Templates

<Steps>
  <Step title="Retrieve templates">
    Use the Get Templates API to fetch all templates associated with your account.
  </Step>

  <Step title="Check template status">
    Verify that your templates are in the "APPROVED" status before using them.
  </Step>

  <Step title="Identify variable placeholders">
    Note the `variable_counts` and `template_formate` to understand how many variables need to be provided when sending a message.
  </Step>

  <Step title="Send messages">
    Use the template ID and required variables to send messages via the [Send Template API](/api-reference/notifier-system/send-template).
  </Step>
</Steps>

## Template Best Practices

<CardGroup cols={2}>
  <Card title="Variable Management" icon="wand-magic-sparkles">
    Keep track of which variables correspond to which placeholders in your template. Consider creating a mapping in your application.
  </Card>

  <Card title="Template Versioning" icon="code-branch">
    Templates can't be edited after submission, but you can create new versions. Use a versioning system in your template names (e.g., welcome\_v2).
  </Card>

  <Card title="Status Monitoring" icon="gauge">
    Regularly check the status of your templates, as WhatsApp can change approval statuses based on user feedback.
  </Card>

  <Card title="Language Support" icon="language">
    Create templates in multiple languages to communicate with your global audience in their preferred language.
  </Card>
</CardGroup>

## FAQs

<AccordionGroup>
  <Accordion title="How long does template approval take?">
    WhatsApp typically reviews templates within 24-48 hours, but this can vary depending on template content and current review volumes.
  </Accordion>

  <Accordion title="Why was my template rejected?">
    Templates may be rejected if they violate WhatsApp's Business Policy, contain prohibited content, or don't match the selected category. Check our [Template Guidelines](/guides/whatsapp/template-guidelines) for more information.
  </Accordion>

  <Accordion title="Can I edit an existing template?">
    No, once submitted, templates cannot be modified. You'll need to create a new template with your desired changes.
  </Accordion>

  <Accordion title="What are the template character limits?">
    Text-only templates have a limit of 1,024 characters. Templates with media have different limits based on the header type.
  </Accordion>
</AccordionGroup>

<Card title="Need help?" icon="headset" href="mailto:team@whatsable.app">
  Our support team is available 24/7 to assist with template issues, API integration, or any other questions.
</Card>
