Powering Email, Push and SMS From One Content API
One curly apostrophe pasted into an SMS cuts the single-message limit from 160 characters to 70, so the message your team approved now bills as three segments.
One curly apostrophe pasted into an SMS cuts the single-message limit from 160 characters to 70, so the message your team approved now bills as three segments. To prevent this, structure each message once as a schema with a field for each channel: an email subject and Portable Text body, a push title and body, and an SMS body validated against its limit. In Sanity, sending platforms can query those fields with GROQ when the message is sent. They can also receive them through a GROQ-powered webhook or a Function when content changes. Content Releases control when everything goes live.
When that structure is missing, problems pile up fast. Most teams write email copy in the ESP, push copy in the push tool, SMS copy in another dashboard, and website copy somewhere else. The same promotion exists four times. It gets translated four times and approved four times, or not at all. Nobody can say which version a customer actually received.
This guide treats messaging as a content problem rather than a sending problem. It covers why channel limits belong in the schema, how to design message types and their validation, and two ways to get content into sending platforms. It ends with how versioning, approvals, scheduling, and preview work when one structured backend powers both web and messaging.
Why should email, push, and SMS copy live in structured content?
Email, push, and SMS copy belongs in structured content because the same message almost always goes out on more than one channel, in more than one language, under more than one set of rules. A spring sale announcement might need a short subject line, a preheader, and a long HTML email body. It also needs a push title, a short push body with a deep link, and an SMS body that fits in one billed segment. When each version is typed into a separate sending tool, nothing connects them. No record says the push and the SMS are the same offer, so a price change gets fixed in email and missed in SMS.
Structured content fixes this by making the message, not the channel, the unit of work. One document holds the shared facts (offer, campaign, locale, and legal copy), and separate fields hold each channel's version. Localization happens once per message instead of once per tool. A translator sees every channel's text side by side, with each limit enforced in the editor. Reuse also works across the website: the website banner headline and the push title can come from the same source field, so one correction shows up everywhere.
The case for the alternative deserves a fair hearing. ESP-native templates, such as Braze Content Blocks or Iterable and Customer.io templates, sit close to the send and support personalization syntax. They work well when a team ships on one channel only. The cost shows up with the second and third channels. Copy gets duplicated across the ESP, the push tool, the SMS tool, and the website, with no shared localization and no single approval record.
Sanity treats this as a shared-foundation problem. As the AI Content Operating System, Sanity keeps message content structured in the Content Lake next to product, campaign, and page content. The website and every sending platform read from the same schema. That is the core difference from legacy CMSes, which split content into separate systems. Sanity gives web and messaging teams one source of content to work from, and both channels inherit the same structure, validation, and history.
What do channel length limits mean for a message schema?
Channel length limits mean a message schema needs a separate, validated field for each channel, because each channel measures length differently and fails differently. SMS is the strictest. According to Twilio's documentation, one GSM-7 SMS holds 160 characters and one UCS-2 SMS holds 70. Once a message spans more than one segment, each segment holds only 153 GSM-7 characters or 67 UCS-2 characters, because 7 characters go to a header that links the segments. Twilio caps combined messages at 1,600 characters, bills per segment, and recommends keeping SMS under 320 characters.
The encoding is what breaks simple validation. A single emoji or curly quote switches the whole message to UCS-2. A check that only counts characters will approve copy that costs two or three times what the team expected. Copy pasted from a word processor is the usual cause, because it carries curly quotes that are easy to miss.
Push notifications are limited by bytes, not characters. Apple Push Notification service and Firebase Cloud Messaging both cap payloads at 4096 bytes (4 KB), and FCM topic messages are limited to 2048 bytes. That limit covers the title, body, deep link, and any custom data, so a long title takes room the app needs for its own data. How much of a title stays visible varies by operating system and device, which is a reason to preview messages instead of hard-coding one number.
Email has looser hard limits but real practical ones. Inbox views cut off long subject lines and preheaders, and the body needs both an HTML version and a plain-text fallback.
For the schema, this means a single message text field can't serve all four channels. Each channel needs its own field and its own rule: a required maximum on the push title, a byte-aware check on the push payload, and an encoding-aware check on the SMS body. In Sanity Studio, these rules run as the editor types. The limit is enforced where the copy is written, not discovered later in a carrier report. For a lifecycle team, that is the difference between a limit written down in a style guide and one the tool actually enforces.
One curly quote turns 160 into 70
How do you design a message schema with channel-specific fields?
A message schema with channel-specific fields is one document type. Its shared fields describe the message, and its nested objects describe how the message looks on each channel. A practical version in Sanity is a `message` document with an internal name, a reference to a campaign, and a locale. It then has three objects: `email` with `subject`, `preheader`, and `body` as Portable Text; `push` with `title`, `body`, and `deepLink`; and `sms` with a plain `body`.
Each field carries its own validation. The starting point is `validation: (Rule) => Rule.required().max(n)`, with n set per channel and per team policy. For SMS, a length cap isn't enough, so add a `Rule.custom()` check that looks for characters outside the GSM-7 set. If it finds any, it can return a warning that the single-message limit just dropped from 160 to 70 characters. It can return an error instead if your policy bans UCS-2. A warning is often the better choice, because an emoji may be intentional, but the editor should still know it changes the cost.
Portable Text is the right format for the email body. Because it is structured rich text, the same content renders to HTML for email and flattens to plain text for an SMS fallback or a push preview. Links, emphasis, and annotations are stored as data rather than markup, so the body works with any renderer.
Two design choices keep the schema easy to maintain. First, make each channel an optional object with a toggle, since not every message goes out everywhere. Then use conditional validation so the SMS rules apply only when SMS is turned on. Second, define personalization tokens, such as a first name or an order number, as documented placeholders that the sending platform fills in. Otherwise each editor invents their own syntax.
Because the schema is code, TypeGen can generate TypeScript types from it. If someone renames a field, the code that maps a message into an ESP or push provider request fails at compile time instead of sending a blank subject line in production. The schema becomes the shared contract between editors, developers, and sending platforms.
How do sending platforms pull message content at send time?
Sending platforms pull message content at send time by calling the content API as the message goes out and turning the JSON response into template variables. Braze Connected Content is the common example. It makes a GET request at send time and passes the parsed JSON to Liquid, Braze's template language. The template becomes a thin layout, and the copy comes from outside the ESP. Contentful has an official Braze app that supports this pattern or syncs fields into Braze Content Blocks, so this is a well-established way to connect the two.
In Sanity, the pull is a GROQ query that returns exactly the fields one channel needs. The email template asks for `*[_type == "message" && slug.current == $slug][0]{ "subject": email.subject, "preheader": email.preheader, "body": email.body }`. The SMS integration asks the same document for `{ "body": sms.body }`. Each channel gets its own shape from one document in a single request. A third-party implementation guide (trackingconsulting.com) shows how to connect Sanity to Braze through Connected Content against Sanity's CDN-backed query API, or how to sync documents into Braze catalogs.
Pulling has clear strengths. Content is always current when the message is sent, and there is no sync job to monitor. A fix published five minutes before a scheduled send makes it into that send. Pulling also has costs. Every send depends on the content API being reachable. Large campaigns multiply the number of requests unless the ESP caches responses. Personalization logic also ends up split across two systems.
A useful rule of thumb: pull at send time for transactional and triggered messages, where freshness matters and each message goes to a moderate number of people. Large broadcast campaigns usually work better when content is pushed into the ESP ahead of time. Many teams use both approaches with the same schema behind each. Either way, keep the GROQ queries in version control next to the integration code. A schema change and the queries that depend on it should ship in the same pull request, and TypeGen can check the query results against the generated types.
How do webhooks and Functions push message content on publish?
Webhooks and Functions push message content on publish by reacting to a document change and sending the new content to the sending platform. The ESP then has a copy before any send happens. Sanity offers two ways to do this, and each suits a different job.
GROQ-powered webhooks fire when a document is created, updated, deleted, or any combination of these. A GROQ filter decides which documents trigger the webhook, and a GROQ projection shapes the request body, which is always JSON. The body can already match what the ESP expects, so you don't need a separate service to reshape it. Filters can also use functions in the `delta::` namespace along with `before()` and `after()`. That lets a webhook fire only when the SMS body actually changed, not every time someone edits an internal note. Every request includes an `idempotency-key` header, so the receiving service can safely ignore repeated deliveries. By default, webhooks don't fire on draft or version changes, only on published ones, which is usually what a sending platform wants.
Sanity Functions handle cases where a request body isn't enough and code needs to run. Functions are serverless handlers that run on Sanity's infrastructure and react to content changes. They can read and write the dataset, follow references, and call external services such as an ESP or push provider API. They are declared in a Blueprint file, `sanity.blueprint.ts`, which sits in the repository next to the application code. For example, a Function could look up the linked campaign, render Portable Text to HTML, create or update a Braze Content Block, and save the returned ID back to the message document.
One detail often trips people up. The Function event values are `create`, `update`, and `delete`. The older `publish` event is deprecated, and publishing a document fires `update` on the published document. A sync Function should therefore use `event.on: ['update']`. Content in Content Releases and Scheduled Drafts lives in the `versions.**` namespace. It triggers Functions only when `includeAllVersions` is set to true.
Pushing on change works best for broadcast campaigns and catalog-style syncs, where the ESP should already have the content before the send instead of calling the content API live.
In Function code, 'on publish' means update
How should message templates be versioned and localized?
Message templates should be versioned in two places: the schema in source control, and the message content in the Content Lake with its own history. Treating them as one problem is how teams end up with templates nobody dares to edit.
The schema is code: the shape of a message, its fields, and its validation rules. In Sanity, it lives in the Studio configuration, goes through pull requests, and deploys with the rest of the application. Adding a `preheader` field or tightening an SMS rule can be reviewed and undone like any other change. The Blueprint that declares Functions lives in the same repository, so the automation that sends content to the ESP is versioned along with the schema it reads.
The message content is data. Edits to a message document are recorded in the Content Lake, so an editor can see what changed and when. A Content Release can group several message changes so they ship together. The same split applies on the ESP side. Layout templates in the ESP change rarely and belong to developers or lifecycle marketers. The copy inside them changes constantly and belongs to editors.
Localization follows the same split. The schema decides how locales work: either a locale field on a separate message document per language, or translated fields inside one document. A separate document per locale usually suits messaging better. Each translation can be approved and scheduled on its own, and SMS limits apply per language. German copy that fits in an email may push an SMS into a second segment. A language written in a non-Latin script usually needs UCS-2 encoding, with its 70-character single-message limit. Encoding-aware validation catches both before anything is sent.
A related need is versions of a message for different audiences or experiment groups. Sanity has announced Content Variants, in closed beta, which keeps the versions of a piece of content in one document. Until that is generally available, model these versions directly in the schema. For example, use an array of named variant objects that the sending platform chooses between, and keep the selection rule in the integration code so it is reviewed and versioned like everything else.
How do approvals, scheduling, and preview work for messaging content?
Approvals, scheduling, and preview for messaging content work best inside the system where the message is written. An approval history split across an ESP, a push console, and an SMS dashboard can't be audited as a whole. A coordinated launch might include a website banner, an email, a push notification, and an SMS, and all four should go live together or not at all.
Scheduling in Sanity uses Content Releases, which group document changes for scheduled publishing. One release can contain the landing page, the message document, and its translations. Releases and Scheduled Drafts live in the `versions.**` namespace, so a Function with `includeAllVersions` turned on can react to content in a release. When the release publishes, it fires the normal `update` events that sync content to sending platforms. The send itself is still scheduled in the ESP. Either line up the release time with the campaign send, or have the ESP pull content at send time.
Approvals depend on how formal the process needs to be. Sanity Workflows is in beta: it is opt-in and may change before general availability. Approval stages are defined in TypeScript and versioned like the rest of the code. An agent can check a draft against a style guide and either move it forward or send it back. An audit question like which messages were published without legal review becomes one GROQ query, because the process leaves its record in the same place as the content. For regulated SMS or financial promotions, that query is what matters.
Preview is where messaging differs most from the web. Presentation Tool and Visual Editing connect the Studio to a live web preview, and a team can add a preview route that renders an email template with the message's Portable Text. For push and SMS, custom preview components in the Studio can show a phone-style mockup, display the segment count, and flag UCS-2 encoding. You build these components yourself; they aren't built-in channel simulators. But because the Studio is a React application you configure, the preview can match your real templates instead of a generic approximation.
Powering email, push, and SMS from one source: how Sanity compares
| Feature | Sanity | Contentful | Braze Content Blocks | Contentstack |
|---|---|---|---|---|
| Message schema with a field per channel | Schema as code in the Studio config: a `message` type with `email`, `push`, and `sms` objects, with TypeScript types for integration code generated by TypeGen. | Content types are defined in the web app or through migration scripts. Channel fields are modeled as separate fields or linked entries in a fixed editor that can be extended with UI extensions. | Copy lives in Content Blocks and message templates inside Braze, organized by channel there rather than as one cross-channel document shared with the website. | Content types and field settings are configured in the Contentstack UI. Channel versions are modeled as fields or modular blocks and served through its delivery APIs. |
| Character limit and SMS encoding validation | `Rule.required().max(n)` on each field, plus a `Rule.custom()` check that finds non-GSM-7 characters and warns that the SMS limit dropped from 160 to 70. | Field validations include length limits and regex patterns. Encoding-aware SMS checks usually need a custom app or UI extension. | Copy is written in the channel composer next to the send, so any checks are tied to that one channel and aren't shared with the website or other sending tools. | Field-level validation rules are set in the content type editor. SMS encoding checks generally need custom extension code. |
| A different response shape for each channel | One GROQ projection returns the email shape and another returns the SMS shape from the same document, with references resolved through `->` in a single request. | REST and GraphQL delivery APIs return entries. GraphQL can select the fields each channel needs, and linked entries are resolved through nested queries or includes. | Content already lives inside the ESP, so Braze sends need no fetch. The website and other sending tools need their own copy of the text. | REST and GraphQL delivery APIs return entries as JSON. Fields can be selected, and reshaping content for each channel is often done in middleware. |
| Pulling content into an ESP at send time | Braze Connected Content can call a GROQ query on Sanity's CDN-backed API at send time. A third-party guide documents the Braze setup, including syncing to catalogs. | The official Braze app for Contentful supports Connected Content at send time or syncing fields into Braze Content Blocks, so the integration is documented and maintained. | Built in: Content Blocks are referenced directly in Braze templates, and Connected Content can call any external JSON API at send time. | The delivery API returns JSON that an ESP can fetch at send time. Your team configures and maintains the connection to each ESP. |
| Pushing content to platforms when it changes | GROQ-powered webhooks with `delta::` filters and `before()`/`after()` fire only when the SMS body changes. A projection shapes the body, and every request carries an idempotency-key header. | Webhooks fire on entry events such as publish, with configurable filters and request bodies. A receiving service usually maps entries to the ESP's format. | Content is edited inside Braze, so there is nothing to sync into Braze. Getting that copy out to the website or other tools takes separate export work. | Webhooks fire on entry events. Automation Hub, a visual trigger-and-action builder, can run flows that call external services without you hosting the code. |
| Serverless content automation | Functions declared in `sanity.blueprint.ts` run on Sanity's infrastructure. They can render Portable Text, call ESP or push provider APIs, and save returned IDs back to the document. | Extensibility comes through the App Framework and marketplace apps. Server-side sync logic often runs in a service you host or in a third-party app. | Campaign and Canvas logic orchestrate sends inside Braze. Transforming content that comes from other systems happens before it reaches Braze. | Automation Hub offers prebuilt connectors and a visual flow builder. It gives less developer control than triggers written in code and versioned in the repository. |
| Coordinated scheduling and approvals | Content Releases group page and message changes for scheduled publishing. Workflows (beta) defines approval stages in TypeScript and makes audits answerable with one GROQ query. | Scheduled publishing and release features are available, and approval workflows are configured in the platform rather than defined in code. | Send scheduling and campaign-level controls live in Braze. They cover the send itself but not the website copy or SMS sent from another tool. | Releases and workflow stages with publishing rules are configured in the UI and support scheduled releases of several entries at once. |