Skip to main content

Templates API

In addition to managing templates through Positus Studio, you can manage them directly through the API. The template endpoints are scoped by workspace and allow you to list, retrieve, validate the name of, create, and delete templates.

Authentication and Scope

All routes require user Bearer Token authentication and are accessed under the desired workspace:
Creating and deleting templates require the authenticated user to be an owner of the workspace. Otherwise, the API responds with 403. The other routes only require the user to have active access to the workspace.
There is no route to edit a template or to search by name. To change a template, create a new one.

List Templates

Returns the workspace templates.
  • There is no pagination or other filters (name, category, or language).
  • Templates with DELETED status are not returned in the list.
  • The PAUSED status has two ids (10 and 11); to filter it, query one id at a time.
Response
See the description of each field in Attributes.

Show Template

Returns a specific template from the workspace.
Response — { "data": { ...template object } }, in the same format as each item in the list. If the template does not belong to the workspace, the API responds with 404.
Unlike the list, the show route also returns templates with DELETED status.

Validate Name

Before creating a template, check whether the name is already in use in the workspace. Trying to create a template with an existing name results in an error.
Response
  • 204 No Content: there is no template with that name.
  • 422 Unprocessable Entity: the name already exists.
The name is normalized the same way as at creation (see Create Template) and compared only with the templates registered in Positus for the workspace, including those already deleted. The check does not query Meta.

Create Template

Creates a template in the workspace. The template is sent to Meta and, if successful, registered in Positus.
Send the data as FormData (multipart/form-data). Templates with a document, image, or video header (and carousel cards with an image or video) require the file to be sent, which must be provided in components[i][example][header_handle][0].
The name is normalized before being saved: it becomes lowercase, and spaces and symbols become _. For example, Meu primeiro template is saved as meu_primeiro_template. The name returned in the response is the normalized one.

Components

The components property is passed to Meta unchanged: Positus does not define or validate component types, parameters, or buttons, and Meta is the one that accepts or rejects the content. See all the possibilities in Meta’s documentation on components. The only cases in which Positus inspects the content of components are header files:

Simple Template

Response — 200 OK
status, category, and wa_id come from Meta’s response. For this reason, the category may differ from the one sent (Meta may recategorize the template) and the status is usually PENDING. Creation responds with 200, not 201.

Template with a File in the Header

The file must be sent in the same FormData field components[1][example][header_handle][0] (index of the HEADER component within components). The example below shows the logical body, where (binary) represents the file.
Response — 200 OK (excerpt). The uploaded file becomes available in header_file, and header_handle[0] now contains the identifier generated by Meta.
Each card with an image or video header requires the corresponding file in components[i][cards][j][components][k][example][header_handle][0] (FormData). The example below shows the logical body.
Response — 200 OK. The card files are returned in carousel_files, in the order of the cards:

Authentication Template

Response — 200 OK (excerpt):
The authentication component options (such as the body and the OTP button) are validated by Meta. To see the default text of authentication templates, use the previews route.

Limits and Errors

When a template is created through the API, the message_template_created event is sent to the workspace webhook.

Delete Template

Deletes a template from the workspace. Requires the workspace owner user.
Response
  • 204 No Content: the template was deleted in Meta and marked as DELETED in Positus.
  • 400: Meta did not delete the template. The response contains { "message": "..." } with the message returned by Meta.
  • 403: the user is not the workspace owner.
Deletion is done by the name of the template in Meta. If the same name exists in more than one language, consider that the deletion may reach all of them, according to Meta’s behavior.

Previews

Returns the authentication template previews provided by Meta for the workspace WABA.
The response is the JSON returned by Meta, without transformation, and is cached for 1 hour for the same combination of workspace, category, languages, and options. If the workspace has no WABA, the API responds with 400.

Restrictions

Returns the template restrictions of the workspace.
Response
This route is informational only: the create endpoint only validates whether display_format and sub_category belong to the accepted values, and does not block submission when order_details is false.

List Templates of a Number

Returns the templates of the workspace to which a number belongs.
Response — { "data": [ ...template objects ] }, with all non-deleted templates of the number’s workspace, with no status filter.

Learn More