Unreleased documentation. These pages follow the main branch and can change before the next release. For supported guidance, use v0.48.0.
A Messaging package is everything a deployment may send: the providers, the sender profiles callers select, the templates, and the access profiles that decide who may call. Here you add a French version of the starter’s SMS reminder, preview it, and package the project for an operator.
Work in the project you built in Send your first message.
Run every command from the directory that holds tutorial-work, with messagingctl on your PATH.
Nothing here needs a running service; an operator installs the released binary as
Deploy Registry Messaging describes.
Check the project
Section titled “Check the project”messagingctl check --project tutorial-work/noticesok: tutorial-work/noticespackage digest: sha256:b819f6d18f1b32ede522cb7c4ad436056a1cc85e10523c891dcfe892623ecb5btemplate: appointment-reminder 1 (email) sample en: renders sample fr: renderstemplate: appointment-reminder-sms 1 (sms) sample en: 1 segment(s), gsm7 85 unitsaccess profile: case-notices (sender)access profile: operations (operator)0 errors, 0 warnings in 18 filesAny edit to these files changes the digest, and the digest is what the operator records.
Read what the project declares
Section titled “Read what the project declares”messaging.yaml names the providers and the sender profiles a caller selects:
# The transports this deployment sends through. The type and, for an http# provider, its scripts under providers/<id>/ are package; each provider's# endpoint and credentials are runtime configuration. `idempotentSubmit`# declares that the provider drops a repeat carrying the same idempotency key.providers: mail-relay: type: smtp sms-gateway: type: http idempotentSubmit: true# What a caller selects: a channel, the provider carrying it, the sender# identity, and for SMS the most segments one message may use.senderProfiles: transactional: channel: email provider: mail-relay sender: notices@example.org reminders-sms: channel: sms provider: sms-gateway sender: Registry maximumSegments: 2A sender profile also carries its dispatch policy, and each message keeps the policy it was
accepted under. A send that definitely failed is retried with a delay that doubles each time. A
send that may have reached the provider is uncertain: under the default onUncertain: hold the
message stops as unknown until an operator settles it, and under retry it is sent again with the
same idempotency key. retry is refused unless the provider declares idempotentSubmit: true or
the profile sets acceptDuplicates: true. Set acceptDuplicates only when a duplicate is better
for the recipient than a missed message.
The access profiles decide who may call:
accessProfiles: case-notices: principalClaim: sub requiredScopes: [messaging:send] requesterClients: [case-system] actorKind: service actsAs: sender senderProfiles: [transactional, reminders-sms] templates: [appointment-reminder, appointment-reminder-sms] requestsPerMinute: 60 burst: 10A token resolves to one profile by its client, its scopes, and its actor kind. A sender may
submit and preview with the sender profiles and templates listed; an operator reads and cancels
every message and may not submit. Messaging inherits no authorisation from a calling product: a
service allowed to act on a case is not thereby allowed to send. requestsPerMinute and burst
are counted per caller in each runtime process; maximumMessagesPerDay, when set, is counted for
the whole profile from accepted messages, so it holds across replicas and restarts.
Registry Messaging configuration lists every key, its default, and its bounds.
Add a French SMS
Section titled “Add a French SMS”A template version lives under templates/<id>/<version>/. Its template.yaml declares the
channel, the locales, and the parts, and each locale has one Jinja file per part. Declare fr for
the SMS reminder and write its text:
sms=tutorial-work/notices/templates/appointment-reminder-sms/1cat >"$sms/template.yaml" <<'YAML'apiVersion: id.registrystack.org/formats/messaging/template/v1alpha1kind: MessagingTemplatechannel: smslocales: [en, fr]parts: [text]YAMLmkdir -p "$sms/fr"cat >"$sms/fr/text.j2" <<'JINJA'Rappel : {{ name }}, votre rendez-vous à {{ office }} est le {{ day|date }}.JINJARender it with the version’s sample data:
messagingctl preview --project tutorial-work/notices --locale fr \ --data "$sms/sample.json" appointment-reminder-sms 1template: appointment-reminder-sms 1 (sms, fr)package digest: sha256:a77193bf48a8fdcc09a4576991fbd0441307cd23e34c550d27a740b66cd0dfce--- textRappel : Ada Lovelace, votre rendez-vous à Central Registry Office est le 01/10/2026.--- sms: 1 segment(s), gsm7 85 unitsThe segment count is what the runtime charges against the sender profile’s maximumSegments. A
submission whose text needs more segments than that is refused with
422 content.too-many-segments; check reports the count but does not compare it.
Check the project again. The French sample now renders at load:
messagingctl check --project tutorial-work/noticesok: tutorial-work/noticespackage digest: sha256:a77193bf48a8fdcc09a4576991fbd0441307cd23e34c550d27a740b66cd0dfcetemplate: appointment-reminder 1 (email) sample en: renders sample fr: renderstemplate: appointment-reminder-sms 1 (sms) sample en: 1 segment(s), gsm7 85 units sample fr: 1 segment(s), gsm7 85 unitsaccess profile: case-notices (sender)access profile: operations (operator)0 errors, 0 warnings in 19 filesWhat a template may do
Section titled “What a template may do”A version directory holds template.yaml, a schema.json (JSON Schema draft 2020-12, with no
outside references) that the caller’s data must satisfy before anything renders, an optional
sample.json every locale must render at load, and the <locale>/<part>.j2 files. An email
version renders subject, text, and optionally html; an SMS version renders exactly text.
Templates are Jinja without a loader: no include, import, extends, or macros, no built-in
filters or globals, and no file, network, or clock access. A missing or null value refuses the
render instead of printing nothing. Two filters format for the requested locale: date for an ISO
calendar date and number(decimals) for a number. HTML parts escape every value, text and SMS parts
strip control characters, and a subject strips newlines. A locale the version does not declare is
refused with 422 template.locale-unavailable, never answered in another language.
To change wording a deployment already sends, add a new version directory, list it under templates in messaging.yaml, and keep the old one until no
caller names it.
Write an HTTP provider’s scripts
Section titled “Write an HTTP provider’s scripts”An smtp provider needs nothing in the package beyond its entry. An http provider has a directory
providers/<id>/ with a provider.yaml and the Rhai scripts it names. The starter’s sms-gateway
declares:
prepareScript: scripts/prepare.rhaiinterpretScript: scripts/interpret.rhaireceiptScript: scripts/receipt.rhairequest: method: post headers: [idempotency-key, x-request-id]responseHeaders: [x-request-id]capabilities: receipts: callback maximumConcurrentRequests: 8The scripts see plain data only, never a credential, a URL, or a header value the runtime owns:
| Script | Receives | Returns |
|---|---|---|
prepare(message, profile) | The message’s messageId, generation, attempt, channel, recipient, parts, and idempotencyKey when the provider declares idempotentSubmit; the profile’s id, channel, sender, maximumSegments | target relative to the operator’s baseUrl, declared headers, bodyFormat json or form, and body |
interpret(response) | status, the declared response headers, and the decoded body | outcome: accepted with a providerReference, transient with an optional retryAfter, permanent with an optional code, or maybe-sent |
receipt(request) | A verified callback’s method, with its form, query, and json limited to the parts the verifier authenticates; an unauthenticated part reads as empty | providerReference and report (sent, delivered, or undelivered), or () to ignore the callback |
Without an interpret script, a 2xx is accepted, 429 and 503 are transient, 408 and any
other 5xx are maybe-sent, and any other status is permanent with the code http.<status>. An
interpret script that fails falls back to the status, except that an unreadable 2xx is
maybe-sent. Return maybe-sent whenever the provider may have taken the message: that is what
keeps it from being sent twice under onUncertain: hold.
Two more examples live in the Registry Stack repository under
products/messaging/examples/providers/: mock, a loopback mock, and form-sms-gateway, a
form-encoded gateway with a form callback.
Package the project
Section titled “Package the project”messagingctl package writes the package into a directory that does not exist yet:
messagingctl package tutorial-work/notices --output tutorial-work/notices-packagecreated: tutorial-work/notices-packagepackage digest: sha256:a77193bf48a8fdcc09a4576991fbd0441307cd23e34c550d27a740b66cd0dfcepackage files: 19The digest is the one check reported. The package holds messaging.yaml, the providers, the
templates, and a SHA256SUMS envelope, with no runtime file, credential, or development state.
Check it as the operator will:
messagingctl check --package tutorial-work/notices-packageThe report is the project’s, headed ok: tutorial-work/notices-package, with the same digest.
Give the operator the directory and the digest. The runtime refuses a package whose files differ
from its SHA256SUMS before it connects to the database, serves only the digest the operator
recorded, and sends only what the package holds, so editing the project never changes what a
running deployment sends.
- Deploy Registry Messaging to record this package and serve it.
- Registry Messaging configuration for every key and the command that checks each file.
- Registry Messaging API for the submission, preview, and status contract your callers use.
Cookies on Registry Stack
We use optional cookies to understand how you use the main Registry Stack website and this documentation. If you contact us, we may link this activity to your enquiry. You can change your choice at any time. Read the privacy policy.
Your browser asks sites not to track you, so optional tracking stays off.
We could not use or save that choice. Optional tracking remains off.