Read data in the browser

Call GET /app and GET /customer from the merchant's browser with the customer token, and learn every response field.

After this page you will be able to read the app and the merchant's own data from the merchant's browser.

Prerequisites: a customer token from POST /identify handed to your frontend, and the Production Nortly API host (https://id.nortly.app).

Once your backend has the customer token from POST /identify, your frontend can read two resources directly from the Identify API:

EndpointReturns
GET /api/2026-07/appThe app the token belongs to and its environment values
GET /api/2026-07/customerThe merchant's own data: Nortly id, domain, tags, custom fields, review

Both need Authorization: Bearer <customer token> and nothing else. No API key is involved, so nothing secret reaches the browser. See Authentication.

  • Host: the Nortly API, https://id.nortly.app (Production). Use the customer token returned by POST /identify.
  • Token lifetime: 24 hours. On 401, ask your backend for a new token. See Authentication.

The snippets on this page are TypeScript for the browser; drop the types for plain JavaScript. They share one base URL:

const BASE_URL = "https://id.nortly.app/api/2026-07";

CORS

Both endpoints support CORS, so you can call them from any origin with fetch.

  • The browser sends an OPTIONS preflight first because of the Authorization header. The service answers 204 with no body.
  • Access-Control-Allow-Origin echoes the request Origin (or * if there is none). Access is controlled by the token, not by cookies; do not send credentials/cookies.
  • Allowed methods: GET, OPTIONS. Allowed request headers: authorization, content-type.
  • X-Identify-API-Version is exposed to JavaScript (Access-Control-Expose-Headers).
  • The preflight answer can be cached by the browser for 24 hours (Access-Control-Max-Age: 86400).

You never call OPTIONS yourself, but curl is the one reliable way to inspect the preflight answer, because a browser hides it from your code:

curl -i -X OPTIONS "https://id.nortly.app/api/2026-07/customer" \
  -H "Origin: https://app.partner-app.test" \
  -H "Access-Control-Request-Method: GET" \
  -H "Access-Control-Request-Headers: authorization"
HTTP/2 204
x-identify-api-version: 2026-07
access-control-allow-origin: https://app.partner-app.test
access-control-allow-methods: GET, OPTIONS
access-control-allow-headers: authorization, content-type
access-control-expose-headers: x-identify-api-version
access-control-max-age: 86400
vary: origin

CORS headers are present on 200, 401 and 404 answers of these endpoints, so your code can read the status and error. A 503 unavailable or a router-level not_found has no CORS headers, so a browser reports it as a network/CORS failure instead of exposing the status; treat such failures as retryable.

GET /app

const res = await fetch(`${BASE_URL}/app`, {
  headers: { Authorization: `Bearer ${customerToken}` },
});
const app = await res.json();
{
  "id": 4821,
  "isDev": false,
  "environments": [
    { "name": "API_BASE_URL", "type": "string", "value": "https://api.partner-app.test" },
    { "name": "FEATURE_FLAGS", "type": "json", "value": { "betaCheckout": true } }
  ]
}
FieldTypeDescription
idintegerNumeric id of the app in Nortly. A JSON number, not a string.
isDevbooleantrue for a development app, false for a production app.
environmentsarrayNamed values configured for the app, sorted by name. Empty when none are configured.
environments[].namestringName of the value.
environments[].typestringKind of the value as configured in Nortly.
environments[].valueany JSONThe configured value. Its JSON type depends on type.

The result depends only on the app in the token, so it is the same for all merchants of your app.

GET /customer

const res = await fetch(`${BASE_URL}/customer`, {
  headers: { Authorization: `Bearer ${customerToken}` },
});
const customer = await res.json();
{
  "nortlyId": "cus_7f3a91",
  "domain": "acme-test.myshopify.com",
  "tags": ["onboarding", "vip"],
  "customFields": [
    { "name": "Account manager", "type": "text", "value": "Sam Rivera" },
    { "name": "Seats", "type": "number", "value": 12 },
    { "name": "Integrations", "type": "multi_select", "value": ["Klaviyo", "Gorgias"] },
    { "name": "Renewal note", "type": "text", "value": null }
  ],
  "review": {
    "rating": 5,
    "text": "Great app, setup took five minutes.",
    "createdAt": "2026-06-03",
    "updatedAt": "2026-06-03"
  }
}

All five top-level fields are always present.

FieldTypeDescription
nortlyIdstringNortly's identifier of the customer. Opaque; do not parse it.
domainstring or nullThe shop's myshopify domain, as pushed with myshopifyDomain. null if Nortly does not have it yet.
tagsarray of stringTags of the customer, sorted alphabetically ignoring case. [] when none.
customFieldsarrayCustomer-level custom fields that are not private, sorted by name ignoring case. [] when none. Read-only.
customFields[].namestringDisplay name of the field.
customFields[].typestringData type of the field as configured in Nortly.
customFields[].valuestring, number, boolean, array of string, or nullThe merchant's value. If none is stored, the field's default; if there is no default either (or the value is empty), null.
reviewobject or nullThe merchant's App Store review of your app. null when no review is linked to this shop, or when the review could not be loaded for this request (a temporary lookup problem does not fail the call).
review.ratingnumberStar rating.
review.textstringReview text; empty string if the review has no text.
review.createdAtstring (YYYY-MM-DD)Date the review was posted.
review.updatedAtstring (YYYY-MM-DD)Date of the latest change to the review; equals createdAt if never changed.

Only data meant for the merchant is returned. Shopify defaults (name, plan, install, billing and trial status), contacts and companies are deliberately not exposed.

Errors

StatuserrorEndpointWhen
401unauthorizedbothThe token is missing, malformed, expired or (on /customer) revoked, or the header is not Bearer <token> with a capital B. Get a new token from your backend.
404not_found/appThe app of the token no longer exists.
404not_found/customerThe merchant is not known for your app yet. Expected right after the first POST /identify, because the merge is asynchronous: retry with a short backoff.
429n/abothRate limiting in front of the service. Back off and retry.
503unavailablebothTemporary failure on the service side. Retry with backoff.

See Errors for the other 404 variants.

We recommend handling the failures in one place. A 401 means the token expired or was revoked: get a new one from your backend and repeat the call once. A 404 on /customer right after the first identify, and a failed fetch (which is how a browser reports a 503), are worth retrying with a growing delay (0.5 s, 1 s, 2 s):

async function get(path: string, retried = false): Promise<Response> {
  const res = await fetch(`${BASE_URL}${path}`, {
    headers: { Authorization: `Bearer ${customerToken}` },
  });
  if (res.status === 401 && !retried) {
    customerToken = await fetchFreshToken(); // your backend endpoint
    return get(path, true); // once
  }
  return res;
}

Next steps

Example

A complete browser module. It asks your backend for a customer token (the GET /nortly-token endpoint from Authentication), keeps it in memory, renews it shortly before expiresAt or once after a 401, and loads GET /app and GET /customer in parallel with retries. Nothing secret is involved: only the customer token reaches the browser.

const BASE_URL = "https://id.nortly.app/api/2026-07";
const TOKEN_URL = "/nortly-token"; // your backend endpoint, returns { token, expiresAt }
const REFRESH_MARGIN_MS = 5 * 60 * 1000;

type CustomerToken = { token: string; expiresAt: string };
type App = {
  id: number;
  isDev: boolean;
  environments: { name: string; type: string; value: unknown }[];
};
type Customer = {
  nortlyId: string;
  domain: string | null;
  tags: string[];
  customFields: { name: string; type: string; value: unknown }[];
  review: { rating: number; text: string; createdAt: string; updatedAt: string } | null;
};

class ApiError extends Error {
  status: number;
  constructor(status: number, code?: string) {
    super(`Identify API answered ${status}${code ? ` ${code}` : ""}`);
    this.status = status;
  }
}

let current: CustomerToken | null = null;

async function getToken(forceRefresh = false): Promise<string> {
  const fresh = current && Date.parse(current.expiresAt) - Date.now() > REFRESH_MARGIN_MS;
  if (!forceRefresh && current && fresh) return current.token;
  const res = await fetch(TOKEN_URL, { credentials: "same-origin" });
  if (!res.ok) throw new Error(`Could not get a customer token: ${res.status}`);
  current = (await res.json()) as CustomerToken;
  return current.token;
}

const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));

