Sites & Organisation

Message Fragments

A MessageFragment is a reusable block of email copy that is concatenated into a transactional email at send time. Fragments are scoped per site, filtered by message_type, and can be further limited to specific offerings or membership types.

The MessageFragment object

Attributes

  • idmongo-idrequired

    Unique identifier of the message fragment.

  • namestringrequired

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

  • message_typestringrequired

    Which transactional email this fragment is included in. Fragments are only rendered into the matching message type.

    Possible values:basket_cancelledbasket_confirmedbasket_follow_upbasket_item_cancelledbasket_reminderorder_summarypay_by_link_requestappointment_enquiry_confirmedvisit_promptmembership_welcomevoucher_recipientmembership_enquiry_confirmednew_ordernew_enquiry
  • messagestringrequirednullable

    The body of the fragment. Accepts a restricted subset of HTML (basic block and inline tags) which is sanitised on save. Liquid-style placeholders such as {{ customer.first_name }} and {{ booking.starts_at }} are interpolated when the email is rendered.

  • priorityintegerrequirednullable

    Render order within a message. Fragments are concatenated in ascending priority order, so lower numbers appear earlier in the email body. Use to control which paragraph leads.

  • offeringsobject[]required

    Offerings this fragment applies to. When empty, the fragment applies to every offering at the site (a global fallback). When non-empty, the fragment is only included if the message's booking contains at least one matching offering.

  • permitted_membership_type_idsstring[]requirednullable

    Optional list of MembershipType IDs. When set, the fragment is only rendered for customers who hold an active membership of one of these types - useful for member-only welcome copy, loyalty perks, or upgrade prompts. Empty/null means no membership filter applies.

  • site_iduuidrequired

    Site the fragment belongs to. Fragments are authored per-site so each location can tailor its email copy.

  • organisation_iduuidrequired

    Organisation that owns the site.

{
  "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_id": "64a9f3b2c3d8e1f4a5b6c7d8",
      "offering_name": "Twilight massage",
      "offering_type": "string"
    }
  ],
  "permitted_membership_type_ids": [
    "65a1c4f7f4c1b22a3c5d1234"
  ],
  "site_id": "00000000-0000-0000-0000-000000000000",
  "organisation_id": "00000000-0000-0000-0000-000000000000"
}
get/shop/message-fragments

List message fragments

listMessageFragments

Retrieves the message fragments configured for the given site. Without offering_id, results are sorted alphabetically by name. When offering_id is supplied, results are filtered to fragments that apply to that offering and sorted by message_type then ascending priority - the order they will be rendered into the customer email.

Query parameters

  • site_iduuidrequired

    Identifier of the site whose message fragments should be returned. Message fragments are scoped per site so each location can author its own transactional email copy. The caller's API key must have access to this site.

  • offering_idmongo-idoptional

    When provided, restricts the returned message fragments to those that apply to the given offering (appointment type, session type, package etc.). The response is additionally sorted by message_type then priority to mirror the order fragments are rendered in the email. Omit to list every fragment at the site, sorted by name.

  • pageintegeroptional

    The page to retrieve results from

  • per_pageintegeroptional

    The number of results to return per page

Responses

  • 200

    The message fragments were successfully retrieved.

  • 401

    The user is unauthenticated

  • 403

    The authenticated user does not have permission.

post/shop/message-fragments

Create a message fragment

createMessageFragment

Creates a new message fragment at the calling 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.

Request body

  • namestringrequired

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

  • message_typestringrequired

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

    Possible values:basket_cancelledbasket_confirmedbasket_follow_upbasket_item_cancelledbasket_reminderorder_summarypay_by_link_requestappointment_enquiry_confirmedvisit_promptmembership_welcomevoucher_recipientmembership_enquiry_confirmednew_ordernew_enquiry
  • messagestringoptionalnullable

    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.

  • priorityintegeroptionalnullable

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

  • offeringsobject[]optional

    Offerings the fragment applies to. Empty means the fragment applies to every offering at the site.

  • permitted_membership_type_idsstring[]optionalnullable

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

Responses

  • 201

    The message fragment was successfully retrieved.

  • 401

    The user is unauthenticated

  • 403

    The authenticated user does not have permission.

  • 422

    The request didn't pass validation

get/shop/message-fragments/{messageFragmentId}

Show a message fragment

getMessageFragment

Retrieves a single message fragment by ID.

Path parameters

Responses

  • 200

    The message fragment was successfully retrieved.

  • 401

    The user is unauthenticated

  • 403

    The authenticated user does not have permission.

  • 404

    The resource couldn't be found

put/shop/message-fragments/{messageFragmentId}

Update a message fragment

updateMessageFragment

Updates an existing message fragment. Omitting permitted_membership_type_ids (or sending an empty array) clears the membership filter so the fragment becomes available to all customers; supply the field with the desired IDs to keep or change the restriction. Requires the SETTINGS_MANAGE permission on the fragment's site.

Path parameters

