novinzodevelopers
Plugins

API access credentials

Authenticate merchant servers on plugin routes using Novinzo-issued plugin API keys and the current store invocation.

API access credentials, which the dashboard calls app API keys, are merchant bearer tokens for plugin routes. Novinzo issues, hashes and authenticates them. Your plugin never stores credentials.

A key opens two kinds of route of each plugin it is granted: your /storefront-public routes, which your Worker authenticates as below, and your admin API, which Novinzo authenticates for you.

A call to your public routes has three steps:

  1. The merchant issues a key in the Novinzo dashboard and grants it your plugin.
  2. Their server sends Authorization: Bearer <token> to your route on their store's domain.
  3. Your Worker asks core-for-plugins to authenticate it within the current invocation store.

Plugin routes only

These credentials authenticate your /storefront-public routes and your admin API, not Novinzo's backend RPC. A merchant's own server calls the store's RPCs with a store API key instead, which also opens your admin API with the access its owner gave it.

Turn it on

Coordinate API credential support with Novinzo during registration. Novinzo configures usesApiAccessCredentials for your plugin.

There is no public self-service registration API. External authors do not need access to Novinzo's database or migrations.

How merchants issue a token

The store owner creates every key under Settings › Developers, with Create API key and the App API key type, and chooses the installed plugins whose public routes and admin APIs it opens. One key can open several, so a merchant whose server calls your plugin and another needs one key. Any store member can list the active store's keys, unless the owner has kept them out of apps; issuing them requires the store owner, and revoking them the owner or a store API key with full access.

RPCPayloadResult
PluginApiKeysNoneid, name, plugins, createdAt, expiresAt, revokedAt. Never the token.
IssuePluginApiKey{ name, plugins, ttlDays }{ id, token, expiresAt }. The token appears once.
RevokePluginApiKey{ id }No result. Repeated revocation preserves the first revocation time.

These are seller operations, not plugin-callable RPCs. A plugin that is not installed returns UnknownPluginError, and one that takes no API keys returns PluginTakesNoApiKeysError; either refuses the whole key. Revoking an id that is not one of the active store's keys returns PluginApiKeyNotFoundError.

The token

PropertyValue
Formatnovinzo_api_ followed by a random UUID.
Lifetime7, 30, 60, 90, 180 or 365 days, selected by the seller.
StorageOnly the hexadecimal SHA-256 digest is stored. The token cannot be recovered.
ScopeOne store and the plugins it is granted. Others and other stores are rejected.

Expiry, revocation, uninstall, plugin retirement and store deletion stop access. Renew by issuing another token before expiry.

How requests reach you

Merchants call the storefront forwarder, not a public plugin Worker URL:

curl -X POST "https://<store-domain>/plugins/licenses/storefront-public/activate-license-key" \
  -H "Authorization: Bearer $NOVINZO_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"licenseKey":"ABCD-1234"}'

The storefront forwarder applies these rules:

  • Only authorization, accept, content-type and idempotency-key caller headers are forwarded.
  • The domain's store requires a current plugin installation. Otherwise, the caller receives 404.
  • Requests share the storefront limit of 60 per 60 seconds per IP and store host.
  • Worker redirects become 502. Credentials are not replayed against another URL.

Your Worker receives x-novinzo-store-id and x-novinzo-plugin-invocation. The signed invocation identifies the store and plugin to c4p.

Use the successful credential response as your handler's store scope. Never authorize a bearer credential without the current invocation.

Your admin API

A merchant's server also calls your /admin routes with the key, through the dashboard's plugin proxy:

curl "https://dashboard.novinzo.com/api/plugins/coupons/admin/coupon?page=1&pageSize=20" \
  -H "Authorization: Bearer $NOVINZO_API_TOKEN"

Novinzo checks the key before your Worker sees the call: it must be live, granted your plugin, and of a store that has it installed, and an x-store-id the call names must be the key's store. A key that fails any of the first three gets 401, and one that passes them but is sent with an x-store-id that is not the key's store gets 400. Neither reaches you. The call arrives as a seller's admin call for the key's store does, with x-novinzo-store-id and an invocation token for that store, never the key, so your admin routes need no change and must not call VerifyApiAccessCredential.

Make sure that the token is valid

Call VerifyApiAccessCredential with the inbound invocation header:

