# PeptideTech Merchant API and Webhooks Guide

Protocol version 2026-11-06. Merchant Agreement version 2026-11-06.4. Prepared November 6, 2026; developer tools added November 8, 2026.

Connect a selected catalogue and receive checkout orders through your own backend, using scoped API keys and signed webhooks. The WooCommerce plugin is an alternative. Start with fictional orders in the sandbox before live onboarding.

## Quickstart

1. Open /partners/sandbox and choose Start sandbox. Copy the ptk_test_ key and signing secret.
2. Download /downloads/merchant-api-example.mjs. Run `PT_SIGNING_SECRET='your sandbox secret' node merchant-api-example.mjs` (Node 22 or newer). It listens on 127.0.0.1:3339 with routes under /peptidetech.
3. Give it a public HTTPS address with a tunnel, for example `cloudflared tunnel --url http://127.0.0.1:3339` or `ngrok http 127.0.0.1:3339`.
4. In the sandbox, choose Test your backend and enter https://your-tunnel-host/peptidetech. PeptideTech sends eight signed requests and reports each result with the reason for any failure.
5. Replace the reference logic with your store's, keeping the test passing. Then follow Live onboarding below; the live signing secret replaces the sandbox one.

Copy-paste receivers and senders for Node, Python, PHP and the shell are on /partners/api.

To have an AI coding agent (Claude Code, Claude, ChatGPT or Codex, Cursor or another) write the integration, use the prompt on /partners/api or in the onboarding connection step, where it includes your store's address. A generic version is /downloads/peptidetech-agent-prompt.md. It carries the full contract, a signing test vector and the sandbox test plan, and tells the agent to read PT_SIGNING_SECRET and PT_API_KEY from environment variables; never paste keys or secrets into an AI chat. Review the agent's work and pass the sandbox backend test before going live.

## Evaluate the sandbox

Open /partners/sandbox and choose Start sandbox. No account, live agreement, store connection or payout wallet is required. The workspace expires after 24 hours. It holds fictional buyers and orders only, and cannot create live orders, send money, send email or publish listings. Backend acknowledgement and payment are simulated in this demo.

The workspace returns a ptk_test_ API key and signing secret. Use them only with /api/partners/sandbox. Test tokens are rejected by the live API; live tokens are rejected by the sandbox. Sessions belong to the token or browser that created them. Avoid entering real customer information.

| Method | Sandbox path | What it does |
| --- | --- | --- |
| POST | /api/partners/sandbox | Create a workspace and one-time test credentials |
| GET | /api/partners/sandbox | Read your workspace with its bearer token or browser cookie |
| POST | /api/partners/sandbox/catalogue | Replace the demo catalogue with 1 to 50 fictional products |
| POST | /api/partners/sandbox/orders | Create a fictional paid order for product_id or the first demo product |
| POST | /api/partners/sandbox/events | Submit a signed demo event |
| POST | /api/partners/sandbox/backend-test | Send signed sample requests to your own backend and report each check |

Catalogue body: {"products":[{"id":"sample-1","name":"Demo research sample","price":"200.00"}]}. The demo order uses a fictional U.S. buyer, no shipping charge and zero tax. To exercise the failure path, create an order, simulate 14 days without handoff, then simulate staff recording the merchant refund. Create another order to try carrier handoff.

Sandbox event envelope: {"id":"demo_event_123456789","type":"clock.advance","data":{"order_id":"SBX-reference"}}. Supported demo types are order.updated or order.shipped (status shipped or delivered with data.handoff_at; the order can be named by order_id or suborder_id), clock.advance (14 days), and refund.recorded. order.updated has the same shape as the live event, so shipment code can move from the sandbox to live unchanged. Sign the exact sandbox event path using the contract below. These demo event types are not live merchant refund permissions.