Request body

  • namestringrequired

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

  • message_typestringoptional

    Which transactional email this fragment is included in.

    Possible values:basket_cancelledbasket_confirmedbasket_follow_upbasket_item_cancelledbasket_reminderorder_summarypay_by_link_requestappointment_enquiry_confirmedvisit_promptmembership_welcomevoucher_recipientmembership_enquiry_confirmednew_ordernew_enquiry
  • messagestringoptionalnullable

    Body of the fragment. Accepts a restricted subset of HTML and is sanitised on save. Liquid-style placeholders are interpolated at send time.

  • priorityintegeroptionalnullable

    Render order within a message. Fragments are concatenated in ascending priority order.

  • offeringsobject[]optional

    Offerings the fragment applies to. Empty means the fragment applies to every offering at the site.

  • permitted_membership_type_idsstring[]optionalnullable

    MembershipType IDs the fragment is restricted to. Omit (or send an empty array) to clear the membership filter; the field is reset when not present in the request body.

Responses

  • 200

    The message fragment was successfully retrieved.

  • 401

    The user is unauthenticated

  • 403

    The authenticated user does not have permission.

  • 404

    The resource couldn't be found

  • 422

    The request didn't pass validation

delete/shop/message-fragments/{messageFragmentId}

Archive a message fragment

deleteMessageFragment

Soft-deletes a message fragment. Once archived the fragment is no longer included in outgoing emails, but its history is retained for auditing.

Path parameters

Responses

  • 204

    The message fragment was successfully archived.

  • 401

    The user is unauthenticated

  • 403

    The authenticated user does not have permission.

  • 404

    The resource couldn't be found

post/shop/message-fragments/{messageFragmentId}/copy

Duplicate a message fragment

copyMessageFragment

Creates a copy of an existing MessageFragment, applying any overrides supplied in the request body. Useful when seeding similar email copy (e.g. per-offering variants of a shared template, or A/B test variants).

Requires the SETTINGS_MANAGE permission on the source fragment's site, plus the create ability on MessageFragment. The copy is created at the source fragment's site.

Path parameters

Request body

  • namestringrequired

    Internal label for the new copy. Conventionally the source's name suffixed with "(Copy)" or a variant tag.

  • message_typestringoptional

    Override the message_type on the new copy. Defaults to the source's value.

    Possible values:basket_cancelledbasket_confirmedbasket_follow_upbasket_item_cancelledbasket_reminderorder_summarypay_by_link_requestappointment_enquiry_confirmedvisit_promptmembership_welcomevoucher_recipientmembership_enquiry_confirmednew_ordernew_enquiry
  • messagestringoptionalnullable

    Body of the fragment. Defaults to the source's value.

  • priorityintegeroptionalnullable

    Render order within a message. Fragments are concatenated in ascending priority order.

  • offeringsobject[]optional

    Offerings the fragment applies to. Empty means the fragment applies to every offering at the site.

  • permitted_membership_type_idsstring[]optionalnullable

    MembershipType IDs the new copy is restricted to.

Responses

  • 201

    The message fragment was successfully retrieved.

  • 401

    The user is unauthenticated

  • 403

    The authenticated user does not have permission.

  • 404

    The resource couldn't be found

  • 422

    The request didn't pass validation

post/shop/message-fragments/{messageFragmentId}/offerings

Attach an offering to a message fragment

createMessageFragmentOffering

Adds an offering to the fragment's offerings list. Once attached, the fragment will be rendered into emails whose booking contains the offering (subject to message_type and permitted_membership_type_ids filters). Adding an offering that is already attached is a no-op.

Requires the update ability on the target fragment, which is granted via the SETTINGS_MANAGE permission on the fragment's site.

Path parameters

Request body

  • offeringrequired

    The offering to attach. Must reference an offering that exists at the fragment's site. The offering_name may be supplied for convenience but is re-resolved by the server before being persisted.

Responses

  • 200

    The message fragment was successfully retrieved.

  • 400

    The request failed.

  • 401

    The user is unauthenticated

  • 403

    The authenticated user does not have permission.

  • 404

    The resource couldn't be found

  • 422

    The request didn't pass validation

delete/shop/message-fragments/{messageFragmentId}/offerings/{offeringId}

Detach an offering from a message fragment

deleteMessageFragmentOffering

Removes an offering from the fragment's offerings list. After removal the fragment will no longer be selected for emails whose booking only contains the detached offering. If the resulting offerings list is empty the fragment reverts to applying to every offering at the site (the global fallback behaviour).

Removing an offering that is not attached is a no-op. Requires the update ability on the target fragment.

Path parameters

  • messageFragmentIdmongo-idrequired

    The ID of the MessageFragment.

  • offeringIdmongo-idrequired

    The ID of the offering to detach from the message fragment. Matches the offering_id field of an entry in the fragment's offerings list.

Responses

  • 200

    The message fragment was successfully retrieved.

  • 401

    The user is unauthenticated

  • 403

    The authenticated user does not have permission.

  • 404

    The resource couldn't be found