POST /api/api-access-credentials/verify
Content-Type: application/json
x-novinzo-plugin-invocation: <inbound invocation token>

{"token":"<merchant bearer credential>"}

Success returns { "storeId": "<uuid>" }. Rejection returns 401 with _tag: "c4p/ApiAccessCredentialRejected".

Malformed, unknown, expired and revoked credentials, keys not granted your plugin, and keys of another store share that rejection. Installation authorization failures remain separate c4p/UnexpectedError failures.

Even a valid credential from another store fails. The invocation, not the bearer alone, fixes the request's store scope.

The licenses implementation

License activation uses this authentication boundary before any license lookup or mutation. Every subsequent query includes the returned store id.

The standalone Worker below exposes /storefront-public/credential-scope. It returns only the authenticated scope and does not implement license activation.

Provision CORE_FOR_PLUGINS with Novinzo as described in Calling the platform.

src/index.js
const uuid = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
const record = (value) => value !== null && typeof value === "object" && !Array.isArray(value);

// Keep incidental serialization and string formatting redacted.
function redactedCredential(value) {
  return {
    reveal: () => value,
    toJSON: () => "[REDACTED]",
    toString: () => "[REDACTED]",
  };
}

export default {
  async fetch(request, env) {
    if (new URL(request.url).pathname !== "/storefront-public/credential-scope") {
      return new Response("Not found", { status: 404 });
    }
    if (request.method !== "POST") return new Response("Method not allowed", { status: 405 });
    const invocation = request.headers.get("x-novinzo-plugin-invocation");
    const storeHeader = request.headers.get("x-novinzo-store-id");
    if (!invocation || !storeHeader || !uuid.test(storeHeader)) {
      return new Response("Missing platform context", { status: 500 });
    }
    const match = /^Bearer\s+(\S+)$/i.exec(request.headers.get("authorization") ?? "");
    if (!match) return new Response("Unauthorized", { status: 401 });
    const credential = redactedCredential(match[1]);

    try {
      const response = await env.CORE_FOR_PLUGINS.fetch(
        "https://core-for-plugins.internal/api/api-access-credentials/verify",
        {
          method: "POST",
          headers: {
            "content-type": "application/json",
            accept: "application/json",
            "x-novinzo-plugin-invocation": invocation,
          },
          body: JSON.stringify({ token: credential.reveal() }),
        },
      );
      const result = await response.json();
      if (
        response.status === 401 &&
        record(result) &&
        result._tag === "c4p/ApiAccessCredentialRejected"
      ) {
        return new Response("Unauthorized", { status: 401 });
      }
      if (
        response.status !== 200 ||
        !record(result) ||
        typeof result.storeId !== "string" ||
        !uuid.test(result.storeId)
      ) {
        return new Response("Credential authentication unavailable", { status: 500 });
      }
      if (result.storeId.toLowerCase() !== storeHeader.toLowerCase()) {
        return new Response("Unauthorized", { status: 401 });
      }
      return Response.json({ storeId: result.storeId });
    } catch {
      // Do not log request objects, credential bodies or caught transport errors.
      return new Response("Credential authentication unavailable", { status: 500 });
    }
  },
};

C4p enforces the invocation-store match itself. The example also compares the returned store with the trusted forwarded header before using it.

Malformed responses never authenticate callers. The example decodes the rejection tag and successful UUID, and fails closed for everything else.

Error mapping

EventPlugin responseMeaning
401 c4p/ApiAccessCredentialRejected401 UnauthorizedCredential rejected for this plugin and invocation store.
Missing or malformed bearer header401 UnauthorizedNo usable merchant credential.
c4p/UnexpectedError or network failure500Authentication failed to run. Not a bad-credential decision.
Malformed c4p response500Authentication result cannot be trusted.

Never log tokens

Never log authorization headers, invocation headers, credential bodies or transport errors containing requests. Log only sanitized failure categories and status codes.

Keep secrets redacted until sending the c4p request. Redaction does not make request or error objects safe to log.

Authenticate every request. Do not persist merchant tokens or cache successful credential lookups.

Uninstall

Uninstalling your plugin removes it from every key of that store in the same transaction. The keys keep opening the store's other plugins. Reinstalling does not give your plugin back to them.

Your store-scoped plugin data remains in your database. Per-request authentication rejects the key on its next use.

Next steps

On this page