Back to Arky

Store Email

Connect the store's Resend account, add a sending address, and choose a complete email for each purpose.

Arky sends a store’s email itself, signed with the store’s own domain. A store sends through its own Resend account, as it takes card payments through its own Stripe account: Arky decides who gets what and when, and Resend only sends. There is no shared Arky address: each store carries its own sending reputation, and Arky never sends a store’s mail under its own name.

A new store already has an editable English starter template for every email purpose, but it sends no email until it connects its Resend account, adds a sending address and selects each email it wants. That includes order receipts and the sign-in codes storefront customers use, so make this part of every launch.

A test store connects Arky’s simulated Resend instead, with one keyless call, and steps 2 and 3 work the same. Its mail never leaves Arky, and you read it through the API.

1. Connect The Store’s Resend Account

Add and verify the store’s domain in its own Resend account, and create one webhook there at Arky’s 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. Then connect the account with a Full access API key (a Sending access key can only send, and Arky also reads the account’s webhooks, domains, suppressions and received mail), that webhook’s signing secret and a name the team recognises:

import { createAdmin } from "arky-sdk/admin";

const sdk = createAdmin({ apiUrl: "https://api.arky.io" });

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,
});
const domain = domains.find((value) => value.name === "northwind.example");
if (domain?.status !== "verified") console.log("Finish the domain's DNS records in Resend first");
  • Connecting checks the key and requires the webhook you created in that Resend account at Arky’s address, switched on, with the events listed and that signing secret; otherwise it is refused with its EMAIL_PROVIDER.WEBHOOK_* code. Arky never creates, replaces or deletes a webhook there. checkSetup reads the webhook again and names each problem it finds.
  • A store can connect several Resend accounts, and any number of stores may share one Resend account, each with the secret pasted into its own connection.
  • The domain list is read live from Resend; Arky keeps no copy. Resend checks the domain when it receives each email: an email from a domain it hasn’t verified ends not_sent with Resend’s reason.
  • replaceKey swaps the key and the webhook secret with the version you read; the connection keeps its id. Only the store’s owner connects, replaces a key or deletes a connection, because the staff sign-in code goes out through it.

2. Add A Sending Address

const orders = 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: orders.id });

An address is one email on one connection. The sender name and the reply-to belong to each email selection, so the same address can send as Northwind and as Northwind support. getReadiness asks Resend whether the address can send and receive right now; sends themselves never wait for it. A store can have more addresses, such as news@ for broadcasts and support@ for support, and an address on a receiving domain can take support email (see Support). Nothing ever switches address on its own: if an address can’t send, its emails end not_sent and staff see why.

3. Select The Store’s Emails

A template is the wording of one email purpose, with its text per language, a default language and a layout around it. The store’s email settings (StoreEmails) hold one complete selection per purpose: the template, the sending address, the sender name and the reply-to. Creating a template selects nothing.

const { id: _id, store_id: _store, created_at: _created, updated_at, ...settings } =
	await sdk.store.emails.get({ store_id: storeId });

const starter = async (type: "customer_sign_in" | "order_received") => {
	const { items } = await sdk.notification.template.find({ store_id: storeId, type });
	return items[0].id;
};
const from = (email_template_id: string) => ({
	email_template_id,
	sending_address_id: orders.id,
	from_name: "Northwind",
	reply_to: { type: "address" as const, email_address_id: orders.id },
});

