List templates

SDK platic.whatsapp.templates.list()

List workspace templates and filter by status or category. Check warnings to see whether each WhatsApp account could be read.

You need an approved template to start a conversation outside the 24-hour window.

Example

const { templates, warnings } = await platic.whatsapp.templates.list();

templates is the complete list; warnings identifies accounts that could not be read.

Query parameters

ParameterTypeDescriptionRequired
workspacestringWorkspace ID. Required if your credential covers several workspaces (list workspaces); without it the answer is 400If the credential has several
statusstringOnly templates in these statuses, comma-separated: APPROVED or APPROVED,PAUSED—
categorystringOnly these categories, comma-separated: MARKETING, UTILITY or AUTHENTICATION—
namestringOnly templates whose name contains this text, case-insensitive. For an exact name use get a template—

For example, ?status=APPROVED&category=UTILITY returns only the utility templates that can already be sent.

Response

data is the list of workspace templates. Each language version is a separate entry: order_update in es_MX and in en_US appears twice.

{
  "status": "success",
  "data": [
    {
      "id": "1234567890123456",
      "name": "order_update",
      "category": "UTILITY",
      "status": "APPROVED",
      "language": "es_MX",
      "source": "meta",
      "content": "Hi {{1}}, your order {{2}} is ready for pickup.",
      "params": ["Ana", "A-1024"],
      "header": { "type": "none", "requiresMedia": false },
      "footer": "Acme",
      "buttons": [],
      "api_example": {
        "name": "order_update",
        "params": ["Ana", "A-1024"]
      },
      "dynamicButtonsCount": 0
    }
  ],
  "warnings": [
    {
      "code": "WHATSAPP_TOKEN_INVALID",
      "message": "WhatsApp rejected the access token of this WhatsApp Business Account: it expired or was revoked. Reconnect the account in Platica and try again.",
      "wabaId": "155598765432109",
      "status": 409
    }
  ]
}
FieldDescription
dataThe templates that pass the filters, in the shape of get a template. Each carries api_example (the body to send it) and dynamicButtonsCount
warningsOnly if something is missing from the list. Each warning carries code and message

There are two kinds of warning:

  • WABA_NOT_FOUND: the workspace has no WhatsApp Business account (WABA) connected. data comes back empty.
  • A WABA whose templates could not be read, with wabaId and status. Its templates are missing from data; those of the other WABAs are there. code is the same one a write on that WABA would answer: WHATSAPP_TOKEN_INVALID or WHATSAPP_PERMISSION_DENIED (reconnect the account in Platica), WHATSAPP_ACCOUNT_RESTRICTED (Meta restricted the account), RATE_LIMITED (wait a few minutes) or UPSTREAM_ERROR (try again in a moment).

Errors

Statusdetails.codeWhen
400INVALID_REQUESTA filter is not valid, such as a category that does not exist (details.issues says which). Also if your credential covers several workspaces and you did not send ?workspace=, or you sent one it does not cover: details.available has the IDs you can use
401UNAUTHENTICATEDThe credential is missing or not valid
403FORBIDDENThe person has no permission in Conversations or Campaigns. The message is Missing conversations or campaigns permission
404WORKSPACE_NOT_FOUNDThe workspace no longer exists
409WHATSAPP_TOKEN_INVALID, WHATSAPP_PERMISSION_DENIED, WHATSAPP_ACCOUNT_RESTRICTEDNo WABA of the workspace could be read through its WhatsApp account. The status and code are those of the first failure; details.wabaId says which and details.wabaErrors lists all of them
429RATE_LIMITEDSame, because WhatsApp is rate limiting requests
502UPSTREAM_ERRORSame, because Platica could not reach WhatsApp. Also if the workspace uses MessageBird (legacy) and its templates could not be read
503TEMPORARILY_UNAVAILABLEPlatica could not read the workspace or its WABAs. Try again in a moment
{
  "code": 409,
  "error": "Conflict - The resource state conflicts with this request",
  "details": {
    "code": "WHATSAPP_TOKEN_INVALID",
    "message": "WhatsApp rejected the access token of this WhatsApp Business Account: it expired or was revoked. Reconnect the account in Platica and try again.",
    "wabaId": "155598765432109",
    "wabaErrors": [
      {
        "wabaId": "155598765432109",
        "code": "WHATSAPP_TOKEN_INVALID",
        "message": "WhatsApp rejected the access token of this WhatsApp Business Account: it expired or was revoked. Reconnect the account in Platica and try again.",
        "status": 409
      }
    ]
  }
}

The general error format is in Errors.