Browse the API docs

Public apps and OAuth

An app in the App Store works for every store that installs it. The merchant sees what the app will be able to see and edit, approves it, and your app gets an Admin API token for that store. It's the OAuth authorization code grant, the way Shopify does it.

How an install works#

  1. 1
    Send the merchant to the store's authorize URL
    Your app asks for the access it needs, with a state to recognize the merchant when they come back.
  2. 2
    The merchant approves
    Weftstore shows the store, your app, what it will be able to see and edit, and its pricing. Signed-out merchants log in first.
  3. 3
    They come back to your redirect URL with a code
    Check the hmac and the state before anything else.
  4. 4
    Swap the code for an access token
    From your server, with your client secret. Then call the Admin API with the token like any other app.

Installs from the App Store's Install button work the same way without the first step: the merchant approves the access your app declares in the partner dashboard and comes back to your first redirect URL with code, shop, timestamp and hmac, and no state. Check the hmac always, and the state only when your app started the install. Test on your store in the partner dashboard is the same install for your own stores while your app is unpublished. An app without a redirect URL opens in the admin instead.

Who can install: people with the Apps and API permission in the store whose own permissions cover what your app asks for, with a confirmed email address, on a plan that includes App Store apps. Until your app is published, only its developer can install it, and only on a store their own account owns: staff in someone else's store can't test your app there.

New to this? Build your first app goes through the whole install with a starter app you can run.

Asking for access#

Send the merchant to
https://example-store.weftgrid.store/admin/oauth/authorize?client_id=slc_6f1d0c4b…&scope=read_orders,write_products&redirect_uri=https%3A%2F%2Fapp.example%2Fauth%2Fcallback&state=6c2f9d1e8a
ParameterWhat it is
client_idYour app's client ID, from the partner dashboard.
scopeComma-separated scopes, each one your app declares (a declared write_x covers read_x). It can be empty.
redirect_uriOne of your app's redirect URLs, exactly as listed: scheme, host, port, path and query, character for character.
stateA random value you keep with the merchant's session and check when they come back. Required.

{shop} is the store's Weftstore address, like example-store.weftgrid.store, or its own domain. A request that fails a check (an unknown client ID, a redirect URL that isn't yours, a scope you don't declare, no state) shows an error page that names the problem, and nobody is redirected anywhere. The page the merchant approves on is valid for 60 minutes.

The redirect back#

Your redirect URL receives
https://app.example/auth/callback?code=Qm9vay1hLXBpY2t1cC…&shop=example-store.weftgrid.store&state=6c2f9d1e8a&timestamp=1761390720&hmac=4b1d0e…
ParameterWhat it is
codeSingle use, for 10 minutes. Swap it for a token right away.
shopThe store's permanent Weftstore address. Send the token request there.
stateYour state, unchanged. Refuse the request when it isn't the one you sent. An install that didn't start in your app (from the App Store, or Test on your store) has none.
timestampWhen the redirect was made, in Unix seconds. Refuse old ones.
hmacHMAC-SHA256 of the other parameters, keyed with your client secret, in hex.

To check hmac: take every query parameter except hmac, write each as key=value with % as %25 and & as %26 (and = as %3D in keys), sort them by key, join them with &, compute the HMAC-SHA256 with your client secret and compare in constant time. The same check works for embedded apps' URLs.

verify-hmac.mjs
import crypto from "node:crypto";

const escape = (text, isKey) => {
  const out = text.replace(/%/g, "%25").replace(/&/g, "%26");
  return isKey ? out.replace(/=/g, "%3D") : out;
};

/** query: the request's URLSearchParams. secret: your app's client secret. */
export function validHmac(query, secret) {
  const given = query.get("hmac") ?? "";
  const message = [...query.entries()]
    .filter(([key]) => key !== "hmac" && key !== "signature")
    .map(([key, value]) => [escape(key, true), escape(value, false)])
    .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))
    .map(([key, value]) => `${key}=${value}`)
    .join("&");
  const expected = crypto.createHmac("sha256", secret).update(message, "utf8").digest("hex");
  return given.length === expected.length && crypto.timingSafeEqual(Buffer.from(given), Buffer.from(expected));
}

// app.get("/auth/callback", (req, res) => {
//   const query = new URL(req.url, "https://app.example").searchParams;
//   if (!validHmac(query, process.env.STORELOOM_CLIENT_SECRET)) return res.sendStatus(400);
//   …check state, then exchange query.get("code") for a token
// });

When the merchant cancels, they come back with error=access_denied and your state (no code, no hmac).

Getting the access token#

Request
curl -X POST "https://example-store.weftgrid.store/admin/oauth/access_token" \
  -H "Content-Type: application/json" \
  -d '{ "client_id": "slc_6f1d0c4b…", "client_secret": "slcs_…", "code": "Qm9vay1hLXBpY2t1cC…" }'
Response
{
  "access_token": "slat_Jx2v9QeL0pWmK4tR7yZb3nHs8dUfAa1c",
  "scope": "read_orders,write_products"
}

