Build an app end to end

From an API key to a live, reviewed app, worked through as a crosslister that syncs a creator's products, stock and orders.

Embed
Preview of the card
<a href="https://linkyhub.net/docs/build-an-app"><img src="https://linkyhub.net/docs/_api/public/orgs/2fd2a4b7-b627-4925-af1e-1c51bf890403/spaces/c4b920fb-a433-40b5-b354-ff84bf0c3eb1/pages/8d430caa-d990-4295-a9c6-7634f92676ff/social-card.svg?v=3e7ae33eec8b" alt="Build an app end to end" width="600" height="315"></a>

This guide builds one real app from start to finish: a crosslister. It lists a creator's Linky Hub products on other marketplaces, keeps stock in step when something sells elsewhere, and pulls Linky Hub orders in so the creator can fulfil them in one place. Creators connect their Linky Hub shop to it with OAuth.

Every endpoint below is in the OpenAPI document. Code samples use $LINKHUB_URL for https://linkyhub.net.

1. Get access

You need an OAuth app (a client id and secret) owned by a Linky Hub account. Usually the account owner is the person who commissioned the app, and you are the developer.

The account owner creates a personal API key: Dashboard → Developers → API keys, with apps:write (and apps:read) ticked, and a short expiry. They hand the key (ak_…) to you over a secure channel. apps:read and apps:write are only ever granted to personal keys; no OAuth token can carry them.

You register the app with it. The account needs a confirmed email address.

curl -X POST "$LINKHUB_URL/api/v3/apps" \
  -H "Authorization: Bearer $LINKHUB_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "ListEverywhere",
    "slug": "listeverywhere",
    "tagline": "List your products on every marketplace and keep stock in step",
    "homepageUrl": "https://listeverywhere.example",
    "redirectUris": ["https://listeverywhere.example/oauth/linkhub/callback"],
    "category": "commerce",
    "scopes": ["products:read", "products:write", "inventory:write", "orders:read", "orders:write"],
    "acceptTerms": true
  }'
{ "id": "clx…", "clientId": "…", "clientSecret": "…" }

Store clientId and clientSecret in your secret manager straight away. The secret is in this response only. If you lose it, POST /api/v3/apps/{id}/rotate-secret issues a new one (the old one keeps working for 24 hours). The full field list is in Personal API keys.

The owner can do the same thing without a key: Dashboard → Developers → Register app, as described in Register an app.

A new app starts in development. It works end to end, but only the account that owns it can authorise it. Build and test against that account. When you are ready for other creators, submit it for review (see Going live); once a Linky Hub admin approves it, anyone can connect it.

2. Connect a creator with OAuth

Linky Hub's authorization server is at https://linkyhub.net/atlas. Its discovery document is at $LINKHUB_URL/.well-known/oauth-authorization-server/atlas, and the API's protected-resource metadata is at $LINKHUB_URL/.well-known/oauth-protected-resource/api/v3.

Issuer

$LINKHUB_URL/atlas

Authorize

$LINKHUB_URL/atlas/oauth2/authorize

Token

$LINKHUB_URL/atlas/oauth2/token

Revoke

$LINKHUB_URL/atlas/oauth2/revoke

Resource (audience)

urn:linkhub:api

Flow

Authorization code with PKCE, S256 only

Send the creator to authorize

Generate a PKCE verifier and a state, keep both in the user's session, and redirect:

import { createHash, randomBytes } from 'node:crypto';

const LINKHUB_URL = process.env.LINKHUB_URL!; // Linky Hub's address
const CLIENT_ID = process.env.LINKHUB_CLIENT_ID!;
const CLIENT_SECRET = process.env.LINKHUB_CLIENT_SECRET!;
const REDIRECT_URI = 'https://listeverywhere.example/oauth/linkhub/callback';

const SCOPES = ['openid', 'offline_access', 'products:read', 'products:write', 'inventory:write', 'orders:read', 'orders:write'];

const base64url = (bytes: Buffer) => bytes.toString('base64url');

