Retrieving List of Templates

This article covers an API method for retrieving a list of templates.

message-matchers/get-by-request Method

The method-matchers/get-by-request method returns code 200 with a JSON object that contains the list of templates for the specified subject ID. If the request fails, the server returns a response with an error code.

For instructions on getting subject IDs for your channels, see the article.

URL

To retrieve the list of templates, send a POST request to the following URL address: https://app.edna.io/api/message-matchers/get-by-request.

Request Format

A JSON object is sent in the request body with the following parameters.

{
    "subjectId": 23,
    "matcherTypes": ["OPERATOR","USER","CUSTOM"]
}
ParameterData typeDescription
subjectIdintegerSubject identifier. To get it, send a request to edna technical support.
matcherTypesstring (optional)Template type. Possible values are:

OPERATOR — Operator template (a template that was registered with a service provider)
USER — User template (a template that was created by a user based on an operator template)
CUSTOM — Template that you create from scratch. It can contain any content that is allowed for this channel

Response Format

As a response to the request, a JSON object that contains a list of templates is returned.

[
  {
    "id": 0,
    "name": "string",
    "channelType": "SMS",
    "language": "string",
    "content": {
      "attachment": {
        "id": 0,
        "fileUrl": "string",
        "originalFileName": "string",
        "size": 0
      },
      "action": "string",
      "caption": "string",
      "header": {
        "headerType": "TEXT",
        "text": "string",
        "attachment": {
          "id": 0,
          "fileUrl": "string",
          "originalFileName": "string",
          "size": 0
        },
        "headerExampleTextParam": "string",
        "headerExampleMediaUrl": "string"
      },
      "text": "string",
      "footer": {
        "text": "string"
      },
      "keyboard": {
        "rows": [
          {
            "buttons": [
              {
                "text": "string",
                "buttonType": "PHONE",
                "otpType": "COPY_CODE",
                "url": "string",
                "urlPostfix": "string",
                "phone": "string",
                "payload": "string",
                "urlTextExample": "string",
                "color": "string",
                "requestLocation": true,
                "autofillText": "string",
                "packageName": "string",
                "hash": "string",
                "appId": 0,
                "ownerId": 0
              }
            ]
          }
        ]
      },
      "securityRecommendation": true,
      "codeExpirationMinutes": 90,
      "textExampleParams": [
        "string"
      ],
      "vkAttachments": [
        {
          "id": 0,
          "fileUrl": "string",
          "originalFileName": "string",
          "size": 0
        }
      ],
      "vkTwoWayEnabled": true
    },
    "contentType": "TEXT",
    "category": "ACCOUNT_UPDATE",
    "status": "string",
    "locked": true,
    "type": "OPERATOR",
    "createdAt": "2023-09-27T11:57:14.834Z",
    "updatedAt": "2023-09-27T11:57:14.834Z"
  }
]
ParameterData typeDescription
idintegerTemplate identifier.
namestringTemplate name.
channelTypestringInteraction channel type.

Possible values:
• WHATSAPP — WhatsApp channel;
• SMS — SMS channel;
• VIBER — Viber channel.
languagestringTemplate language. Only for the WHATSAPP and VIBER channels.
contentobjectTemplate content.
content.attachmentobjectTemplate attachment. Only for the WHATSAPP channel.
content.attachment.idintegerThe ID of the attachment file.
content.attachment.
fileUrl
stringThe URL of the file.
content.attachment.
originalFileName
stringThe file name.
content.attachment.sizeintegerThe file size.
content.actionstringThe link of the button. Only for VIBER channels.
content.captionstringAction button caption. Only for the VIBER channels.
content.headerobjectField that defines the template header. Only for the WHATSAPP channels.
content.headerTypestringHeader type. If there is no header in the template, headerType is not sent. Only for the WHATSAPP channels.
content.header.textstringThe header text.
content.header.attachmentobjectThe file information is in the header.
content.header.attachment.
id
integerThe file information is in the header.
content.header.attachment.
fileUrl
stringThe URL of the file in the header.
content.header.attachment.
originalFileName
stringThe file name in the header.
content.header.attachment.
fileSize
integerThe file size in the header.
content.header.
headerExampleTextParam
stringAn example of the title text.
content.header.
headerExampleMediaUrl
stringThe URL of the sample header file.
content.textstringThe template text.
content.footerobjectContains the template footer. Only for the WHATSAPP channels.
content.footer.textstringThe footer text.
content.keyboardarray of objectsInformation about the buttons. Only for the WHATSAPP and VIBER channels.
content.keyboard.rowsarray of objectsInformation about the buttons.
content.keyboard.rows.buttonsobjectArray of objects, in each of which a button is defined.
content.keyboard.rows.buttons.textstringThe button text.
content.keyboard.rows.buttons.buttonTypestringThe button type.
content.keyboard.rows.buttons.otpTypestringThe type of one-time password button: COPY_CODE or ONE_TAP. Only for the WHATSAPP channels.
content.keyboard.rows.buttons.urlstringThe URL to open when a client presses the button.
content.keyboard.rows.buttons.urlPostfixstringThe dynamic part of URL.
content.keyboard.rows.buttons.phonestringThe phone number to dial when a client presses the button.
content.keyboard.rows.buttons.payloadstringThe quick reply text.
content.keyboard.rows.buttons.urlTextExamplestringThe URL example provided for template registration.
content.keyboard.rows.buttons.autofillTextstringThe OTP button label. Max length is 25 characters.
content.keyboard.rows.buttons.packageNamestringThe package name for the autofill button.
content.keyboard.rows.buttons.hashstringThe hash of the application footer for the autofill button. Only for the WHATSAPP channel.
content.securityRecommendationbooleanIf the parameter value is true, a security recommendation is displayed in the template-based message. Only for the WHATSAPP channel.
content.codeExpirationMinutesintegerThe one-time password is valid in minutes. Only for the WHATSAPP channel.
contentTypestringTemplate content type.

Possible values are indicated in uppercase:
TEXT — text;
IMAGE — image;
DOCUMENT — a document;
VIDEO — video;
AUDIO — sound;
BUTTON — the button;
LOCATION — coordinates, address, and description of the location. The coordinates are converted to a Google Maps snapshot.;
AUTHENTICATION — a message with a one-time password and a copy button.
categorystringTemplate category. Only for the WHATSAPP and VIBER channels.
statusstringStatus of the template registration with an operator (service provider). Possible values are:
APPROVED — active template. Only approved templates can be used for sending messages;
REJECTED — rejected by the operator;
PENDING — registration is in progress;
NOT_SENT — draft;
ARCHIVED — archived;
PAUSED — paused;
DISABLED — disabled.
lockedbooleanAttribute that defines whether the template is blocked. Possible values are:

TRUE — the template is blocked;
FALSE — the template is active.
typestringTemplate type. Possible values are:

OPERATOR — operator template (a template that was registered with a service provider);
USER — user template (a template that was created by a user based on an operator template).
createdAtstringTemplate creation time.
updatedAtstringTime when the template was last modified.

Request Response Codes

CodeDescription
okThe request has been successfully completed.
error-subject-unknownThe specified signature name does not exist.
error-syntaxThe channel type is specified incorrectly.