RPC
Call the backend over HTTP without private packages and understand its authentication and JSON messages.
RPC sends a named operation to a server. Novinzo serves these operations at POST /rpc through Effect RPC.
The HTTP interface does not require a Novinzo SDK. Use the request and response schemas in the reference.
A server with a store API key uses https://dashboard.novinzo.com/api as NOVINZO_API. For any other caller, ask Novinzo for the backend base URL of your environment. Set NOVINZO_API before you run a direct HTTP example.
Who can call /rpc
| Caller | Authentication | Available operations |
|---|---|---|
| Storefront server client | x-storefront-request: true, plus shopper cookies where required. | Public storefront operations and authorized shopper operations. |
| Seller | Dashboard session cookie and x-store-id for a store-scoped operation. | Seller operations for stores that the seller can access. |
| Merchant server | Authorization: Bearer novinzo_sk_…, a store API key. | The operations of the key's store that its access covers. |
| Plugin | The platform invocation token, forwarded over the BACKEND service binding. | Permission-protected operations for the store in the token. |
Plugin calls require the store grant and a current installation:
| Operation | Permission | Additional restriction |
|---|---|---|
| OrderDetails | orders:read | Returns the complete order details, including sensitive buyer data. |
| PreparedCheckoutCreate | checkout:write | Prepares an unpaid checkout, not a payment. |
| WebhookEventPublish | checkout:write | The calling plugin must own the event type. |
| PluginPaymentMethodActivate | payments:provide | One method per plugin per store; a store can run several plugins'. |
| PluginPaymentMethodDeactivate | payments:provide | Acts only on the calling plugin's payment method. |
| PluginPaymentReport | payments:provide | The report must match the payment core recorded for that checkout. |
| GetAnalytics | analytics:read | Aggregates only; it returns no order, buyer or payment. |
| GetVariantInsights | analytics:read | Aggregates for one product's variants only. |
| SendingDomainRegister, Get, Verify, Remove | emails:customize | The store's own sending domain only. |
| OrderLineDeliveryReport | deliveries:write | Only lines the calling plugin delivers and ships. |
| OrderLineReplacementHold, Confirm, Release, Shipped | replacements:write | Only lines the calling plugin delivers and ships; a replacement never charges the buyer. |
| OrderLineRestock | returns:write | Never more units than were reported delivered. |
| OrderLineRefund | refunds:write | Only lines the calling plugin delivers; core sets the amount. |
| VariantKeysIssue | keys:issue | Only variants another plugin delivers keys for; idempotent per saleRef. |
| SellerOrderPushSend | push:send | Only the store's paid orders; at most one notification per order. |
Binding props and caller-supplied plugin names do not authenticate these calls. See Backend RPC for the service-binding example.
A merchant's own server calls /rpc with a store API key. An app API key is different: it authenticates the public routes and admin APIs of the plugins it is granted, not /rpc.
The backend selects the storefront server only when x-storefront-request equals true. Other requests go to the admin server.
Sending a tag to the wrong server produces Unknown request tag: <Tag> as a Die cause.
Wire format
NDJSON contains one JSON value per line. Send Content-Type: application/ndjson and end every message with \n.
End every message with a newline
Add the trailing newline. The server does not parse an unfinished line, so it cannot answer that message.
The request envelope
{
"_tag": "Request",
"id": "0",
"tag": "StorefrontGetStore",
"payload": { "storeSubdomain": "acme" },
"headers": []
}| Field | Meaning |
|---|---|
_tag | The literal Request. |
id | A string identifier that the response repeats as requestId. |
tag | The operation name from the reference. |
payload | The operation payload, or null when it has no payload. |
headers | An empty array. Put authentication and routing headers on the HTTP request. |
The server supplies the HTTP headers to each operation. Optional tracing fields are traceId, spanId, and sampled.
Response lines
Expected operation outcomes use HTTP 200. Read the Exit message to distinguish success from failure.
A success contains the JSON result in value:
{
"_tag": "Exit",
"requestId": "0",
"exit": { "_tag": "Success", "value": { "id": "…", "name": "Acme" } }
}A failure contains a list of causes:
{
"_tag": "Exit",
"requestId": "0",
"exit": {
"_tag": "Failure",
"cause": [
{
"_tag": "Fail",
"error": { "_tag": "StorefrontNotFoundError", "resource": "Store", "identifier": "acme" }
}
]
}
}| Cause tag | Meaning |
|---|---|
Fail | An expected error in error. Its _tag identifies the error contract. |
Die | An unexpected server defect in defect. |
Interrupt | An interrupted request. |
A protocol failure can produce a Defect message instead of an Exit. Do not treat it as an operation result.
An HTTP rejection before the RPC server is not an NDJSON outcome. Examples include rate limits with status 429 and refused origins with status 403.
Invalid payloads
A payload outside the operation schema produces InvalidRequest before the handler runs:
{
"_tag": "Exit",
"requestId": "0",
"exit": {
"_tag": "Failure",
"cause": [
{
"_tag": "Fail",
"error": { "_tag": "InvalidRequest", "message": "The request payload is invalid." }
}
]
}
}Use the reference schema to make sure that the payload matches the contract. This error does not identify the invalid field.
JSON encoding
| Value | Representation |
|---|---|
| Entity identifiers | Strings, usually UUIDs. |
| Dates | ISO 8601 strings. |
| Big integers | Decimal strings. |
| Money | {"amountMinorUnits":"1999","currency":"USD"}. |
| Nullable values | The value or null. |
| Optional keys | Omit them when the schema permits omission. |
| No result | null in the success value. |
Calling it with cURL
Replace acme with a store subdomain in your environment. printf supplies the required trailing newline:
printf '%s\n' '{"_tag":"Request","id":"0","tag":"StorefrontGetStore","payload":{"storeSubdomain":"acme"},"headers":[]}' |
curl -X POST "$NOVINZO_API/rpc" \
-H "Content-Type: application/ndjson" \
-H "x-storefront-request: true" \
--data-binary @-Use --data-binary to preserve the newline.
Calling it from TypeScript
The following JavaScript also works in a TypeScript project that permits JavaScript files. It uses built-in fetch and does not import private contracts.
Save it as get-store.mjs and run it with Node.js 22 or later. Set NOVINZO_API and STORE_SUBDOMAIN in your environment first.
export async function getStore(apiUrl, storeSubdomain) {
const response = await fetch(new URL("/rpc", apiUrl), {
method: "POST",
headers: {
"content-type": "application/ndjson",
"x-storefront-request": "true",
},
body:
JSON.stringify({
_tag: "Request",
id: "0",
tag: "StorefrontGetStore",
payload: { storeSubdomain },
headers: [],
}) + "\n",
});
if (!response.ok) {
throw new Error(`RPC HTTP failure: ${response.status}`);
}
const frames = (await response.text())
.split("\n")
.filter((line) => line.trim() !== "")
.map((line) => JSON.parse(line));
const result = frames.find(
(frame) =>
frame !== null &&
typeof frame === "object" &&
frame._tag === "Exit" &&
frame.requestId === "0",
);
if (!result || !result.exit || typeof result.exit !== "object") {
throw new Error("RPC response did not contain the requested outcome");
}
if (result.exit._tag === "Failure") {
const causes = Array.isArray(result.exit.cause) ? result.exit.cause : [];
const failure = causes.find((cause) => cause?._tag === "Fail");
throw new Error(failure?.error?._tag ?? "RPC request failed");
}
if (
result.exit._tag !== "Success" ||
!result.exit.value ||
typeof result.exit.value.name !== "string"
) {
throw new Error("RPC response did not contain a store");
}
return result.exit.value;
}
if (!process.env.NOVINZO_API || !process.env.STORE_SUBDOMAIN) {
throw new Error("Set NOVINZO_API and STORE_SUBDOMAIN before running this example");
}
const store = await getStore(process.env.NOVINZO_API, process.env.STORE_SUBDOMAIN);
console.log(store.name);The reference defines the full store result. This example reads only its name and rejects failed or malformed outcomes.
Tenancy
| Operation category | Store identity |
|---|---|
| Store-scoped seller operations | The seller session and x-store-id. |
| Permission-protected plugin operations | The invocation token. |
| Shopper authentication, orders, invoices, checkout initiation, and prepared checkout pages | The store domain in Host. |
| Public store, product, and cart operations | A documented payload identifier. |
| Checkout status, completion, cancellation, and payment changes | The checkout session identifier. |
Call shopper routes through the store domain, such as /api/auth/* and /api/orders. The storefront forwards the domain and cookies to the backend.
A direct request to the backend uses the backend host, not a store host. It cannot resolve a domain-scoped store operation.
CORS and origins
CORS controls which browser origins can read an HTTP response. Direct backend browser access permits only Novinzo dashboard origins with credentials.
The admin server rejects a disallowed Origin with 403 Origin not allowed.
Call /rpc from a server or the plugin service binding. Use the storefront API for code on store pages.
Rate limits
Storefront RPCs are rate limited per client IP and host. A limit rejection uses HTTP 429, not an Exit message.
Calls made with a store API key are limited to 600 a minute per key, and to 600 a minute from one IP address whatever key they carry. Past that they are answered with HTTP 429 and Retry-After.
Documented RPC groups
The reference includes the store operations merchants' servers call with store API keys, public storefront contracts, and the workflows plugin authors need to understand.
| Group | Server | Purpose |
|---|---|---|
| Storefront | Storefront | Store, theme, catalog, and payment data. |
| Storefront products | Storefront | Product details and variant availability. |
| Cart | Storefront | Current prices and availability for a cart. |
| Checkout | Storefront | Payment sessions. |
| Storefront prepared checkouts | Storefront | Hosted pay-page data. |
| Payment surcharges | Storefront | What each payment method adds at checkout. |
| Customer auth | Storefront | Email code sign-in. |
| Customer orders | Storefront | Orders for the signed-in shopper. |
| Order access | Storefront | Shopper and guest order access. |
| Invoices | Storefront | Authorized invoice downloads. |
| Store credit | Storefront | The signed-in shopper's store credit. |
| Customer subscriptions | Storefront | The signed-in shopper's subscriptions, and cancelling one. |
| Theme preview | Admin | Theme files and render data. |
| Plugin installs | Admin | Installation and permission grants. |
| Store-private plugins | Admin | Plugins of the store's own, which only it can install. |
| Store-private plugin deploy tokens | Admin | Tokens that deploy a store-private plugin from CI. |
| Store-private plugin deployments | Admin | A store-private plugin's deployments. |
| Store-private plugin previews | Admin | The preview novinzo-plugin dev uploads. |
| Store-private plugin secrets | Admin | Secrets for a store-private plugin's Worker. |
| Store-private plugin repository | Admin | The GitHub repository a store-private plugin deploys from. |
| Store-private plugin sources | Admin | Store-private plugins whose source Novinzo hosts. |
| Store theme sources | Admin | A store theme whose source Novinzo hosts. |
| Plugin API keys | Admin | Keys that open the public routes of the plugins granted. |
| Store | Admin | The store's settings, currency and custom domain. |
| Store API keys | Admin | Keys the store's own servers call these RPCs with. |
| Products | Admin | Products and their variants. |
| Product deliveries | Admin | Keys and stock, files and delivery webhooks per variant. |
| Orders | Admin | Orders, their details and statistics. |
| Order logs | Admin | What happened to an order. |
| Order payments | Admin | Marking an order paid that its provider has not confirmed. |
| Refunds | Admin | Refunds through the provider that took the payment. |
| Order line deliveries | Admin | What a plugin delivered on a line. |
| Order line replacements and returns | Admin | Replacement units and returned stock for lines a plugin ships. |
| Order line refunds | Admin | Refunds of the lines a plugin delivers. |
| Customers | Admin | The store's customers. |
| Subscriptions | Admin | Customers' subscriptions, their renewals, and cancelling. |
| Webhook endpoints | Admin | Where the store's events are sent, and their deliveries. |
| Analytics | Admin | The store's sales measures. |
| Variant insights | Admin | How each of a product's variants sells and brings buyers back. |
| Prepared checkouts | Admin | Unpaid checkouts for a buyer to pay. |
| Webhook events | Admin | Publication of plugin-owned events. |
| Plugin payments | Admin | A plugin-run payment method and its payment reports. |
| Variant keys | Admin | License keys a plugin sells outside the store's checkout. |
| Seller order push | Admin | A paid order's notification on the team's phones. |
| Sending domains | Admin | The store's own sending domain for its emails. |
Each admin operation's page says whether a store API key can call it. A plugin calls only the operations listed above.
Excluded groups
The public reference excludes seller account administration, payment-provider secrets, wallet internals, and operator endpoints. Being left out of the reference does not mean a store API key is refused one: what no key can do lists the operations it is.
Do not share seller credentials to reach an excluded operation. Use a store API key where it is allowed or a supported plugin contract, or coordinate an integration with Novinzo.
Reading the reference
Each operation appears as POST /rpc#<Tag> because all operations share one HTTP endpoint. The fragment labels the page, not a request path.
Send the actual request to POST /rpc. The body contains the full envelope, with the operation schema under payload.
The response schema lists success values and error causes, including InvalidRequest. Authorization lists the required cookies, headers, or invocation token.
The cURL sample follows the operation store identity. Some samples call a same-origin storefront route with plain JSON instead of direct NDJSON.
Set STORE_DOMAIN to the store domain for those samples. Set the named cookie variables to valid cookies from that store session.
OTP request samples save a cookie in OTP_COOKIE_JAR. Use the same cookie file for the subsequent verification request.
Replace schema-derived sample values before you send the request.
The reference has no browser playground because its connections and cookie authentication require the supported callers.
Viewed GET
The order whose viewer the storefront proved the calling plugin acts for. The order comes from the invocation token, never from the request, so a plugin cannot read any other.
GetAnalytics POST
The store's sales measures for sellers and plugins with its analytics:read grant. A store API key can call it, a read-only one included. Plugins can call this RPC with the invocation token after the store grants `analytics:read`.