export function startConnect(session: { verifier?: string; state?: string }) {
  const verifier = base64url(randomBytes(32));
  const state = base64url(randomBytes(16));
  session.verifier = verifier;
  session.state = state;

  const url = new URL('/atlas/oauth2/authorize', LINKHUB_URL);
  url.search = new URLSearchParams({
    response_type: 'code',
    client_id: CLIENT_ID,
    redirect_uri: REDIRECT_URI,          // exactly as registered
    scope: SCOPES.join(' '),             // openid is required; offline_access gets you a refresh token
    resource: 'urn:linkhub:api',         // the Linky Hub API
    state,
    code_challenge: base64url(createHash('sha256').update(verifier).digest()),
    code_challenge_method: 'S256',
  }).toString();
  return url.toString();                 // redirect the browser here
}

Parameter

Value

response_type

code

client_id

Your clientId

redirect_uri

One of your registered redirect URIs, matched exactly

scope

Space-separated. openid is required; add offline_access for a refresh token, then the API scopes

resource

urn:linkhub:api

state

A random value you check on the way back

code_challenge

Base64url SHA-256 of the verifier

code_challenge_method

S256

The creator signs in to Linky Hub and sees your app's name and every scope you asked for, in plain words. They can untick any scope except openid. A creator may well let you read products but not change them. So never assume you got what you asked for: read scope from the token response, store it with the connection, and switch features off in your UI when a scope is missing.

The creator is then sent back to your redirect_uri with code and state (or with error=access_denied if they declined). The code lasts 60 seconds.

Exchange the code

Authenticate with your client secret using HTTP Basic (client_secret_basic) and send the verifier:

type TokenResponse = {
  access_token: string;
  token_type: 'Bearer';
  expires_in: number;      // seconds; 3600
  refresh_token?: string;  // only with offline_access
  id_token?: string;
  scope: string;           // what the creator actually granted
};

const basic = 'Basic ' + Buffer.from(`${encodeURIComponent(CLIENT_ID)}:${encodeURIComponent(CLIENT_SECRET)}`).toString('base64');

async function token(params: Record<string, string>): Promise<TokenResponse> {
  const response = await fetch(`${LINKHUB_URL}/atlas/oauth2/token`, {
    method: 'POST',
    headers: { Authorization: basic, 'Content-Type': 'application/x-www-form-urlencoded' },
    body: new URLSearchParams(params),
  });
  if (!response.ok) throw new Error(`token ${response.status}: ${await response.text()}`);
  return response.json();
}

export async function finishConnect(query: URLSearchParams, session: { verifier?: string; state?: string }) {
  if (query.get('error')) throw new Error(`creator declined: ${query.get('error')}`);
  if (!session.state || query.get('state') !== session.state) throw new Error('state mismatch');

  const tokens = await token({
    grant_type: 'authorization_code',
    code: query.get('code')!,
    redirect_uri: REDIRECT_URI,
    code_verifier: session.verifier!,
    resource: 'urn:linkhub:api',
  });

  const granted = new Set(tokens.scope.split(' '));
  // Save tokens.refresh_token (encrypted), the expiry and `granted` against your user.
  return { tokens, granted, canFulfil: granted.has('orders:write') };
}

The access token is a JWT for the audience urn:linkhub:api and lasts one hour (expires_in: 3600). Send it as Authorization: Bearer … on every API call.

Refresh

With offline_access you get a refresh token. It lasts up to 30 days, and expires sooner if it goes unused for 30 days. Refresh shortly before the access token expires, or once when the API answers 401 invalid_token:

export async function refresh(refreshToken: string) {
  const tokens = await token({ grant_type: 'refresh_token', refresh_token: refreshToken, resource: 'urn:linkhub:api' });
  // If the response carries a new refresh_token, store it and drop the old one.
  return tokens;
}

If refreshing fails with invalid_grant, the creator has disconnected you or the token has expired: mark the connection broken and ask them to connect again.

Revoke

When the creator disconnects inside your app, revoke the refresh token (that ends the grant) and delete what you stored:

export async function disconnect(refreshToken: string) {
  await fetch(`${LINKHUB_URL}/atlas/oauth2/revoke`, {
    method: 'POST',
    headers: { Authorization: basic, 'Content-Type': 'application/x-www-form-urlencoded' },
    body: new URLSearchParams({ token: refreshToken, token_type_hint: 'refresh_token' }),
  });
}

Creators can also disconnect you from Apps in their Linky Hub dashboard. Their tokens stop working at once, and if your webhook subscribes to grant.revoked you are told (see Webhooks). Stop syncing that creator when it arrives.

