# Template management



Learn about common endpoints used to manage templates, including getting, editing, deleting, archiving, and unarchiving templates.

## Get templates

Use the [Message Templates API](https://developers.facebook.com/documentation/business-messaging/whatsapp/reference/whatsapp-business-account/message-template-api#get-version-waba-id-message-templates) to get a list of templates in a WhatsApp Business account.

### Get all templates

Example request to get all templates (default fields):

```shell
curl 'https://graph.facebook.com/v23.0/102290129340398/message_templates' \
-H 'Authorization: Bearer EAAJB...'
```

Example response, truncated (`...`) for brevity:

```json
{
  "data": [
    {
      "name": "reservation_confirmation",
      "parameter_format": "NAMED",
      "components": [
        {
          "type": "HEADER",
          "format": "IMAGE",
          "example": {
            "header_handle": [
              "https://scontent.whatsapp.net/v/t61..."
            ]
          }
        },
        {
          "type": "BODY",
          "text": "*You're all set!*\n\nYour reservation for {{number_of_guests}} at Lucky Shrub Eatery on {{day}}, {{date}}, at {{time}}, is confirmed. See you then!",
          "example": {
            "body_text_named_params": [
              {
                "param_name": "number_of_guests",
                "example": "4"
              },
              {
                "param_name": "day",
                "example": "Saturday"
              },
              {
                "param_name": "date",
                "example": "August 30th, 2025"
              },
              {
                "param_name": "time",
                "example": "7:30 pm"
              }
            ]
          }
        },
        {
          "type": "FOOTER",
          "text": "Lucky Shrub Eatery: The Luckiest Eatery in Town!"
        },
        {
          "type": "BUTTONS",
          "buttons": [
            {
              "type": "URL",
              "text": "Change reservation",
              "url": "https://www.luckyshrubeater.com/reservations"
            },
            {
              "type": "PHONE_NUMBER",
              "text": "Call us",
              "phone_number": "+16467043595"
            },
            {
              "type": "QUICK_REPLY",
              "text": "Cancel reservation"
            }
          ]
        }
      ],
      "language": "en_US",
      "status": "APPROVED",
      "category": "UTILITY",
      "id": "1387372356726668"
    },
    {
      "name": "coupon_expiration_reminder_number_vars",
      "parameter_format": "POSITIONAL",
      "components": [
        {
          "type": "HEADER",
          "format": "TEXT",
          "text": "Act fast, {{1}}!",
          "example": {
            "header_text": [
              "Pablo"
            ]
          }
        },
        {
          "type": "BODY",
          "text": "Just a quick reminder—your exclusive coupon code, {{1}}, *expires in only {{2}} days!* Don't miss out on our special deals. Use your code at checkout before it's too late.\n\nHappy shopping! 😃",
          "example": {
            "body_text": [
              [
                "SUMMER20",
                "10"
              ]
            ]
          }
        },
        {
          "type": "FOOTER",
          "text": "Lucky Shrub Succulents"
        },
        {
          "type": "BUTTONS",
          "buttons": [
            {
              "type": "URL",
              "text": "See deals",
              "url": "https://www.luckyshrub.com/deals"
            },
            {
              "type": "QUICK_REPLY",
              "text": "Unsubscribe"
            }
          ]
        }
      ],
      "language": "en",
      "status": "APPROVED",
      "category": "MARKETING",
      "sub_category": "CUSTOM",
      "id": "1304694804498707"
    }

    ...

  ],
  "paging": {
    "cursors": {
      "before": "QVFIU...",
      "after": "QVFIU..."
    },
    "next": "https://graph.facebook.com/v23.0/10229..."
  }
}
```

### Get all templates and specific fields

Example request to get the name, category, and status of all templates in a WhatsApp Business account, limiting the response to 5 templates per result set:

```shell
curl 'https://graph.facebook.com/v23.0/102290129340398/message_templates?fields=name,category,status&limit=5' \
-H 'Authorization: Bearer EAAJB...'
```

Example response:

```json
{
  "data": [
    {
      "name": "reservation_confirmation",
      "category": "UTILITY",
      "status": "APPROVED",
      "id": "1387372356726668"
    },
    {
      "name": "coupon_expiration_reminder_number_vars",
      "category": "MARKETING",
      "status": "APPROVED",
      "id": "1304694804498707"
    },
    {
      "name": "coupon_expiration_reminder_named_vars",
      "category": "MARKETING",
      "status": "APPROVED",
      "id": "1625063511800527"
    },
    {
      "name": "address_update",
      "category": "UTILITY",
      "status": "PENDING",
      "id": "1137051647947973"
    },
    {
      "name": "reservation_confirmation_short_banner",
      "category": "UTILITY",
      "status": "REJECTED",
      "id": "1166414785519855"
    }
  ],
  "paging": {
    "cursors": {
      "before": "QVFIU...",
      "after": "QVFIU..."
    },
    "next": "https://graph.facebook.com/v23.0/10229..."
  }
}
```

### Get all approved and rejected templates

Example request to get all approved templates and their name, category, and status (swap `status=approved` with `status=rejected` to get rejected templates instead):

```shell
curl 'https://graph.facebook.com/v23.0/102290129340398/message_templates?fields=name,category,status&status=approved' \
-H 'Authorization: Bearer EAAJB...'
```

Example response:

```json
{
  "data": [
    {
      "name": "reservation_confirmation",
      "category": "UTILITY",
      "status": "APPROVED",
      "id": "1387372356726668"
    },
    {
      "name": "coupon_expiration_reminder_number_vars",
      "category": "MARKETING",
      "status": "APPROVED",
      "id": "1304694804498707"
    },
    {
      "name": "coupon_expiration_reminder_named_vars",
      "category": "MARKETING",
      "status": "APPROVED",
      "id": "1625063511800527"
    },
    {
      "name": "calling_permission_request",
      "category": "MARKETING",
      "status": "APPROVED",
      "id": "1092999222892024"
    },
    {
      "name": "location_request_v1",
      "category": "MARKETING",
      "status": "APPROVED",
      "id": "3373761659571648"
    },
    {
      "name": "order_confirmation",
      "category": "UTILITY",
      "status": "APPROVED",
      "id": "1667696820637468"
    }
  ],
  "paging": {
    "cursors": {
      "before": "QVFIU...",
      "after": "QVFIU..."
    },
    "next": "https://graph.facebook.com/v23.0/10229..."
  }
}
```

## Create templates

Use the [Message Templates API](https://developers.facebook.com/documentation/business-messaging/whatsapp/reference/whatsapp-business-account/message-template-api#post-version-waba-id-message-templates) to [create a template](https://developers.facebook.com/documentation/business-messaging/whatsapp/templates/overview#creation). See also [Create templates](https://developers.facebook.com/documentation/business-messaging/whatsapp/templates/overview#creation) for detailed component and parameter guidance.

### Template name validation

Template names can only contain lowercase alphanumeric characters and underscores (regex: `^[a-z0-9_]+$`). The maximum length is 512 characters. If a name contains uppercase letters, spaces, or special characters, the API returns error code `100`.

Template names must be unique within a WhatsApp Business account for each language. Creating a template with a name that already exists for the same language returns error code `100`, subcode `2388024`, with message "Content in This Language Already Exists".

### Category and language validation

The API validates template parameters at creation time. Invalid categories or unsupported [language codes](https://developers.facebook.com/documentation/business-messaging/whatsapp/templates/supported-languages) return error code `100`. Starting with v23.0, template component parameter issues at send time return error code `132018`.

## Edit templates

Use the [Message Template API](https://developers.facebook.com/documentation/business-messaging/whatsapp/reference/whatsapp-business-account/message-template-api#post-version-template-id) to edit a template. You can also use the [Message templates](https://business.facebook.com/latest/whatsapp_manager/message_templates) panel in WhatsApp Manager to edit templates.

### Edit template limitations

- Only templates with an `APPROVED`, `REJECTED`, or `PAUSED` status can be edited.
- You can only edit a template's category, components, or time-to-live.
- You cannot edit individual template components; the API replaces all components with those in the edit request payload.
- You cannot edit the category of an approved template.
- Approved templates can be edited up to 10 times in a 30-day window, or 1 time in a 24-hour window. Rejected or paused templates can be edited an unlimited number of times.
- After you edit an approved or paused template, the API automatically re-approves the template unless it fails template review.

### Edit template category

Example request:

```shell
curl 'https://graph.facebook.com/v23.0/1252715608684590' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer EAAJB...' \
-d '
{
  "category": "MARKETING"
}'
```

Example response:

```json
{
  "success": true
}
```

### Edit template components

Example request to overwrite a template's existing components with new components.

```shell
curl 'https://graph.facebook.com/v23.0/564750795574598' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer EAAJB...' \
-d '
{
  "components": [
    {
      "type": "HEADER",
      "format": "TEXT",
      "text": "Our {{1}} is on!",
      "example": {
        "header_text": [
          "Spring Sale"
        ]
      }
    },
    {
      "type": "BODY",
      "text": "Shop now through {{1}} and use code {{2}} to get {{3}} off of all merchandise.",
      "example": {
        "body_text": [
          [
            "the end of April",
            "25OFF",
            "25%"
          ]
        ]
      }
    },
    {
      "type": "FOOTER",
      "text": "Use the buttons below to manage your marketing subscriptions"
    },
    {
      "type": "BUTTONS",
      "buttons": [
        {
          "type": "QUICK_REPLY",
          "text": "Unsubscribe from Promos"
        },
        {
          "type": "QUICK_REPLY",
          "text": "Unsubscribe from All"
        }
      ]
    }
  ]
}'
```

## Delete templates

Use the [Message Templates API](https://developers.facebook.com/documentation/business-messaging/whatsapp/reference/whatsapp-business-account/message-template-api#delete-version-waba-id-message-templates) to delete a template by name or ID, or delete multiple templates by their IDs.

This endpoint requires the `whatsapp_business_management` permission. If you only have the `whatsapp_business_messaging` permission, the API returns error code `200`.

If a template with the specified name does not exist, the API returns an error.

### Delete template limitations

- If you delete a template that has been sent in a template message but has yet to be delivered (for example, because the WhatsApp user's phone is turned off), the template's status is set to `PENDING_DELETION` and WhatsApp attempts delivery for 30 days.
- If you delete an approved template, you cannot create a new template with the same name for 30 days.
- Templates that are in a disabled status cannot be deleted.

### Delete template by name

Deleting a template by name deletes all templates that match that name (meaning templates with the same name but different languages will also be deleted).

Example request:

```shell
curl -X DELETE 'https://graph.facebook.com/v23.0/102290129340398/message_templates?name=order_confirmation' \
-H 'Authorization: Bearer EAAJB...'
```

Example response:

```json
{
  "success": true
}
```

### Delete template by ID

To delete a template by ID, include the template's ID along with its name in your request; only the template with the matching template ID will be deleted.

Example request:

```shell
curl -X DELETE 'https://graph.facebook.com/v23.0/102290129340398/message_templates?hsm_id=1407680676729941&name=order_confirmation' \
-H 'Authorization: Bearer EAAJB...'
```

Example response:

```json
{
  "success": true
}
```

### Delete templates by IDs

To delete multiple templates at once, include an array of template IDs in the `hsm_ids` query parameter. You can include up to 100 template IDs per request.

The `hsm_ids` parameter cannot be combined with the `name` or `hsm_id` parameters. If any of the template IDs are invalid, the entire request fails and no templates are deleted.

Example request:

```shell
curl -X DELETE 'https://graph.facebook.com/v23.0/102290129340398/message_templates?hsm_ids=[1387372356726668,1304694804498707]' \
-H 'Authorization: Bearer EAAJB...'
```

Example response:

```json
{
  "success": true
}
```

## Archive and unarchive templates

When templates have been inactive for 12 months or more, the platform automatically archives them and schedules them for deletion after 28 days. You can also manually archive or unarchive templates in bulk using the API.

See [template archival](https://developers.facebook.com/documentation/business-messaging/whatsapp/templates/template-archival) for more information about auto-archival, the archive and unarchive endpoints, and notifications.