Send client_id, client_secret and code as JSON or as a form. Keep the token on your server like a password and send it in X-Storeloom-Access-Token. A new token replaces the store's previous one for your app. scope is what the merchant approved; requests outside it get 403.

A store that already installed your app can approve it again, for example to give it more access. It then comes back with a new code, the token you exchange it for replaces the old one, and the old one answers 401 from then on. A 401 on the Admin API therefore means the store uninstalled your app or approved it again: forget the token and start the install over.

StatuserrorWhen
400invalid_requestclient_id, client_secret or code is missing, repeated or too long.
401invalid_clientNo app has this client ID, or the client secret is wrong.
400invalid_grantThe code isn't this store's or this app's, is older than 10 minutes, or was already used.
429slow_downToo many token requests from one address (30 a minute). Retry-After says when to try again.

Errors come as { "error": "…", "error_description": "…" }.

Embedded apps#

An embedded app opens inside the Weftstore admin: your app URL loads in a frame under a bar with your app's name and an Open in new tab link. The URL carries shop, host (base64 of where the admin is), timestamp, locale, embedded=1 and an hmac made the same way as on the redirect. Apps that aren't embedded open in a new tab with the same parameters, without embedded.

Your app URL receives
https://app.example/admin?embedded=1&hmac=9c0a7f…&host=bG9jYWxob3N0OjMwMDAvYWRtaW4&locale=en&shop=example-store.weftgrid.store&timestamp=1761390720

The frame is sandboxed with allow-scripts allow-forms allow-same-origin allow-popups allow-downloads: your pages can't navigate the admin itself. Serve them over https from your own domain. While you build, a Weftstore that runs on your machine over http can frame http://127.0.0.1 and http://localhost addresses too: browsers block an http frame only inside an https page.

Your pages also have to say that the admin may frame them. Every other page of Weftstore refuses to be framed, and so does yours unless you allow it. Send this header with every page that loads in the frame:

Response header
Content-Security-Policy: frame-ancestors https://store.weftgrid.com

https://store.weftgrid.com is the address of this admin: it is the host parameter decoded, with its scheme. Don't send X-Frame-Options, which many frameworks add by default: it can say "never" or "only my own site", not "this one other site", and your pages would be refused in the admin. An app that works on more than one Weftstore can build the value from the signed host parameter, as the starter app does:

server.mjs
  // Inside the admin the app sits in a frame, and only the admin may frame it. The signed `host` value says where the
  // admin is (base64 of "<address>/admin"). Don't send X-Frame-Options: it can't name another site.
  const framed = q.get("embedded") === "1";
  const adminAddress = Buffer.from(q.get("host") ?? "", "base64url").toString("utf8").split("/")[0];
  const headers = { "Content-Security-Policy": isShop(adminAddress) ? `frame-ancestors ${SHOP_SCHEME}://${adminAddress}` : "frame-ancestors 'none'" };

Charging merchants#

Paid apps create a monthly charge with POST /recurring_application_charges.json and send the merchant to its confirmation_url. The merchant approves or declines it and comes back to your return_url with charge_id; read the charge to see which. An approved charge is billed on the store's Weftstore invoice after its free trial, until you cancel it or the app is uninstalled. Approving a new charge cancels your app's current one. Charges nobody answers expire after 48 hours. Every change sends app_subscriptions/update to your app.

Storefront scripts#

With write_script_tags, your app can load up to 10 scripts on the store's pages with the script tags endpoints. They load when shoppers are on the store's own address (its subdomain or domain), never on the platform's preview paths, and they're removed when the app is uninstalled.

A script's URL must be https. A Weftstore that runs as a development server over plain http also takes http://localhost, http://127.0.0.1 and *.localhost addresses, so you can build without a tunnel; a hosted one refuses them with must be an https URL. Adding the same URL twice is refused with src: ["has already been added"], so look for it first with GET /script_tags.json?src=….

When a store uninstalls your app#

  • Its open charges are cancelled (app_subscriptions/update), then app/uninstalled is sent with the store as its payload. Subscribe to both with POST /webhooks.json. If your server doesn't answer with a 2xx, app/uninstalled is tried again on the usual schedule.
  • Then the token stops working, and the app's webhooks and storefront scripts are removed. Calls with the old token answer 401.
  • 48 hours later shop/redact is sent to your privacy webhook URL: erase what you kept about the store. If the store installs your app again before then, it is cancelled. See Uninstall and privacy messages and Privacy webhooks.
  • Webhooks to installed apps are signed with your client secret, as described in Verifying signatures. Rotating the secret in the partner dashboard updates every store at once.
Subscribe after the install
curl -X POST "https://store.weftgrid.com/api/admin/2026-10/webhooks.json" \
  -H "X-Storeloom-Access-Token: $STORELOOM_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "webhook": { "topic": "app/uninstalled", "address": "https://app.example/hooks/uninstalled" } }'