Push merchant data

Send merchant details and contacts with POST /identify, understand partial updates and the asynchronous merge.

After this page you will be able to send merchant details and contacts to Nortly from your backend and obtain a customer token.

Prerequisites: an API key for your app (Authentication), the Production Nortly API host and Node.js 20 or later for the examples (TypeScript; drop the types for plain JavaScript).

POST /api/2026-07/identify tells Nortly about one merchant (shop) that uses your app and returns a customer token for that merchant. Call it from your backend, for example when the merchant opens your app or when their data changes.

  • Host: the Nortly API, https://id.nortly.app (Production).
  • Credential: your API key, as Authorization: Bearer <api key>. See Authentication.
  • Body: a JSON object. Send Content-Type: application/json.

Request fields

Only shopId is required. Every other field is optional.

FieldTypeRequiredDescription
shopIdstringyesShopify shop id: the numeric id ("1234567890") or the full GID ("gid://shopify/Shop/1234567890"). A value that does not start with gid:// is treated as the numeric id. Must not be empty.
myshopifyDomainstringnoThe shop's *.myshopify.com domain. Returned as domain by GET /customer.
namestringnoShop or company name.
emailstringnoMain contact email of the shop.
countrystringnoCountry, free text.
industrystringnoIndustry, free text.
shopifyPlanstringnoThe shop's Shopify plan, free text, for example Basic or Plus. Stored in Nortly; not returned by GET /customer.
shopDescriptionstringnoShort description of what the shop sells.
domainstringnoThe shop's public (custom) domain.
contactsarray of contactnoPeople at the merchant. See below.

Text fields must be strings. null or any other type is rejected with 400. Unknown properties are ignored.

Contact fields

FieldTypeDescription
emailstringIdentifies the contact (exact match). A contact without email is ignored.
namestringFull name.
phonestringPhone number in any format.
labelstringRole: primary, secondary, billing, technical, sales, customer_support, user, intake or customer. Any other value is ignored (the stored label is kept) and does not cause an error.
jobTitlestringJob title.

Send contact values as strings. Contact fields are not validated when you call the endpoint.

Partial-update semantics

You never have to send the full record.

  • Omitted fields keep their stored value. Send only what changed.
  • A field you send replaces the stored value, including an empty string "". To leave a value alone, leave the field out.
  • The merchant is created if it does not exist. If it exists, only the fields you send are updated. A request with just shopId creates the merchant when needed, links it to your app and issues a token, and changes nothing else.
  • Contacts are matched by email. An existing contact is updated with the fields you send (omitted contact fields keep their value); an unknown email creates a contact; each contact is linked to the shop. Contacts you do not list are never removed, and a contact edited in Nortly keeps its edits for fields you leave out.

Asynchronous merge

The response is sent as soon as the request is validated and a token is issued. The merge into Nortly happens afterwards.

  • 200 means accepted, not already visible. There is no completion callback.
  • For a merchant that was never identified before, GET /customer may answer 404 not_found for a short time. Retry with a short backoff.
  • Data that cannot be stored is dropped without an error being reported to you. Keep the payload within the fields above and send strings.
  • Repeating the same call is safe: the stored data ends up the same. Each call issues a new token.

Request examples

The snippets below share one small helper that sends the request and returns the token. It runs on your backend, where the API key lives.

