Skip to main content
Altcraft Docs LogoAltcraft Docs Logo
User guideDeveloper guideAdmin guide
Company siteHelp center
English
  • Русский
  • English
v72
  • v74
  • v73
  • v72
Login
  • User documentation
  • FAQ
  • Altcraft glossary
  • Profiles and databases
  • Communication channels
  • Segmentation
  • Message templates
    • Working with message templates
    • Visual editor for email-template
    • Template fragments
    • Image gallery
    • Content personalization
    • Creating tables based on array elements
    • Block editor for email template
    • Variables and Functions in Altcraft
      • Logical expressions in messages
      • Loops in messages
      • Market variables in templates
      • Using the JSONPath functionality
    • Dynamic content in messages
    • Importing and exporting a message template
    • Importing a template from a third-party service
    • Exporting a template from Pixcraft
  • Campaigns
  • Automation scenarios
  • Market
  • Loyalty programs
  • Reports and analytics
  • Integrations
  • Weblayers
  • Settings
  • API requests: where to start
  • Changelog
  • library
This is documentation for Altcraft Platform v72. This documentation is no longer maintained.
The information for up-to-date platform version at this page is available (v74).
  • Message templates
  • Variables and Functions in Altcraft
Documentation for version v72

Variables and Functions in Altcraft

Profile Data​

Profile Data
DescriptionVariable
Email address{lead.email}
Phone list{lead.phones}
First name{lead._fname}
Last name{lead._lname}
Birth date{lead._bdate}
Gender{lead._sex}
Registration date{lead._regdate}
Registration IP{lead._regip}
Registration city{lead._regcity}
Registration country{lead._regcountry}
Registration URL{lead._regurl}
IP address{lead._ip}
City{lead._city}
Country{lead._country}
Region{lead._region}
Postal code{lead._postal_code}
Time zone{lead._tz}
Vendor{lead._vendor}
Profile ID{lead._id}
XXM hash{lead._xxm}
XX hash{lead._xxh}
MD5 hash{lead._md5}
Custom field{lead.field_name}

Subscriptions​

Profile Subscriptions
DescriptionVariable
Subscription email address{subscription.email}
Email domain{subscription.email_domain}
Subscription email list{subscription.emails}
Subscription phone{subscription.phone}
Subscription phone list{subscription.phones}
Push subscriptions list{subscription.pushes}
MD5 of email{subscription.email_md5}
MD5 of phone{subscription.phone_md5}
Subscription hash{subscription.hash_id}
Primary subscription field{subscription_field("channel" "field_name" resource_id)}

channel — string like "email"

field_name — name of field like "domain"

resource — ID like 10

The subscription_field function allows inserting fields from subscriptions regardless of the current message channel. For example:

{subscription_field("sms" "phone")}

If multiple subscriptions match, the one with the highest priority is selected.

Available fields:

ChannelFieldDescription
emailemailEmail address
domainEmail domain
domain_groupDomain group
md5MD5 hash
smsphonePhone
md5MD5 hash
pushsubscription_idPush subscription ID
bundle_idiOS APNs app bundle ID
providerPush provider
tip

Similarly, data from custom channel subscriptions can be inserted. Fields in main channels match the SID fields you define when creating the channel.

UTM​

UTM Variables

If a profile has UTM tags in their card, they can be inserted into message templates.

DescriptionVariable
UTM campaign{lead._utm_campaign}
UTM source{lead._utm_source}
UTM medium{lead._utm_medium}
UTM content{lead._utm_content}
UTM term{lead._utm_term}

External JSON​

External JSON Content

External JSON is a way to generate dynamic messages with content from your server at the moment of sending.

Details: Using JSON Content in Messages

Use {json.variable} in text. list and object types support loops. Use {json.object.key_name} for keys.

Market​

Using Market Variables

To include order and product info in messages, insert market variables into the template. More: Using Market Variables in Messages

Date and Time​

Date and Time Variables
DescriptionVariableExample
Formatted date{format}{format datenow "%Y-%m-%D %H:%M:%S timezone, %I am"} → 2018-12-25 18:56:10 +03:00, 6 pm
Raw date{datenow}2018-12-25T18:56:10+0300
Add date{adddate()}{adddate(datenow 0 0 3)} → 2018-12-27T18:56:10+0300
Full year{yearlong}2018
Short year{year}18
Month{month}12
Day{day}10
24-hour{hours}18
12-hour{hours12}06
AM/PM{ampm}PM
Minutes{minutes}56
Seconds{seconds}10

