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"] }
Parameter | Data type | Description |
subjectId | integer | Subject identifier. To get it, send a request to edna technical support. |
matcherTypes | string (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" } ]
Parameter | Data type | Description |
id | integer | Template identifier. |
name | string | Template name. |
channelType | string | Interaction channel type. Possible values: • WHATSAPP — WhatsApp channel;• SMS — SMS channel;• VIBER — Viber channel. |
language | string | Template language. Only for the WHATSAPP and VIBER channels. |
content | object | Template content. |
content.attachment | object | Template attachment. Only for the WHATSAPP channel. |
content.attachment.id | integer | The ID of the attachment file. |
content.attachment. | string | The URL of the file. |
content.attachment. | string | The file name. |
content.attachment.size | integer | The file size. |
content.action | string | The link of the button. Only for VIBER channels. |
content.caption | string | Action button caption. Only for the VIBER channels. |
content.header | object | Field that defines the template header. Only for the WHATSAPP channels. |
content.headerType | string | Header type. If there is no header in the template, headerType is not sent. Only for the WHATSAPP channels. |
content.header.text | string | The header text. |
content.header.attachment | object | The file information is in the header. |
content.header.attachment. | integer | The file information is in the header. |
content.header.attachment. | string | The URL of the file in the header. |
content.header.attachment. | string | The file name in the header. |
content.header.attachment. | integer | The file size in the header. |
content.header. headerExampleTextParam | string | An example of the title text. |
content.header. | string | The URL of the sample header file. |
content.text | string | The template text. |
content.footer | object | Contains the template footer. Only for the WHATSAPP channels. |
content.footer.text | string | The footer text. |
content.keyboard | array of objects | Information about the buttons. Only for the WHATSAPP and VIBER channels. |
content.keyboard.rows | array of objects | Information about the buttons. |
content.keyboard.rows.buttons | object | Array of objects, in each of which a button is defined. |
content.keyboard.rows.buttons.text | string | The button text. |
content.keyboard.rows.buttons.buttonType | string | The button type. |
content.keyboard.rows.buttons.otpType | string | The type of one-time password button: COPY_CODE or ONE_TAP. Only for the WHATSAPP channels. |
content.keyboard.rows.buttons.url | string | The URL to open when a client presses the button. |
content.keyboard.rows.buttons.urlPostfix | string | The dynamic part of URL. |
content.keyboard.rows.buttons.phone | string | The phone number to dial when a client presses the button. |
content.keyboard.rows.buttons.payload | string | The quick reply text. |
content.keyboard.rows.buttons.urlTextExample | string | The URL example provided for template registration. |
content.keyboard.rows.buttons.autofillText | string | The OTP button label. Max length is 25 characters. |
content.keyboard.rows.buttons.packageName | string | The package name for the autofill button. |
content.keyboard.rows.buttons.hash | string | The hash of the application footer for the autofill button. Only for the WHATSAPP channel. |
content.securityRecommendation | boolean | If the parameter value is true , a security recommendation is displayed in the template-based message. Only for the WHATSAPP channel. |
content.codeExpirationMinutes | integer | The one-time password is valid in minutes. Only for the WHATSAPP channel. |
contentType | string | Template 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. |
category | string | Template category. Only for the WHATSAPP and VIBER channels. |
status | string | Status 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. |
locked | boolean | Attribute that defines whether the template is blocked. Possible values are: • TRUE — the template is blocked;• FALSE — the template is active. |
type | string | 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). |
createdAt | string | Template creation time. |
updatedAt | string | Time when the template was last modified. |
Request Response Codes
Code | Description |
ok | The request has been successfully completed. |
error-subject-unknown | The specified signature name does not exist. |
error-syntax | The channel type is specified incorrectly. |