novinzodevelopers
RPC

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

CallerAuthenticationAvailable operations
Storefront server clientx-storefront-request: true, plus shopper cookies where required.Public storefront operations and authorized shopper operations.
SellerDashboard session cookie and x-store-id for a store-scoped operation.Seller operations for stores that the seller can access.
Merchant serverAuthorization: Bearer novinzo_sk_…, a store API key.The operations of the key's store that its access covers.
PluginThe 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:

OperationPermissionAdditional restriction
OrderDetailsorders:readReturns the complete order details, including sensitive buyer data.
PreparedCheckoutCreatecheckout:writePrepares an unpaid checkout, not a payment.
WebhookEventPublishcheckout:writeThe calling plugin must own the event type.
PluginPaymentMethodActivatepayments:provideOne method per plugin per store; a store can run several plugins'.
PluginPaymentMethodDeactivatepayments:provideActs only on the calling plugin's payment method.
PluginPaymentReportpayments:provideThe report must match the payment core recorded for that checkout.
GetAnalyticsanalytics:readAggregates only; it returns no order, buyer or payment.
GetVariantInsightsanalytics:readAggregates for one product's variants only.
SendingDomainRegister, Get, Verify, Removeemails:customizeThe store's own sending domain only.
OrderLineDeliveryReportdeliveries:writeOnly lines the calling plugin delivers and ships.
OrderLineReplacementHold, Confirm, Release, Shippedreplacements:writeOnly lines the calling plugin delivers and ships; a replacement never charges the buyer.
OrderLineRestockreturns:writeNever more units than were reported delivered.
OrderLineRefundrefunds:writeOnly lines the calling plugin delivers; core sets the amount.
VariantKeysIssuekeys:issueOnly variants another plugin delivers keys for; idempotent per saleRef.
SellerOrderPushSendpush:sendOnly 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": []
}
FieldMeaning
_tagThe literal Request.
idA string identifier that the response repeats as requestId.
tagThe operation name from the reference.
payloadThe operation payload, or null when it has no payload.
headersAn 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 tagMeaning
FailAn expected error in error. Its _tag identifies the error contract.
DieAn unexpected server defect in defect.
InterruptAn 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

ValueRepresentation
Entity identifiersStrings, usually UUIDs.
DatesISO 8601 strings.
Big integersDecimal strings.
Money{"amountMinorUnits":"1999","currency":"USD"}.
Nullable valuesThe value or null.
Optional keysOmit them when the schema permits omission.
No resultnull 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 categoryStore identity
Store-scoped seller operationsThe seller session and x-store-id.
Permission-protected plugin operationsThe invocation token.
Shopper authentication, orders, invoices, checkout initiation, and prepared checkout pagesThe store domain in Host.
Public store, product, and cart operationsA documented payload identifier.
Checkout status, completion, cancellation, and payment changesThe 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.

GroupServerPurpose
StorefrontStorefrontStore, theme, catalog, and payment data.
Storefront productsStorefrontProduct details and variant availability.
CartStorefrontCurrent prices and availability for a cart.
CheckoutStorefrontPayment sessions.
Storefront prepared checkoutsStorefrontHosted pay-page data.
Payment surchargesStorefrontWhat each payment method adds at checkout.
Customer authStorefrontEmail code sign-in.
Customer ordersStorefrontOrders for the signed-in shopper.
Order accessStorefrontShopper and guest order access.
InvoicesStorefrontAuthorized invoice downloads.
Store creditStorefrontThe signed-in shopper's store credit.
Customer subscriptionsStorefrontThe signed-in shopper's subscriptions, and cancelling one.
Theme previewAdminTheme files and render data.
Plugin installsAdminInstallation and permission grants.
Store-private pluginsAdminPlugins of the store's own, which only it can install.
Store-private plugin deploy tokensAdminTokens that deploy a store-private plugin from CI.
Store-private plugin deploymentsAdminA store-private plugin's deployments.
Store-private plugin previewsAdminThe preview novinzo-plugin dev uploads.
Store-private plugin secretsAdminSecrets for a store-private plugin's Worker.
Store-private plugin repositoryAdminThe GitHub repository a store-private plugin deploys from.
Store-private plugin sourcesAdminStore-private plugins whose source Novinzo hosts.
Store theme sourcesAdminA store theme whose source Novinzo hosts.
Plugin API keysAdminKeys that open the public routes of the plugins granted.
StoreAdminThe store's settings, currency and custom domain.
Store API keysAdminKeys the store's own servers call these RPCs with.
ProductsAdminProducts and their variants.
Product deliveriesAdminKeys and stock, files and delivery webhooks per variant.
OrdersAdminOrders, their details and statistics.
Order logsAdminWhat happened to an order.
Order paymentsAdminMarking an order paid that its provider has not confirmed.
RefundsAdminRefunds through the provider that took the payment.
Order line deliveriesAdminWhat a plugin delivered on a line.
Order line replacements and returnsAdminReplacement units and returned stock for lines a plugin ships.
Order line refundsAdminRefunds of the lines a plugin delivers.
CustomersAdminThe store's customers.
SubscriptionsAdminCustomers' subscriptions, their renewals, and cancelling.
Webhook endpointsAdminWhere the store's events are sent, and their deliveries.
AnalyticsAdminThe store's sales measures.
Variant insightsAdminHow each of a product's variants sells and brings buyers back.
Prepared checkoutsAdminUnpaid checkouts for a buyer to pay.
Webhook eventsAdminPublication of plugin-owned events.
Plugin paymentsAdminA plugin-run payment method and its payment reports.
Variant keysAdminLicense keys a plugin sells outside the store's checkout.
Seller order pushAdminA paid order's notification on the team's phones.
Sending domainsAdminThe 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.

On this page