await sdk.store.emails.update({
	...settings,
	store_id: storeId,
	expected_updated_at: updated_at,
	customer_sign_in: from(await starter("customer_sign_in")),
	order_received: from(await starter("order_received")),
});
PurposeSelection
a customer asks for a sign-in codecustomer_sign_in
a signed-in customer proves a new email, and the old one hears of itcustomer_email_verification, email_changed
a team member signs in on the store’s login page, or is invitedstore_admin_sign_in, store_admin_invite
an order is placed, including pending paymentorder_received
a contact’s first order is confirmedfirst_order_placed
a shipment leaves, arrives, or a pickup is readyorder_dispatched, order_delivered, order_ready_for_pickup
an order is cancelled or refundedorder_cancelled, order_refunded
a booking is confirmed or moved, comes up, or is cancelledbooking_confirmed, booking_reminder, booking_cancelled
an offer is sent, revised, or still waitsoffer_sent, offer_revised, offer_reminder
someone is added to a company, or their access changescompany_invite, company_access_notice
a return is requested, approved or declinedreturn_requested, return_approved, return_declined
a renewal comes up or its payment failsrenewal_upcoming, renewal_payment_failed
a membership is cancelledmembership_cancelled
the team should hear about an order, a return or a conversation’s new messageorder_alert, return_alert, conversation_message_alert, with their recipient lists
a customer sends a form, or it reaches a stage, and the team hears of itFormEmails.received, FormEmails.stage_changed, FormEmails.submission_alert
  • Only the store’s owner changes the store_admin_sign_in selection, its template and that template’s layout, because the staff sign-in code goes out in them.
  • Each selection is checked against the saved setup: a same-store sending address on a connection, a same-store reply-to and a template of that exact purpose. Selecting nothing (null) sends nothing; setup scripts set only empty selections, so an email someone switched off stays off.
  • Each email goes to the contact of what it is about, such as the order’s contact, and is written in that contact’s language when the template has it, otherwise in the template’s default language.
  • Staff choose whether the customer gets an email each time they cancel, move a booking, refund, mark a shipment, or decide a return.
  • Preview and test fill the template with a sample of exactly the data the email will get; a test goes to the administrator’s own email.
  • A template can print only the fields its purpose carries (allowed_fields in template.findDefaults). A selected email whose wording still can’t be built from its data is recorded not_sent with render_failed: <reason>, and the action that sent it goes on; a code request whose wording can’t be built is refused instead.

Storefront Sign-In Codes

Storefronts never send email themselves. A customer sign-in code goes out with the store’s customer_sign_in selection; the storefront only asks for it, for an explicit contact:

import { initialize } from "arky-sdk/storefront";
import { createOrderToken } from "arky-sdk/utils";

const arky = initialize("arky_pk_...", {
	locale: "en",
	createVisitorIdentity: () => ({
		customer_id: crypto.randomUUID(),
		session_id: crypto.randomUUID(),
	}),
	createSessionId: () => crypto.randomUUID(),
	createId: () => crypto.randomUUID(),
	createOrderToken,
});

await arky.customer.requestCode({
	contact: { email: "[email protected]", language: "en" },
});

await arky.customer.verify({ code: "123456" });
  • The code email’s id comes from your createId. A retry after a lost answer reuses it, so one email goes out; a request after an answer, such as “send me another code”, gets a new one. Pass id to pick it yourself. verify takes the id of the signed-in session the code makes from createSessionId, and keeps it when it retries that verification.
  • Code requests are refused at once while the store has no customer_sign_in email selected or its email sending is paused (409 CUSTOMER_SIGN_IN.UNAVAILABLE) or its sending address can’t send (409 EMAIL_ADDRESS.NOT_SENDING), so show your own message then. A code asked again too soon, a wrong or expired code and too many wrong codes have their own codes too: CUSTOMER_SIGN_IN.CODE_RECENT, CUSTOMER_SIGN_IN.CODE_INVALID and CUSTOMER_SIGN_IN.ATTEMPTS_EXHAUSTED. With a bot check on the publishable key, send the widget’s token as bot_check_token.
  • When a signed-in customer changes their email, the code to the new address is the customer_email_verification email, and the old address gets email_changed.

What Arky Handles

  • Bounces and spam complaints come from the connection’s Resend reports and block the address for that store. When Resend skips an address because its own suppression list holds it, its report ends that email as suppressed and blocks nothing in Arky, because Resend’s list already covers the whole Resend team, every store that shares it included. Unsubscribes from broadcast emails stop broadcasts to the address.
  • Nothing is stopped. An email that waits is never cancelled. Right before each try Arky checks the deadline, the store, the sending address and its connection, and the store’s suppressions, and an email that may no longer go ends not_sent with its reason.
  • Pausing. The store’s owner, or a platform administrator, can pause all of a store’s email: emails wait until sending is allowed again and then all go, so a pause delays mail and never cancels it, and the store’s sign-in codes are refused meanwhile. See Pause Store Email.
  • History. Every email is an outgoing email: staff search by address and see each email’s type, status and a redacted preview. A finished one is kept 30 days.
  • Arky’s own mail, the Arky sign-in code and store billing mail, goes through Arky’s own Resend account from Arky’s address. A store’s own login page and team invites use the store’s selections.
Tip

Support email works the other way round: a support flow’s email entry takes the email a receiving address gets, and the team replies from Admin with the conversation’s selection. See Support. For newsletters, see Newsletters and Broadcasts.