# Task: add the Peptides·Index orders endpoint (spec v2.0) — step 2: sales

You are helping a peptide vendor add the **orders endpoint** to a store that already publishes its catalog to Peptides·Index (peptides-index.com), a price-comparison site. Your goal is one HTTPS endpoint, `GET /orders` (any path), that returns the orders Peptides·Index sent this store, with no customer data, in the exact shape of Appendix A's "Orders" — behind the same key as the catalog endpoint.

**This is step 2 of 2. It is optional**: the store is listed on its catalog alone, and this is what adds sales reporting. The catalog endpoint and the key already exist from step 1 (https://peptides-index.com/vendors/api-guide/prompt.md?step=catalog). Find them, reuse their key check, and **do not change the catalog endpoint**. If you find no catalog endpoint, stop and tell the human to do step 1 first.

Everything you need is in this one message: these instructions and **Appendix A** (the full v2.0 spec; read "Orders" in full before you write any code). The phase numbers are the full guide's, so this step runs Phases 1, 6, 7 and 8.

**One exception: a Shopify store whose storefront is a Shopify theme.** It builds no endpoints and sets no key — ask which plan it is on (Phase 2, item 7), then go straight to **Shopify theme stores** at the end; nothing there is code. A headless Shopify store (its storefront is its own app) follows the phases like any custom store.

## Hard rules

1. **Never invent a price, discount, shipping cost, delivery time, compound amount or lab link.** If you cannot read it from the store's own data, ask the human. A missing field is fine; a made-up one gets published.
2. **Read-only.** Every endpoint you build only reads. It never writes to the store, never creates orders, never changes prices or stock. The only order anywhere in this work is the one test order the human places themselves when the orders endpoint is connected (Phase 8).
3. **Never expose customer data** — no names, emails, phones, addresses, IPs, customer ids, carts or accounts, on any endpoint. The catalog endpoint carries only the catalog fields in Appendix A, and no orders. Orders are a separate endpoint (Phase 6) with its own allow-list of fields.
4. **Omit anything that is not a research compound** — bacteriostatic water, syringes, supplies, merch, gift cards. A product with no `compounds` must not appear in the feed.
5. **The key lives in configuration, not in code.** Every endpoint reads it from the environment variable `PEPTIDES_INDEX_KEY` — except on **WordPress**, where the plugin's own settings page holds it (Phase 4). Never hard-code it, put it in a URL or commit it to a public repository. It is not a secret from you: in Phase 7 you ask the human for it, set it yourself and use it for the live checks.
6. **Build and test locally or on staging first** when you can, then deploy it yourself — there is no approval step. Ask before installing third-party software or packages.

## Tools

If you have a browser (through MCP or similar), use it for everything a person would check by eye: opening each `coa_url`, comparing the feed against the live storefront, creating and removing the Phase 8 test product in the store admin, and walking through checkout with the referral link. Use real HTTP requests (`curl` / `fetch`) for the API checks, never the browser, so status codes and headers are the real ones.

In a browser: **the human logs in themselves** — you never type a password, a card number or any payment detail; if checkout asks for payment, stop and hand it to them. Touch only the test product, the test order and the plugin's settings page. If you have no browser, tell the human exactly what to click and what to paste back, and do the rest yourself.

## Phase 1 — Detect, don't ask

Inspect the codebase and environment before asking the human anything. Determine:

- **Platform.** WooCommerce: `wp-config.php`, `wp-content/plugins/woocommerce`. Shopify: theme files (`layout/theme.liquid`, `sections/`), `shopify.app.toml`, or a Shopify API client in the code. Otherwise Next.js, another Node framework, PHP, Python, or something else — read `package.json`, `composer.json`, `requirements.txt` / `pyproject.toml`.
- **Where products live** — the database tables, CMS collections or API that hold products, variants, prices, stock and any bundle / quantity pricing. Find where a variant's own price lives, not just the parent product's.
- **Hosting** — what serves the site and how environment variables are set there.
- **Anything in front of the site** — a login, age or research-use-only gate; a members-only, wholesale or coming-soon plugin; password protection; a security plugin or setting that limits the API to logged-in users; a CDN or firewall (Cloudflare, Wordfence, Sucuri) or the host's bot protection. Check the code and plugin list, then request the home page and one product page with `curl` (no cookies): a redirect to a sign-in page or a challenge page is a gate. Name each one you find; each endpoint is exempted from it when it is built.
- **On WordPress, also any code or plugin that filters `rest_authentication_errors`** — a research-use or members-only gate often does. It answers before the plugin's `permission_callback` runs, so our key never reaches your check.

If you have **no code access** (for example you are a chat assistant), say so plainly and take the matching path in Phase 4. A Shopify store with no repository is usually a theme store: confirm, then follow **Shopify theme stores**. On WordPress that means handing the human a ready-to-upload plugin zip, never code to paste into the theme.

Report what you found in a few lines before moving on.

## Phase 6 — Orders endpoint

This endpoint is **optional**: a store is listed on its catalog alone. Build it when the vendor wants its sales reported automatically — it is how commission is reconciled without anyone logging into the store's affiliate portal, and what gives them sales reporting. Read Appendix A, "Orders", in full. Detect what you can from the code and the platform; ask the human only for what you cannot detect — typically where the store records our referral link, and how any custom order statuses map. Then:

1. **Find how this store attributes an order to Peptides·Index.** Use your Peptides·Index referral code and link, shown in the vendor portal (usually `PEPTIDES` and `?ref=PEPTIDES`). The coupon: orders where that code was applied. The ref link: orders that arrived through that link — find where the store records that (an affiliate plugin's or app's referral record, or order meta / note attributes). If the store records no ref at all, report `"coupon"` attribution only and tell the human. Ask about anything you cannot find; never guess which orders are ours.
2. **Build a second route beside the catalog**, behind the SAME Bearer check and the SAME `PEPTIDES_INDEX_KEY` — the same rules as the catalog route: the key check before any work, `503` `{"error":"key_not_configured"}` when the key is unset, `Cache-Control: private, no-store` and `Vary: Authorization` on every response, and its path excluded from every gate Phase 1 found (never a gate switched off, never the key check loosened). It reads orders server-side, keeps only the ones attributed to us, and pages them (at most 500, sorted by `updated_at` oldest first, then `id`). Make `next_cursor` encode the last order's `updated_at` and `id`, and fetch the next page strictly after that pair (keyset pagination) — never a page number or offset: an order updated mid-pull shifts the rows and one gets skipped. Compare `id` the way you sort it (numeric ids as numbers). If you keep only our orders after the query (as on WooCommerce), build the cursor from the last order you **scanned**, not the last you returned, and send it whenever more rows remain — a page can hold fewer than 500 orders, or none, and still carry a `next_cursor`. It stays opaque to us.
3. **Build every order from an allow-list** of exactly the fields in Appendix A — `id`, `created_at`, `updated_at`, `status`, `currency`, `subtotal`, `discount`, `commissionable`, `attribution`, `coupon_code`, `click_id`, and `items` with `sku` and `qty`. `coupon_code` is optional: send `null` or leave it out when the store has nothing for it. `click_id`: build it if the platform can carry it (below); otherwise, and on an order that arrived without a `pi_click`, it is `null`. Never serialise the platform's own order object and delete fields from it: a field the platform adds next year would leak. **No names, emails, phones, addresses, IPs or customer ids, anywhere.**
4. **`since` filters on the last-modified time**, so refunds and cancellations come back through it.
5. **Map statuses** to the six in Appendix A and show the human your mapping. Ask about any custom status.

**WooCommerce.** Register `GET /wp-json/peptides-index/v2/orders` in the same plugin, with the same `permission_callback`. Read with `wc_get_orders` filtered on `date_modified` ≥ `since`, and keep an order only if `$order->get_coupon_codes()` contains our referral code (compare case-insensitively, as WooCommerce does) or it carries the ref marker. Build each entry from the getters you need (`get_id`, `get_date_created`, `get_date_modified`, `get_subtotal`, `get_discount_total`, `get_total_refunded`, the items' `get_product()->get_sku()` and `get_quantity()`) — never `get_data()`, never the REST API's own order response. A typical mapping: `pending` / `on-hold` → `pending`, `processing` → `paid`, `completed` → `fulfilled`, `cancelled` / `failed` → `cancelled`, `refunded` → `refunded`, and any order with a partial refund → `partially_refunded`.

**Shopify (headless).** A second route in the same app. Orders need the `read_orders` scope on the Dev Dashboard app — tell the human it is a wider permission than the catalog needed when they add it. Query orders by `updated_at_min` = `since`, keep those whose `discount_codes` include our referral code or that carry the ref, and copy across only the allow-listed fields: never `customer`, `email`, `phone`, `billing_address`, `shipping_address`, `browser_ip`, `client_details` or `note`. Without the `read_all_orders` scope Shopify only returns the last 60 days, which is fine for a feed that is polled.

**The store's admin API is never exposed.** The route calls it server-side with fixed queries you wrote. It does not pass our query string, a path, a field list or a GraphQL query through to it, never returns its response as-is, and never reveals its token. The only input it reads from us is `since` and `cursor`: validate both (a bad `since` is a `400`), and ignore anything else in the query string rather than forwarding it.

**`click_id` — you decide, and if it can be built, build it.** Our outbound links add `pi_click=<value>` to the landing URL. Work out from the code whether this store can carry a value from the landing page to the order. **If it can, build it as part of this endpoint without asking** — keep the value in a first-party cookie (about 30 days) or the session when a visitor lands, attach it to the order they place (order meta in WooCommerce, set at checkout; a cart attribute in Shopify), and return it as `click_id`, unchanged. Treat it as opaque, but store it only if it is 1–64 characters of printable ASCII, otherwise store nothing (a longer one fails the whole order); a later landing with a valid value replaces the earlier one. Page caches (WP Rocket, Cloudflare APO) can skip PHP on the landing page, so capture it where code actually runs — a small script, or at add-to-cart or checkout — not only on page load. **If it cannot** (or only with a risky change to checkout), skip it, send `null`, and say why in one line of your report — it does not hold up the listing. Either way, an order that arrived without a `pi_click` sends `null`.

**Validate.** Run every row of Appendix A's "What the orders checker runs" table: no key and a wrong key → `401` or `403`; `PEPTIDES_INDEX_KEY` unset → `503` `{"error":"key_not_configured"}`; `since` set to the current time → `"orders": []`; `commissionable` ≤ `subtotal` − `discount` on every order; every SKU found in the catalog. Show the human one real response, and search it for anything that looks like a person — an `@`, a phone number, a street, an IP. Deploy it. Then continue to Phase 7.

## Phase 7 — The key

**In this step the key is normally already set**, from the catalog step: the orders route reads the same one. Skip "Get it" and "Set it" if the catalog endpoint already answers `200` with the key, and run the test below on the orders URL. (If it is not set after all, set it wherever the catalog endpoint reads it.)

An endpoint whose server never received the key rejects Peptides·Index's real key, and nobody can see why — so this phase is not done until the self-test below passes. The key is not a secret from you: it only keeps other sites out of the feed.

1. **Get it.** Ask the human to open https://peptides-index.com/vendors/portal → Integration kit → copy their API key, and paste it here — always, even if they also set it themselves, because you need it to run the checks.
2. **Set it** where this platform reads it (Phase 4, "Where `PEPTIDES_INDEX_KEY` is set"): the host's environment variable, then redeploy — or, on WordPress, **Settings → Peptides Index → API key → Save**. Never in source code or a public repository.
3. **Test it** on **each** live endpoint URL, with the key in `PEPTIDES_INDEX_KEY` in your shell. If you cannot make HTTP requests, give the human the commands and ask for the output:

```bash
curl -s -o /dev/null -w '%{http_code}' -H "Authorization: Bearer $PEPTIDES_INDEX_KEY" <url>
```

Expected: `200`. And the same command without the header:

```bash
curl -s -o /dev/null -w '%{http_code}' <url>
```

Expected: `401` (or `403`). If the first prints `503`, the key is not set on the server yet, or the site was not redeployed (on WordPress: not saved in Settings → Peptides Index); if it prints `401`, the value on the server differs from the portal's — usually extra spaces or quotes. On WordPress, if the right key still gets `401`, the host may be stripping the `Authorization` header before PHP sees it: check the plugin reads `HTTP_AUTHORIZATION` and `REDIRECT_HTTP_AUTHORIZATION`, and add `CGIPassAuth On` (or `SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1`) to `.htaccess`.

**If you cannot set it yourself** — a host settings screen you cannot reach — give the human this block verbatim, then run the test once they say it is done:

> 🔑 One step for you: open https://peptides-index.com/vendors/portal → Integration kit → Copy your API key → paste it into your hosting's environment settings as `PEPTIDES_INDEX_KEY` → redeploy (on WordPress: **Settings → Peptides Index → API key → Save** instead). Then tell me it's done.

Once every endpoint prints `200` and `401`, continue to Phase 8.

## Phase 8 — Verify it live, then one test order (last)

Now prove it on the live URLs, before the human checks it in the portal. If you could not test locally, run the remaining checks of the earlier phases here first. **Run every check for real** — make the request, open the page — and never report one as passing because the code looks right.

**Requests that need the key.** Run them yourself, with the key from Phase 7. If you cannot make HTTP requests at all, give the human the exact commands and ask them to paste back the output.

1. **The gate.** Every live URL: the key → `200` and valid JSON; no header, and a wrong key → `401` (or `403`). Then the same URL with no header right after a keyed `200` must still get `401` (or `403`) — not a cached `200`. Every response, `401` and `503` included, carries `Cache-Control: private, no-store` and `Vary: Authorization` (`curl -sD - -o /dev/null <url>` prints the headers). With no header, the body must be your endpoint's own `{"error":"unauthorized"}`: a 401 from a login or research-use gate (often JSON too), a redirect, an HTML page or a challenge fails, even though the status code looks right. The Peptides·Index checker runs from our server, not yours, so a firewall that trusts your network can pass here and still block us — the portal checker has the final word.
5. **Orders.** `since` set to now returns `"orders": []`; results run oldest `updated_at` first; `next_cursor` pages through without repeats; search the whole response for `@`, a phone number, a street, an IP and the words email, name, address, phone — none may appear.

Fix anything that fails, redeploy, and check again.

**The test order — it completes the Sales step.** A real order is the only thing that proves a sale through Peptides·Index reaches the orders endpoint. You guide; **the human places it**, and checks each step in the vendor portal's **Test order** step.

1. Set up a hidden test product, left out of the catalog and search, priced low — $5–$10, or whatever the payment processor accepts. Not a free or near-free order through a full-discount coupon: many processors and affiliate plugins skip those, and the order must be attributable to Peptides·Index. Give it a SKU, such as `PI-TEST` — an order line with no SKU fails the order.
2. The human opens this store's referral link from the vendor portal (usually `?ref=PEPTIDES`) with `&pi_click=testorder234` added, goes to the test product by its direct URL, checks at checkout that the referral code (usually `PEPTIDES`) is applied — entering it if not — and pays normally.
3. Confirm it appears in `GET /orders` (with `since` set before the order time) with the right `status`, `subtotal`, `discount`, `commissionable`, `attribution` and `items` (`sku`, `qty`), `click_id` exactly `testorder234` (or `null` if you could not build the capture), and no customer data. Then the human enters that `id` in the portal's **Test order** step and presses **Check** — it must pass before the refund.
4. They refund it in full through the payment gateway, from the store admin, so the money actually goes back. Confirm the same `id` comes back with the new `status`, `commissionable` at `0` and a later `updated_at`, then the human presses **Check refund** in the same step.
5. Delete or unpublish the test product.

**Report.** End with a short pass/fail list covering every check in this phase, the test order's `id`, and the orders endpoint URL. Then tell the human, in the vendor portal: in **2 · Sales**, paste the orders URL and run its check, then use the **Test order** step — **Check** after placing the order, **Check refund** after refunding it; both must pass for the step to read done — and ask them to tell you what the check shows. Peptides·Index already holds the key. The pass/fail list is theirs to keep, or to send Peptides·Index if anything failed. Tell them too: if they ever add a login, age or research-use gate, a coming-soon page or bot protection, both endpoint paths must stay excluded from it.

## Shopify theme stores — no code

A Shopify store whose storefront is a **Shopify theme** has no orders step yet: it builds no endpoints at all. Tell the human so and stop.

---

# Appendix A — the spec (v2.0), verbatim

# Vendor catalog API

The Peptides·Index vendor catalog API spec, version 2.0.

**One read-only endpoint gets you listed: your catalog**, behind a key we issue you — your prices, pack deals, shipping and lab certificates, listed accurately. A second, optional endpoint reports the orders our readers place with you, which is how commission is reconciled and what gives you sales reporting.

## The entire requirement

`sku` · `name` · `url` · `price` · `compounds`

Five fields per product, plus `schema_version`, `updated_at` and your vendor name, URL and currency — that is the catalog, and **the catalog is all it takes to be listed**. Everything else in this document is optional, and comes in two further steps you can take whenever you like (see "Three steps, one required").

**`compounds` says what is in the product, in our words**: a `slug` from our compound list, the `amount` in one unit, and its `unit` — `{ "slug": "bpc-157", "amount": 10, "unit": "mg" }`. A product with no compounds — bacteriostatic water, syringes, merch — is not something we list. Leave it out.

Every field below is annotated with its **type** — `string`, `number`, `boolean`, `array`, `object`, or an `enum` with its allowed values — and whether it is required. If you are handing this to an AI coding assistant, copy the **AI onboarding prompt** from the top of the guide instead: it is this spec plus our current compound list plus step-by-step instructions, in one paste.

## Three steps, one required

- **1 · Catalog — required.** You send the catalog endpoint: the five fields above per product (`form`, `in_stock`, `packs` and `coa_url` when you have them), and confirm your referral link in the portal. **You get:** listed, a portal that shows what we list and why, and the clicks we send you.
- **2 · Sales — optional.** You send the orders endpoint (see "Orders") and place one test order. **You get:** your sales reported automatically, with no affiliate-portal logins. Sales reporting in your portal is coming soon.
- **3 · Store info — optional.** You send your delivery options, payment methods and volume discount in the feed's `vendor` block (see "Everything you can add") — or type them into your portal's Settings if you would rather. No endpoint of its own. **You get:** your full store profile on your page: how you deliver, how shoppers can pay, your deals.

Do step 1 now and the others when it suits you, before or after you are listed. Connect all three to stay eligible for our vendor spotlights and price-drop posts; price comparisons include your store either way. None of the steps changes how you rank — ranking is on price and data, never on what you have connected or what we earn.

Each step has its own AI prompt, so an assistant is only ever given the work for the step you are on: [catalog](https://peptides-index.com/vendors/api-guide/prompt.md?step=catalog) (it covers store info too) and [sales](https://peptides-index.com/vendors/api-guide/prompt.md?step=sales). Your portal's Integration kit links the one for your platform.

---

Today we read most vendors by scraping product pages. That works until it doesn't, and when it breaks, *your* listing is the one that goes wrong: a stale price, a missing pack deal, a vial whose size we couldn't parse and so couldn't rank at all. This spec is the fix. Expose your catalog endpoint, check our key on it, and your listing stays in step with your store, refreshed daily.

## Why bother — what it fixes, from real cases

| What happens without it | What this gives you |
| --- | --- |
| Your pack deal is printed on the page but not anywhere we can read, so we publish your single-vial price as your best price. One vendor's BPC-157 showed as **$3.50/mg** when their real floor was **$2.45/mg** — they looked 30% more expensive than they are. | `packs[]` and `volume_discount` — every deal, in the comparison. |
| A product's size lives only in prose ("a full 10mg per vial"). No size means no cost per mg, which means **the listing cannot be ranked at all**. | `compounds[].amount` — explicit. |
| A blend titled `10/3mg` gets read as 3 mg, pricing it at **$26.66/mg instead of $6.15**. | One `compounds` entry per component — no parsing, no guess. |
| A vial dosed in **international units** has no milligram figure, so it ranks against nothing — or a number meant as IU is read as mg. | `unit: "iu"` — the unit travels with the number, and IU is compared only with IU. |
| A spray labelled `50mg/30mL` gets read as 30. | `amount: 50` — the peptide, not the solvent. |
| Your product is called "RT-3" or "Reta 10". To you that is obviously retatrutide; to a scraper it is a guess, and a wrong guess puts your listing in someone else's comparison. | `compounds[].slug` — you name the compound from our list, so nobody guesses. |
| A reader outside the US sees your US shipping cost, or none at all, and finds out at checkout that delivery is $40 and three weeks. | `shipping[]` — cost **and** duration, per destination. |
| You re-slug a product; our old row keeps serving its last price with a link to a 404. | `sku` — stable, so a rename is a rename, not a phantom. |
| Your COA is a PDF we must OCR, or one we never find — or, worse, one we find by name that belongs to someone else. We once attributed 46 certificates to two vendors because a similarly-named company shared a word with them. | `coa_url` — a link to the certificate for that product, ideally the **lab's own copy** or a PDF. We verify it with the lab, so it is yours and nobody else's. |

We do not charge for a listing and we do not rank by commission. Accurate data is the entire benefit: a vendor whose prices and deals are right shows up correctly in every comparison a reader runs.

## The API

Two endpoints behind the same key: the catalog, which is required, and orders, which is optional. Put them wherever they fit your stack and send us the full URLs. The catalog:

```
https://yourdomain.com/api/peptides-index/v2/catalog
```

| Endpoint | Required | Returns |
| --- | --- | --- |
| `GET /catalog` | Yes | Your vendor block and every product you want listed, in one response. |
| `GET /orders` | No — optional (step 2) | The orders our readers placed with you, without any customer data — see "Orders" at the end. |

**HTTPS only.** The catalog has no pagination, no incremental sync and no webhooks: we fetch the whole catalog every time, and a few hundred products is a few hundred kilobytes. A product that is in one response and missing from the next has been delisted, and we act on that — so a full catalog is self-describing in a way a partial one never is. **Keep sold-out products in the feed** with `in_stock: false`: filter them out and they are delisted, then retired after three days.

### The key

Every endpoint is gated with a **read-only key that we issue you** — one unique key per vendor, in the vendor portal's Integration kit. We send it on every request as a header:

```
Authorization: Bearer <your key>
```

1. **Store** it as an environment variable named `PEPTIDES_INDEX_KEY` on your server, and read it from there — or, on WordPress, in the Peptides·Index plugin's settings page (**Settings → Peptides Index**; a `PEPTIDES_INDEX_KEY` constant in `wp-config.php` overrides it). Keep it out of your source code and never commit it to a public repository: it is what keeps other sites out of your feed. A new value usually takes effect only after a redeploy.
2. **Check** it on every request. Missing or wrong key: answer `401` (a `403` is accepted too) with the body `{"error":"unauthorized"}` and nothing else. That body is how our checker tells your key check from anything else answering for your site (see "Our key is the only gate"). Compare in constant time if your language offers it.
3. **Refuse to run without it.** If `PEPTIDES_INDEX_KEY` is missing or empty on your server, answer `503` with the body `{"error":"key_not_configured"}` — never `200`, and never compare our header against an empty string. Our checker reads that answer and tells you, in words, that the key is not set yet, instead of reporting a rejected key.
4. **Send** us the two endpoint URLs, catalog and orders, through the vendor portal. We already hold the key.

> **Don't let a cache serve it.** Send `Cache-Control: private, no-store` and `Vary: Authorization` on every response from every endpoint, including `401` and `503`. A page cache or CDN in front of your site can otherwise store the keyed response and hand it to the next visitor with no key at all — our checker requests the same URL without the key to catch exactly that, and fails the endpoint if a cache answers.

> **Never put the key in the URL.** We only ever send it as a header, and a `?key=` query string is written into your access logs, your CDN's logs, analytics and every proxy in between.

The catalog endpoint should serve your catalog and nothing else — not orders, not customers, not your store's admin API. Orders get their own endpoint, described at the end. We can rotate or revoke the key at any time: when we issue a new one, swap it into your environment variable, and the old one stops working the moment you do.

### HTTP behaviour we rely on

Mostly things your web server already does.

- **We fetch daily** and always fetch the full catalog. Rate limit us however you like; a handful of requests a day is the whole load.
- **Answer within a few seconds.** The portal's check gives up after 6 seconds, and the scheduled fetch retries a slow answer before it gives up for the day. If building the catalog is slow, serve a pre-generated file or a cached copy behind the same key check (see "A pre-generated file is fine").
- **`ETag` and/or `Last-Modified` — welcome, not required.** Return either and we send back `If-None-Match` / `If-Modified-Since`; a **304 Not Modified** with an empty body is a perfect answer when nothing changed.
- **Status codes that mean what they say.** `200` with data, `304` unchanged, `401` (or `403`) bad or missing key, `429` when we are asking too often, `503` during maintenance — and `503` with `{"error":"key_not_configured"}` when your own `PEPTIDES_INDEX_KEY` is not set. Please send `Retry-After` with `429` and `503`; we will back off rather than hammer you or, worse, conclude your catalog is empty.
- **Our key is the only gate.** We fetch from a server, never from a signed-in browser, so anything in front of your site answers us instead of your endpoint: a login, age or research-use-only gate, a members-only or wholesale plugin, a coming-soon page, password protection, a security setting that limits your API to logged-in users, or a firewall or bot check (Cloudflare, Wordfence, Sucuri, your host's anti-bot). Exclude both endpoint paths from every one of them — including any you add later. A gate without that exclusion stops your listing updating at our next fetch, and to us it looks like a rejected key. A real maintenance window that answers `503` with `Retry-After` is fine.

> **Never return `200` with an empty or partial `products[]` during an outage.** A successful-looking empty catalog reads as "this vendor delisted everything". We guard against it on our side — a vendor yielding zero products is skipped, never pruned — but a `503` is unambiguous and safer for both of us.

### A pre-generated file is fine

If it is simpler, build the JSON on a schedule and serve that file from the endpoint — **as long as the same Bearer check guards it**. A public file at a guessable URL is not gated, and anyone can scrape your whole catalog from it. A WordPress/WooCommerce plugin, a route in a headless Shopify app, a small serverless function — anything that answers the URL with the right JSON, behind the key, is a correct implementation. **A Shopify store on a theme builds none of this:** the vendor portal connects the store directly instead (its Shopify steps).

## What we actually need

Per product: `sku`, `name`, `url`, `price` and `compounds`. At the top: `schema_version` (`"2.0"`), `updated_at` — when your catalog last changed, as an ISO 8601 timestamp that includes a timezone (`Z` or an offset such as `-05:00`) — and your vendor `name`, `url` and `currency`. Without `compounds` we do not know what the product is or how much of it you sell, so we cannot compare it with anything.

That is the whole requirement. Every catalog field below this is optional and improves what we can show; send what you have and omit the rest. **A missing field is read as unknown and handled. A wrong one gets published.**

A complete, working response can be this short:

```jsonc
{
  "schema_version": "2.0",
  "updated_at": "2026-09-22T21:05:17Z",
  "vendor": { "name": "Your Company", "url": "https://yourdomain.com", "currency": "USD" },
  "products": [
    { "sku": "BPC10", "name": "BPC-157 10mg", "url": "https://yourdomain.com/product/bpc-157/",
      "price": 39.00, "compounds": [ { "slug": "bpc-157", "amount": 10, "unit": "mg" } ] }
  ]
}
```

A blend, with its composition — the shape that is easy to get wrong. `blend` names it as one of our listed blends; `compounds` still lists every component with its amount, because that is what the price per mg is computed from:

```jsonc
{ "sku": "KLOW80", "name": "KLOW 80mg",
  "url": "https://yourdomain.com/product/klow/",
  "price": 120.00, "form": "vial",
  "blend": "klow",
  "compounds": [
    { "slug": "ghk-cu",  "amount": 50, "unit": "mg" },
    { "slug": "bpc-157", "amount": 10, "unit": "mg" },
    { "slug": "tb-500",  "amount": 10, "unit": "mg" },
    { "slug": "kpv",     "amount": 10, "unit": "mg" }
  ] }
```

Ship that first if you like — it already gets your prices right. The rest of this document is what you can add afterwards, in any order.

## Everything you can add

```jsonc
{
  "schema_version": "2.0",                // string, REQUIRED — the version of THIS SPEC, not of your catalog
  "updated_at": "2026-09-22T21:05:17Z",   // string, REQUIRED — ISO 8601 with a timezone (Z or an offset),
                                          // when your catalog last changed
  "vendor": {
    "name": "Example Research",           // string, REQUIRED
    "url": "https://example.com",         // string, REQUIRED — your storefront
    "currency": "USD",                    // string, REQUIRED — ISO 4217, uppercase.
                                          // Applies to EVERY price in the feed.
    "ships_to": ["US", "CA"],             // array of strings — ISO 3166-1 alpha-2, uppercase
    // array of objects — what delivery costs and how long it takes, PER DESTINATION.
    // A country MUST NOT appear in more than one entry.
    //   countries : array of strings, REQUIRED — ISO alpha-2
    //   cost      : number — in `currency`; 0 means free
    //   free_over : number | null — order subtotal that makes it free; null = never
    //   days_min  : number | null — business days, low end
    //   days_max  : number | null — business days, high end
    "shipping": [
      { "countries": ["US"], "cost": 12, "free_over": 150, "days_min": 2, "days_max": 4 },
      { "countries": ["CA"], "cost": 25, "free_over": null, "days_min": 7, "days_max": 14 }
    ],
    // array of objects — EVERY method you accept, or omit the field entirely.
    //   method  : string, REQUIRED — "card" | "crypto" | "zelle" | "venmo" | "cashapp" | anything else you take
    //   pct_off : number | null — ONLY where paying that way costs less
    "payment_methods": [
      { "method": "card" },
      { "method": "crypto", "pct_off": 5 }
    ],
    // object | null — a percentage off for buying more. Omit or null if you have none.
    //   scope             : enum, REQUIRED — "cart" (mix and match across products)
    //                                      | "product" (N of the same item)
    //   tiers             : array of objects, REQUIRED — { min_qty: number, pct_off: number }
    //   stacks_with_packs : boolean — default false: we take whichever of this and
    //                       a product's `packs` is cheaper
    "volume_discount": {
      "scope": "cart",
      "tiers": [ { "min_qty": 3, "pct_off": 10 }, { "min_qty": 5, "pct_off": 20 } ],
      "stacks_with_packs": false
    }
  },
  "products": [
    {
      "sku": "BPC10",                        // string, REQUIRED — unique, and never changes
      "name": "BPC-157 10mg",                // string, REQUIRED — exactly as listed on your site
      "url": "https://example.com/p/bpc-157", // string, REQUIRED — absolute, on your own site
      // array of objects, REQUIRED — what is in ONE unit. One entry per compound.
      //   slug   : string | null, REQUIRED — from OUR compound list; null if it is not on it
      //   name   : string — REQUIRED when slug is null; what you call the compound
      //   amount : number, REQUIRED — per unit: per vial, per capsule, per bottle of spray
      //   unit   : enum, REQUIRED — "mg" | "mcg" | "iu"
      "compounds": [ { "slug": "bpc-157", "amount": 10, "unit": "mg" } ],
      // string | null — ONLY for a blend we list: the slug of that named blend,
      // one flagged "blend": true in /api/compounds. Omit it for a single
      // compound and for a blend we do not list. Never inside `compounds`.
      "blend": null,
      "form": "vial",                        // enum — "vial" | "capsule" | "tablet" | "spray" | "nasal" | "topical" | "kit" | "other"; default "vial"
      "unit_count": 1,                       // number — vials per unit sold, capsules per bottle; default 1
      "price": 39.00,                        // number, REQUIRED — ONE unit at quantity 1, in `currency`
      "min_qty": 1,                          // number | null — smallest quantity you sell; default 1
      "in_stock": true,                      // boolean | null — null means your platform cannot tell
      // array of objects | null — this product's own bundles.
      //   qty   : number, REQUIRED — units in the pack
      //   price : number, REQUIRED — the TOTAL for the pack, as your checkout shows it
      "packs": [ { "qty": 10, "price": 350.00 } ],
      // string | null — the current batch's certificate: best the LAB's own verify
      // page or PDF; a PDF or image on your own site is accepted too.
      "coa_url": "https://portal.ils-lab.com/verify/atZrY5XXDL3dPY0B"
    }
  ]
}
```

## Our compound list

Every `compounds[].slug` comes from one public endpoint — no key needed:

```
GET https://peptides-index.com/api/compounds
```

```jsonc
{
  "updated_at": "2026-09-22T21:05:17Z",
  "count": 74,
  "compounds": [
    { "slug": "bpc-157", "name": "BPC-157", "aliases": ["BPC-157", "Oral BPC-157"] },
    { "slug": "klow", "name": "KLOW", "aliases": ["KLOW"], "blend": true }
  ]
}
```

- **Match on `name` and `aliases`**, then send the `slug`. Aliases are the names vendors actually use, so your product name is often already in there.
- **Named blends carry `"blend": true`**; every other entry omits the key. A blend slug goes in a product's `blend` field, never in `compounds`.
- **Slugs are permanent.** Each one is the last part of that compound's public URL on our site (`/peptide/bpc-157`), so it does not change. Map once and the mapping holds.
- **Not on the list?** Send `"slug": null` with your `"name"` for the compound. We review it and either map it to an existing slug or add a new one; until then that product is not ranked. Never invent a slug — one we do not have matches nothing.

The list is also embedded in the AI onboarding prompt on this page, for assistants that cannot make web requests.

## Field notes, in order of how often they go wrong

### `price` is ONE unit, at quantity 1

> **`price` is what one unit costs when a customer adds it to the cart at quantity 1. Never a pack total, never a derived per-mg figure.** Ten vials for $350 is a `packs` entry, not `price: 350` — and so is a bundle your store lists as a product of its own ("BPC-157 10mg 3 Pack Special"): send it as a `packs` entry on the single product, not as a second product.

This is the single easiest field to get wrong, because most ecommerce systems have exactly one "price" and for a bundle product it is the bundle's. Exporting that straight through multiplies your cost per mg by the bundle size and drops you to the bottom of every comparison you should be winning.

"One unit" is whatever your cart counts as one:

| You sell | Send |
| --- | --- |
| One 10 mg vial for $39 | `price: 39`, `unit_count: 1` |
| A box of 5 vials as a single item, $175 | `price: 175`, `unit_count: 5` — your cart counts one box |
| Single vials, but only in fives, $35 each | `price: 35`, `min_qty: 5` — your cart counts vials, and five is the minimum |
| A bottle of 60 capsules for $60 | `price: 60`, `form: "capsule"`, `unit_count: 60` |

`price` is always present. **If you cannot price a product, leave the product out** rather than sending `0` or `null` — a zero price is the cheapest listing on the site.

### `compounds` — what is in it, in our words

`compounds` is an **array of objects**, one per compound in the product. Each has a `slug`, an `amount` and a `unit`.

- **`slug` comes from our compound list**, not from your product names — see "Our compound list" above. A slug names the compound, not the form: BPC-157 capsules are `bpc-157` with `form: "capsule"`.
- **`amount` is per unit** — per vial, per capsule, per bottle of spray. Not the package total (we multiply by `unit_count`), not a concentration, and not a dose. A 10 mL vial holding 600 mg is `amount: 600`. A bottle of 60 × 0.5 mg capsules is `amount: 0.5` with `unit_count: 60`.
- **`unit` is `"mg"`, `"mcg"` or `"iu"`.** IU and milligrams measure different things and there is no conversion between them. An IU listing is compared with other IU listings, never with a milligram one.
- **A blend is one entry per component**, with the amounts you already print on the label. A `10/3mg` Tesamorelin/Ipamorelin is two entries, `tesamorelin` at `10` and `ipamorelin` at `3`. Do not send the sum, and do not send percentages — you know the vial holds 10 mg and 3 mg, and round-tripping that through 76.9% / 23.1% loses precision in both directions. Mixed units are fine (`5` mg and `500` mcg); we normalise them.
- **A compound that is not on our list** gets `"slug": null` and your `"name"` for it. We review it and either map it to an existing compound or add it; until then it is not ranked.

### `blend` — naming one of our blends

Some blends are compounds on our list in their own right — `klow`, `wolverine`, `tesamorelin-ipamorelin` — flagged `"blend": true` in [/api/compounds](https://peptides-index.com/api/compounds). If your product is one of them, set `"blend"` to that slug **and** still list every component in `compounds` with its amount. The `blend` field decides which blend page you appear on; the components decide your price per mg.

- **A blend we do not list:** omit `blend` and just list the components. Any product with two or more compounds is treated as an unnamed blend.
- **Never put a blend slug inside `compounds`.** `{ "slug": "klow", "amount": 80 }` hides the composition and gives us nothing to compute from.
- We do not infer `blend` from components: two vendors' "KLOW" can differ, so the named blend is yours to state.

**A size you cannot state honestly is better left out** — send the product without it and tell us. A missing size costs you a ranking; a wrong one costs a reader's trust.

### `form` decides what you are compared against

Cost per mg is only meaningful within a route: capsules and vials are never ranked against each other, because oral use needs far more material and mg-for-mg would make capsules look 2–37× better. Getting `form` right protects you from a flattering comparison a reader would rightly distrust.

We group the forms into routes — injectable (`vial`), oral (`capsule`, `tablet`), spray (`spray`, and `nasal` for nasal drops, which is compared with spray), and `other` — and compare only within one. A wrong `form` is not a small error: it is your listing in someone else's table.

**Topical: accepted, price comparison coming soon.** Serums, creams and gels are `form: "topical"`. We list them, but do not yet compare them on cost per mg; when topical comparison arrives, your listings join it with no change on your side.

**Ten identical vials sold as one item is not a kit.** Many shops call that a "kit"; for us it is `form: "vial"` with `unit_count: 10`, or a `packs` entry. `form: "kit"` is for a bundle that is not one thing — different compounds in one box, or a vial sold with its water and syringes. We list a kit, but we do not rank it on cost per mg.

### `url` must be on your own site

Every product `url` has to be on the store you applied with: the same host, a subdomain of it, or its parent (`shop.example.com` for `example.com`, or the other way round). A sibling subdomain (`store.example.com` when you applied with `shop.example.com`) or any other site is refused: the checker reports it as `product-domain` and that product is not imported. Our Buy button sends shoppers to this link with our referral code added, so it must be the product page itself.

### `sku` must be unique and stable

It is how we know your renamed product is the same product. **A changed SKU is a new product**: the old listing looks delisted, the new one looks new, and its price history starts again from zero. Two products sharing a SKU is worse — one of them silently disappears.

### Shipping is per destination, and duration counts as much as cost

`shipping` is an **array of objects**, and **a country must not appear in more than one entry**. We could have said "the first matching entry wins", which would have made the order of a JSON array into business logic — reordering your entries would change the price a reader sees. An overlap is a validation error instead: we tell you, you fix it.

Two vendors at the same cost per mg are not the same offer to someone in Toronto. One ships for $12 in two days; the other charges $40 and takes three weeks through customs. `days_min` / `days_max` are **business days**, and a range is fine — most readers want to know whether it is "this week" or "next month".

A country in `ships_to` with no `shipping` entry is shown as "ships here, cost unknown". That is honest, but a real number is better.

### `free_over` is worth more than it looks

A $12 flat fee on a $39 vial is almost a third of the price again, and a reader comparing two vendors at $3.90/mg is really choosing between very different totals. Free-over thresholds also decide whether buying three is cheaper than buying one somewhere else.

### `payment_methods` changes the real price

Several vendors take 5–10% off for crypto or a bank transfer and say so only at checkout — by which point a reader has already chosen someone else on a headline number that was never the number. If you do this, tell us: it is one of the few things that genuinely moves where you land.

> **Send the whole list or none of it.** A partial list reads as the complete set and sends a reader to a checkout that wanted something else. We tried reading payment methods off storefronts and a scan of one vendor's page found "crypto, Venmo, Cash App" and missed "card" — from a single sentence that listed all four. So we publish nothing unless we have the lot.

### `packs` vs `volume_discount`

`packs` is **this product**: "10 vials of BPC-157 for $350". Its `price` is the **total for the pack**, exactly as your checkout shows it — not a per-vial figure; we divide. `volume_discount` is a percentage off for quantity: with `scope: "cart"` it is mix-and-match ("any 3 vials, 10% off"); with `scope: "product"` it counts only the same item ("3 of the same, 10% off"). Both are welcome; they display differently because they are different offers.

### How the discounts combine

You can express three price reductions — `packs`, `volume_discount` and a `payment_methods` percentage — and we compute a best achievable price from them. The rule we apply:

1. **Quantity discounts do not stack with each other.** `packs` and `volume_discount` are alternatives and we take whichever is cheaper at that quantity. Set `volume_discount.stacks_with_packs: true` **only** if your checkout genuinely applies both — if it is on and your checkout does not honour it, we publish a price nobody can buy at.
2. **A payment-method discount applies on top**, because it is nearly always a percentage off the final total. If yours is either/or with a quantity discount, tell us when you send the endpoint.

So ten vials on a pack, paid in crypto at 5% off, is the pack price less 5%.

### `min_qty` when you do not sell singles

Some vendors' smallest purchase is several of an item. Keep `price` as the one-unit figure and set `min_qty` to the number that has to be bought; we multiply. With `price: 35` and `min_qty: 5` we list a pack of 5 at $175 and show no single price; a `packs` entry for exactly 5 is used instead when you send one, larger packs are listed as sent, and smaller ones are left out because they cannot be bought. Omit the field if you sell singles. A spec with nowhere to say "you cannot buy one of these" invites a per-vial price nobody can actually pay, which is what we once published for one vendor until we caught it.

### `in_stock`

`true` or `false` if you know — and **keep a sold-out product in the feed with `in_stock: false`**: a product missing from the feed reads as delisted, and after three days it is retired with its price history. **`null` if your platform genuinely cannot tell** — some cannot. `null` is shown as "unknown", never as out of stock, so it costs you nothing; `true` on something you cannot ship costs a reader a wasted checkout.

## Lab certificates: send the link, not the numbers

We do not want purity figures, test panels or lab names from you. Send `coa_url` — a link to the certificate for the batch you are selling now — and **we verify it with the lab**: we identify the lab, read the certificate and, wherever the lab publishes its records, check the result against them.

**Any link works; some work better.** In order of preference:

1. **The lab's own copy** — its verify page or a lab-hosted PDF. Nothing to read twice: it already is the lab's record.
2. **A PDF on your own site.** Fine — we match it to the lab's record.
3. **An image on your own site** (a JPG or PNG of the certificate). Accepted, but a PDF or the lab's link reads more reliably.

| Lab | What a lab-hosted `coa_url` looks like |
| --- | --- |
| ILS | `https://portal.ils-lab.com/verify/<id>` |
| Freedom Diagnostics | `https://coas.freedomdiagnosticstesting.com/<code>.pdf` |
| Janoshik | `https://verify.janoshik.com/tests/<task>_<key>` |
| Vanguard | `https://verifiedbyvanguard.com/verify/<code>` |

Another lab is fine — send its verify page or PDF and we will add it.

Why a link, and why the lab's copy when you have it:

- **A link keeps itself current.** Update it when a new batch is tested and your listing follows; nobody has to send us a file.
- **It cannot be attributed to the wrong vendor.** Matching certificates by name is how 46 of them once ended up on two vendors that had never commissioned them. A link you give us, for your own product, is yours by construction.
- **It carries the whole panel.** Purity barely separates vendors — across everyone we list it runs from about 99.3% to 99.8%. Endotoxin, sterility, heavy metals and fentanyl screening do, and only about one certificate in five we hold carries a fentanyl screen. Everything you paid to have tested gets shown.

> **No link yet? You can still be listed.** `coa_url` is optional. Where we already hold a certificate for a product, the checker counts it; where we hold none, that product is listed without a certificate until you send one.

> **More than one document for a batch?** If your lab issues separate reports for the batch you are selling now — an endotoxin or sterility report beside the purity certificate — send them together as a list: `"coa_url": ["https://…/purity.pdf", "https://…/endotoxin.pdf"]`. Up to 10 links; the order does not matter. We read every link, and a separate test report is recognised as one — it is never counted as a second certificate. One link, sent as a string, works exactly as before.

Keep it current: when a new batch is tested, update the link. An old batch's certificate on a new batch's listing is the one thing in this section that can actually hurt you.

## What we compute ourselves

Do not send derived numbers. From `price`, `unit_count`, `packs` and `compounds` we compute:

- **per-vial price** (or per capsule) — `price ÷ unit_count`, and the same for every pack;
- **package total** — `amount × unit_count`, summed across components for a blend;
- **cost per mg** (or per IU) — within one form only;
- **best achievable price** — packs, volume discount and payment discount combined as described above.

If you send your own versions of these, they will disagree with ours on rounding at the very least, and a reader will see two numbers.

## What we do with it

1. **Fetch on schedule** — daily, with your key, respecting `Retry-After`. We fetch only the URL you give us. It is not permission to crawl the rest of your site, and your `robots.txt` does not apply to it.
2. **Publish** price, cost per mg, stock, packs, shipping and the lab's certificate on each listing, matched to our compound pages by `slug`.
3. **Never** alter your prices, and never rank by what we earn.

## Check it yourself before you send it

Every feed is validated on our side, and a failure is a conversation rather than a silent drop. These are the same checks, plus one ours never runs (a wrong key: our checker does not send one) — run them first and there will be nothing to talk about:

| Check | Why it exists |
| --- | --- |
| Every product has `sku`, `name`, `url`, `price` and `compounds` | They are the whole requirement. |
| `schema_version` is `"2.0"`, `vendor.name` and `vendor.url` are present, and `updated_at` is an ISO 8601 timestamp with a timezone (`Z` or an offset) | Our checker needs them to pass you: without a timezone we cannot tell when your prices changed. |
| `sku` is unique within the response | Two products on one SKU and one of them disappears. |
| `price` is present and greater than 0 on every product | A zero price is the cheapest listing on the site. Omit what you cannot price. |
| `vendor.currency` is an ISO 4217 code (`USD`, `EUR`, `GBP`…) | Every price in the feed is read in it. |
| Every `compounds[].amount` is positive, and `unit` is `mg`, `mcg` or `iu` | A zero or missing amount means no cost per mg. |
| Every `compounds[].slug` is on our list, or `null` with a `name` | An invented slug matches nothing. |
| `blend`, if present, is a slug flagged `"blend": true` in /api/compounds, and that product lists 2 or more `compounds` | A named blend without its components cannot be priced per mg. |
| No blend slug appears inside `compounds` | It hides the composition. |
| Every pack's price per vial (`price ÷ qty`, then `÷ unit_count`) is below the single price | A pack that costs more per vial is almost always a per-vial figure sent as a total, or the reverse. |
| No country appears in two `shipping` entries | Otherwise the rate a reader sees depends on array order. |
| `coa_url`, where you send one, is an absolute `https` link — or a list of up to 10 — to that product's current certificate and its separate reports; best the lab's own page or a PDF | We verify it with the lab; a relative or plain-`http` link cannot be fetched. |
| `stacks_with_packs` is `true` only if your checkout really applies both | Otherwise we publish a total nobody can buy at. |
| Diluents, syringes and merch are left out | Anything with no `compounds` is ignored anyway. |
| A sold-out product is still in the feed, with `in_stock: false` | A product missing from the feed is delisted, and retired after three days. |
| A bundle is a `packs` entry on its single product, not a product of its own | A "3 Pack Special" product is compared as one vial at the pack's total. |
| No `Authorization` header → `401` or `403`; wrong key → `401` or `403`; the key we issued → `200` | The endpoint is gated, and our key is the only way in. We never send a wrong key, so test that one yourself. |
| With no header, the `401` body is your endpoint's own `{"error":"unauthorized"}` — not a login or research-use gate's 401, a redirect, an HTML page or a bot challenge | Both gates that have cut vendors off so far answered with a JSON 401 of their own. Only the body tells them apart from your key check. |
| With `PEPTIDES_INDEX_KEY` unset or empty on the server → `503` `{"error":"key_not_configured"}`, never `200` | A missing key must not open the endpoint, or match an empty header. The 503 tells both of us exactly what is wrong. |
| Right after a keyed `200`, the same URL with no header still gets `401` or `403` — not a cached `200` | Our checker makes exactly that request. A page cache or CDN that replays the keyed answer opens your feed to anyone; `Cache-Control: private, no-store` and `Vary: Authorization` prevent it. |

## Validating it

Send the catalog URL — and the orders URL, when you build one — through the [vendor portal](https://peptides-index.com/vendors/portal) — we already hold the key, so there is nothing else to send. We run it and reply with exactly what we parsed — every product, compound, pack and certificate we read — so you can see your listing before it is live. If a field is wrong, we would rather find it in the diff than after publication.

## Orders

The second endpoint, and step 2: the orders our readers placed with you, with no customer data in them. **It is optional** — you are listed on your catalog alone, and you can add this before or after. It does not change how you rank — ranking is on price and data, never on what we earn.

### Why it exists

We watch what we send you. Clicks alone say which links people follow, not which of them became an order, a refund or nothing at all — and the only other place to find that out is your affiliate portal, which somebody has to log into and read by hand. An orders endpoint replaces that login: we read the same figures on a schedule, and it is how commission is reconciled — when your numbers and ours disagree, we both have one record to point at.

### The request

```
GET <your orders URL>?since=<ISO-8601 UTC>&cursor=<opaque>
Authorization: Bearer <your key>
```

- **The same key as the catalog**, checked the same way: missing or wrong key → `401` or `403` with `{"error":"unauthorized"}` and nothing else; `PEPTIDES_INDEX_KEY` unset on your server → `503` `{"error":"key_not_configured"}`. There is no second key to issue or store.
- **`since` means orders UPDATED since then, not created.** A refund or a cancellation changes an order you already sent us, and it only reaches us if its `updated_at` moves and `since` catches it. Example: `since=2026-09-22T00:00:00Z`.
- **`cursor`** is yours: an opaque string from your last page's `next_cursor`, passed back unchanged with the same `since`. The first request has no `cursor`. Build it from the last order's `updated_at` and `id`, and return the orders strictly after that pair — not a page number or an offset, which skips an order that changes during the pull.
- The status codes are the catalog's: `200` with data, `401` or `403`, `429` and `503` with `Retry-After`. Never `200` with an empty list during an outage — it reads as "no orders".

Send us the URL with the catalog's. It can be any path; `/api/peptides-index/v2/orders` beside the catalog is a sensible default.

### The response

```jsonc
{
  "schema_version": "2.0",                  // string, REQUIRED — the version of THIS SPEC, as in the catalog
  "orders": [                               // array, REQUIRED — at most 500 per page; [] when there are none
    {
      "id": "10482",                        // string, REQUIRED — your order number; stable, never reused
      "created_at": "2026-09-20T14:02:11Z", // string, REQUIRED — ISO 8601, UTC; a real date, 2000 or later
      "updated_at": "2026-09-21T09:30:00Z", // string, REQUIRED — ISO 8601, UTC; moves on every change
      // enum, REQUIRED — "pending" | "paid" | "fulfilled" | "cancelled" | "refunded" | "partially_refunded"
      "status": "paid",
      "currency": "USD",                    // string, REQUIRED — ISO 4217, uppercase
      "subtotal": 120.00,                   // number, REQUIRED — the items, before discounts; no shipping, no tax
      "discount": 12.00,                    // number, REQUIRED — the amount taken off the items; 0 if none
      "commissionable": 108.00,             // number, REQUIRED — what the agreed commission applies to
      // enum, REQUIRED — how the order reached you from us: "coupon" | "ref" | "both"
      "attribution": "both",
      "coupon_code": "PEPTIDES",            // string | null, OPTIONAL — the code as entered; null or left out when none
      "click_id": "k3v7q2mz5xab",           // string | null — our pi_click value from the visit; null only when the order came without one
      // array of objects, REQUIRED — what was bought
      //   sku : string, REQUIRED — the same sku as in your catalog
      //   qty : integer, REQUIRED — greater than 0
      "items": [ { "sku": "BPC10", "qty": 3 } ]
    }
  ],
  "next_cursor": null                       // string | null — pass it back for the next page; null on the last one
}
```

- **Only orders attributed to us** — placed with our referral code, arriving through our referral link, or both. Both are shown in the vendor portal (usually `PEPTIDES` and `?ref=PEPTIDES`). Nobody else's orders, not even with the customer removed.
- **At most 500 orders per page.** Past that, return a `next_cursor` and we ask again.
- **At most 20 pages per pull.** We follow `next_cursor` for 20 pages — 10,000 orders — and stop; the rest come on the next pull, which asks from the latest `updated_at` we hold, less a two-day overlap.
- **Sorted by `updated_at`, oldest first, across every page.** That is what makes stopping at page 20 safe: everything up to the last order we read has arrived, so the next pull resumes from there without a gap. In any other order, a pull that stops early holds a late `updated_at` while earlier orders it never reached fall behind `since`, and never arrive.
- **An order can reach us more than once** — on a later page, or again after it changes. We key on `id`, and the copy with the later `updated_at` wins, so re-sending is always safe.
- **Amounts are JSON numbers, 0 or more, and under 10 billion.** `108.00`, not `"108.00"`. A negative `subtotal`, `discount` or `commissionable` fails the order, and so does one that does not round to less than `9999999999.99`. We store cents: amounts are compared after rounding to two decimals.
- **Timestamps are real dates.** `created_at` and `updated_at` must exist on the calendar (`2026-02-30` fails, it is not rolled into March), be no earlier than `2000-01-01`, and be no more than a day ahead of our clock. A date in the far future would otherwise hold the window of every later pull.
- **One field is optional: `coupon_code`.** Leave it out or send `null` — absent reads as `null`. Our code is the one shown in the vendor portal (usually `PEPTIDES`), and `attribution` already says whether it was used.
- **`click_id`: build the capture wherever your platform can carry it (below).** It is `null` on an order that arrived without a `pi_click`, such as one where the customer typed our code, or on a platform that cannot carry it. When you send either field, it is a string within its limit below.
- **Field limits.** Longer values are rejected, not truncated — a cut-off order number would match the wrong order, or none. Lengths are counted in bytes, so a character outside plain ASCII counts as two or more:
  - `id` — at most 100 characters, and not empty
  - `coupon_code` — at most 100 characters
  - `click_id` — at most 64 characters
  - `items[].sku` — at most 120 characters, and not empty
- **A bad order is skipped, not half-stored.** An order that breaks any rule here is left out and the rest of the page is kept; the checker names it. A page that is not in the orders shape, or a `next_cursor` we have already been given, ends the pull — nothing from it is stored, and we try again next time.

> **No customer data, ever.** Anywhere in the response: no names, emails, phone numbers, addresses, IP addresses, customer ids or user ids, order notes or client details — not in a field of their own, not inside another one, not "just the city", and not beside the orders either (a top-level `"customers"` list counts). We have no use for them and do not want to hold them. **A response that contains any of them fails the check**, whatever else in it is right; an order carrying one is never stored, and a page carrying one outside its orders ends the pull.

### `commissionable` is the number the commission is worked out from

It is the amount your agreed commission applies to: **after discounts, before shipping and tax**. So it can never be more than `subtotal` − `discount`. It can be less — if some products earn no commission, leave them out of it — but never more. We send the figure rather than working it out ourselves because only your checkout knows what it excludes; if we derived it, the two sides would disagree on the first order that had an exception.

A refund lowers it: a `partially_refunded` order sends the amount that is still commissionable — commission is paid on that remaining amount — and a `refunded` or `cancelled` one sends `0`.

### `click_id` — build it with the endpoint, if your platform can

Our outbound links carry a `pi_click` parameter — `?pi_click=k3v7q2mz5xab` on the URL a reader lands on. Keep it when the reader lands (a first-party cookie or the session, for about 30 days), attach it to the order they place, and send it back as `click_id`, unchanged. Store it only if it is 1–64 characters of printable ASCII, otherwise store nothing; a later landing with a valid value replaces the earlier one. A page cache (WP Rocket, Cloudflare APO) can skip PHP on the landing page, so capture it where code actually runs — a small script, or at add-to-cart or checkout — not only on page load. It lets both sides match an order to the exact visit that produced it, rather than to a code anyone can type — and it is far easier to build now, alongside the endpoint, than to come back for later. Most stores can: WooCommerce and most custom stores easily, Shopify through a cart attribute.

Treat it as opaque — today it is 12 characters, `a`–`z` and `2`–`7`, but do not validate it against that. `click_id: null` is right for an order that arrived without one; `coupon` / `ref` attribution still works for those. If your platform cannot carry a value from the landing page to the order, send `null` — nothing fails, and it does not hold up your listing.

### What the orders checker runs

The same idea as the catalog checks: run them first and there is nothing to discuss.

| Check | Why it exists |
| --- | --- |
| No `Authorization` header → `401` or `403`; wrong key → `401` or `403`; our key → `200` | Orders are more private than a catalog. Our key is the only way in — a check that only looks for the header is not a gate. |
| With no header, the `401` body is your endpoint's own `{"error":"unauthorized"}` — not a login or research-use gate's 401, a redirect, an HTML page or a bot challenge | Both gates that have cut vendors off so far answered with a JSON 401 of their own. Only the body tells them apart from your key check. |
| With `PEPTIDES_INDEX_KEY` unset or empty on the server → `503` `{"error":"key_not_configured"}`, never `200` | A missing key must never open your orders. The checker reports it as "not set yet", not as a rejected key. |
| The response is valid JSON in the orders shape above | A shape we cannot read is a shape we cannot count. |
| No customer data anywhere in the response | Names, emails, phones, addresses, IPs, notes and customer ids — on an order or anywhere around the orders — fail it outright. |
| `commissionable` ≤ `subtotal` − `discount` on every order | A commission base larger than what the customer paid for the items is an error, whichever way it happened. |
| Every `items[].sku` is in your catalog | A warning, not a failure: an item you have since delisted is still a real sale. |
| `since` set to the current time returns `"orders": []` | Proves `since` is applied — otherwise every poll re-reads your whole order history. |
| `next_cursor`, passed back as `cursor`, returns the next page — none of the first page's orders again | A cursor that is ignored sends the first page forever, and we never see the rest. |
| Orders are sorted by `updated_at`, oldest first, on the first page and into the next | A warning, not a failure: out of order, a pull that stops at page 20 can leave orders behind for good. |
| `status`, `currency` and `attribution` use the listed values; `currency` is three uppercase letters | A status we do not recognise is an order we cannot count. |
| A `click_id` is shaped like ours | A warning, not a failure: something else in that field means the store is sending the wrong value. |

### One test order (it completes the sales step)

The checker proves the endpoint answers correctly; it cannot see a real sale. So the sales step is done once you have placed one real test order: make a hidden test product priced low — $5–$10, or whatever your payment processor accepts (a free or near-free order is one many processors and affiliate plugins skip, and it must be attributed to us) — and give it a SKU, such as `PI-TEST`: an order line with no SKU fails the order. Open your referral link from the vendor portal with `&pi_click=testorder234` added (the portal's **Test order** step shows it), go to the test product by its direct URL, check at checkout that your referral code is applied (enter it if not), and pay normally. Confirm it appears in your orders endpoint (with `since` set before the order), then use the portal's **Test order** step: enter the order id and press **Check** after placing it — while it is paid, within 30 days. Then refund it through your payment gateway, confirm it comes back with the new status, `commissionable` at `0` and a later `updated_at`, and press **Check refund** after refunding it. Both must pass for the sales step to read done. Delete or unpublish the test product afterwards. The AI prompt walks you through it (Phase 8).

---

Peptides·Index · vendor catalog API, spec version 2.0 · September 2026.
