Back to Arky

Store Email

Email connections to the store's Resend accounts, sending addresses, templates with layouts, and complete email selections

Email Connections

A store sends through its own Resend accounts. Each email connection is one Resend account, connected with a Full access API key of that account, the signing secret of the account’s webhook at Arky’s address, and a name the team recognises. A Sending access key can only send, and Arky also reads the account’s webhooks, domains, suppressions and received mail. A store can connect several, and any number of stores may share one Resend account.

Arky never creates, replaces or deletes a webhook in a Resend account. The merchant creates one webhook there at Arky’s one address for store mail, https://api.arky.io/v1/webhooks/resend, with the events email.sent, email.delivered, email.delivery_delayed, email.bounced, email.failed, email.complained, email.suppressed and email.received, and pastes its signing secret into each store’s connection as webhook_secret. Connecting checks the key and requires exactly one webhook at Arky’s address, switched on, with those events and that secret: otherwise it is refused with 409 EMAIL_PROVIDER.WEBHOOK_MISSING, WEBHOOK_DUPLICATED, WEBHOOK_DISABLED, WEBHOOK_EVENTS_MISSING or WEBHOOK_SECRET_MISMATCH. Each delivery report names the store email it is about and each received email its recipients, so it reaches the store it belongs to.

Domain creation and DNS verification happen in the Resend account. findDomains lists the connection’s domains live through its key and keeps no copy: each domain reads not_started, pending, verified, partially_verified, partially_failed, failed or temporary_failure, with its DNS records and whether it is sending_enabled and receiving_enabled. replaceKey swaps the key and the webhook secret with the version you read, and the connection keeps its id: with a key of the same Resend account, mail that was never handed to Resend goes on through the new key, and with a key of another account the queued mail ends. checkSetup reads the account’s webhook again through the key and answers Arky’s address, the events to set, the webhook it found and each problem by name (webhook_missing, webhook_duplicated, webhook_disabled, webhook_events_missing, webhook_secret_mismatch). Only the store’s owner connects a Resend account, replaces its key or deletes the connection, because the staff sign-in code goes out through it. A connection still in use can’t be deleted.

A store’s mode decides what it connects. A live store connects a Resend account (409 EMAIL_PROVIDER.ARKY_PROVIDER_NEEDS_TEST_STORE for arky_resend). A test store connects only arky_resend, Arky’s simulated Resend, with one keyless call naming its domains (409 EMAIL_PROVIDER.TEST_STORE_NEEDS_ARKY_RESEND for resend), and its mail never leaves Arky.

POST /v1/stores/{store_id}/email-providers
SDK: sdk.notification.emailProvider.connect()
POST /v1/stores/{store_id}/email-providers/arky-resend
SDK: sdk.notification.emailProvider.connectArkyResend()
GET /v1/stores/{store_id}/email-providers
SDK: sdk.notification.emailProvider.find()
GET /v1/stores/{store_id}/email-providers/{id}/domains
SDK: sdk.notification.emailProvider.findDomains()
GET /v1/stores/{store_id}/email-providers/{id}/setup
SDK: sdk.notification.emailProvider.checkSetup()
PUT /v1/stores/{store_id}/email-providers/{id}
SDK: sdk.notification.emailProvider.replaceKey()
DELETE /v1/stores/{store_id}/email-providers/{id}?expected_updated_at=
SDK: sdk.notification.emailProvider.delete()
const connection = await sdk.notification.emailProvider.connect({
  store_id: storeId,
  id: crypto.randomUUID(),
  name: "Northwind Resend",
  api_key: resendApiKey,
  webhook_secret: resendWebhookSecret,
});
const { items: domains } = await sdk.notification.emailProvider.findDomains({
  store_id: storeId,
  id: connection.id,
});

Email Addresses

An address is { id, store_id, email_provider_id, email }: one address on a domain of one connection, unique in the store (409 EMAIL_ADDRESS.EMAIL_TAKEN). It sends the emails that select it and, when its domain receives in Resend and a support flow’s entry names it, receives support email. The sender name and the reply-to belong to each email selection, not to the address.

getReadiness asks Resend live whether the address can send and receive: each side is ready, unavailable with a reason, or check_failed. Sending never waits for that check: an email checks only the saved setup, and Resend’s own refusal ends it not_sent with Resend’s reason. An address still in use can’t be deleted.