Backend test body: {"base_url":"https://your-tunnel-host/peptidetech"}. Using the sandbox signing secret, PeptideTech calls your POST /verify, POST /quote with no items and with the first sandbox product, POST /webhooks with integration.test, the same with a deliberately wrong signature (which must be refused with a 4xx), POST /webhooks with a fictional order.paid, that order.paid again (which must return the same order), and GET /orders/{suborder_id}. The response lists each check as pass, warn, fail or skipped, with the HTTP status, time, the request sent and an excerpt of your response. Sandbox requests carry "sandbox": true in the body and the header x-peptidetech-sandbox: 1. The base URL must be public HTTPS with no credentials, query or fragment; redirects are refused, each call has eight seconds and the whole test forty. The test is limited to 20 runs an hour per sandbox. Passing it is not live verification.

## Live onboarding and access

1. Implement the four backend endpoints below on HTTPS under your store domain or a subdomain. Public DNS must resolve only to public addresses. Redirects are refused.
2. Create your merchant account, read and sign the current Merchant Agreement, and choose API and webhooks in the connection step. The sandbox never performs these actions for you.
3. With the owner account password, configure the backend base URL and explicitly grant quotes:read, orders:create and orders:read. Save the signing secret shown once. This authorizes only the documented endpoints, with no general backend administrator or database access.
4. Issue a ptk_api_ scoped bearer token for your server. Keys expire after 1 to 90 days; the portal issues 30-day keys by default. Keep secrets on the server. Owners can revoke keys; reconfiguring the endpoint rotates the signing secret and revokes all scoped keys.
5. Verify the backend. PeptideTech checks the challenge proof, an empty USD quote and an integration.test webhook. Do not create a customer order for integration.test. Verification does not establish real payment settlement.
6. Accept merchant responsibilities with your account password: tax countries, a dispatch promise of 1–14 days, refunds and product liability. Optionally authorize signed operations requests to your backend.
7. Push only the products you want listed and heartbeat at least daily. Match the exact package and publish the required citations. Add your own payout wallet and switch checkout on in the portal. Listing remains conditional on the current agreement, verified backend, fresh feed, matched products, citations or grace period, payout wallet, checkout enabled and no suspension. GoAffPro is optional.

Your backend must retain durable order and event idempotency records. The downloadable reference backend uses in-memory storage and demonstrates the contract; replace that storage before live use.

## Permissions and live endpoints

Live base path: /api/partners/v2. Header: Authorization: Bearer ptk_api_... Browser sessions and legacy plugin keys do not authenticate this API. Each token belongs to one store. Invalid, revoked or expired keys return 401; insufficient scope returns 403; suspension stops API access.

| Method and path | Required scope | Data and purpose |
| --- | --- | --- |
| GET /account | account:read | Own store slug, listing state, backend verification and protocol version |
| POST /catalogue | catalogue:write | Upsert at most 250 published products; remove at most 250 product ids |
| GET /orders/pending | orders:read | Own paid orders awaiting acknowledgement, including fulfilment details |
| POST /orders/ack | orders:write | suborder_id, merchant order_id and optional order_number |
| POST /events | By event type | Signed catalogue.upsert, order.updated, case.responded or heartbeat |
| GET /operations | operations:read | Own refund, dispute, verification and tax cases |
| POST /operations/respond | operations:write | Submit case_id, reference and note as unverified evidence |
| GET /tax?month=YYYY-MM | tax:read | Own merchant tax report |

No token grants wallet changes, agreement signing, account administration, other stores' orders, refund proof approval, debt reversal or marketing permission. Those remain separate portal or staff actions.

Catalogue example:

```json
{"products":[{"id":"bpc-10","name":"BPC-157 10mg","price":"200.00","currency":"USD","status":"publish","stock_status":"instock","stock_quantity":10,"permalink":"https://yourstore.example/products/bpc-10","coa_links":[]}],"remove":[]}
```

Include package size in the name or attributes. Optional attributes, categories, description, sku and COA links support matching and evidence review. Draft/private products are refused. Existing screening applies, including controlled substances and HGH. Removal body: {"remove":["bpc-10"]}. Merchants cannot set grades. A limited API feed does not change the evidence requirements.

## Backend endpoints PeptideTech calls

Append these paths to the granted base URL, such as https://api.yourstore.example/peptidetech. All calls are signed. Respond with JSON. Quotes have an eight-second timeout, paid-order delivery twenty seconds, and responses a 1 MB limit.