async function identify(body: Record<string, unknown>) {
  const res = await fetch("https://id.nortly.app/api/2026-07/identify", {
    method: "POST",
    headers: {
      Authorization: `Bearer ${process.env.NORTLY_API_KEY}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify(body),
  });
  if (!res.ok) throw new Error(`POST /identify failed: ${res.status}`);
  return (await res.json()) as { token: string; expiresAt: string };
}

Minimal: only the required field.

await identify({ shopId: "1234567890" });

Full: shop details and two contacts.

await identify({
  shopId: "gid://shopify/Shop/1234567890",
  myshopifyDomain: "acme-test.myshopify.com",
  name: "Acme Test Store",
  email: "[email protected]",
  country: "US",
  industry: "Apparel",
  shopifyPlan: "Basic",
  shopDescription: "Organic cotton basics, shipped worldwide.",
  domain: "shop.acme-test.example",
  contacts: [
    { name: "Jane Doe", email: "[email protected]", phone: "+1 555 0100", label: "primary", jobTitle: "Founder" },
    { email: "[email protected]", label: "billing" },
  ],
});

Partial update: only the country changes, everything else is kept.

await identify({ shopId: "1234567890", country: "CA" });

Response

200 OK with the customer token. Use it in the browser: see Read data in the browser.

{
  "token": "EXAMPLE-NOT-A-REAL-TOKEN",
  "expiresAt": "2026-07-16T09:30:00.000Z"
}
FieldTypeDescription
tokenstringCustomer token for GET /app and GET /customer. Opaque; bound to your app and this merchant.
expiresAtstring (UTC date-time)Expiry of the token, 24 hours after issue, for example 2026-07-16T09:30:00.000Z.

The response headers include X-Identify-API-Version and X-Request-Id (a UUID). Quote the request id when you contact support.

Errors

StatuserrorWhenWhat to do
400invalid_jsonThe body is not valid JSON.Fix the body.
400invalid bodyThe body is valid JSON but not an object (null, a number, a string, a boolean).Send a JSON object.
400shopId is requiredshopId is missing, empty or not a string.Send a non-empty string.
400<field> must be a stringA text field (myshopifyDomain, name, email, country, industry, shopifyPlan, shopDescription, domain) is not a string, for example null.Send a string or omit the field.
400contacts must be an arraycontacts is not an array.Send an array.
401unauthorizedThe Authorization header is missing or is not Bearer <api key>, or the key is malformed, unknown or revoked.Use the Nortly API host and a valid key.
429n/aRate limiting in front of the service.Back off and retry.
503unavailableTemporary failure on the service side.Retry with exponential backoff; retrying is safe.

The 400 validation messages are human-readable text, so match on the status code rather than on the exact wording. See Errors for the full error contract.

We recommend retrying only what can succeed on a second try. A 400 or 401 needs a fixed request or key; a 429 or 503 is worth repeating after a growing delay:

const retryable = (status: number) => status === 429 || status === 503;

Example: a Shopify app sends the signed-in user

Use this when your app is an embedded Shopify app and you want the staff member who opened it to appear in Nortly as a contact.

1. Get the online access token. The staff member opens your app and Shopify App Bridge gives your frontend a session token (an ID token). Your backend exchanges it for an online access token with Shopify's token exchange, a POST to https://{shop}.myshopify.com/admin/oauth/access_token with these form fields:

FieldValue
client_id, client_secretYour app's credentials.
grant_typeurn:ietf:params:oauth:grant-type:token-exchange
subject_tokenThe ID token from App Bridge.
subject_token_typeurn:ietf:params:oauth:token-type:id_token
requested_token_typeurn:shopify:params:oauth:token-type:online-access-token

The online token is tied to that staff member and is valid for 24 hours or until they log out of the Shopify admin. The response includes an associated_user object with the staff member's email, email_verified, account_owner and collaborator flags and, when Shopify returns them, first_name and last_name. A 400 from Shopify means the ID token is stale: get a fresh one from App Bridge and retry. See Shopify's online access tokens and token exchange guides.

2. Turn it into a contact (three lines).

const user = tokenResponse.associated_user; // from the exchange above
const label = user.collaborator ? "customer_support" : user.account_owner ? "primary" : "user";
const contact = { email: user.email, name: `${user.first_name ?? ""} ${user.last_name ?? ""}`.trim(), label };

The label follows who the person is. Check collaborator first:

associated_userlabelWho
collaborator: truecustomer_supportA partner or agency account, not merchant staff.
account_owner: trueprimaryThe store owner.
anything elseuserOther staff of the merchant.

Shopify advises trusting email only when email_verified is true; skip the contact when it is not.

3. Send it with the shop.

await fetch("https://id.nortly.app/api/2026-07/identify", {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.NORTLY_API_KEY}`, "Content-Type": "application/json" },
  body: JSON.stringify({
    shopId: shop.id,
    name: shop.name,
    // send a text field only when it has a value: null is rejected with 400
    ...(shop.description ? { shopDescription: shop.description } : {}),
    contacts: [contact],
  }),
});

Which contact data you can send

  • Phone. associated_user does not contain a phone number, so send phone only when the person gave it to your app (for example in a form). Shopify's Admin API can return a staff member's phone (StaffMember.phone), but it needs the read_users access scope, which Shopify enables only for finance embedded apps and for apps installed on Shopify Plus or Advanced stores, on request to Shopify Support. Do not rely on it. When you omit phone, Nortly keeps the phone it already has for that contact.
  • Shop description. shopDescription is optional text about what the shop sells. Shopify has no general store description. The closest field is shop.description in the Admin GraphQL API, which is the shop's meta description for search engines: it may be empty or marketing copy. Send it as it is, trimmed, when it has a value, and leave the field out otherwise. It is public merchant text, not personal data.

Next steps

Example

A complete script for your backend (Node.js 20 or later). It pushes one merchant with a contact, retries 429 and 503 with exponential backoff, reports the other errors and prints the customer token. Save it as push-merchant.ts and run it with NORTLY_API_KEY=<your API key> npx tsx push-merchant.ts.

const IDENTIFY_URL = "https://id.nortly.app/api/2026-07/identify";
const API_KEY = process.env.NORTLY_API_KEY;

type Contact = {
  email: string;
  name?: string;
  phone?: string;
  label?: string;
  jobTitle?: string;
};

type IdentifyRequest = {
  shopId: string;
  myshopifyDomain?: string;
  name?: string;
  email?: string;
  country?: string;
  industry?: string;
  shopifyPlan?: string;
  shopDescription?: string;
  domain?: string;
  contacts?: Contact[];
};

type IdentifyResponse = { token: string; expiresAt: string };

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

async function identify(payload: IdentifyRequest, maxAttempts = 5): Promise<IdentifyResponse> {
  if (!API_KEY) throw new Error("Set NORTLY_API_KEY to your API key.");

  for (let attempt = 1; ; attempt++) {
    const res = await fetch(IDENTIFY_URL, {
      method: "POST",
      headers: { Authorization: `Bearer ${API_KEY}`, "Content-Type": "application/json" },
      body: JSON.stringify(payload),
    });

    if (res.ok) {
      console.log("Accepted, request id:", res.headers.get("x-request-id"));
      return (await res.json()) as IdentifyResponse;
    }

    const { error } = (await res.json().catch(() => ({}))) as { error?: string };

    // 429 (rate limiting) and 503 (temporary failure): repeating the same body is safe.
    if ((res.status === 429 || res.status === 503) && attempt < maxAttempts) {
      await sleep(500 * 2 ** (attempt - 1));
      continue;
    }
    if (res.status === 400) throw new Error(`Invalid request: ${error}. Fix the payload.`);
    if (res.status === 401) throw new Error("401 unauthorized: check that the API key is valid and not revoked, and the host.");
    throw new Error(`POST /identify failed: ${res.status} ${error ?? ""}`.trim());
  }
}

async function main(): Promise<void> {
  // Send a text field only when it has a value: null is rejected with 400.
  const description = process.env.SHOP_DESCRIPTION;

  const { token, expiresAt } = await identify({
    shopId: process.env.NORTLY_SHOP_ID ?? "1234567890",
    myshopifyDomain: "acme-test.myshopify.com",
    name: "Acme Test Store",
    country: "US",
    ...(description ? { shopDescription: description } : {}),
    contacts: [{ email: "[email protected]", name: "Jane Doe", label: "primary" }],
  });

  // The merge into Nortly happens after the response: 200 means "accepted".
  console.log(`Token valid until ${expiresAt}: hand it to your frontend (${token.length} characters).`);
}

main().catch((err) => {
  console.error(err instanceof Error ? err.message : err);
  process.exitCode = 1;
});

Did this page help you?