POST /v1/stores/{store_id}/email-addresses
SDK: sdk.notification.emailAddress.create()
GET /v1/stores/{store_id}/email-addresses
SDK: sdk.notification.emailAddress.find()
GET /v1/stores/{store_id}/email-addresses/{id}/readiness
SDK: sdk.notification.emailAddress.getReadiness()
DELETE /v1/stores/{store_id}/email-addresses/{id}
SDK: sdk.notification.emailAddress.delete()
const sender = await sdk.notification.emailAddress.create({
  store_id: storeId,
  id: crypto.randomUUID(),
  email: "[email protected]",
  email_provider_id: connection.id,
});
const readiness = await sdk.notification.emailAddress.getReadiness({
  store_id: storeId,
  id: sender.id,
});

Templates And Layouts

A template is the wording of one email purpose: { key, name, type, default_language, layout_id, content }, where type is the exact purpose and content holds subject, nullable preheader, html and text per language. The default_language is one of its languages. An email is written in its contact’s language when the template has it, and in the default language otherwise. A template is selected only for its own purpose (409 EMAIL_TEMPLATE.WRONG_TYPE), by as many selections as need it. Creating a template does not select it.

The purposes are customer_sign_in, store_admin_sign_in, customer_email_verification, email_changed, order_received, first_order_placed, order_dispatched, order_delivered, order_ready_for_pickup, order_cancelled, order_refunded, booking_confirmed, booking_reminder, booking_cancelled, offer_sent, offer_revised, offer_reminder, company_invite, company_access_notice, store_admin_invite, return_requested, return_approved, return_declined, renewal_upcoming, renewal_payment_failed, membership_cancelled, form_received, form_stage_changed, form_submission_alert, order_alert, return_alert, conversation_message_alert, support_message and broadcast.

Every template names a layout, the frame around its body: { key, name, logo_media_id, content }, whose html holds exactly one {{{body}}} and whose text holds exactly one {{body}}, per language. A layout has every language of the templates that use it (409 EMAIL_TEMPLATE.LAYOUT_LANGUAGE_MISSING), and a language a template still uses can’t be removed from it (409 EMAIL_LAYOUT.LANGUAGE_IN_USE). Template HTML prints every value escaped.

A new store gets one editable English starter template for each of the 34 purposes, keyed by its purpose, and the editable plain layout. Only the store’s owner changes a store_admin_sign_in template and the layouts such templates use, because the staff sign-in code goes out in them; a store that wants others to edit its main layout gives the staff sign-in template a layout of its own. findDefaults lists each purpose’s starter wording with its allowed_fields, the data that purpose’s emails carry. A sign-in or verification template prints {{code}}, and a broadcast template {{unsubscribe_url}} or {{unsubscribe_token}}, in both its HTML and its text. A template or layout still in use can’t be deleted.

POST /v1/stores/{store_id}/email-templates
SDK: sdk.notification.template.create()
GET /v1/stores/{store_id}/email-templates
SDK: sdk.notification.template.find()
GET /v1/stores/{store_id}/email-templates/defaults
SDK: sdk.notification.template.findDefaults()
POST /v1/stores/{store_id}/email-templates/{id}/preview
SDK: sdk.notification.template.preview()
POST /v1/stores/{store_id}/email-templates/{id}/test
SDK: sdk.notification.template.test()
POST /v1/stores/{store_id}/email-layouts
SDK: sdk.notification.layout.create()
PUT /v1/stores/{store_id}/email-layouts/{id}
SDK: sdk.notification.layout.update()
GET /v1/stores/{store_id}/emails
SDK: sdk.store.emails.get()
PUT /v1/stores/{store_id}/emails
SDK: sdk.store.emails.update()

Store Emails

StoreEmails holds one complete selection per purpose, or null for an email the store doesn’t send. A selection is an Email:

interface Email {
  email_template_id: string;
  sending_address_id: string;
  from_name: string;
  reply_to: { type: "address"; email_address_id: string } | { type: "external"; email: string };
}
const { id, store_id, created_at, updated_at, ...settings } = await sdk.store.emails.get({
  store_id: storeId,
});
const { items: [receipt] } = await sdk.notification.template.find({
  store_id: storeId,
  type: "order_received",
});

await sdk.store.emails.update({
  ...settings,
  store_id: storeId,
  expected_updated_at: updated_at,
  order_received: {
    email_template_id: receipt.id,
    sending_address_id: sender.id,
    from_name: "Northwind",
    reply_to: { type: "address", email_address_id: sender.id },
  },
});

update saves the complete settings with their expected_updated_at. Only the store’s owner changes the store_admin_sign_in selection; another member’s save is refused only when it changes that selection. Nothing is selected for a new store: the app or Admin selects each email once a real sending address exists, and a later setup run never turns a deliberately empty selection back on. A selection is checked against the saved setup only (a same-store sending address on a connection, a same-store reply-to address and a template of the right purpose); a support message’s reply-to must be one of the store’s addresses (409 EMAIL_ADDRESS.NOT_RECEIVING for an external one). offer_reminder_after_days (7 to start) times the offer reminder, and creation_templates names the starter templates new forms, support flows and broadcasts begin with.

