MessageFragments

Create a message fragment

Creates a new message fragment at the given site. The fragment is immediately eligible to be rendered into outgoing emails of the matching message_type once any offerings or permitted_membership_type_ids filters are satisfied. Requires the SETTINGS_MANAGE permission.

post/shop/message-fragments

Request body

namestring required

Internal label for the fragment, shown in the admin UI when authoring email templates. Not visible to customers.

message_type'basket_cancelled' | 'basket_confirmed' | 'basket_follow_up' | 'basket_item_cancelled' | 'basket_reminder' | 'order_summary' | 'pay_by_link_request' | 'appointment_enquiry_confirmed' | 'visit_prompt' | 'membership_welcome' | 'membership_cancelled' | 'voucher_recipient' | 'membership_enquiry_confirmed' | 'new_order' | 'new_enquiry' required

Which transactional email this fragment is included in. Required at creation; cannot be inferred from any other field.

messagestring nullable

Body of the fragment. Accepts a restricted subset of HTML tags (basic block and inline) which is sanitised on save. Liquid-style placeholders are interpolated at send time.

priorityinteger nullable

Render order within a message. Fragments are concatenated in ascending priority order. Omit to leave unordered.

permitted_membership_type_idsstring[] nullable

Optional list of MembershipType IDs. When set, the fragment is only rendered for customers who hold an active membership of one of these types.

site_idstring uuid required

Identifier of the site this fragment belongs to. Fragments are scoped per site so each location can author its own transactional email copy.

Example request

{
  "name": "Spa - arrival instructions",
  "message_type": "basket_confirmed",
  "message": "<p>Hi {{ customer.first_name }} - we're looking forward\nto seeing you on {{ booking.starts_at|date }}.</p>\n",
  "priority": 10,
  "offerings": [
    {
      "offering_name": "Twilight massage",
      "offering_type": "appointment"
    }
  ]
}

Response

The message fragment was successfully retrieved.

Example response

{
  "data": {
    "id": "65d4a6f7f4c1b22a3c5d4e8a",
    "name": "Spa - arrival instructions",
    "message_type": "basket_confirmed",
    "message": "<p>Hi {{ customer.first_name }} - we're looking forward to\nseeing you on {{ booking.starts_at|date }}. Please arrive\n15 minutes early to check in at reception.</p>\n",
    "priority": 10,
    "offerings": [
      {
        "offering_name": "Twilight massage",
        "offering_type": "appointment"
      }
    ],
    "permitted_membership_type_ids": [
      "65a1c4f7f4c1b22a3c5d1234"
    ]
  }
}

Changes