| Endpoint | Required response |
| --- | --- |
| POST /verify | proof = hex HMAC-SHA256(signing secret, challenge); permissions includes quotes:read, orders:create, orders:read |
| POST /quote | quote_id, expires_at, currency USD, items, ships, item_tax, shipping_methods, errors |
| POST /webhooks | integration.test returns ok true and challenge proof; order.paid creates one order and returns order_id, order_number, status processing |
| GET /orders/{suborder_id} | order_id, order_number, status, tracking and handoff_at for this order |

Quote input: {"items":[{"external_id":"bpc-10","qty":1}],"currency":"USD","address":{"name":"Demo Buyer","line1":"Example address","city":"Example city","state":"TX","postcode":"77001","country":"US"}}. Before the shopper gives an address, it is omitted. Verification sends empty items and expects empty arrays, with currency USD.

Quote item fields: external_id, name, sku, unit_price, line_total, in_stock and stock_quantity. Shipping service fields: id, label, cost, tax, days_min and days_max. Return item_tax separately from shipping tax. Use finite, nonnegative decimal USD amounts and true live stock. A quote reserves no stock; honour the quoted order once paid.

Paid event envelope: {"id":"evt_suborder-uuid","type":"order.paid","version":"2026-11-06","data":{...order fields...}}. The real id is evt_ followed by the suborder UUID. The same suborder can arrive by webhook and the pending-order fallback. Use a unique suborder_id in your order database and acknowledge the existing order on every duplicate.

## Signatures events and retries

Both directions use x-peptidetech-timestamp (Unix seconds), x-peptidetech-nonce (event id for events), and x-peptidetech-signature (hex HMAC-SHA256). The signed string is:

```text
timestamp.nonce.METHOD.path.sha256hex(raw body)
```

Use the actual path including the configured prefix, uppercase method, and exact raw body bytes. A GET signs an empty body. Reject timestamps outside five minutes, malformed signatures and reused event ids with different bodies. Compare signatures in constant time. Keep credentials out of URLs and logs.

Single-file helpers with no dependencies implement this for Node 18+ (/downloads/peptidetech-signing.mjs), Python 3.8+ (/downloads/peptidetech_signing.py) and PHP 7.4+ (/downloads/peptidetech-signing.php): verify an incoming request or webhook, sign an outgoing request, and compute the challenge proof. /downloads/peptidetech-signing-vectors.json holds test vectors computed by PeptideTech's own signer; each helper checks them with --test, and a custom implementation should reproduce them.

PeptideTech's refusals of a signed event name the cause in code: bad_timestamp, expired_timestamp (with server_time), bad_event_id, event_id_mismatch or bad_signature. A bad_signature answer also contains signed: the method, path, body_sha256 and string_to_sign PeptideTech computed, never the secret or the expected signature, so the string your code signed can be compared directly.

Inbound live envelope: {"id":"event_123456789abcdef","type":"order.updated","data":{"suborder_id":"uuid","status":"shipped","handoff_at":"2026-11-06T20:00:00Z","tracking":[{"carrier":"Example carrier","number":"example-tracking"}]}}. The id must have 16 to 100 letters, digits, underscores or hyphens, and equal the nonce header.

- catalogue.upsert requires catalogue:write and takes the catalogue body in data.
- order.updated requires orders:write. It takes suborder_id, status, optional order_id/order_number, tracking and note. Use shipped or delivered only with handoff_at after payment and not in the future. A tracking label on processing is refused as shipment. Completed is not an API status; report actual handoff separately.
- heartbeat requires account:read and keeps the connection's feed activity current.

A completed duplicate returns the previous result with duplicate true. A changed body for an existing id returns 409. An event in progress returns 409 in_progress; retry that id and body with a fresh timestamp/signature. Event receipts are retained for 90 days. Do not replay older events.

Paid-order webhooks retry after 1, 5, 15 and 60 minutes, then every six hours. Delivery is at least once. Poll GET /orders/pending if a push fails and acknowledge the merchant order with POST /orders/ack. Signed status polling can reconcile quiet orders. Staff can inspect failed dispatches and redispatch. Persist receiver idempotency records for the order's lifetime.