The team’s alerts are order_alert, return_alert and conversation_message_alert, each with its recipient list, order_alert_recipients, return_alert_recipients and conversation_message_alert_recipients. The conversation alert goes when a conversation becomes the team’s turn: a customer’s new email or chat message hands it to the team, or the customer answers a team reply. A recipient is { type: "store_role", store_role_id, language } or { type: "email", email, language }, in a store language, and a selected alert needs at least one (409 STORE_EMAILS.ALERT_RECIPIENT_COUNT). An email recipient is a person’s address, never one of the store’s own (409 STORE_EMAILS.ALERT_RECIPIENT_STORE_ADDRESS): mail from the store’s own addresses is ignored when it arrives, and alerts and other automatic store emails say Auto-Submitted: auto-generated.

Each email goes to the contact of what it is about: the order’s contact for order, fulfillment, booking and return emails, the offer’s contact, the member’s current contact for renewal and membership emails, the submission’s email contact for form emails, the request’s contact for codes, the previous verified contact for the email-changed notice, the invitation’s contact for invites, and each alert recipient. An email without a contact is recorded with no recipient; Arky never looks for another address.

order_received is queued at placement, including pending paid checkout, with the order’s link; a free sign-up gets none. Staff can resend an order’s receipt, which queues a new email with the current wording and a new order link; it is refused while order_received is empty (409 STORE_EMAILS.ORDER_RECEIVED_EMPTY). The new link replaces the old one only when the resent email is queued to go; a resend recorded not_sent leaves the old link working. first_order_placed goes when an order’s lines are first confirmed and no earlier order of the store with confirmed lines has the same contact email. Email change goes to the previous address. Staff cancellation, booking moves, refunds, fulfillment and return decisions carry an explicit customer-notification choice. A membership cancellation notice covers every and never members.

Forms own their separate FormEmails: received, stage_changed keyed by stage ID, submission_alert and its alert_recipients, each a complete Email of the matching form purpose. Receipt and stage recipients come from the submission’s email contact: the submitted typed Email answer with the submission’s language, without proving or changing a Customer.

For template tests, retain one outgoing_email_id for retries and name the language, sending_address_id, from_name and reply_to to send with; the test goes to the signed-in administrator’s own account email. Preview and test use each purpose’s actual data contract: its sample has exactly the shape its producers send, and there are no email-only views and no storefront links Arky would invent. Offer wording reads the note at cart.offer.status.note and the expiry at cart.offer.status.expires_at, and builds its cart link from the cart’s id; receipts carry the order’s order_token. Order data lists each applied promotion with its current blocks at order.promotions. Foreign or unavailable template paths are refused. Inside {{#each list}} wording reads only this, this.<field of the item>, @index and @key.

Each purpose’s allowed_fields lists exactly the data its emails carry, and a template that prints anything else is refused when it is saved.

Wording prints money with {{format_money <amount> <currency>}}, in the currency’s own decimals, and a moment with {{format_datetime <moment> <timezone> "<pattern>"}}; both show nothing for a missing value. The pattern is required: a chrono strftime pattern written in the wording itself, so each language writes its own date. Month and weekday names print in English, so other languages write numeric dates, and a day, such as a chosen end day, takes a pattern without a time, so it never prints midnight:

LanguageWordingPrints
Bosnian, Croatian{{format_datetime ends_at store.timezone "%-d. %-m. %Y."}}6. 11. 2026.
English{{format_datetime ends_at store.timezone "%b %-d, %Y"}}Nov 6, 2026
German{{format_datetime ends_at store.timezone "%-d.%-m.%Y"}}6.11.2026
Italian{{format_datetime ends_at store.timezone "%-d/%-m/%Y"}}6/11/2026
French{{format_datetime ends_at store.timezone "%d/%m/%Y"}}06/11/2026

A moment whose time matters names it in its pattern, such as "%-d. %-m. %Y. u %H:%M" (6. 11. 2026. u 14:30) or "%b %-d, %Y at %-I:%M %p" (Nov 6, 2026 at 2:30 PM). Saving a template whose format_datetime has no pattern, or a pattern chrono can’t read, is refused (409 EMAIL_TEMPLATE.DATE_PATTERN); a pattern that a variable gives is checked when the email renders.

Wording that still can’t be built from an email’s data, such as a subject that comes out empty or a date pattern from a variable that can’t be read, records that email not_sent with render_failed: <reason>, and never a part of a date; the action that sent it goes on. A code request whose wording can’t be built is refused instead. See delivery history for factual sent, not-sent and uncertain outcomes.