Centro di Conoscenza
Esplora la nostra libreria di informazioni sui nostri prodotti e servizi
Placeholders
With the SMS API, you can use placeholders (also called custom fields, dynamic fields) in the message text, which will be automatically replaced when API requests are made.
To use a placeholder in the body of the text message, you write the name of the placeholder between two curly braces. eg. {{companyName}}
You can set your own values for the following placeholders in each application you create from your Account Dashboard:
- {{companyName}}
- {{companyUrl}}
- {{companyEmail}}
- {{companyPhone}}
- {{appTrack}}
Why would you want to use placeholders?
The SMS API provides support for a wide variety of placeholders, which enables you to dynamically replace a specified placeholder with randomly generated data or any value saved in the application settings.
Placeholders are useful when you already have an integration or an application and you need to modify the company name, URL, email or business phone number, without having to make changes in your code. You can simply edit the application settings from SMS.CX Account Dashboard.
There are some built-in placeholders that you can use with the SMS API:
Placeholder | What it does | Example placeholder | Replaced value |
---|---|---|---|
{{numbers}} | Replaces the placeholder with a random generated 4 characters long (default length) string of numbers. To set the length of the generated string of numbers, specify the length inside the placeholder. Min 1 - Max 20 characters | {{numbers}} {{numbers:6}} {{numbers:10}} |
5419 449351 7833014329 |
{{letters}} | Generates random 4 characters long (default length) string of uppercase letters. String length can be specified. Min 1 - Max 20 characters | {{letters}} {{letters:8}} {{letters:12}} |
HWMJ BFIAFMLX AQOPNBZAHTRM |
{{alphanumeric}} | Generates random 4 characters long (default length) string of numbers and uppercase letters. String length can be specified (between 1-20 characters) |
{{alphanumeric}} {{alphanumeric:6}} {{alphanumeric:9}} |
TY72 WU17U8 BXJZ78B03 |
{{shortlink:ID}} | Generates tracking string for a short link. The ID of the short link must be provided inside the placeholder. By using this placeholder when sending SMS in bulk, the API will generate unique tracking string for every phone number |
{{shortlink:gHv}} | https://en.ax/gHv/qWz |
{{attachment:ID}} | Generates tracking string for an attachment link. The ID of the attachment must be provided inside the placeholder. By using this placeholder when sending bulk SMS, the API will generate unique tracking string for each phone number |
{{attachment:vBi}} | https://en.ax/vBi/qWz |
{{optoutLink}} | Replaces the placeholder with the opt-out link. Unique tracking string will be generated for each phone number that receive the SMS |
{{optoutLink}} | https://en.ax/hT2/bVs |
When you send an SMS to a group of contacts you can use the custom data that was imported with those contacts, by using the following placeholders:
- {{firstName}}
- {{lastName}}
- {{email}}
- {{field1}}
- {{field2}}
- {{field3}}
- {{field4}}
- {{field5}}
Note: If a contact doesn't have data in one of the above custom fields (no first name, no email, etc.), the API will replace the placeholder with empty value. You don't have to worry about the recipient receiving SMS with placeholder in text.