async function get<T>(path: string, retryOn: number[] = [429, 503]): Promise<T> {
  let refreshed = false;
  let force = false;
  for (let attempt = 1; ; attempt++) {
    let res: Response;
    try {
      const token = await getToken(force);
      force = false;
      // No cookies are sent to the Identify API; the token is the only credential.
      res = await fetch(`${BASE_URL}${path}`, { headers: { Authorization: `Bearer ${token}` } });
    } catch (err) {
      // A 503 has no CORS headers, so the browser reports it as a failed fetch.
      if (attempt >= 5) throw err;
      await sleep(500 * 2 ** (attempt - 1));
      continue;
    }

    if (res.ok) return (await res.json()) as T;

    if (res.status === 401 && !refreshed) {
      refreshed = true; // expired or revoked token: ask the backend for a new one, once
      force = true;
      continue;
    }
    if (retryOn.includes(res.status) && attempt < 5) {
      await sleep(500 * 2 ** (attempt - 1));
      continue;
    }
    const { error } = (await res.json().catch(() => ({}))) as { error?: string };
    throw new ApiError(res.status, error);
  }
}

export async function loadIdentifyData(): Promise<{ app: App; customer: Customer }> {
  const [app, customer] = await Promise.all([
    get<App>("/app"),
    // 404 on /customer is expected for a moment after the first identify call.
    get<Customer>("/customer", [404, 429, 503]),
  ]);
  return { app, customer };
}

loadIdentifyData()
  .then(({ app, customer }) => {
    console.log("App", app.id, "environments:", app.environments.map((e) => e.name));
    console.log("Customer", customer.nortlyId, customer.tags, customer.review?.rating ?? "no review");
  })
  .catch((err) => console.error("Could not load Identify data:", err));

Did this page help you?