Skip to main content

Webhook payload templates

When a webhook is configured with a custom payload, the request body is rendered from a Twig template. The template receives variables drawn from the event that triggered the webhook, available in camelCase format.

Global variables​

These two variables are present for all events:

VariableTypeDescription
actionstringThe event type identifier: case_created, case_transitioned, attachment_added, field_created, field_updated, rule_action, user_created, or user_updated. For User events on payload version 1, the value is create or update instead.
versionintThe payload version number

Variables by event​

The table below shows which top-level objects are available for each event:

EventcaseattachmentfielduserEvent-specific
Attachment added✓ ¹✓addedBy
Case created✓createdBy
Case transitioned✓transition, transitionedBy, previousStatus, newStatus
Field created✓
Field updated✓
Rule action✓initiatedBy, trigger, context
User created✓ ²
User updated✓ ³

¹ On Attachment added events, case only provides reference and type. ² On User created event, user also provides person only if the payload is custom. ³ On User updated event, user also provides person only if the payload is custom.

Variable reference​

case​

PropertyTypeDescription
case.referencestringCase reference
case.createdAtDateTimeCreation timestamp
case.updatedAtDateTimeLast updated timestamp
case.status.slugstringStatus slug
case.status.titlestringStatus title
case.status.typestringStatus type
case.type.slugstringCase type slug
case.type.titlestringCase type title
case.type.service.slugstringService group slug
case.type.service.titlestringService group title
case.valuesmapField values keyed by field slug — see Field values
case.addressRelationshipsarrayLinked addresses — see Address
case.personRelationshipsarrayLinked people — see Person
case.organisationRelationshipsarrayLinked organisations — see Organisation

createdAt, updatedAt, status, values, addressRelationships, personRelationships, and organisationRelationships are not available when case appears in an Attachment added event.

Field values​

Case field values are accessed as case.values['field-slug']. Each value exposes:

PropertyTypeDescription
typestringField type (e.g. text, choice, date, datetime, checkbox, textarea, url)
namestringField slug
redactedboolWhether the value has been redacted
valuemixedThe field value. A string for text/date fields, a boolean for checkboxes, and an array of strings for multi-choice fields. null if redacted.

Example:

{% if case.values['priority'] is defined %}
Priority: {{ case.values['priority'].value }}
{% endif %}

For field names that contain hyphens or start with a number, always use bracket notation. For other field names, dot notation also works:

{{ case.values['123-my-field'].value }} {# required for hyphenated or numeric-start slugs #}
{{ case.values.my_field.value }} {# works for simple slugs #}

Address​

Used within case.addressRelationships[n].address, person.addresses[n], person.primaryAddress, and organisation.address.

PropertyType
summarystring
streetstring
paonstring
saonstring
localitystring
townstring
postTownstring
postCodestring
administrativeAreastring
uprnstring
usrnstring
eastingint
northingint
externalReferencestring
referencestring
typestring
custombool

Person​

Used within case.personRelationships[n].person and createdBy.person. Also used within user.person on user created and user updated events for custom payload.

PropertyTypeDescription
referencestringPerson reference
namestringFull name
emailstringEmail address
primaryAddressAddressPrimary address — see Address
addressesarrayAll linked addresses — see Address

Organisation​

Used within case.organisationRelationships[n].organisation.

PropertyTypeDescription
referencestringOrganisation reference
namestringOrganisation name
addressAddressSee Address

attachment​

Available on the Attachment added event.

PropertyTypeDescription
attachment.fileNamestringFile name
attachment.descriptionstringDescription
attachment.identifierstringAttachment identifier
attachment.mimeTypestringMIME type
attachment.sizeintFile size in bytes
attachment.downloadUrlstringTime-limited download URL
attachment.downloadUrlExpiryDateTimeWhen the download URL expires

field​

Available on Field created and Field updated events.

PropertyTypeDescription
field.slugstringField slug
field.typestringField type (e.g. text, choice, date)
field.titlestringField label
field.expandedboolWhether the field is displayed expanded (choice fields only)
field.multipleboolWhether multiple selections are allowed (choice fields only)
field.choicesarrayAvailable choices, each with label, value, and disabled properties (choice fields only)
field.defaultChoicesarrayDefault selected values (choice fields only)

user​

Available on User created and User updated events.

PropertyTypeDescription
user.idintUser ID
user.referencestringUser reference
user.emailstringEmail address
user.forenamestringFirst name
user.surnamestringLast name
user.namestringFull name
user.photostringPhoto URL
user.timezonestringTimezone
user.enabledboolWhether the account is enabled
user.emailVerifiedboolWhether the email has been verified
user.incompleteboolWhether the profile is incomplete
user.group.slugstringUser group slug
user.group.titlestringUser group title
user.privilegeLevel.slugstringPrivilege level slug
user.privilegeLevel.titlestringPrivilege level title
user.type.slugstringUser type slug
user.type.titlestringUser type title
user.createdAtDateTimeWhen the account was created
user.updatedAtDateTimeWhen the account was last updated

For custom payload, the following is also available in addition to the above:

PropertyTypeDescription
user.person.referencestringPerson reference
user.person.namestringFull name
user.person.emailstringEmail address
user.person.addressesarrayAll linked addresses — see Address
user.person.primaryAddress.summarystring
user.person.primaryAddress.streetstring
user.person.primaryAddress.paonstring
user.person.primaryAddress.saonstring
user.person.primaryAddress.localitystring
user.person.primaryAddress.townstring
user.person.primaryAddress.postTownstring
user.person.primaryAddress.postCodestring
user.person.primaryAddress.administrativeAreastring
user.person.primaryAddress.uprnstring
user.person.primaryAddress.usrnstring
user.person.primaryAddress.eastingint
user.person.primaryAddress.northingint
user.person.primaryAddress.externalReferencestring
user.person.primaryAddress.referencestring
user.person.primaryAddress.typestring
user.person.primaryAddress.custombool

Event-specific variables​

Attachment added​

VariableTypeDescription
addedBy.referencestringUser reference
addedBy.namestringFull name
addedBy.emailstringEmail address

Case created​

VariableTypeDescription
createdBy.referencestringUser reference
createdBy.namestringFull name
createdBy.emailstringEmail address
createdBy.group.slugstringUser group slug
createdBy.group.titlestringUser group title
createdBy.privilegeLevel.slugstringPrivilege level slug
createdBy.privilegeLevel.titlestringPrivilege level title
createdBy.type.slugstringUser type slug
createdBy.type.titlestringUser type title
createdBy.personPersonSee Person

Case transitioned​

VariableTypeDescription
transition.slugstringTransition slug
transition.titlestringTransition title
transitionedBy.referencestringUser reference (null if triggered by a rule)
transitionedBy.namestringFull name
transitionedBy.emailstringEmail address
previousStatus.slugstringStatus slug before the transition
previousStatus.titlestringStatus title before the transition
previousStatus.typestringStatus type before the transition
newStatus.slugstringStatus slug after the transition
newStatus.titlestringStatus title after the transition
newStatus.typestringStatus type after the transition

Rule action​

Rule action templates have access to case (see above) plus the following:

VariableTypeDescription
initiatedByUser (partial)The user who triggered the rule. null for time-based triggers (Date, Date and time, Time in status). Provides: reference, name, email, group, privilegeLevel, type.
trigger.typestringOne of: transition, field_changed, event, date, date_time, time_in_status
contextobjectContextual data for the trigger. Structure depends on trigger.type. null when not applicable.

Trigger context by type:

trigger.typeAvailable properties
transitiontrigger.transition (slug, title); context.previousStatus, context.newStatus (slug, title, type)
field_changedtrigger.field (slug, type, title); context.originalValue, context.updatedValue — see Field values
datetrigger.dateDefinition (slug, title, basedOn, delta); trigger.dateDefinition.field (slug, type, title) — only present when basedOn is case_field. context is null.
date_timetrigger.triggerAt (DateTime). context is null.
time_in_statustrigger.status (slug, title, type); trigger.minutes (int). context is null.
eventtrigger.event (string identifier). See table below for context structure.

Event trigger context (when trigger.type is event):

trigger.eventcontext
case.creatednull
case.attachment.newcontext.attachment — see attachment
case.message.newcontext.message: headerId, subject, content, createdAt, recipients
case.message.replySame structure as case.message.new
case.note.newcontext.note.createdAt
case.membership.addedcontext.membership.type (user or user_group); context.membership.user or context.membership.userGroup
case.membership.removedSame structure as case.membership.added

Working with dates​

Date properties are DateTime objects. Use the |date() filter to format them. Any PHP date format string is valid:

{{ case.createdAt|date('c') }} {# ISO 8601: 2019-10-09T13:10:10+00:00 #}
{{ case.createdAt|date('d/m/Y H:i') }} {# 09/10/2019 13:10 #}

Tips​

  • Use {% if variable is defined %} to guard against missing data, particularly for initiatedBy, transitionedBy, and rule action context objects.
  • When iterating all case field values:
    {% for slug, fieldValue in case.values %}
    {{ slug }}: {{ fieldValue.value }}
    {% endfor %}
  • The |default() filter is useful for variables that may be null: {{ transitionedBy.email|default('system') }}

Examples​

Case created​

{
"reference": "{{ case.reference }}",
"case_type": "{{ case.type.slug }}",
"created_by": "{{ createdBy.email }}",
"created_at": "{{ case.createdAt|date('c') }}"
}

Case transitioned​

{
"reference": "{{ case.reference }}",
"transition": "{{ transition.slug }}",
"previous_status": "{{ previousStatus.slug }}",
"new_status": "{{ newStatus.slug }}",
"transitioned_by": "{{ transitionedBy.email|default('system') }}"
}

User created​

{
"id": {{ user.id }},
"reference": "{{ user.reference }}",
"email": "{{ user.email }}",
"name": "{{ user.name }}",
"created_at": "{{ user.createdAt|date('c') }}",
"enabled": {{ user.enabled ? 'true' : 'false' }}
}

Rule action — transition trigger​

{
"case_reference": "{{ case.reference }}",
"trigger_type": "{{ trigger.type }}",
"transition": "{{ trigger.transition.slug }}",
"previous_status": "{{ context.previousStatus.slug }}",
"new_status": "{{ context.newStatus.slug }}",
"initiated_by": "{{ initiatedBy.email|default('system') }}"
}

Rule action — field changed trigger​

{
"case_reference": "{{ case.reference }}",
"field": "{{ trigger.field.slug }}",
"original_value": "{{ context.originalValue.value|default('null') }}",
"updated_value": "{{ context.updatedValue.value|default('null') }}"
}