Skip to main content
GET
/
api
/
email
/
dynamic-fields
Get dynamic fields for a context type
curl --request GET \
  --url https://dev.exante.app/api/email/dynamic-fields \
  --header 'Authorization: Bearer <token>'
{
  "fields": [
    {
      "token": "{client_name}",
      "label": "Client Name",
      "type": "str"
    }
  ]
}
Retrieve the list of available dynamic field tokens for a given context type. Use this to discover what placeholders can be used in email templates and to build dynamic field pickers in your UI.

What are Dynamic Fields?

Dynamic fields are placeholders (like {invoice_number} or {client_name}) that get replaced with actual values when preparing an email. They let you create reusable email templates that automatically populate with context-specific data. For example, a template like:
Hi {client_name},

Invoice {invoice_number} for {amount_due} is due on {due_date}.
Gets resolved to:
Hi Acme Corp,

Invoice INV-2024-001 for $1,500.00 is due on March 15, 2024.

Query Parameters

ParameterRequiredDescription
context_typeYesThe entity type to get fields for (e.g., "invoice")

Available Context Types

Context TypeDescription
invoiceInvoice-related fields (amounts, dates, client info, payment links)
Additional context types may be added in the future. Use this endpoint to dynamically discover available fields rather than hardcoding them.

Response

Returns an array of field definitions:
{
  "fields": [
    {
      "token": "{invoice_number}",
      "label": "Invoice Number",
      "type": "str"
    },
    {
      "token": "{amount_due}",
      "label": "Amount Due",
      "type": "currency"
    },
    {
      "token": "{due_date}",
      "label": "Due Date",
      "type": "date"
    },
    {
      "token": "{client_name}",
      "label": "Client Name",
      "type": "str"
    }
  ]
}

Field Properties

PropertyDescription
tokenThe placeholder to use in templates (e.g., {invoice_number})
labelHuman-readable name for display in UI
typeData type hint: str, date, currency, int, email, url

Invoice Context Fields

When context_type=invoice, the following fields are available:
TokenLabelTypeExample Value
{invoice_number}Invoice NumberstrINV-2024-001
{issue_date}Issue DatedateJanuary 15, 2024
{due_date}Due DatedateFebruary 15, 2024
{paid_date}Paid DatedateFebruary 10, 2024
{status}Statusstroverdue
{currency}CurrencystrUSD
{collection_method}Collection Methodstrsend_invoice
{total_cents}Total Amountcurrency$2,000.00
{amount_due}Amount Duecurrency$1,500.00
{subtotal}Subtotalcurrency$1,800.00
{discounts}Discountscurrency$0.00
{tax_amount}Tax Amountcurrency$200.00
{credit_notes}Credit Notescurrency$0.00
{amount_paid}Amount Paidcurrency$500.00
{amount_remaining}Amount Remainingcurrency$1,500.00
{payment_link}Payment Linkurlhttps://pay.example.com/
{days_overdue}Days Overdueint10
{age_in_days}Invoice Age (Days)int45
{client_name}Client NamestrAcme Corp
{client_email}Client Emailemailbilling@acme.com
{organization_name}Organization NamestrMy Company LLC
{current_date}Current DatedateMarch 25, 2024

Error Responses

StatusCause
400Missing context_type parameter
400Invalid or unsupported context_type

Use Cases

Building a Template Editor

Fetch available fields to populate a dropdown or autocomplete:
const response = await fetch('/api/email/dynamic-fields?context_type=invoice');
const { fields } = await response.json();

// Render field picker
fields.forEach(field => {
  addFieldOption(field.token, field.label);
});

Validating Templates

Check that a template only uses valid tokens:
const validTokens = new Set(fields.map(f => f.token));
const usedTokens = template.match(/\{[^}]+\}/g) || [];

const invalid = usedTokens.filter(t => !validTokens.has(t));
if (invalid.length > 0) {
  showError(`Unknown fields: ${invalid.join(', ')}`);
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Query Parameters

context_type
string
required

Context type key, e.g. invoice

Response

Dynamic fields returned successfully

fields
object[]
required