## Data-sharing settings

Each store chooses what it shares in its data-sharing settings, in the onboarding connection step and the dashboard's settings. Only the owner can change them (POST /api/partners/data-settings from the signed-in portal); team members can read them. PeptideTech enforces them on its side for the API and the WooCommerce plugin alike: a field switched off is discarded when it arrives, and data already stored for it is removed when the setting is saved. Defaults share everything, as before these settings existed. GET /api/partners/v2/account returns the current data_settings so a backend can stop sending what would be discarded.

| Setting | Key and options | Effect |
| --- | --- | --- |
| Stock levels | stock: "exact" or "status" | "status" discards stock_quantity from the catalogue and quotes; buyers see out of stock instead of a count |
| Product descriptions | descriptions: true or false | false discards descriptions; matching uses name, SKU, attributes and categories |
| AI-assisted product matching | ai_matching: true or false | false sends no product data to the AI matcher (OpenRouter); unplaced products wait for staff. Certificates are still read by an AI vision model |
| Notes on order updates | order_notes: true or false | false discards the optional note on order.updated |
| Buyer phone on paid orders | buyer_phone: true or false | false leaves the phone out of order.paid and pending orders |
| Address with quotes | quote_address: "full" or "region" | "region" sends only city, state, postcode and country before payment |

Always shared: product name, price and in-stock status; product link and certificate links; live quote prices, shipping options and tax; the merchant order id and number; carrier, tracking number and handoff time.

## Buyer data and marketing

Quotes receive requested product ids, quantities and a delivery address when available, before payment, to calculate stock, shipping and tax. The address can include name, line1, line2, city, state, postcode, country and phone if supplied. Quote input has no payment card data.

Paid-order delivery and pending-order reads share only this merchant's suborder: suborder_id, checkout reference, quote id, buyer email and delivery address; item ids, quantities and paid unit prices; chosen shipping service; item, shipping, tax and order totals; payment method/provider, coin, transaction ids, the merchant wallet, fee and rate, payout amount, wallet amount, guarantee offset and repayment.

No card number, CVV, customer password or login, order access key, other merchant's order or other merchant's wallet is included. Use buyer information for fulfilment and support. The platform has no separate merchant marketing opt-in at checkout. Buyers can separately subscribe through your own explicit consent flow; an order email address is not permission to add them to marketing.

## Handoff refunds and payout offsets

The agreement uses carrier handoff within 14 days after payment, rather than delivery. The API records handoff_at, tracking, merchant order reference and event activity. The dashboard shows shipment and guarantee state, order totals, fees, payouts and offsets. Handoff is a merchant report; PeptideTech does not query a carrier to independently verify it. A label that the carrier never receives is not shipment under the agreement.

If unshipped at the deadline, the merchant owes the customer a refund. Automatic store credit and a merchant debt back up that duty. A request opens automatically at the recorded dispatch deadline, or at 14 days when no shorter promise was recorded. The merchant arranges and funds the refund. A configured independent evidence service can verify the settlement; otherwise staff review it. An API status of refunded does not prove money was returned. Card-network disputes still require a supported provider feed or manual handling. A late shipment does not automatically reverse issued credit or debt.

Later checkouts can offset at most 50% of each merchant payout while debt is outstanding. Unspent customer credit is reversed when a refund is proved; spent goodwill credit does not automatically reduce the required money refund. A merchant can dispute the debt in the dashboard with evidence. There is no funded reserve or automated provider refund API.

## A 200 dollar order

These illustrations assume no prior debt, no store credit and the default 20% seller fee. The tax amount is an illustrative merchant quote, not a determination of taxability or a jurisdiction's rate.

| Amount in USD | No tax example | Tax quoted by merchant |
| --- | --- | --- |
| Merchandise | 200.00 | 180.00 |
| Shipping | 0.00 | 10.00 |
| Tax | 0.00 | 10.00 |
| Seller order total | 200.00 | 200.00 |
| PeptideTech seller fee | 40.00 | 40.00 |
| Expected merchant proceeds before offsets | 160.00 | 160.00 |
| Card processing paid by buyer | 10.00 | 10.00 |
| Buyer pays by card | 210.00 | 210.00 |