Output Functions​

Output Functions
DescriptionVariableExample
Number formattingformat{format 1000000000 ","} → 1,000,000,000
Variable lengthlength{length("abc")} → 3
Array of valuesarray{array[1 "2" 3.3]} → [1 2 3.3]
Random array elementrandomize{randomize(array[1 2 3])} → 1

Example: {randomize(lead.Favourite_genres)} → "Detective"
Array limitlimit{limit(array[1 2 3] 2)} → [1 2]
Check if number is eveniseven{iseven(2)} → true
{iseven(3)} → false
URL encodingurlencode{urlencode(lead._regurl)} → http%3A%2F%2Ftest.testdomain.com%2Fsomething
URL decodingurldecode{urldecode(lead._regurl)} → http://test.testdomain.com/something
Uppercase all lettersuppercase{uppercase("text")} → TEXT
Uppercase first letteruppercasefirst{uppercasefirst("john")} → John

Encryption​

Encryption and Hashing

Template variable encryption is used when data must be passed via a URL without being exposed in server logs or to the user. For example, you may want to encode pre-filled form data using base58 for decoding on the website side.

Use the crypt function in the template editor via the </> button → Encryption:

{crypt(algorithm field key)}

Supported algorithms:

  • base58
  • base64
  • sha1
  • sha256
  • aes
  • blowfish

For sha1, sha256, aes, and blowfish you must provide a key.

AES and Blowfish details:

AESBlowfish
Initialization vectorFirst 16 bytesFirst 8 bytes
ModeCFBCBC
Key length128-bit (16 chars)64-bit (8 chars)
Paddingzero paddingzero padding
tip

All encryption/decryption uses Base64URL encoding.

Examples:

{crypt(base58 lead._fname)}
{crypt(base64 lead._lname)}
{crypt(sha256 lead.custom_field "encrypt_key")}
{crypt(sha1 lead._city "encrypt_key")}
{crypt(aes lead._fname "key1234567891234")}
{crypt(blowfish lead._fname "key12345")}

For string values, wrap in quotes. Numbers can be passed as-is:

{crypt(base58 "value")}
{crypt(base64 42)}

Hash algorithms also support optional salt:

  • md5 + salt
  • xxh32 + salt
  • xxh64 + salt

Same syntax:

{crypt(md5 subscription.email "salt")}
{crypt(xxh32 loyalty.new2.promocode "salt")}
{crypt(xxh64 json.text "salt")}

Encrypted values are Base64-encoded.

Logical Expressions​

Logical Expressions

Logical expressions are explained in detail here.

For simple conditions, use the following structure:

{if lead.age gte 18}
18 or older.
{else}
Under 18.
{end}

Fragments​

Message Fragments

Fragments are reusable blocks used across multiple messages—such as headers, footers, or social media blocks.

To insert a fragment:

{fragment.<fragment_shortname>}

To insert a random fragment:

{randomfragment[fragment.name1 fragment.name2 fragment.name3]}

More on fragment usage: this article.

Parameters​

Parameters
DescriptionVariable
Sent message ID (SMID){send_message_id}
Resource token{resource_token}
Template ID{msgid}
Campaign ID{campid}
Resource ID{resid}
Database ID (profile list){listid}
Campaign SUBID{subid}
Resource name{resname}
Database name{listname}
Message type{msg_type}
Resource URL{resurl}
Resource domain{resdomain}
Message name{msgname}
Campaign name{campname}
SMS sender name{from_name_sms}
Segment ID{segid}
Segment name{segname}
Attribute value {attribute_value("attribute")}, where "attribute" is the API name of the attribute

Service​

Service Parameters
DescriptionVariable
API Content{apicontent.field_name}
Cancel message delivery{cancel}

Tracking​

Tracking Variables
DescriptionVariable
Tracking domain{trkdomain}
Open tracking pixel{pixel}
Read tracking pixel{read}
Preferences link{preferences}
Unsubscribe link{unsubscribe}
Global unsubscribe link{globalunsubscribe}
Add to suppression list{suppress}
Web version link{webversion}