The full OAuth reference, including the device flow for apps with no browser, is in Connect with OAuth.

3. Choose scopes

Ask for the fewest scopes the app needs. Every scope is a line the creator reads on the consent screen, and a short, obviously justified list gets approved by creators and by Linky Hub's review. For a crosslister:

Scope

Why the crosslister needs it

openid

Required. Identifies the creator.

offline_access

A refresh token, so syncing keeps working after the first hour.

products:read

Read products, variants, images, prices and stock to list them elsewhere. Also needed for the product.updated and inventory.low webhooks.

products:write

Only if your app creates or edits Linky Hub products (for example importing a listing from another marketplace).

inventory:write

Set stock when an item sells elsewhere. It changes stock and nothing else, so a sync-only app does not need products:write.

orders:read

Read Linky Hub sales so you can decrement stock elsewhere and show orders. Also needed for the order.* webhooks.

orders:write

Only if your app fulfils orders (marks them shipped, with tracking), or to make test orders while you build.

orders:read_customer

Sensitive. Buyers' names, emails and shipping addresses. Ask only if your app prints labels or ships; without it, orders come back without a buyer field.

orders:refund

Sensitive; approved apps only. Refunds. Leave it out unless refunds are a core feature.

Least privilege in practice: a crosslister that only pushes Linky Hub listings outward and keeps stock in step needs products:read inventory:write orders:read. Add products:write for importing, orders:write for fulfilment, and orders:read_customer only when you actually ship. Because the creator can untick anything except openid, design each feature to degrade cleanly when its scope is missing.

Scopes are fixed in the app registration (scopes on POST /apps). You can only ask creators for scopes the app registered, and an approved app cannot add scopes. Every scope is described in Scopes.

4. The crosslister flows

All calls go to $LINKHUB_URL/api/v3 with Authorization: Bearer $ACCESS_TOKEN. Money is always in the smallest currency unit (cents), and timestamps are ISO 8601.

A small helper used below:

async function api<T>(accessToken: string, path: string, init: RequestInit = {}): Promise<T> {
  const response = await fetch(`${LINKHUB_URL}/api/v3${path}`, {
    ...init,
    headers: { Authorization: `Bearer ${accessToken}`, 'Content-Type': 'application/json', ...init.headers },
  });
  if (response.status === 429) {
    const wait = Number(response.headers.get('retry-after') ?? '1');
    await new Promise((resolve) => setTimeout(resolve, wait * 1000));
    return api(accessToken, path, init);
  }
  const body = await response.json();
  if (!response.ok) throw Object.assign(new Error(body.message), { code: body.error, status: response.status });
  return body as T;
}

List products, with variants and images

