📦 Templates

Notification Templates in Tatum allow you to define custom response formats for your webhook notifications. These templates can be applied to specific subscription types, enabling consistent and tailored payloads for your applications.

📄 Table of Contents

  1. Creating a Notification Template
  2. Listing Notification Templates
  3. Updating a Notification Template
  4. Deleting a Notification Template
  5. Using Templates in Subscription Creation

1. Creating a Notification Template

To create a custom notification template, send a POST request to the /v4/notification/template endpoint.

Request Example:

curl --request POST \
     --url https://api.tatum.io/v4/subscription/template \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --header 'x-api-key: YOUR_API_KEY' \
     --data '
{
  "format": "json",
  "keys": {
    "amount": "value",
    "sentFrom": "from",
    "sentTo": "to"
  }
}
'

Response Example:

{
  "id": "TEMPLATE_ID"
}

2. Listing Notification Templates

To retrieve all your notification templates, send a GET request to the /v4/notification/templates endpoint.

Request Example:

curl --request GET \
     --url 'https://api.tatum.io/v4/subscription/template?pageSize=10' \
     --header 'accept: application/json' \
     --header 'x-api-key: YOUR_API_KEY'

Response Example:

[
  {
    "format": "json",
    "keys": {
      "amount": "value",
      "sentFrom": "from",
      "sentTo": "to"
    },
    "id": "TEMPLATE_ID"
  }
]

3. Updating a Notification Template

To update an existing notification template, send a PUT request to /v4/notification/template/{id}, replacing {id} with the template's ID.

Request Example:

curl --request PUT \
     --url https://api.tatum.io/v4/subscription/template/Template_ID \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --header 'x-api-key: YOUR_API_KEY' \
     --data '
{
  "format": "json",
  "keys": {
    "sentAmount": "value",
    "sentTo": "to",
    "sentFrom": "from"
  }
}
'

Response Example:

204 OK

4. Deleting a Notification Template

To delete a notification template, send a DELETE request to /v4/notification/template/{id}, replacing {id} with the template's ID.

Request Example:

curl --request DELETE \
     --url https://api.tatum.io/v4/subscription/template/Template_ID \
     --header 'accept: application/json' \
     --header 'x-api-key: YOUR_API_KEY'

Response Example:

204 OK

5. Using Templates in Subscription Creation

When creating a subscription, you can specify a templateId to use a custom notification template.

Request Example:

curl -X POST https://api.tatum.io/v4/subscription?type=mainnet \
  -H 'Content-Type: application/json' \
  -d '{
    "type": "ADDRESS_EVENT",
    "attr": {
      "address": "0xF64E82131BE01618487Da5142fc9d289cbb60E9d",
      "chain": "ETH",
      "url": "https://<YOUR_WEBHOOK_URL>",
      "templateId": "TEMPLATE_ID"
    }
  }'

Response Example:

{
  "id": "sub_1234567890",
}

🧩 Template Field Placeholders

Tatum supports the following placeholders in your template fields:

  • {{address}}: The address associated with the event.
  • {{amount}}: The amount involved in the transaction.
  • {{asset}}: The asset type (e.g., ETH, BTC).
  • {{blockNumber}}: The block number in which the transaction was included.
  • {{txId}}: The transaction ID.

These placeholders are dynamically replaced with actual values when the notification is triggered.

🛡️ Security Considerations

  • IP Whitelisting: Whitelist Tatum's IP addresses to allow only trusted sources to send requests to your webhook.
  • HMAC Verification: Enable HMAC webhook digest to verify the authenticity of incoming requests.
  • HTTPS: Always use HTTPS for your webhook URLs to encrypt data in transit.

📚 Additional Resources