Scenarios​

Scenario Variables
DescriptionVariable
Scenario name{workflow_name}
Scenario ID{workflow_id}
Scenario node ID{node_id}
Scenario node type{node_type}

Events​

Events Variables
DescriptionVariable
First event{event.first}
Last event{event.last}
All eventsIterator over the list of events:
{for event.all}
{.}
else - {cancel}
if empty array
{end}
Events count{event.count}

With these variables, you can pass information about the pixel trigger event in trigger campaigns or scenarios. To call it, you need to specify a variable of the type {event.first.<parameter>}. Optional parameters:

  • id
  • type
  • date
  • test
  • pixel_id
  • goal
  • value
  • data
  • geo_address
  • geo_city
  • geo_country
  • geo_lat
  • geo_long
  • geo_region
  • geo_tld
  • geo_time_zone
  • geo_zip
  • utm_campaign
  • utm_content
  • utm_keyword
  • utm_medium
  • utm_source
  • utm_term
  • user_agent
  • accept_language
  • vendor
  • browser
  • os
  • origin
  • referer
  • device
  • count_items
  • categories
  • send_message_id
  • channel
  • resource_id
  • template_id
  • campaign_id
  • subid
  • loyalty_id
  • promocode
  • content
  • custom_data

You can read more about these parameters here.

Emoji​

You can insert emoji into your message templates. To do so, select the emoji from the variables menu in the template editor.

Profile Relations​

Profile Relations

General syntax:

{relation.[relation_shortname].[direct|reverse].[property].[count|total|top]}

Example: count of direct relations by profit property:

{relation.managers_loyal.direct.profit.count}

Top reverse relations by profit, using loop to output:

{for $index $item = relation.managers_loyal.reverse.profit.top}
{$item.lead._fname} {$item.lead._lname} ({$item.value} profit)
{else} There is no ‘profit’ for you :(
{end}

Sum of profit from direct relations:

{relation.managers_loyal.direct.profit.total}

Editor Functions​

Price Formatting

Use this function to separate numbers into groups of three digits with a chosen separator.

Price 8.000 RUR
<p>Price {format json.price "."} RUR</p>

Access it via </> → Output Functions → Formatting.

Date Offset

The function adddate(date, year, month, day) returns a new date with the added interval.

<p>Event starts on {adddate(lead.notify_date 0 0 10)}</p>

It can be used inside format():

<p>Event starts on {format adddate(lead.notify_date 0 0 10) "%Y-%m-%D"}</p>

Access via </> → Date and Time → Date Offset.

Date Formatting

To format dates based on regional preferences, use this:

<p>Birth date {format lead._bdate "%D.%m.%Y"}</p>

Supported date formatting options:

# years
"%y": "06"
"%Y": "2006"
"yy": "06"
"YYYY": "2006"

# months
"%m": "01"
"MM": "01"
"%B": "January"
"month": "January"
"%ru_month": "январь"

# days
"%d": "2"
"%D": "02"
"DD": "_2"
"%A": "Monday"
"weekday": "Monday"

# hours
"%H": "15"
"%I": "3"
"hh": "15"
"hours": "15"
"twelve_h": "3"

# mins
"%M": "04"
"mm": "04"

# seconds
"%S": "05"
"ss": "05"

# am/pm indicator
"am": "pm"
"AM": "PM"
"%p": "pm"

# timezone
"tzone": "-07"
"timezone": "-07:00"
"%Z": "Z0700"

If using external JSON content, Altcraft can parse RFC 3339 strings into datetime:

ModeFormat
JSON"date_time": "2023-02-21T11:10:35.141Z"
Template{format apicontent.date_time "%Y-%m-%d %H:%M:%S"}
Preview2023-02-21 11:10:35

Access via </> → Date and Time → Formatted Date.

Last updated on Jan 14, 2026
Previous
Block editor for email template
Next
Logical expressions in messages
  • Profile Data
  • Subscriptions
  • UTM
  • External JSON
  • Market
  • Date and Time
  • Output Functions
  • Encryption
  • Logical Expressions
  • Fragments
  • Parameters
  • Service
  • Tracking
  • Scenarios
  • Events
  • Emoji
  • Profile Relations
  • Editor Functions
© 2015 - 2025 Altcraft, LLC. All rights reserved.