GET /products (products:read) returns products newest first, each with its images (cover first), variants, stock and sales count. Page with limit (default 50, max 200) and cursor. Filter with updatedSince (ISO 8601: products changed at or after it, a variant's change included) and externalId (the product you tagged with that id).

curl "$LINKHUB_URL/api/v3/products?limit=100" -H "Authorization: Bearer $ACCESS_TOKEN"
{
  "data": [
    {
      "id": "cm3prod1",
      "blockId": "cm3block1",
      "kind": "DIGITAL_DOWNLOAD",
      "name": "Logo hoodie",
      "description": "Heavyweight cotton.",
      "images": [{ "id": "cm3img1", "url": "https://…/hoodie.jpg", "alt": "Black hoodie, front", "position": 0 }],
      "priceCents": 4500,
      "compareAtCents": null,
      "currency": "USD",
      "isActive": true,
      "soldOut": false,
      "inventory": null,
      "variants": [
        { "id": "cm3var1", "name": "M / Black", "sku": "HOOD-M-BLK", "priceCents": null, "compareAtCents": null, "inventory": 12, "position": 0, "isActive": true },
        { "id": "cm3var2", "name": "L / Black", "sku": "HOOD-L-BLK", "priceCents": 4800, "compareAtCents": null, "inventory": 3, "position": 1, "isActive": true }
      ],
      "salesCount": 41,
      "source": "block",
      "editableInPlace": false,
      "externalId": "crossly-8812",
      "url": "https://linkyhub.net/ada#block-cm3block1",
      "updatedAt": "2026-11-20T14:02:11.000Z"
    }
  ],
  "products": ["… the same array, deprecated …"],
  "nextCursor": "cm3prod1"
}

The list is in data. The same array also comes under products for older integrations; that key is deprecated, so read data.

  • A variant with priceCents: null uses the product's price. A variant with inventory: null is untracked; a product with inventory: null is unlimited.

  • Use the variant sku to match listings on other marketplaces.

  • source tells you who owns the product: block (sold from the creator's page), shopify or print-on-demand (owned by that sync; do not fight it), or external.

  • externalId is your own id for the product, as you set it. Only your app sees it; for any other app it is null.

  • url links to the product on the creator's public page (an anchor on its block), or is null when no block sells it.

  • updatedAt is the latest change to the product or any of its variants. For an incremental sync, keep the time you last started one and ask for ?updatedSince= that time.

GET /products/{productId} returns one product in the same shape.

Create and update a product

POST /products (products:write) creates a product and the block that sells it on the creator's page. It is live immediately. name and priceCents are required. Images must already be at a URL; to host one on Linky Hub, upload it first with POST /media (media:write, multipart/form-data with a file part) and use the url it returns.

curl -X POST "$LINKHUB_URL/api/v3/products" \
  -H "Authorization: Bearer $ACCESS_TOKEN" -H "Content-Type: application/json" \
  -d '{
    "name": "Logo hoodie",
    "description": "Heavyweight cotton.\nRuns large.",
    "priceCents": 4500,
    "currency": "USD",
    "externalId": "crossly-8812",
    "images": [{ "url": "https://cdn.example/hoodie.jpg", "alt": "Black hoodie, front" }],
    "variants": [
      { "name": "M / Black", "sku": "HOOD-M-BLK", "inventory": 12 },
      { "name": "L / Black", "sku": "HOOD-L-BLK", "inventory": 3, "priceCents": 4800 }
    ]
  }'

It answers 201 with the product, in the shape above. Other optional fields: compareAtCents, soldOut, inventory (for a product without variants), allowCustomAmount and minimumCents, and pageId (defaults to the main page).

  • description is plain text up to 5,000 characters. Line breaks are kept, and a long one shows a "Read more" on the page.

  • externalId (up to 255 characters) is your id for the product, unique per creator for your app: a second product with the same one is 409 conflict. Set or change it on PATCH too, clear it with null, and find the product again with GET /products?externalId=.

  • Send an Idempotency-Key header (up to 200 characters) so a retry is safe: see Idempotency.

For shipped goods, send "isPhysical": true on create (or on a PATCH later). Checkout then collects the buyer's shipping address, and the product's orders come back with isPhysical: true and the address under orders:read_customer. Leave it off for downloads.

PATCH /products/{productId} changes only the fields you send. images replaces the whole gallery. isActive: false hides a product without deleting it; DELETE /products/{productId} works only on a product that has never sold.

curl -X PATCH "$LINKHUB_URL/api/v3/products/cm3prod1" \
  -H "Authorization: Bearer $ACCESS_TOKEN" -H "Content-Type: application/json" \
  -d '{ "priceCents": 3900, "compareAtCents": 4500 }'

Variants have their own endpoints: POST /products/{productId}/variants adds one (name required; sku, priceCents, compareAtCents, inventory, isActive optional), PATCH /variants/{variantId} changes one, and DELETE /variants/{variantId} removes one.

Set stock

This is the call a crosslister makes most. It needs only inventory:write, and it sets an absolute count (not a delta), so a retry is harmless.

For a product without variants, PUT /products/{productId}/inventory. 0 marks it sold out; a positive number un-sells it; null means unlimited.

curl -X PUT "$LINKHUB_URL/api/v3/products/cm3prod1/inventory" \
  -H "Authorization: Bearer $ACCESS_TOKEN" -H "Content-Type: application/json" \
  -d '{ "inventory": 7 }'

For one variant, PUT /variants/{variantId}/inventory, where null means untracked:

curl -X PUT "$LINKHUB_URL/api/v3/variants/cm3var2/inventory" \
  -H "Authorization: Bearer $ACCESS_TOKEN" -H "Content-Type: application/json" \
  -d '{ "inventory": 2 }'

The product endpoint answers with the updated product; the variant endpoint with the updated variant.

// Something sold on another marketplace: read the current Linky Hub count, then set it.
async function soldElsewhere(accessToken: string, productId: string, variantId: string, quantity: number) {
  const product = await api<{ variants: { id: string; inventory: number | null }[] }>(accessToken, `/products/${productId}`);
  const current = product.variants.find((variant) => variant.id === variantId)?.inventory;
  if (current == null) return; // untracked: nothing to keep in step
  await api(accessToken, `/variants/${variantId}/inventory`, {
    method: 'PUT',
    body: JSON.stringify({ inventory: Math.max(0, current - quantity) }),
  });
}

Because writes are absolute, keep one source of truth for the count in your app and avoid read-modify-write races between workers for the same SKU (one queue per creator works well).

List and read orders

GET /orders (orders:read) returns sales newest first. Filter with status (PENDING, PAID, FULFILLED, REFUNDED, PARTIALLY_REFUNDED, FAILED, CANCELED), productId, since (ISO 8601: orders created at or after it) and updatedSince (orders changed at or after it: paid, fulfilled, tracking edited, refunded), and page with limit and cursor.

For incremental sync, keep the newest updatedAt you have seen and ask for updatedSince that instant next time. Page through every result: the order is still newest-created first, not by update time.

curl "$LINKHUB_URL/api/v3/orders?status=PAID&since=2026-11-01T00:00:00Z" -H "Authorization: Bearer $ACCESS_TOKEN"
{
  "orders": [
    {
      "id": "cm3ord1",
      "status": "PAID",
      "amountCents": 4800,
      "subtotalCents": 4800,
      "discountCents": 0,
      "currency": "USD",
      "productId": "cm3prod1",
      "productName": "Logo hoodie",
      "variantId": "cm3var2",
      "variantName": "L / Black",
      "quantity": 1,
      "isPhysical": false,
      "provider": "STRIPE",
      "paidAt": "2026-11-21T09:15:42.000Z",
      "refundedCents": 0,
      "refundedAt": null,
      "createdAt": "2026-11-21T09:15:30.000Z",
      "updatedAt": "2026-11-21T09:15:42.000Z",
      "test": false,
      "fulfilledAt": null,
      "trackingNumber": null,
      "carrier": null,
      "trackingUrl": null,
      "platformFeeCents": 0,
      "processingFeeCents": null,
      "netCents": null,
      "shippingCents": 0,
      "taxCents": 0,
      "buyer": { "email": "sam@example.com", "name": "Sam Lee", "shippingAddress": null }
    }
  ],
  "nextCursor": null
}
  • Each order is one unit of one product (quantity is always 1).

  • buyer is present only when the token was granted orders:read_customer. Without it the field is absent, not empty.

  • test: true marks a test order. Leave those out of anything that counts real sales.

GET /orders/{orderId} returns one order in the same shape.

Fees

Linky Hub takes no cut of any sale, on any plan. Checkout charges on the creator's own Stripe or PayPal account with no application fee, so:

  • platformFeeCents is always 0.

  • processingFeeCents is what Stripe or PayPal kept. Linky Hub does not record it on the order, so it is null (the creator sees it in their Stripe or PayPal dashboard). It is 0 on a test order.

  • netCents is amountCents minus both fees, so it is null whenever processingFeeCents is.

  • shippingCents and taxCents are 0: checkout adds no separate shipping or tax line. The product price is what the buyer pays.

Physical goods

Set "isPhysical": true on a product (create or PATCH). From then on:

  1. Checkout collects a shipping address. Stripe and PayPal validate it.

  2. Paid orders come back with isPhysical: true and stay PAID until you fulfil them. Nothing flips them on its own, unlike a download.

  3. With orders:read_customer, buyer.shippingAddress has the address in one shape, whichever provider took the payment:

{
  "name": "Sam Lee",
  "line1": "1 Main St",
  "line2": null,
  "city": "Springfield",
  "state": "IL",
  "postalCode": "62701",
  "country": "US",
  "phone": null
}

country is ISO 3166-1 alpha-2. Any field the buyer or provider did not give is null, and phone usually is. shippingAddress itself is null for a digital order.

  1. Ship it, then call fulfil with the tracking (below).

Mark an order fulfilled

POST /orders/{orderId}/fulfil (orders:write) marks a PAID order FULFILLED, sets fulfilledAt, and answers { "ok": true }. Calling it on an order that is already fulfilled also succeeds, so a retry is safe. Any other status is refused with 400 invalid_request.

All the body fields are optional:

Field

trackingNumber

Up to 100 characters.

carrier

Up to 50 characters, such as USPS or Royal Mail.

trackingUrl

An http(s) URL.

notifyBuyer

true emails the buyer that it shipped, with the tracking. Never sent for a test order.

curl -X POST "$LINKHUB_URL/api/v3/orders/cm3ord1/fulfil" \
  -H "Authorization: Bearer $ACCESS_TOKEN" -H "Content-Type: application/json" \
  -d '{ "carrier": "USPS", "trackingNumber": "9400111899223344556677", "trackingUrl": "https://tools.usps.com/go/TrackConfirmAction?tLabels=9400111899223344556677", "notifyBuyer": true }'

To correct the tracking, call it again. If you send any of the three tracking fields, all three are replaced, and a field you leave out becomes null. fulfilledAt keeps the first time. GET /orders/{orderId} returns trackingNumber, carrier, trackingUrl and fulfilledAt. order.fulfilled fires once per order, on the first fulfil. The creator can do the same from Dashboard → Orders → Mark shipped.

Refunds

POST /orders/{orderId}/refunds needs orders:refund, which is granted only to approved apps (it moves money). It refunds on the creator's own payment account, in full or in part:

curl -X POST "$LINKHUB_URL/api/v3/orders/cm3ord1/refunds" \
  -H "Authorization: Bearer $ACCESS_TOKEN" -H "Content-Type: application/json" \
  -H "Idempotency-Key: refund-ebay-1234567890" \
  -d '{ "amountCents": 1000, "reason": "Returned on another marketplace" }'
{ "id": "cm3ref1", "orderId": "cm3ord1", "amountCents": 1000, "reason": "Returned on another marketplace", "status": "succeeded", "createdAt": "2026-11-22T10:00:00.000Z" }
  • Leave out amountCents to refund everything not yet refunded. You cannot refund more than was paid.

  • The order becomes PARTIALLY_REFUNDED or REFUNDED. Only PAID, FULFILLED and PARTIALLY_REFUNDED orders can be refunded; anything else is 409 conflict.

  • status is succeeded, pending or failed.

  • PayPal orders cannot be refunded through the API (409); the creator refunds them from PayPal.

  • GET /orders/{orderId}/refunds (orders:read) lists refunds on an order as { "refunds": [...] }.

Test mode

While your app is in development (not yet approved), you can make test orders on your own account. You can also make them with a personal API key. Test orders let you run the whole flow before any real sale: order.paid, fulfil and refund.

POST /test/orders (orders:write) creates a PAID order on one of the creator's products, flagged "test": true, and fires order.paid through the same code a real sale uses. It answers 201 with the order.

curl -X POST "$LINKHUB_URL/api/v3/test/orders" \
  -H "Authorization: Bearer $ACCESS_TOKEN" -H "Content-Type: application/json" \
  -d '{ "productId": "cm3prod1", "variantId": "cm3var2", "buyer": { "email": "you@example.com", "name": "Test Buyer" } }'
  • variantId is required when the product has variants. The price is the variant's, or the product's.

  • buyer is optional (email, name, shippingAddress in the shape above). A physical product gets a sample US address if you leave it out.

  • Only for an OAuth token from an app that is not approved yet, acting for the app's owner, or for a personal API key. Anything else gets 403 forbidden. Once your app is approved, make test orders with a personal key.

  • No money moves and nothing is charged. The buyer is never emailed, and stock and salesCount do not change. Test orders are left out of earnings, analytics, payouts and affiliate commission. They show in Dashboard → Orders with a "test" label.

  • order.paid, order.fulfilled and order.refunded payloads carry "test": true for a test order.

Fulfil a test order with POST /orders/{orderId}/fulfil as usual. To refund one, call POST /test/orders/{orderId}/refunds (orders:write, the same body as a real refund, Idempotency-Key optional). This works before your app is approved for orders:refund. Nothing goes through Stripe. The order becomes REFUNDED or PARTIALLY_REFUNDED and order.refunded fires. Only test orders can be refunded this way. An approved app holding orders:refund can also refund a test order through the normal endpoint, and it skips Stripe the same way.

Pagination

Every list returns its items under data, with a nextCursor. Pass it back as ?cursor= for the next page; null means you have everything. Lists also repeat the items under a key named after them (products, orders); those keys are deprecated, so read data.

async function allProducts(accessToken: string) {
  const products = [];
  let cursor: string | null = null;
  do {
    const page: { data: unknown[]; nextCursor: string | null } =
      await api(accessToken, `/products?limit=200${cursor ? `&cursor=${encodeURIComponent(cursor)}` : ''}`);
    products.push(...page.data);
    cursor = page.nextCursor;
  } while (cursor);
  return products;
}

For an incremental order sync, page GET /orders?since= from the time of your last successful sync, and rely on webhooks for anything sooner.

Idempotency

Two writes take an Idempotency-Key header. Derive the key from something stable in your system, such as the marketplace's listing or return id.

  • Refunds require one. Sending the same key again returns the first refund instead of making a second; reusing a key for a different order is 409 conflict.

  • POST /products takes one optionally. Within 24 hours, the same key returns the first product (still 201) instead of creating a second; the same key with a different body is 409 conflict. After 24 hours the key can be used again.

The other writes are safe to retry by design: stock is set absolutely, fulfilling twice is a no-op, and PATCH sets fields to values.

Errors

Every error is JSON with a stable error code to branch on and a message to show a person:

{ "error": "insufficient_scope", "message": "This token was not granted products:write." }

Status

error

What to do

400

invalid_request

The input is wrong; message names the field. Do not retry unchanged.

401

unauthorized

No bearer token.

401

invalid_token

Expired or revoked. Refresh once and retry; if refreshing fails, the creator must reconnect.

403

insufficient_scope

The creator did not grant the scope this call needs (the WWW-Authenticate header names it). Hide the feature or ask them to reconnect.

403

forbidden

Not allowed for this account.

404

not_found

No such thing, or it is not this creator's.

405

method_not_allowed

Wrong method for this path.

409

conflict

The state does not allow it (for example refunding a fully refunded order).

413

invalid_request

Body over 256 KB.

429

rate_limited

Wait Retry-After seconds, then retry.

500

server_error

Ours. Retry later with backoff.

503

unavailable

Temporarily unavailable. Retry later.

Rate limits

600 requests a minute per app and creator. Every response carries RateLimit-Limit, RateLimit-Remaining and RateLimit-Reset (seconds until the window resets), so you can slow down before you hit it. Over it you get 429 rate_limited with a Retry-After header in seconds: wait that long, then retry. Each creator has their own budget, so one large shop does not slow the others, but a full catalogue sync for one creator should page at limit=200 and spread its stock writes out.

5. Webhooks

Polling is the fallback; webhooks are how a crosslister hears about a Linky Hub sale fast enough to stop overselling elsewhere.

Each app has one webhook URL, with the events you want. Set it on the app's page under Dashboard → Developers, or from your deploy script with a personal API key that holds apps:write. The URL must be https on a public host. The signing secret is shown once, when the webhook is first created.

curl -X PUT "$LINKHUB_URL/api/v3/apps/$APP_ID/webhook" \
  -H "Authorization: Bearer $LINKHUB_API_KEY" -H "content-type: application/json" \
  -d '{"url":"https://example.com/api/webhooks/linkyhub","events":["order.paid","order.fulfilled","order.refunded","product.updated","inventory.low","grant.revoked"]}'
# → { "url": "…", "events": [...], "secret": "whsec_…", "createdAt": "…" }

curl -X POST "$LINKHUB_URL/api/v3/apps/$APP_ID/webhook/test" -H "Authorization: Bearer $LINKHUB_API_KEY"

GET on the same path reads the webhook back without its secret, and DELETE removes it. POST …/webhook/rotate-secret returns a new secret, and the old one keeps verifying for 24 hours. See Webhooks.

You receive an event only for creators who connected your app and granted the scope it needs:

Event

Needs

Use in a crosslister

order.paid

orders:read

A sale on Linky Hub: decrement stock on other marketplaces.

order.fulfilled

orders:read

Mark it shipped in your app.

order.refunded

orders:read

Reflect the refund.

product.updated

products:read

Re-read the product and update your listings.

inventory.low

products:read

Stock is at or below 5.

grant.revoked

none

The creator disconnected your app: stop syncing and delete their tokens.

user.updated, user.deleted

none

The creator's Linky Hub sign-in account changed or was deleted.

subscriber.created (audience:read) and event.registration (events:read) exist too, but a crosslister has no use for them.

The body is JSON: { id, type, timestamp, creator: { id }, data }. creator.id is the sub of the access token you hold for that creator, on every event type, so look up the connection by it. (If a delivery has no top-level creator, read data.creator.id, or data.user_id for grant.revoked and user.*.) data carries ids rather than full records; for example order.paid carries orderId, amountCents, currency, productId, productName and variantId. Treat the payload as a nudge and fetch the current state from the API before acting.

Verifying

Deliveries are signed with the Standard Webhooks headers webhook-id, webhook-timestamp and webhook-signature. Verify the signature against the raw body before trusting anything in it, and reject timestamps more than five minutes old. The standardwebhooks library does both:

import { Webhook } from 'standardwebhooks';

const webhook = new Webhook(process.env.LINKHUB_WEBHOOK_SECRET!);

export async function POST(request: Request) {
  const body = await request.text(); // raw body: do not parse before verifying
  let event: { type: string; creator: { id: string } | null; data: Record<string, unknown> };
  try {
    event = webhook.verify(body, Object.fromEntries(request.headers)) as typeof event;
  } catch {
    return new Response('bad signature', { status: 400 });
  }

  const deliveryId = request.headers.get('webhook-id')!;
  await queue.add({ deliveryId, event }); // answer fast, work later; skip ids you have already seen
  return new Response(null, { status: 204 });
}

Delivery

Answer 2xx within a few seconds and do the work afterwards. Failed deliveries are retried with backoff. Deliveries can arrive more than once and out of order: deduplicate on webhook-id, and re-read the order or product from the API when order matters. More in Webhooks.

6. MCP

The same API is a Model Context Protocol server at https://linkyhub.net/api/mcp, so an assistant can run the same flows as tools (products_list, inventory_set, orders_fulfil and so on), filtered to the scopes the creator granted. It takes OAuth tokens and registers its own client, so a crosslister does not need it; it is useful for an AI assistant inside your app. See Connect an assistant (MCP).

7. Going live

Submit for review

When the app works for your own account, submit it:

curl -X POST "$LINKHUB_URL/api/v3/apps/$APP_ID/submit" -H "Authorization: Bearer $LINKHUB_API_KEY"

(or request review from the app's page in the dashboard). A Linky Hub admin reviews it, and the owner gets an email when it is approved or suspended. Once approved, any creator can connect it, and scopes marked "approved apps only", such as orders:refund, become grantable. An approved app cannot add scopes. An app that breaks the developer terms can be suspended, and its tokens stop working.

Before you submit, make sure name, tagline, description, homepageUrl and category are filled in (PATCH /api/v3/apps/{id}): they are what creators and reviewers see.

Security checklist

  • The client secret, refresh tokens and webhook secret live in a secret manager or encrypted at rest, never in a browser, mobile app, log or git repository.

  • PKCE (S256) and a random state on every authorization, and state checked on return.

  • Redirect URIs are exact, https, and only the ones you use.

  • Scopes are the minimum, and orders:read_customer only if you ship.

  • You read the granted scope from every token response and handle a missing scope.

  • A 401 triggers one refresh, not a loop; a failed refresh marks the connection broken.

  • Disconnecting in your app revokes the refresh token and deletes the creator's data you no longer need; grant.revoked does the same.

  • Webhook signatures and timestamps are verified on the raw body, and deliveries are deduplicated on webhook-id.

  • Retry-After is honoured on 429.

  • Refunds always carry a stable Idempotency-Key.

  • Buyer details, if you have them, are used only to fulfil orders, and deleted when you no longer need them.

  • The personal API key used to register the app has a short expiry, and is revoked when development is done.

  • You can rotate the client secret (POST /api/v3/apps/{id}/rotate-secret) and redeploy within its 24-hour overlap.

Support

Ask in the Developers category of the community, and watch the changelog for API changes and the status page for incidents.

Reference

Updated