The fee applies to items, shipping and tax. Quoted tax is not independently remitted by PeptideTech. Crypto processing is 4.00 plus the network estimate in both examples; the buyer total is 204.00 plus that estimate. Actual settlement depends on provider confirmation and wallet receipts. A real payment has not yet been established by the production checkout records checked for this rollout.

For a fully card-paid order cancelled for non-shipment, the full refund request in either example is 210.00, including the allocated 10.00 buyer processing fee. The 40.00 seller fee remains retained. A merchant already paid 160.00 therefore needs another 50.00 to fund that refund. Automatic requests, reminders, tax entries and independent proof checks are available; PayGate money movement is not. If 200.00 of goodwill credit remains unused, it is reversed when the refund is confirmed. Spent goodwill credit does not silently reduce the required cash refund.

A 200.00 guarantee debt can offset 80.00 of the 160.00 merchant proceeds on the next equivalent sale, leaving 80.00 paid to the merchant and 120.00 debt outstanding. Offsets do not reduce the next buyer's total.

## Contract tax and live pilot eligibility

The agreement names peptidetech.is as operator and chooses Icelandic law. It does not name an incorporated contracting entity. That contracting-party question must be resolved before a live commercial commitment. The contracts remain unreviewed drafts.

The merchant calculates tax, collects through checkout and files/remits where legally responsible. PeptideTech records the quoted tax and confirmed refund adjustments. Reports do not file returns, remit tax or establish taxability. Any marketplace obligations imposed on PeptideTech remain. The final allocation still needs professional review before relying on it.

The platform applies research-use attestation and product screening, including blocking controlled substances and HGH. These checks do not establish that any particular product, marketing claim or buyer is legally eligible. There is no automated age or laboratory credential verification. A live U.S. pilot needs an agreed, reviewed product list and buyer policy, not an assumption that all research-labelled products are permitted.

## Support and reference material

Support: none; no email inbox or chat is monitored, and the setup is self-serve (https://peptidetech.is/contact). The API documentation page is /partners/api. Download the OpenAPI specification, the Node reference backend, the signing helpers, their test vectors and the AI agent prompt there. The onboarding connection step shows the same documentation and a prompt personalised for your store. The reference backend runs on Node 22 or newer and requires PT_SIGNING_SECRET; it never prints the secret. Live credentials and secrets are generated in the merchant portal, not exchanged over email.

## Merchant operations and independent evidence

The owner may enable signed refund.requested, dispute.requested, tax.requested and verification.requested events on the verified backend. Each has id = ops_<case UUID>_<revision>, type and data containing the case. Return {"ok":true,"event_id":"the received id"}. Persist delivery idempotency; deduplicate money refunds by the underlying order/refund request, because reminders have new event revisions.

GET /operations shows the store's cases and capability flags. POST /operations/respond accepts {"case_id":"UUID","reference":"provider reference","note":"explanation"}. Alternatively send signed case.responded with those fields in data. A reference is an assertion, not proof: these endpoints cannot mark a refund paid, verify an identity, remit tax, reverse debt, or access any payout wallet. A submitted case awaits independent verification. Cases retry with backoff and daily reminders. Unresolved overdue refund/dispute cases pause checkout.

GET /tax?month=YYYY-MM returns quoted sale tax and confirmed refund tax entries in USD. The merchant remains responsible for its filings and remittance, subject to marketplace obligations imposed by law. Merchant claims do not count as verified remittance.

Only the operator can connect the trusted evidence service. That service must check original payment/settlement, carrier or identity sources independently; it must not echo seller assertions as verified. Without it, relevant cases explicitly await review. PayGate provides no cash-refund, arbitrary debit or dispute-feed capability in this integration. Buyer age and laboratory credentials are not verified automatically.

The implementation contract for the evidence service, retry rules, full capability table and record lifecycle is in /downloads/merchant-operations.md.
