The interactive reference needs JavaScript. The full guide follows; it is also served as markdown at /llms-full.txt and as OpenAPI at /openapi.json.
# OpenStock API (v1.6.0) Canonical integration guide: https://api.openstock.sh/llms-full.txt. This guide and its endpoint examples are served from the same API release as /openapi.json and /docs. Use this current version when an older evaluation pack or cached copy differs. ## Overview: cashback for your wallet **OpenStock is a white-label cashback API for agents, assistants and wallets.** Quote an exact cashback amount before an agent buys, report the paid order, and receive the cleared cashback in your own receiving account for allocation to the user. Your users keep their existing wallet and never create an OpenStock account. Four facts make the integration safe to ship, and the API states each one explicitly: - **The quote is the commitment.** A successful funded quote reserves backing and commits exact cents for an eligible basket: a $100 basket at 8% commits $8, a $2,000 basket at 15% with a $100 cap commits $100. OpenStock funds it. Every eligible US storefront without a native offer of its own earns the funded rate discovery shows, 8% at almost every store, capped at $100 per order; a store with a native offer earns that offer’s rate through the same funded quote. Amazon and non-US storefronts are excluded. - **Agent checkout earns.** The funded path takes a paid-order report from merchant-API or browser checkout. It needs no tracking cookie and no browser session. Discovery tells you the path to use for each store in `checkout.recommended`. - **You credit your users’ wallets from money you have received.** After the 30-day hold, OpenStock transfers cleared cashback to the USD receiving account you connect and verify through the API. You match the receipt, credit the user once keyed by the transfer id, and acknowledge. You never front funds. - **A credit is never unwound.** A refund during the 30-day hold reduces the reward before it is credited. After release, OpenStock absorbs ordinary shortfalls and late merchant clawbacks, and a bank return after you have credited a user is re-sent by OpenStock on the same transfer: the user keeps the reward and you carry no loss. What you provide is one USD receiving account and the credit into your own ledger. OpenStock provides the rest: the funded commitments, the ledger, the payout rail and the funds it sends, the verification deposit that proves bank delivery, signed events and replay. | Step | Contract | | --- | --- | | Discover | Resolve the exact storefront, country, eligibility and the checkout path to use | | Quote | Commit the cashback amount, checkout deadline and reporting deadline for the basket | | Purchase | Check out in a browser or through the merchant API, then attest the completed payment | | Hold | Keep the cashback reserved and unspendable for 30 days; refunds can reduce it during the hold | | Connect | Submit your receiving account once; confirm the $1.00 verification deposit from your statement | | Settle | Daily or on demand, OpenStock transfers available cashback to that account | | Credit | Match the receipt, credit the user once keyed by the transfer id, acknowledge receipt and allocation | An `os_test_` key rehearses every step, the receiving-account connection included, on a simulated ledger with `livemode: false` on every response. An `os_live_` key resolves stores, commits quotes and activates links for real. The deployment is the same for both; gate on `livemode` and the key prefix, never on the environment name. ## Quickstart: quote to user-wallet allocation Set `OPENSTOCK_API_KEY` to an account-bound sandbox key with the cashback, wallet, transfer and event scopes listed below. This Python 3 script uses only the standard library and a fresh simulated user and order. It neither buys a product nor transfers real funds. It covers a funded quote, held purchase, partial refund, clearance, connecting and verifying a receiving account, a transfer, separate receipt and allocation, a bank return after allocation, and event replay. ```python import datetime as dt, json, os, uuid, urllib.request BASE = "https://api.openstock.sh" KEY = os.environ["OPENSTOCK_API_KEY"] if not KEY.startswith("os_test_"): raise SystemExit("Use an os_test_ sandbox key") run = uuid.uuid4().hex user, order = "test-" + run, "order-" + run def now(): return dt.datetime.now(dt.timezone.utc).isoformat(timespec="milliseconds").replace("+00:00", "Z") def call(path, body=None): request = urllib.request.Request(BASE + path, data=None if body is None else json.dumps(body).encode(), headers={"Authorization": "Bearer " + KEY, "Content-Type": "application/json"}) with urllib.request.urlopen(request, timeout=30) as response: return json.load(response) # 1. Discover the storefront and the checkout path to use. storefront = "https://www.nike.com/" found = call("/v1/cashback/stores", {"query": storefront, "country": "US"}) store = found["store"] assert found["match"]["by"] == "url" and store["status"] == "active" and store["country"] == "US" assert store["checkout"]["recommended"] == "funded" and store["checkout"]["agent_api_checkout"] # 2. Commit the eligible basket. The quote, not the discovery percentage, is the promise. quote = call("/v1/cashback/quotes", {"store_id": store["store_id"], "user_id": user, "storefront_url": storefront, "eligible_amount": 10000, "country": store["country"], "checkout_mode": "merchant_api", "expected_checkout_seconds": 259200, "idempotency_key": order + ":quote"}) assert quote["livemode"] is False print("Committed cashback cents:", quote["cashback"]["amount"]) # 3. In production: complete payment, then report its actual time and order reference. report = call("/v1/cashback/purchases/report", {"user_id": user, "store_id": store["store_id"], "country": "US", "order_id": order, "amount": 10000, "currency": "USD", "quote_id": quote["quote_id"], "purchased_at": quote["created_at"], "evidence": {"type": "partner_attested", "reference": "sandbox-payment-" + run}, "idempotency_key": order + ":report"}) assert report["livemode"] is False and report["estimated"] is False def balance(): result = call("/v1/wallets/read", {"queries": [{"query_id": "balance", "user_id": user, "type": "balance"}]})["results"][0] assert result["livemode"] is False and not result.get("error"), result return result["data"] assert balance()["available"]["amount"] == 0 # held for 30 days call("/v1/cashback/purchases/refund", {"user_id": user, "store_id": store["store_id"], "order_id": order, "amount": 4000, "currency": "USD", "idempotency_key": order + ":refund"}) held = balance()["reserved"]["amount"] print("Reward after the simulated $40 return:", held) # 480 # Sandbox only: simulate the hold ending, rather than waiting 30 days. call("/v1/cashback/sandbox/reports/advance", {"user_id": user, "report_id": report["report_id"], "outcome": "creditable"}) assert balance()["available"]["amount"] == held # 4. Connect the receiving account once. The sandbox simulates the bank; live sends a real $1.00. destination = call("/v1/settlement/destination", {"account_holder_name": "Example Wallet, Inc.", "bank": {"routing_number": "021000021", "account_number": "000123456789", "account_type": "checking"}, "address": {"first_line": "1 Main St", "city": "Palo Alto", "state": "CA", "post_code": "94301"}, "idempotency_key": "receiving-account:" + run})["destination"] if destination["status"] == "pending_verification": # a known account comes back as it stands assert destination["verification"]["status"] == "sent" statement = destination["sandbox_statement"] # live: read the OSV reference from your bank statement destination = call("/v1/settlement/destination/verify", {"destination_id": destination["id"], "reference": statement["reference"], "amount": statement["amount"]})["destination"] assert destination["status"] == "verified", destination readiness = call("/v1/settlement/readiness") assert readiness["configuration_ready"] and readiness["blockers"] == [] print("Live account still needs:", readiness["live_account"]["next_steps"]) # 5. Transfer, then acknowledge receipt and allocation as two separate facts. transfer = call("/v1/transfers", {"user_id": user, "amount": held, "currency": "USD", "idempotency_key": order + ":transfer"})["transfer"] assert transfer["livemode"] is False and transfer["credit_key"] == transfer["id"] sent = call("/v1/cashback/sandbox/transfers/advance", {"transfer_id": transfer["id"], "status": "sent"})["transfer"] assert sent["provider_reference"].startswith("simulated_") receipt = {"reference": "sandbox-bank-" + run, "received_at": now(), "amount": sent["amount"], "provider_reference": sent["provider_reference"]} received = call("/v1/transfers/acknowledge", {"transfer_id": transfer["id"], "received": True, "allocated": False, "receipt": receipt})["transfer"] assert received["status"] == "succeeded" and received["allocated_at"] is None # Production: commit your own wallet credit once, keyed by transfer["credit_key"], before this call. allocated = call("/v1/transfers/acknowledge", {"transfer_id": transfer["id"], "received": True, "allocated": True, "allocation": {"reference": "sandbox-wallet-" + run, "allocated_at": now()}})["transfer"] assert isinstance(allocated["allocated_at"], str) assert balance()["transferred"]["amount"] == held # 6. A bank return after allocation never unwinds the user credit: it is re-sent on the same transfer. reissued = call("/v1/cashback/sandbox/transfers/advance", {"transfer_id": transfer["id"], "status": "returned"})["transfer"] assert reissued["status"] == "processing" and reissued["reissue"]["count"] == 1 assert reissued["credit_key"] == transfer["id"] and reissued["allocated_at"] == allocated["allocated_at"] assert balance()["transferred"]["amount"] == held and balance()["available"]["amount"] == 0 resent = call("/v1/cashback/sandbox/transfers/advance", {"transfer_id": transfer["id"], "status": "sent"})["transfer"] call("/v1/transfers/acknowledge", {"transfer_id": transfer["id"], "received": True, "allocated": False, "receipt": {**receipt, "reference": "sandbox-bank-" + run + "-2", "received_at": now(), "provider_reference": resent["provider_reference"]}}) cursor = None while True: page = call("/v1/events/read", {"limit": 100, **({"cursor": cursor} if cursor else {})}) print("Events:", [event["type"] for event in page["items"]]) # Persist resume_cursor only after durably processing these events. cursor = page["next_cursor"] if cursor is None: print("Resume cursor:", page["resume_cursor"]); break print("Final balance:", balance()) ``` Retry writes with their original idempotency key and body. A new basket needs a new quote and key. Sandbox fast-forwarding and the simulated bank are a rehearsal of the contract; the live key runs the same calls against real stores, the real payout rail and your real account. ## Agent checkout guide 1. Call `POST /v1/cashback/stores` with the actual storefront or product URL and `country: "US"`. Keep regional paths: `https://www.nike.com/gb/` is not the US storefront even though its store ID can be shared. Read `status`, the resolved `country` and `checkout.recommended`. `match.by` says whether you matched a URL, a domain or a name; a name is a search, so confirm the store or resolve the checkout URL before quoting. 2. When `checkout.recommended` is `funded`, call `POST /v1/cashback/quotes` with that same actual URL in `storefront_url`, the discovered `store_id`, explicit `country: "US"` and the eligible merchandise subtotal in USD cents: after discounts, excluding tax, shipping and gift cards. The API resolves the URL again and checks it against the store and country before committing funds, so a name match can never fund the wrong store. Show the successful quote’s `cashback.amount` as the payable amount, never the discovery percentage. A $100 eligible basket at 8% commits $8; a $2,000 basket at 15% with a $100 cap commits $100. Cashback is rounded to the nearest cent, and a basket whose cashback rounds to zero is refused with `QUOTE_UNAVAILABLE`. 3. Complete checkout by `checkout_expires_at`. The default window is 72 hours; request up to seven days with `expected_checkout_seconds`. Browser and merchant API checkout are supported for this OpenStock-funded commitment, which does not depend on tracking cookies. 4. Call `POST /v1/cashback/purchases/report` before `report_expires_at` with `quote_id`, the exact eligible amount, actual `purchased_at`, order ID and `evidence: {type: "partner_attested", reference: "your-payment-reference"}`. Report only orders your own payment system captured; this is your attestation that the order was paid. Keep supporting records. The report deadline is 14 days after the checkout deadline. The funded path is the path for an agent that pays. Where a store also has a native link offer, `checkout.recommended` still says `funded` whenever a funded quote is available, because the funded quote earns without a browser session; Sephora, for example, carries both a native 2.5% link and a funded 2.5% quote with a $100 cap, and the quote is the one to use. A changed basket or an expired checkout window needs a fresh quote before payment. The quote is reserved for one purchase and scoped to your account, user and ledger. Unavailable funding returns `503 GUARANTEE_UNAVAILABLE` without issuing a new commitment. Respect eligibility and the returned terms; broad discovery coverage does not make every product eligible. Use the payment’s actual ISO 8601 UTC time for `purchased_at`. Whole-second timestamps are accepted when payment occurred in the quote’s creation second; a precise timestamp before the quote or any future timestamp returns HTTP 400 with `INVALID_PURCHASE_TIMESTAMP`, naming `purchased_at` and explaining whether it precedes the quote or is in the future. Correct the timestamp from the payment record. A new quote cannot retroactively authorize an order that was already paid. Send the merchant’s confirmation order number as `order_id` and retain any other merchant-issued IDs with your payment evidence. A numeric transaction ID and a confirmation order number can be matched automatically only when the merchant supplies their relationship; matching totals or purchase times is insufficient. If a `cashback.pending` event has reason `funded_order_identity_unverified`, provide the merchant’s ID mapping and evidence reference to your OpenStock contact. The funded commitment remains recorded while the separate native purchase awaits reconciliation; do not create another report to force a match. ### Native tracking links and codes, for browser checkout Native offers remain available when the shopper checks out in their own browser and you choose the store’s own attribution method (`checkout.recommended` is `native_link` or `native_code` only where no funded quote exists). Open the activation URL in the same persisted browser context that completes checkout and let the browser follow every redirect. Never send your API key to tracking or merchant hosts. A successful redirect does not prove attribution, commission or payment, and native cashback waits for the store to confirm and pay, typically 30 to 90 days; a funded quote does not. `attribution_window.kind` states `timed`, `same_session`, `unknown` or `not_required`; `duration_seconds` is explicit for a timed window. A missing historical day count means unknown, not same session. Activation rejects an unsupported requested checkout duration. An OpenStock-funded quote can cover a checkout that is longer than a native window. For a generated, single-use code bound to `wallet_id`, use that code on the order. Other public codes are not bound to the user. Native purchases without a funded quote remain subject to merchant validation and payment; do not present an uncommitted native rate as a guaranteed amount. The sandbox link completion credits at once because it simulates an already-confirmed purchase; live native credits arrive after the store pays. ## Wallet integration guide `POST /v1/wallets/read` batches up to 20 user queries. Read `balance`, `pending_purchases`, `purchases` and `transactions`; follow `next_cursor` until null. A `wallet_not_found` result means no wallet yet; other query errors must not be shown as a zero balance. | Balance | Meaning | What to show the user | | --- | --- | --- | | `reserved` | Cashback still in the purchase hold | Pending, with the quoted cents | | `available` | Cleared cashback at OpenStock that can be reserved for a transfer | Pending: it is not yet in your account | | `transfer_pending` | Available cashback reserved for an outstanding transfer | Pending: on its way to your account | | `transferred` | Cashback whose transfer receipt you acknowledged | Credited, once your ledger has posted it | Show the quoted cents from the moment the quote succeeds and keep the reward pending until your ledger has credited it from received funds. A funded purchase has `estimated: false` even while its status is pending: its amount is committed, but it stays unspendable during the 30-day hold. Before release, a refund reduces the held amount and emits an adjustment or reversal event. A $40 refund of a $100 order with $8 cashback leaves $4.80 held. Once the funded cashback is available, OpenStock absorbs ordinary commission shortfalls and late merchant clawbacks; an ordinary refund does not silently reduce the user’s available balance. Daily clearance processes eligible holds. Request-time reads are not a substitute for monitoring the clearance job. Quotes backed by OpenStock do not wait 45–90 days for merchant payment. Legacy native purchases without a guarantee can still wait for merchant confirmation and payment. Use opaque user identifiers, stable idempotency keys and the correct ledger. Rotating a key preserves users in the partner account. All settlement amounts are USD cents; never display a response with `livemode: false` as real money. ## Fund your existing wallet with real USD OpenStock pays cleared cashback into the USD receiving account you connect, by USD bank transfer, daily as cashback clears or on demand. You match each receipt, credit the user in your own wallet ledger, and acknowledge. The partner never funds the reward and never fronts money: availability at OpenStock is the point at which we initiate the payout, and your user credit follows receipt. Users do not need an OpenStock account. The rail pays one verified receiving account per partner. It does not call an external consumer-wallet credit API and does not route to individual user bank accounts; your wallet backend is the last step, and the transfer id is its idempotency key. ### Connect your receiving account 1. **Submit the account.** Call `POST /v1/settlement/destination` once with the account holder, routing and account numbers, account type and address. The details are registered on OpenStock’s payout rail as the recipient; OpenStock keeps the recipient id and the last four digits. The call needs `transfers:write`. 2. **Receive the verification deposit.** OpenStock sends $1.00 to the new account with a ten-character bank reference starting `OSV`. The sandbox marks it sent at once and prints the statement line in `sandbox_statement`; a live deposit shows up on your real statement, and the API never returns its reference. A live deposit reads `pending` until it is sent; replay the submission with the same `idempotency_key` and body until it reads `sent`. 3. **Confirm it.** Call `POST /v1/settlement/destination/verify` with the reference and exact amount from the statement. A match verifies the account, switches daily and on-demand settlement on, and records that OpenStock has delivered real USD to your account. Replays return the verified account; a mismatch answers `409 VERIFICATION_MISMATCH` and changes nothing. That is the whole onboarding on your side. Everything else is OpenStock’s: the live key, the payout rail and the funds it sends, the daily scheduler, signed events. A later submission with a new idempotency key and different bank details replaces the current account once the new one is verified; until then the verified account keeps receiving settlement. The same bank account under a new key returns the account as it stands and is never deposited to twice. ### Read readiness before you ship Call `GET /v1/settlement/readiness` with the credential you intend to use; it needs `wallets:read` and never moves money. It answers for that key’s ledger: - `configuration_ready` and `blockers`, with `next_steps` naming who resolves each blocker: `partner` or `openstock`. A sandbox key is ready as soon as it has the transfer scopes; it pays a simulated receiving account until you connect one, and reports the same account’s live state in `live_account` so the live go-live gap is visible while you rehearse. - `settlement.destination`: the connected account, its verification deposit and status. - `verification`: what has been checked for real. For a live key, `bank_receipt` is `verified` once you confirmed the deposit, and `user_wallet_credit` is `verified` once a transfer carries your allocation acknowledgment, read from the live ledger and cached ten minutes. The sandbox reports `simulated` for each. - `onboarding.steps`: the five-step checklist with owners, from credentials to the first allocation. ### Transfers Request a transfer with `POST /v1/transfers`: send `user_id`, `amount` in USD cents, `currency: "USD"` and `idempotency_key`. The amount is reserved atomically, so concurrent requests cannot spend it twice; two simultaneous transfers of a full balance produce one acceptance and one `409 INSUFFICIENT_BALANCE`. Retry with the same key after an uncertain response. With daily settlement enabled, OpenStock creates at most one automatic transfer per user per UTC day; on-demand requests can move newly released cashback sooner. | Status | Meaning | | --- | --- | | `reserved` / `processing` | Funds are held for dispatch | | `sent` | The payout rail reports sending the transfer; receipt is not yet confirmed | | `reconciling` | The dispatch outcome is uncertain; funds remain reserved | | `succeeded` | You acknowledged receipt | | `failed` / `returned` | A confirmed failure or return before allocation; available funds are restored | A transfer returned or cancelled by the bank **after** you allocated it does not end in `returned`. It goes back to `processing`, `reissue.count` increments, the returned attempt is listed in `reissue.history`, and OpenStock sends the money again under the same transfer id and credit key. One event, `transfer.reissued` (reason `returned_after_allocation` or `failed_after_allocation`), tells you; `transferred` and `allocated_at` are unchanged, and you acknowledge receipt of the re-sent money as usual. After three re-sends the transfer stops as `returned` with reason `reissue_limit_reached` and OpenStock settles it with you by hand; the credit still stands. The user keeps the reward and you carry no shortfall. Read `POST /v1/transfers/read` by transfer ID or paginate the list. After money reaches your account, call `POST /v1/transfers/acknowledge` with `received: true` and `receipt: {reference, received_at, amount: {amount, currency: "USD"}, provider_reference}`, matched against the transfer id, provider reference, USD amount and receiving account on your bank record. Acknowledging before `sent` is rejected; a receipt for the wrong amount answers `409 RECEIPT_MISMATCH`. References identify records retained by your backend; send no bank numbers or personal details. Conflicting evidence is rejected; retry the same evidence after a timeout. ### Credit each user exactly once First acknowledge actual receipt with `{received: true, allocated: false}`. Then use `credit_key` (the transfer id) as a unique external-credit key in your wallet database. In one database transaction, insert that key and credit the associated user for the received amount; on a duplicate key, read the existing credit instead of crediting again. After that transaction commits, acknowledge `{received: true, allocated: true}` with `allocation: {reference, allocated_at}`. If the acknowledgment times out, retry it without repeating the wallet credit. Never mark allocation complete before your own ledger commit. The credit key never changes, including when a transfer is re-sent after a bank return, so a retry cannot credit twice. Consume `POST /v1/events/read` in order. Deduplicate event IDs, persist the returned `resume_cursor` only after applying the events, and follow `next_cursor` while present. Replay is safe. Events describe holds, adjustments, release and transfer transitions. `transfer.evidence_recorded` adds reconciliation metadata to an earlier acknowledgment; it must never trigger another user credit. Re-read the referenced purchase or transfer when reconciling. The event log is per account and ledger; a new key sees its account’s whole history. ### Webhook verification and recovery Configure a separate HTTPS endpoint and verification key for each ledger during onboarding. A delivery contains `{id, livemode, events}` with the same events as the replay endpoint. Verify `X-OpenStock-Signature: t=<unix-seconds>,v1=<hex-signature>` against HMAC-SHA256 of the timestamp, a literal period, and the exact raw request body, using the partner-and-mode verification key. Select the key with `X-OpenStock-Key-Version`; compare signatures in constant time and reject timestamps outside a five-minute tolerance. Do not reserialize JSON before verification. Timestamp compatibility: pending deliveries first persisted before contract v1.5 may contain numeric `events[].created_at` values in Unix milliseconds. Those bodies and delivery IDs remain unchanged until acknowledgment, including retries after an upgrade. After verifying the signature over the exact raw body and checking its freshness, parse the JSON and normalize a numeric event timestamp with `new Date(value).toISOString()`; do not treat it as Unix seconds. Newly created deliveries and event replay responses use ISO 8601 UTC strings, including when replaying older events. This exception applies only to already persisted webhook bodies. Return a 2xx response only after durably accepting the delivery. `X-OpenStock-Webhook-Id` is stable across retries; deduplicate individual event IDs as well. The queue continues healthy delivery pages immediately. Failed deliveries preserve the exact persisted body, with exponential backoff from one minute capped at one hour; the five-minute scheduler recovers due work. Use the replay cursor to recover gaps or a prolonged endpoint outage. A webhook is a notification, not bank receipt or user allocation. Ledger changes and their events are recorded atomically; webhook delivery follows asynchronously. Do not treat notification arrival as an approval gate before the ledger changes. Keep held cashback out of the spendable wallet balance, and use the transfer receipt and allocation acknowledgments to reconcile funded user credits. ## Discovery guide `POST /v1/cashback/stores` resolves the actual storefront and country. Marketplace seller pages resolve to the marketplace; alternatives may be regional storefronts and do not imply a separate seller cashback program. `active` means eligible, `not_eligible` carries a reason, and `unknown` requires retrying before commitment. `match.by` is `url`, `domain` or `name`; a name is a search ("Apple Services" is Apple and ineligible, "Apple Rose Beauty" is an ordinary eligible store), so for agent checkout resolve the URL the agent will pay on. Discovery and activation use `type: "percentage"`. Every percentage discovery preview has `basis: "quote_required"`: discovery reserves no funding and makes no payable commitment. `cashback`, `attribution` and `requires_browser_context` describe the native offer. When present, `sponsored_checkout` separately describes the OpenStock-funded path: `quote_required: true`, `funding: "openstock"`, report attribution, no required browser context, its percentage rate and `max_per_order` cap. `checkout.recommended` picks between them for an agent that pays: `funded` whenever a funded quote exists, else the native method; `checkout.agent_api_checkout` says whether that path earns without a browser session. Use the successful quote’s `cashback.amount`, not the discovery percentage, as the promised amount. The funded path can apply a cap even when the native offer does not. Examples describe configured scenarios; live discovery and a successful quote are the current authority. ### Coverage, by name `POST /v1/cashback/coverage` resolves the top US retailers by traffic, plus well-known specialty storefronts, exactly as discovery would, and returns each with its status, recommended path, rate and cap, with counts in `summary`. It is a named list you can check store by store, refreshed at most hourly; the index cannot express a percentage of US shopping. `POST /v1/cashback/catalog` lists the whole merchant index with stable ID pagination, including merchants without a popularity rank. Send `{"country":"US","limit":500}` and continue with each `next_cursor` until null. Every entry carries `funded`: whether a funded quote can be requested there under the current policy, with its cap, or the reason it cannot; discovery gives the store’s rate. `catalog.funded_eligible_entries` and `catalog.excluded_entries` say how much of the index can be quoted; `catalog.house_rate` is the funded rate and default cap for stores without a native offer. Pages observe a changing index, not a frozen snapshot: deduplicate by `store_id` and record `observed_at`. The index-wide counts are taken about hourly and carry `counted_at`. Resolve a specific checkout URL through discovery and obtain a quote before promising cashback; catalog eligibility is a policy evaluation, not a quote. `POST /v1/cashback-savings` remains a deprecated discovery projection. Integrate the canonical store, quote, purchase and wallet endpoints for new work. ## Security and compliance OpenStock is built by Mate (Checkmate Intelligence, Inc.). The [terms and data processing agreement](https://usemate.ai/terms) describe the contractual processing framework. Request the applicable agreement and current security materials during onboarding; a public agreement does not mean a particular partner has signed it. The SOC 2 report scope includes cashback operations: purchase attribution, reward and wallet records, holds and reversals, and payout orchestration through partner APIs including OpenStock. See the [public security scope](https://usemate.ai/knowledge-hub/privacy-faqs) and request the report for its system boundary, tests, review period and exceptions. Keep bearer keys on your server and use HTTPS. Restrict settlement and acknowledgment capabilities to the services that need them. Use a random, partner-scoped user ID or a keyed HMAC that only you can map back to the user. Do not send email addresses, email hashes, public account handles, bank account numbers or payment credentials as user IDs or evidence. Receiving-account details are accepted only by `POST /v1/settlement/destination`, which registers them on OpenStock’s payout rail and retains the recipient id and last four digits. Evidence references should identify records you retain. Signed sandbox checkout links are private; do not log or share them. The cashback integration processes partner and opaque user identifiers, storefront and order identifiers, eligible amounts, payment times and evidence references, quote and reward records, transfer references, acknowledgments and event-delivery metadata. It does not require shopper history or the user’s identity in your wallet. Confirm retention, deletion, access controls, subprocessor and receiving-account details in your agreement and onboarding review. ### Credential scopes | Scope | Enables | | --- | --- | | `cashback:read` | Storefront discovery, coverage and the catalog | | `cashback:write` | Quotes, activation, paid-order reports, refunds and sandbox cashback/transfer simulations | | `wallets:read` | Cashback balances, purchases, transactions and settlement readiness | | `transfers:read` | Transfer status and listing | | `transfers:write` | Transfer requests, receipt/allocation acknowledgments and the receiving account | | `events:read` | Durable event replay | | `shopping:read` | Optional merchant and product search | | `shopping:write` | Optional discount-code requests | | `shoppers:read` | Optional authorized shopper history | A wallet integration needs the first six capabilities; it does not need the optional shopping or shopper-history scopes, and a cashback-only key answers them with `403 INSUFFICIENT_SCOPE`. Use dedicated keys per service where practical. Key prefixes select sandbox or live, not permissions. ## Integration readiness **What the sandbox proves.** Every contract rule, with simulated money: exact cents and caps, idempotent replay and `409 IDEMPOTENCY_CONFLICT` on a changed body, purchase timestamp checks, refunds during the hold, clearance, atomic transfer reservation, the distinct `sent`, receipt and allocation facts, receipt mismatches, failed and returned transfers, the re-send of a return after allocation, the receiving-account connection and verification, and ordered event replay. `livemode` is false on every response. **What the live key proves.** Real storefront resolution and rates, live funded quotes backed by OpenStock funds, real activation links and their redirect chains, and live wallet reads. Settlement to your account needs the receiving account below; until then `GET /v1/settlement/readiness` names that one partner-owned step and reports what the live ledger has verified. **What you provide.** One USD receiving account, submitted through the API, and the confirmation of its $1.00 verification deposit from your statement. That confirmation is the live proof of bank delivery. Then credit users in your own ledger keyed by `credit_key`, and acknowledge. | Go-live step | Owner | When | | --- | --- | --- | | Sandbox rehearsal of the whole lifecycle | Partner | Any time, with the sandbox key | | Live key with the transfer scopes | OpenStock | Issued alongside the sandbox key | | Receiving account submitted and verified | Partner | One API call, then one confirmation once the deposit appears on your statement | | First live transfer, receipt and allocation | Partner | After the first funded reward clears its 30-day hold, or on demand for any available balance | **How to present it to users.** Show the quoted cents from the successful quote, never a discovery percentage. Keep the reward pending through the hold and until your ledger has credited it from received funds, then show it as credited. Report only orders your own payment system captured. **Operations.** https://status.openstock.sh probes the API every five minutes, including discovery, the click link, sandbox checkout and wallet reads, and publishes its history at /status.json. Uptime describes availability, not payouts; payouts are evidenced by readiness, transfer receipts and allocation acknowledgments. Quote `X-Request-Id` when you contact support. ## Limits, versioning and support Use the limits in the request schemas, batch reads and tell your OpenStock contact your expected peaks. Quote `X-Request-Id` for support at https://openstock.sh/developer-access. Tolerate new response fields. Contract v1.6 adds the receiving-account connection, `checkout.recommended`, `match.by`, catalog eligibility, named coverage, `credit_key` and the re-issue of returned transfers; v1.5 requires the actual `storefront_url` and explicit country on quotes, uses ISO 8601 monetary API response timestamps and new webhook timestamps, and separates native discovery from quote-required sponsored previews. Funded pending purchases have `estimated: false`. Update earlier clients that expected epoch timestamps, `percent`, or same-session attribution inferred from null. Webhook receivers must retain the narrow pre-v1.5 pending-delivery exception described in [Webhook verification and recovery](#webhook-verification-and-recovery), normalizing numeric event timestamps only after raw-body signature verification. ## How to run a production evaluation of the cashback integration This section is the whole evaluation: the quickstart with a coverage check, the live checks, the catalog and the coverage evidence. Assess two things and report them together as one recommendation: - **Integration readiness.** Whether an integration can be built now against the sandbox contract, with go-live gated on the one step the partner owns: connecting and confirming its receiving account. - **US store coverage.** Whether the evidence in the coverage step supports offering cashback across US online shopping. Report sandbox findings and live-key findings separately. **Access.** Base URL `https://api.openstock.sh`. Your two keys are issued separately by your OpenStock contact and never appear here: a sandbox key (`os_test_…`, simulated money, `livemode: false` on every cashback response) and a live key (`os_live_…`, real stores, quotes, activation links and wallet reads, `livemode: true`). Send either as `Authorization: Bearer <key>` and keep both private. At go-live OpenStock issues production keys through a channel you nominate and revokes the evaluation keys. Both keys are cashback-only (shopping and shopper-history endpoints answer `403 INSUFFICIENT_SCOPE`) and carry the cashback, wallet, transfer and event scopes. The live key cannot move money until a receiving account is verified; everything else on it is real. `GET /health` reports `environment: "production"` for the deployment and `ledgers: ["live","sandbox"]`; gate on `livemode` and the key prefix, never on the environment name. ### Step 1. Funded cashback, end to end, in the sandbox Copy the block below into `quickstart.py` and run it with the sandbox key. It is the quickstart above with a coverage section at the end, and it can be run repeatedly on the same key. It discovers Nike and reads `checkout.recommended`, commits a quote, reports a paid order, refunds $40 during the hold, releases the hold, connects a receiving account and confirms its $1.00 verification deposit from the simulated statement line, reads `GET /v1/settlement/readiness`, reserves a transfer, acknowledges receipt and allocation as two facts, simulates a bank return after allocation and shows the transfer re-sent with the same `credit_key`, `allocated_at` and `transferred`, reads the event log, and then proves coverage against the named list, the whole index and a spot check. ```bash OPENSTOCK_API_KEY=<your sandbox key> python3 quickstart.py ``` ```python import datetime as dt, json, os, uuid, urllib.request BASE = "https://api.openstock.sh" KEY = os.environ["OPENSTOCK_API_KEY"] if not KEY.startswith("os_test_"): raise SystemExit("Use an os_test_ sandbox key") run = uuid.uuid4().hex user, order = "test-" + run, "order-" + run def now(): return dt.datetime.now(dt.timezone.utc).isoformat(timespec="milliseconds").replace("+00:00", "Z") def call(path, body=None): request = urllib.request.Request(BASE + path, data=None if body is None else json.dumps(body).encode(), headers={"Authorization": "Bearer " + KEY, "Content-Type": "application/json"}) with urllib.request.urlopen(request, timeout=30) as response: return json.load(response) # 1. Discover the storefront and the checkout path to use. storefront = "https://www.nike.com/" found = call("/v1/cashback/stores", {"query": storefront, "country": "US"}) store = found["store"] assert found["match"]["by"] == "url" and store["status"] == "active" and store["country"] == "US" assert store["checkout"]["recommended"] == "funded" and store["checkout"]["agent_api_checkout"] # 2. Commit the eligible basket. The quote, not the discovery percentage, is the promise. quote = call("/v1/cashback/quotes", {"store_id": store["store_id"], "user_id": user, "storefront_url": storefront, "eligible_amount": 10000, "country": store["country"], "checkout_mode": "merchant_api", "expected_checkout_seconds": 259200, "idempotency_key": order + ":quote"}) assert quote["livemode"] is False print("Committed cashback cents:", quote["cashback"]["amount"]) # 3. In production: complete payment, then report its actual time and order reference. report = call("/v1/cashback/purchases/report", {"user_id": user, "store_id": store["store_id"], "country": "US", "order_id": order, "amount": 10000, "currency": "USD", "quote_id": quote["quote_id"], "purchased_at": quote["created_at"], "evidence": {"type": "partner_attested", "reference": "sandbox-payment-" + run}, "idempotency_key": order + ":report"}) assert report["livemode"] is False and report["estimated"] is False def balance(): result = call("/v1/wallets/read", {"queries": [{"query_id": "balance", "user_id": user, "type": "balance"}]})["results"][0] assert result["livemode"] is False and not result.get("error"), result return result["data"] assert balance()["available"]["amount"] == 0 # held for 30 days call("/v1/cashback/purchases/refund", {"user_id": user, "store_id": store["store_id"], "order_id": order, "amount": 4000, "currency": "USD", "idempotency_key": order + ":refund"}) held = balance()["reserved"]["amount"] print("Reward after the simulated $40 return:", held) # 480 # Sandbox only: simulate the hold ending, rather than waiting 30 days. call("/v1/cashback/sandbox/reports/advance", {"user_id": user, "report_id": report["report_id"], "outcome": "creditable"}) assert balance()["available"]["amount"] == held # 4. Connect the receiving account once. The sandbox simulates the bank; live sends a real $1.00. destination = call("/v1/settlement/destination", {"account_holder_name": "Example Wallet, Inc.", "bank": {"routing_number": "021000021", "account_number": "000123456789", "account_type": "checking"}, "address": {"first_line": "1 Main St", "city": "Palo Alto", "state": "CA", "post_code": "94301"}, "idempotency_key": "receiving-account:" + run})["destination"] if destination["status"] == "pending_verification": # a known account comes back as it stands assert destination["verification"]["status"] == "sent" statement = destination["sandbox_statement"] # live: read the OSV reference from your bank statement destination = call("/v1/settlement/destination/verify", {"destination_id": destination["id"], "reference": statement["reference"], "amount": statement["amount"]})["destination"] assert destination["status"] == "verified", destination readiness = call("/v1/settlement/readiness") assert readiness["configuration_ready"] and readiness["blockers"] == [] print("Live account still needs:", readiness["live_account"]["next_steps"]) # 5. Transfer, then acknowledge receipt and allocation as two separate facts. transfer = call("/v1/transfers", {"user_id": user, "amount": held, "currency": "USD", "idempotency_key": order + ":transfer"})["transfer"] assert transfer["livemode"] is False and transfer["credit_key"] == transfer["id"] sent = call("/v1/cashback/sandbox/transfers/advance", {"transfer_id": transfer["id"], "status": "sent"})["transfer"] assert sent["provider_reference"].startswith("simulated_") receipt = {"reference": "sandbox-bank-" + run, "received_at": now(), "amount": sent["amount"], "provider_reference": sent["provider_reference"]} received = call("/v1/transfers/acknowledge", {"transfer_id": transfer["id"], "received": True, "allocated": False, "receipt": receipt})["transfer"] assert received["status"] == "succeeded" and received["allocated_at"] is None # Production: commit your own wallet credit once, keyed by transfer["credit_key"], before this call. allocated = call("/v1/transfers/acknowledge", {"transfer_id": transfer["id"], "received": True, "allocated": True, "allocation": {"reference": "sandbox-wallet-" + run, "allocated_at": now()}})["transfer"] assert isinstance(allocated["allocated_at"], str) assert balance()["transferred"]["amount"] == held # 6. A bank return after allocation never unwinds the user credit: it is re-sent on the same transfer. reissued = call("/v1/cashback/sandbox/transfers/advance", {"transfer_id": transfer["id"], "status": "returned"})["transfer"] assert reissued["status"] == "processing" and reissued["reissue"]["count"] == 1 assert reissued["credit_key"] == transfer["id"] and reissued["allocated_at"] == allocated["allocated_at"] assert balance()["transferred"]["amount"] == held and balance()["available"]["amount"] == 0 resent = call("/v1/cashback/sandbox/transfers/advance", {"transfer_id": transfer["id"], "status": "sent"})["transfer"] call("/v1/transfers/acknowledge", {"transfer_id": transfer["id"], "received": True, "allocated": False, "receipt": {**receipt, "reference": "sandbox-bank-" + run + "-2", "received_at": now(), "provider_reference": resent["provider_reference"]}}) cursor = None while True: page = call("/v1/events/read", {"limit": 100, **({"cursor": cursor} if cursor else {})}) print("Events:", [event["type"] for event in page["items"]]) # Persist resume_cursor only after durably processing these events. cursor = page["next_cursor"] if cursor is None: print("Resume cursor:", page["resume_cursor"]); break print("Final balance:", balance()) # 7. Prove US store coverage: the named list, the whole index, and a spot check of your own. # Discovery, coverage and the catalog answer the same for both keys. coverage = call("/v1/cashback/coverage", {"country": "US"}) named = coverage["retailers"] excluded = [r["name"] for r in named if r["status"] != "active"] print("Named US retailers:", len(named), "| funded:", coverage["summary"]["eligible"], "| excluded:", excluded) assert len(named) >= 120 and excluded == ["Amazon"], (len(named), excluded) catalog = call("/v1/cashback/catalog", {"country": "US", "limit": 500})["catalog"] share = catalog["funded_eligible_entries"] / catalog["indexed_entries"] print(f"Indexed US storefronts: {catalog['indexed_entries']:,} | funded-eligible: {share:.3%} | counted {catalog['counted_at']}") assert share > 0.999 # Any US store you care about: resolve it and read the funded rate it earns. for query in ["https://www.apple.com/", "https://www.tjmaxx.com/", "https://www.heb.com/", "Alo Yoga", "Hoka"]: hit = call("/v1/cashback/stores", {"query": query, "country": "US"})["store"] assert hit and hit["status"] == "active" and hit["checkout"]["recommended"] == "funded", (query, hit) funded = hit["sponsored_checkout"] print(f" {hit['name']}: funded {funded['rate']['value']}% up to ${funded['max_per_order']['amount'] / 100:.0f} per order") ``` Beyond the script, check exact cents and caps, idempotency (replaying a quote returns the same commitment; a changed basket under the same key answers `409 IDEMPOTENCY_CONFLICT`), concurrent transfers of one balance (one `202`, one `409 INSUFFICIENT_BALANCE`), `RECEIPT_MISMATCH` on a receipt short by a cent, that `transferred` never moves backwards, and that `POST /v1/wallets/read` answers zero balances after a quote and `wallet_not_found` before one. Cashback is rounded to the nearest cent; a basket whose cashback rounds to zero is refused with `QUOTE_UNAVAILABLE`. ### Step 2. Live discovery and readiness with the live key Call `POST /v1/cashback/stores` for `https://www.nike.com/` (funded 8%, $100 cap, `agent_api_checkout: true`), `https://www.sephora.com/` (a native 2.5% link and a funded 2.5% quote; `checkout.recommended` is `funded` because the quote needs no browser session), `https://www.apple.com/` (`active`, funded 5%, $100 cap), `https://www.amazon.com/` (`not_eligible`, `merchant_policy`) and `https://www.nike.com/gb/` (`not_eligible`, `unsupported_country`). Read `match.by` for a URL and for a name such as `Apple Rose Beauty`. Commit one live funded quote for a $100 basket and let it expire unreported, so no live order is involved. Optionally activate one native link with `POST /v1/cashback/activate` and follow its redirect chain in a browser. Then call `GET /v1/settlement/readiness` with the live key: it names `destination_unverified` as the one remaining step, shows the onboarding checklist with its owners, and reports what the ledger has verified. ### Step 3. Catalog Page `POST /v1/cashback/catalog` with `{"country":"US","limit":500}` until `next_cursor` is null. Pages answer in about a second. Every entry carries `funded` (eligible with its cap, or the reason it is not; discovery gives each store's rate). `catalog.indexed_entries`, `funded_eligible_entries` and `excluded_entries` are counted about hourly and carry `counted_at`, while each page is read at `observed_at`. Amazon is the only excluded entry. There is no market-share percentage; `coverage` points at the named list instead. ### Step 4. Proving US store coverage OpenStock does not report a share of US shopping, because no figure it holds weighs stores by sales. What it can prove, and what the script's last section checks, is this: 1. **The rule.** OpenStock funds cashback at every indexed US storefront except Amazon: 8% at almost every store, Apple at 5%, and a store's own rate where it has a native offer, capped at $100 per order. There is no allowlist to be on; a store earns because it resolves. 2. **The named list.** `POST /v1/cashback/coverage` names the top US retailers by traffic plus well-known specialty stores (T.J. Maxx, H-E-B, Whole Foods, the Google Store, Nintendo, Poshmark, Starbucks, Delta, Hoka, On and others), each with live status, rate, cap and checkout path. Every one of them is funded except Amazon. The list is refreshed hourly and carries `generated_at`. 3. **The index.** `POST /v1/cashback/catalog` enumerates about 201,000 US storefronts, every one evaluated for funded eligibility; all but Amazon's entries are eligible, which is more than 99.99% of the index. This is a share of the index, not of US spend, and the catalog says so. 4. **Your own spot check.** Run any list of US stores you care about through `POST /v1/cashback/stores`, by URL or by name. Expect `active` with `checkout.recommended: "funded"` and the rate in `sponsored_checkout`. A store that does not resolve has no online storefront in the index: Trader Joe's sells nothing online, and Aldi's US grocery orders run through Instacart. A store that resolves and is not eligible is Amazon, by policy, or a non-US storefront. Report the four together: the rule, the named list with its count, the index with its funded share and `counted_at`, and the result of your spot check. ### Going live The partner provides one USD receiving account through `POST /v1/settlement/destination` and confirms the `OSV` reference and $1.00 amount of the verification deposit from its bank statement through `POST /v1/settlement/destination/verify`; that confirmation is the live proof of bank delivery and switches daily and on-demand settlement on. OpenStock provides the live key, the funded commitments, settlement funding, the daily scheduler, signed events and replay. Credit each user from received funds, exactly once, keyed by `transfer.credit_key`; show the quoted cents from the successful quote and keep the reward pending until your ledger has credited it. A bank return after that credit is OpenStock's to re-send, never the partner's loss and never taken back from the user. Webhooks: when you are ready, send one HTTPS endpoint per ledger. OpenStock registers each and hands you its verification key out of band, so you can test signature verification against the sandbox before go-live. Production keys, the data processing agreement and the current security report are provided at onboarding. Report your findings with the recommendation. ## Optional shopping endpoints With the corresponding scopes, a key can resolve merchants, generate discount codes, price products and read shopper history. Shopping endpoints use live merchant data and code generation even with a sandbox key; sandbox mode isolates the cashback and settlement lifecycle. Explicit cashback-only credentials do not grant shopping or shopper-history access. ### Generated, not found When a partnered merchant has an active single-use offer, OpenStock creates a new code through the store’s checkout at the moment of the request: the code did not exist before you asked, and it applies by construction, subject to the eligibility the merchant configured. For the rest of the stores it does what an information API does, with one addition a feed cannot make: it measures whether each public code still works and tells you. | | A coupon or deals feed | OpenStock | | --- | --- | --- | | Where a code comes from | Scraped or syndicated from the web, some time ago | Created at the store for this request (`source: "generated"`), configured by the merchant (`merchant_issued`), or observed in the wild (`observed`) | | Does it work? | Unknown until checkout; “verified” means someone saw it work once | `generated` and `merchant_issued` apply by construction (`probability: 1`, subject to `conditions`); `observed` codes carry their measured recent success rate | | What the assistant can say | “Try this code” | “Here is your code” | | Single-use and abuse | Public codes leak, get shared, and get killed by the merchant | Generated codes are single-use and tied to the request by `idempotency_key`; the merchant sets the discount | | When there is no code | No saving | Cashback may be available; inspect its terms | | Evidence in the response | None | `source`, `probability`, `partnered`, `conditions`, `last_success`, `apply_count`, `success_count` | The distinction is in the JSON, not just in this document. Everything an ordinary deals API can return is what OpenStock labels `observed`. ### Coverage - **Merchant-backed offers:** codes created at the store on request or claimed from a merchant’s pool, alongside configured codes and codeless offers. Every item reports its source and whether it is single-use. - **Observed codes:** ranked by recent checkout reliability, with lifetime attempts and last-success evidence when available. Set `min_probability` to the bar you want to show a shopper; `suppressed_code_count` tells you how many fell below it. - **Delivery:** median and quartiles in days. `measured_delivery`: observed order-to-delivery times for this merchant. `processing_plus_transit_estimate`: the merchant’s observed order-to-dispatch time plus an assumed 2 days in transit. `network_default`: we have no order data for this merchant yet, so this is what most US stores in the network deliver in (3–5 days); phrase it as "typically", not as this merchant’s figure. A null `sample_size` is unknown, not zero. Null `estimated_shipping` means delivery does not apply or the merchant did not resolve. - **Products:** live listings by product name from a feed refreshed roughly daily: price against regular price, image, the store’s product page and, when the store resolves, its OpenStock merchant id and an attributed link to the product page. Confirm the price at the store before promising it. Pass `store` (the brand’s own store name, exact case) when the shopper wants it from the brand: that store’s listing leads, resellers follow. - **Shopper history:** the merchants a shopper has bought from and browsed, purchases first. ### Your first discount code Use a key with `shopping:read` and `shopping:write`, set `OPENSTOCK_API_KEY`, then run this Python 3 script. It uses only the standard library, resolves Brooklinen by domain and passes the returned merchant id into the offer request. This optional example is not part of the cashback-only wallet quickstart. ```bash python3 - <<'PY' import json, os, uuid, urllib.error, urllib.request BASE_URL = "https://api.openstock.sh" api_key = os.environ.get("OPENSTOCK_API_KEY") if not api_key: raise SystemExit("Set OPENSTOCK_API_KEY to your partner key before running.") def post(path, body): request = urllib.request.Request( BASE_URL + path, data=json.dumps(body).encode(), headers={"Authorization": "Bearer " + api_key, "Content-Type": "application/json"}, method="POST") try: with urllib.request.urlopen(request, timeout=30) as response: print("Request ID:", response.headers.get("X-Request-Id")) return json.load(response) except urllib.error.HTTPError as error: request_id = error.headers.get("X-Request-Id", "unknown") raise SystemExit(f"HTTP {error.code} (request {request_id}): {error.read().decode()}") search = post("/v1/merchants/search", {"queries": [ {"query_id": "brooklinen", "type": "domain", "value": "brooklinen.com"}]}) merchant = search["results"][0]["items"][0] if merchant["id"] is None: raise SystemExit("Merchant did not resolve; inspect the search response.") print("Merchant and shipping:", json.dumps(merchant, indent=2)) # Keep this body and key to retry the same shopping session. body = {"queries": [{"query_id": "brooklinen", "merchant_id": merchant["id"], "idempotency_key": str(uuid.uuid4()), "limit": 3}]} print("Offer request (save for retry):", json.dumps(body)) offers = post("/v1/merchants/codes", body) print(json.dumps(offers, indent=2)) PY ``` **Inspect the result:** `source: "generated"` identifies a code created at the store for this request. Read `single_use`, `conditions`, `description` and expiry alongside it. A null `code` is a codeless offer: the discount applies through `activation_url`, so send the shopper there rather than showing a code. **Replay issuance:** call the codes endpoint again with the saved request body. If the first request issued a code, keeping the same merchant and `idempotency_key` returns that code rather than a second one. Start a new key for a new intended issuance; include your partner and session identity in your production key namespace. **Name the shopper:** add `shopper_name` (a first name, never an email or phone) and a code minted for that request carries it after the code’s prefix, as in `<prefix>-RORY-4O8HHBUN-CN`, so it reads as the shopper’s own. The prefix is not part of the contract: do not parse codes by it. Only the first word is used, and only when it is plain letters (A–Z); an accented or non-Latin name, an email or a phrase with punctuation mints a code with no name rather than a mangled one. The name applies at first issuance: a replay returns the code already minted. ### Interpreting the response | Field | Meaning for your integration | | --- | --- | | `source` + `single_use` | Created at the store, configured by the merchant, or an observed public code; whether one shopper can use it is explicit | | `probability` | Public-code reliability score from recent checkout activity; merchant-backed offers use 1, subject to eligibility | | `conditions` + `description` | Check minimum spend, product/customer restrictions and subscription terms; tags may not capture every restriction | | `minimum_subtotal`, `combines_with`, `restricted_to_collections`, `customer_restricted` | The terms as figures and booleans: the minimum with its currency, whether the code combines with other order, product or shipping discounts, and whether it is limited to collections or customers. Stated for merchant-configured and minted codes; null on an observed public code means the copy does not say | | `cashback` + `activation_url` | An additional offer when available, including when no code clears your threshold | | `estimated_shipping.basis` | Distinguishes merchant order data from a processing estimate or the all-stores default | | product `price` + `updated_at` | The store’s price at the last feed refresh (about daily); `merchant.id` feeds the codes endpoint and `activation_url` lands on the product page with attribution | | history `type` | `purchased` records an observed order; `visited` records browsing; purchases are listed first | ### Shopper identity For a history lookup, SHA-256 hash the authorized shopper’s email after trimming whitespace and lowercasing it. Send the 64-character hex digest as `email_sha256`; never send the raw email. The [fixture](https://openstock.sh/examples/shopper-history.json) is a complete example response. ```python import hashlib email_sha256 = hashlib.sha256(email.strip().lower().encode("utf-8")).hexdigest() ``` ### Explore the examples Open **Merchants → Batch merchant offer codes** in the interactive reference and choose a generated offer, a generated offer with the shopper’s name, an observed public code, cashback with no qualifying code, an unknown merchant, or a wallet-bound request with a sandbox key. Search includes measured delivery, an all-stores estimate and a miss. Products includes a priced listing with its image, a store outside OpenStock and a miss. Shoppers includes a purchase-and-visit example and an empty response. The named examples are complete responses, and every request in them can be run live. Merchant ids in the search, codes and shopper examples are real; the store id in the product example is illustrative, so take `merchant.id` from a live response before calling the codes endpoint. ## Request and result conventions - Authenticate with `Authorization: Bearer $OPENSTOCK_API_KEY` from your server. The documentation, `/health`, the hosted sandbox checkout and the activation link are public: the checkout takes its signed token in the body, and the link needs nothing. - Cashback endpoints take one request object; `/v1/wallets/read` takes up to 20 queries. The shopping endpoints take a `queries` array: 1–50 for merchant search, 1–20 for codes and history, 1–10 for products. Results keep query order and echo `query_id`, which must be unique within a batch. - **Coverage, catalog and settlement:** `POST /v1/cashback/coverage` names the top US retailers with their live status and path; `POST /v1/cashback/catalog` enumerates the whole index with each entry’s funded eligibility; follow `next_cursor`. Connect the receiving account with `POST /v1/settlement/destination`, confirm its deposit with `POST /v1/settlement/destination/verify`, and inspect the key’s scopes, blockers, checklist and verified facts with `GET /v1/settlement/readiness`. Live payouts are OpenStock-funded USD bank transfers to that account; record receipt and wallet-allocation references with `/v1/transfers/acknowledge`. - **Storefronts:** cashback discovery and quotes need the actual storefront URL, including regional paths. Quotes require `storefront_url` and explicit `country`; the URL is resolved again before funding. Do not replace it with a bare store ID or a different country’s homepage. - **Optional shopping domain queries:** a `domain` query on a shopping endpoint accepts a bare domain or any URL on it: scheme, `www.`, port, path and query are ignored. `domains` in those results are hostnames only. This normalization does not apply to funded checkout storefronts. - **Money and time:** monetary amounts are integer USD cents. Public monetary API response timestamps and newly created webhook event timestamps are ISO 8601 UTC strings, including wallet purchases, transactions, transfers and events. Already persisted pre-v1.5 webhook deliveries retain numeric event timestamps in Unix milliseconds until acknowledgment; see [Webhook verification and recovery](#webhook-verification-and-recovery) and normalize only after verifying the raw body. The webhook signature’s `t` parameter is Unix seconds for signature freshness verification. - **Misses:** shopping lookups answer a miss inside a `200`, never a `404`. Search returns one item with `id: null`; codes return `items: []`, `activation_url: null`, `cashback: null`; products and history return `items: []`. Empty code items with a non-null `activation_url` mean the store resolved but no code cleared your threshold. - **Tracing:** every response carries `X-Request-Id`. Merchant search and products add `X-OpenStock-Cache: hit | partial | miss`. - **Retries:** use bounded backoff for transport failures, `500` and `503`, keeping the body and idempotency key. Fix a `400`, `401`, `403` or `409` before retrying. A timeout may come after the work was done; reuse the key rather than starting again. ### Errors Every error is `{"error":{"code":"…","message":"…"}}`; switch on `code`, show `message` to a developer, not a user. Each cashback endpoint lists its own errors in the endpoint reference. These apply everywhere: | Status | Code | Meaning | | --- | --- | --- | | 400 | `VALIDATION_ERROR` | A field is missing, malformed or out of range; the message names it. Fix the request. | | 400 | `MALFORMED_JSON` | The body is not JSON. Send `Content-Type: application/json` and a JSON body. | | 401 | `MISSING_AUTH` | No `Authorization: Bearer` header. | | 401 | `INVALID_API_KEY` | The key is unknown or revoked. | | 403 | `INSUFFICIENT_SCOPE` | The key does not permit this operation. Use a key with the required capability. | | 429 | `RATE_LIMITED` | The request limit was reached. Honor Retry-After before retrying. | | 404 | `NOT_FOUND` | No such route, or no such cashback link. | | 406 | `NOT_ACCEPTABLE` | `/docs` was asked for a format other than HTML or markdown. | | 500 | `INTERNAL_ERROR` | Unexpected. Retry with backoff and the same idempotency key, and quote `X-Request-Id`. | | 503 | `PRODUCTS_UNAVAILABLE` | The product feed is unavailable; other endpoints are unaffected. Retry shortly. | Batched reads report a failed query inside its result, beside the queries that succeeded, as `error: {code, message}`: | Code | Meaning | | --- | --- | | `partner_account_required` | The key is not attached to a partner account, so it has no users. | | `live_key_required` | A code bound to a user earns live cashback: request it with your `os_live_` key. | | `wallet_not_found` | The user has not earned anything yet. Reads never create wallets. | | `wallet_unavailable` | The ledger could not be read for this query. Retry it. | ## Endpoint reference and complete examples The examples are the named examples in /openapi.json, schema-checked and complete; /openapi.json also has an example of every error. Cashback and wallet endpoints come first, then the shopping endpoints. ### POST /v1/cashback/purchases/report **Report a purchase your user or agent completed** · operationId `reportCashbackPurchase` For an OpenStock-funded purchase, send the quote_id, actual purchased_at, store order number, exact quoted eligible subtotal and partner-attested payment/order evidence. Do not also send a native click or code. The quote belongs to one user, store and purchase; another order cannot reuse it. Evidence is a trusted partner attestation of the completed purchase, not merchant commission confirmation. Cashback remains held for 30 days before it becomes available and enters daily settlement. Without a quote, native tracked-link or code reports still require their matching click_id or code. A partner report without purchase evidence is not automatically released. Reports are idempotent; altered purchase details under an existing key are refused. **Errors** | Status | Code | When | What to do | | --- | --- | --- | --- | | 400 | `INVALID_PURCHASE_TIMESTAMP` | A funded purchase timestamp precedes its quote or is in the future; the message identifies purchased_at and the reason. | Use the actual payment timestamp from your records. Do not create a new quote after payment to work around a timestamp error. | | 404 | `QUOTE_NOT_FOUND` | The quote is missing or belongs to another user, account or mode. | Use this user’s quote from the same ledger. | | 409 | `QUOTE_MISMATCH` | The purchase differs from the commitment. | Use the quote for this completed purchase; obtain a new quote before a changed checkout. | | 409 | `QUOTE_EXPIRED` | Checkout or reporting occurred after the deadline. | Complete and report within the returned deadlines. | | 409 | `INVALID_QUOTE` | The ledger cannot accept this quote for the order. | Check the quote, order and idempotency key. | | 400 | `VALIDATION_ERROR` | A field is missing, malformed or out of range. The message names the field. | Fix the request; do not retry it unchanged. | | 400 | `MODE_MISMATCH` | The body asks for the other ledger than the key is bound to. | Omit `mode`: a key with a mode decides the ledger. | | 403 | `PARTNER_ACCOUNT_REQUIRED` | The key is not attached to a partner account, so it has no users. | Use the live or sandbox key issued for your account. | | 404 | `ATTRIBUTION_NOT_FOUND` | The click_id or code was not issued to this user at this store. | Send the `click_id` activation returned, or the code issued to this user. | | 409 | `STORE_UNAVAILABLE` | The store_id is not one discovery returns. | Use a `store_id` from discovery. | | 409 | `STORE_NOT_ELIGIBLE` | The store is not eligible, as Amazon is. | Pick a store whose status allows cashback. | | 409 | `ATTRIBUTION_REQUIRED` | The store attributes through its link or a code, and the report sent neither. At a code store the message asks for the code. | Send the `click_id` or `code` the order used. | | 409 | `IDEMPOTENCY_CONFLICT` | The key was used before for this user with a different report. | Retry with the original body, or use a new key. | | 409 | `ORDER_CONFLICT` | The order was reported before with another store or amount. | Report each order once, as its confirmation shows it. | | 409 | `OPEN_REPORT_LIMIT` | The user has 50 reports still waiting for their stores. | Retry once some are matched or expire. | | 409 | `UNSUPPORTED_CURRENCY` | The store is attributed by report and the order is not in USD. | Report the order in USD. | | 503 | `REPORT_UNAVAILABLE` | The report could not be recorded. | Retry with the same body and idempotency_key. | #### A purchase made through an activation link Report the order as soon as checkout completes, with the click_id activation returned. The report stays pending, an estimate, until the store’s own record of the purchase arrives. Complete request: ```bash curl -sS -X POST https://api.openstock.sh/v1/cashback/purchases/report \ -H "Authorization: Bearer $OPENSTOCK_API_KEY" \ -H "Content-Type: application/json" \ -d '{"user_id":"u_9f86d081884c7d65","store_id":"01g4s5d0h956te86ff90h6xts4","country":"US","click_id":"cx01jbz8k2m4q6s8u0w2y4a6c8e0","order_id":"C00512345678","amount":12999,"currency":"USD","idempotency_key":"u_9f86d081884c7d65:C00512345678:report"}' ``` Complete response example: ```json { "report_id": "rpt_8172ebd9fd4a13a9b4dab8c6d1e338fd56b924832e5da5f465290c2d2c339c3f", "status": "pending", "attribution": "link", "store_id": "01g4s5d0h956te86ff90h6xts4", "order_id": "C00512345678", "order_amount": { "amount": 12999, "currency": "USD" }, "click_id": "cx01jbz8k2m4q6s8u0w2y4a6c8e0", "code": null, "estimated": true, "cashback": { "amount": 1950, "currency": "USD" }, "purchase": null, "purchased_at": "2026-11-03T15:04:05.000Z", "reported_at": "2026-11-03T15:04:05.000Z", "expires_at": "2026-11-18T14:58:00.000Z", "livemode": true } ``` #### A purchase at a store attributed by report A committed OpenStock-funded quote for Walmart fixes $10.40 on a $129.99 eligible subtotal. The partner attests payment; cashback is held for 30 days. Complete request: ```bash curl -sS -X POST https://api.openstock.sh/v1/cashback/purchases/report \ -H "Authorization: Bearer $OPENSTOCK_API_KEY" \ -H "Content-Type: application/json" \ -d '{"user_id":"u_9f86d081884c7d65","store_id":"01g4s4frn4vbdpd0ntckz32dtx","country":"US","order_id":"100482913","amount":12999,"currency":"USD","quote_id":"qt_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa","purchased_at":"2026-11-03T15:04:05.000Z","evidence":{"type":"partner_attested","reference":"payment-100482913"},"idempotency_key":"u_9f86d081884c7d65:100482913:report"}' ``` Complete response example: ```json { "report_id": "rpt_e0974dd0a66cfc3c90faab3e7a6262a786644059458a6b1208215bcef913bcbe", "status": "matched", "attribution": "report", "store_id": "01g4s4frn4vbdpd0ntckz32dtx", "order_id": "100482913", "order_amount": { "amount": 12999, "currency": "USD" }, "click_id": null, "code": null, "estimated": false, "cashback": { "amount": 1040, "currency": "USD" }, "purchase": { "id": "wallet-report#rpt_e0974dd0a66cfc3c90faab3e7a6262a786644059458a6b1208215bcef913bcbe", "status": "pending", "order_id": "100482913", "cashback": { "amount": 1040, "currency": "USD" }, "refunded_amount": { "amount": 0, "currency": "USD" }, "hold_ends_at": "2026-12-03T15:04:05.000Z" }, "purchased_at": "2026-11-03T15:04:05.000Z", "reported_at": "2026-11-03T15:04:05.000Z", "expires_at": null, "livemode": true } ``` Request body: - `mode` (`live` | `sandbox`, optional) — Which ledger to use. Defaults to the mode your API key is bound to. A bound key rejects the other mode with 400 MODE_MISMATCH. - `user_id` (string, optional) — The opaque user ID you used when activating or requesting codes. An email address is rejected with 400. - `wallet_id` (string, optional) — Alias of user_id. Send either one. - `store_id` (string, required) — OpenStock store ID: the id store discovery and /v1/merchants/search return. A store id from /v1/cashback-savings also works; reports answer with the OpenStock store ID. - `quote_id` (string, optional) — Committed quote from /v1/cashback/quotes. Its exact eligible subtotal and user must match this report. Quote-backed purchases use OpenStock-funded verification independently of native link tracking. - `evidence` (object, optional) — The trusted partner’s payment/order evidence reference, retained for reconciliation. This attests a completed purchase; it does not claim merchant commission confirmation. - `type` (`partner_attested`, required) - `reference` (string, required) - `occurred_at` (string, optional) - `country` (string, optional) [default "US"] - `click_id` (string, optional) — The click_id /v1/cashback/activate returned for this user and store. Send it for a purchase made through that link. - `code` (string, optional) — The single-use code issued to this user at this store (from /v1/merchants/codes with the user’s ID), when the order used it. - `order_id` (string, required) — The store’s order number from the order confirmation, as your user or agent saw it. - `amount` (integer, required) [range 1–100000000] — Order amount in minor units: 12999 is $129.99. For a funded quote, send its exact eligible merchandise subtotal after discounts, excluding tax, shipping and gift cards. For a native link or code report, send the recorded order amount. - `currency` (string, required) - `purchased_at` (string, optional) — Actual completed-purchase time (ISO 8601). Required for a funded quote and must fall between quote creation and checkout_expires_at; submit before report_expires_at. Native reports default to the report time and cannot be more than 90 days old. - `idempotency_key` (string, required) Response `200` — The purchase report and the wallet purchase it belongs to - `report_id` (string, required) - `status` (`pending` | `matched` | `expired`, required) — pending: awaiting purchase matching or required verification. matched: a wallet purchase carries this report, including an accepted funded-quote purchase. expired: the applicable reporting or matching deadline elapsed without an accepted purchase. matched does not mean spendable; read the wallet balance. - `attribution` (`link` | `code` | `report`, required) — How the purchase is attributed: a tracked link, an issued code, or an OpenStock-funded quote and paid-purchase report. Legacy reports without a funded quote and evidence do not automatically earn spendable cashback. - `store_id` (string, required) - `order_id` (string, required) - `order_amount` (object, required) - `amount` (integer, required) — Amount in the currency’s minor units (USD cents, for example). - `currency` (string, required) - `click_id` (string | null, required) - `code` (string | null, required) - `estimated` (boolean, required) — False for an accepted funded quote, including during its hold: cashback is committed cents, reduced only by eligible hold-period refunds. True for native or unfunded pending reports whose amount is still an estimate. Spendability is separate; read wallet available and reserved. - `cashback` (object | null, required) — Cashback in USD: the funded quote amount less eligible hold-period refunds, or a native report estimate until confirmation. It becomes transferable only in the wallet available balance. Null when no amount can be determined or the report expired. - `amount` (integer, required) — Amount in the currency’s minor units (USD cents, for example). - `currency` (`USD`, required) - `purchase` (object | null, required) — The wallet purchase this report belongs to, once there is one. It lists in /v1/wallets/read with this report_id, order_id and click_id. - `id` (string, required) - `status` (`pending` | `credited` | `ineligible` | `reversed`, required) - `order_id` (string, required) — The order number recorded for the paid purchase. - `cashback` (object | null, required) - `amount` (integer, required) — Amount in the currency’s minor units (USD cents, for example). - `currency` (`USD`, required) - `refunded_amount` (object | null, required) - `amount` (integer, required) — Amount in the currency’s minor units (USD cents, for example). - `currency` (`USD`, required) - `hold_ends_at` (string | null, required) — Scheduled hold end for a report purchase. Accepted, funded and evidenced quotes clear after 30 days, less eligible refunds. A date alone does not make an unfunded or unverified legacy report creditable. - `purchased_at` (string, required) - `reported_at` (string, required) - `expires_at` (string | null, required) — When a pending report expires if no purchase arrives. - `livemode` (boolean, required) ### POST /v1/cashback/purchases/refund **Report a refund of a purchase attributed by your report** · operationId `refundCashbackPurchase` Report each refund of an OpenStock-funded purchase, using the refunded eligible merchandise amount. Before release, a refund lowers held cashback and a full refund leaves it ineligible. After cashback becomes available, OpenStock absorbs ordinary later reversals: the user’s available or transferred funds remain unchanged and a cashback.reversal_absorbed event records the return. Native tracked-link or code purchases receive their returns from the store and answer REFUND_NOT_REQUIRED here. **Errors** | Status | Code | When | What to do | | --- | --- | --- | --- | | 400 | `VALIDATION_ERROR` | A field is missing, malformed or out of range. The message names the field. | Fix the request; do not retry it unchanged. | | 400 | `MODE_MISMATCH` | The body asks for the other ledger than the key is bound to. | Omit `mode`: a key with a mode decides the ledger. | | 403 | `PARTNER_ACCOUNT_REQUIRED` | The key is not attached to a partner account, so it has no users. | Use the live or sandbox key issued for your account. | | 404 | `PURCHASE_NOT_FOUND` | You did not report this order for this user at this store. | Send the store_id and order_id of the reported purchase. | | 409 | `REFUND_NOT_REQUIRED` | The purchase was attributed by a link or code: the store reports its returns. | Nothing: the wallet shows the return when the store reports it. | | 409 | `UNSUPPORTED_CURRENCY` | The refund is not in USD. | Report the refund in USD. | | 409 | `IDEMPOTENCY_CONFLICT` | The key was used before for a different refund. | Use a new key for each refund. | | 503 | `REPORT_UNAVAILABLE` | The refund could not be recorded. | Retry with the same body and idempotency_key. | #### A partial return before the credit The user returned $40.00 of the $129.99 order while it was still pending: the purchase now earns on $89.99. Complete request: ```bash curl -sS -X POST https://api.openstock.sh/v1/cashback/purchases/refund \ -H "Authorization: Bearer $OPENSTOCK_API_KEY" \ -H "Content-Type: application/json" \ -d '{"user_id":"u_9f86d081884c7d65","store_id":"01g4s4frn4vbdpd0ntckz32dtx","order_id":"100482913","amount":4000,"currency":"USD","idempotency_key":"u_9f86d081884c7d65:100482913:refund-1"}' ``` Complete response example: ```json { "report_id": "rpt_e0974dd0a66cfc3c90faab3e7a6262a786644059458a6b1208215bcef913bcbe", "status": "matched", "attribution": "report", "store_id": "01g4s4frn4vbdpd0ntckz32dtx", "order_id": "100482913", "order_amount": { "amount": 12999, "currency": "USD" }, "click_id": null, "code": null, "estimated": false, "cashback": { "amount": 720, "currency": "USD" }, "purchase": { "id": "wallet-report#rpt_e0974dd0a66cfc3c90faab3e7a6262a786644059458a6b1208215bcef913bcbe", "status": "pending", "order_id": "100482913", "cashback": { "amount": 720, "currency": "USD" }, "refunded_amount": { "amount": 4000, "currency": "USD" }, "hold_ends_at": "2026-12-03T15:04:05.000Z" }, "purchased_at": "2026-11-03T15:04:05.000Z", "reported_at": "2026-11-03T15:04:05.000Z", "expires_at": null, "livemode": true } ``` Request body: - `mode` (`live` | `sandbox`, optional) — Which ledger to use. Defaults to the mode your API key is bound to. A bound key rejects the other mode with 400 MODE_MISMATCH. - `user_id` (string, optional) — The opaque user ID you used when activating or requesting codes. An email address is rejected with 400. - `wallet_id` (string, optional) — Alias of user_id. Send either one. - `store_id` (string, required) — OpenStock store ID: the id store discovery and /v1/merchants/search return. A store id from /v1/cashback-savings also works; reports answer with the OpenStock store ID. - `order_id` (string, required) — The store’s order number from the order confirmation, as your user or agent saw it. - `amount` (integer, required) [range 1–100000000] — Eligible merchandise refunded this time, in the order currency’s minor units. Partial refunds accumulate and reduce held cashback proportionally. Once cashback is available, ordinary refunds are recorded without taking back the cleared reward; OpenStock absorbs the adjustment. - `currency` (string, required) - `idempotency_key` (string, required) Response `200` — The purchase report and the wallet purchase it belongs to - The same `CashbackPurchaseReport` object as `POST /v1/cashback/purchases/report` returns. ### POST /v1/cashback/sandbox/reports/advance **Fast-forward a sandbox purchase report** · operationId `advanceSandboxCashbackReport` Sandbox only. creditable simulates a verified purchase completing its hold and credits the available sandbox balance; a report without required purchase evidence cannot be released. expired simulates a native link or code report receiving no matching purchase. Rehearse refunds before release to reduce held cashback, and after release to observe an absorbed reversal without debiting the user. No real money moves. **Errors** | Status | Code | When | What to do | | --- | --- | --- | --- | | 400 | `VALIDATION_ERROR` | A field is missing, malformed or out of range. The message names the field. | Fix the request; do not retry it unchanged. | | 403 | `SANDBOX_KEY_REQUIRED` | A live key called a sandbox simulation. | Call it with your `os_test_` key. | | 403 | `PARTNER_ACCOUNT_REQUIRED` | The key is not attached to a partner account, so it has no users. | Use the live or sandbox key issued for your account. | | 404 | `REPORT_NOT_FOUND` | The report_id is not one of this user’s sandbox reports. | Send a report_id the report endpoint returned for this user. | | 409 | `INVALID_TRANSITION` | A matched report cannot expire, and a refunded or reversed one cannot be credited. | Read the report’s status and choose another outcome. | | 409 | `UNSUPPORTED_CURRENCY` | The report has no USD estimate to credit. | Rehearse with a USD order. | | 503 | `REPORT_UNAVAILABLE` | The sandbox could not be updated. | Retry the same request. | #### The store confirms and pays a reported purchase A sandbox key moves a pending link report on: the purchase is credited to the sandbox balance at once. Complete request: ```bash curl -sS -X POST https://api.openstock.sh/v1/cashback/sandbox/reports/advance \ -H "Authorization: Bearer $OPENSTOCK_API_KEY" \ -H "Content-Type: application/json" \ -d '{"user_id":"u_9f86d081884c7d65","report_id":"rpt_8172ebd9fd4a13a9b4dab8c6d1e338fd56b924832e5da5f465290c2d2c339c3f","outcome":"creditable"}' ``` Complete response example: ```json { "report_id": "rpt_8172ebd9fd4a13a9b4dab8c6d1e338fd56b924832e5da5f465290c2d2c339c3f", "status": "matched", "attribution": "link", "store_id": "01g4s5d0h956te86ff90h6xts4", "order_id": "C00512345678", "order_amount": { "amount": 12999, "currency": "USD" }, "click_id": "cx01jbz8k2m4q6s8u0w2y4a6c8e0", "code": null, "estimated": false, "cashback": { "amount": 1950, "currency": "USD" }, "purchase": { "id": "sandbox_4f0b6c2a9d8e1f3b5a7c9e0d2b4f6a8c1e3d5b7f9a0c2e4d6b8f0a1c3e5d7b9f", "status": "credited", "order_id": "C00512345678", "cashback": { "amount": 1950, "currency": "USD" }, "refunded_amount": null, "hold_ends_at": null }, "purchased_at": "2026-11-03T15:04:05.000Z", "reported_at": "2026-11-03T15:04:05.000Z", "expires_at": null, "livemode": false } ``` Request body: - `user_id` (string, optional) — The opaque user ID you used when activating or requesting codes. An email address is rejected with 400. - `wallet_id` (string, optional) — Alias of user_id. Send either one. - `report_id` (string, required) - `outcome` (`creditable` | `expired`, required) — creditable: simulate completion of verification and the hold for an evidenced funded quote, or confirmation/payment for a native purchase. Unfunded legacy reports cannot auto-clear. expired: simulate an unmatched report passing its deadline. No real money moves. Response `200` — The purchase report and the wallet purchase it belongs to - The same `CashbackPurchaseReport` object as `POST /v1/cashback/purchases/report` returns. ### POST /v1/cashback/stores **Find the exact store for a shopper URL, domain or name** · operationId `findCashbackStores` Resolves the storefront a shopper is on from the URL they are viewing, a domain or a store name. checkout.recommended names the path to integrate: the funded quote wherever it exists, because it earns for merchant-API checkout without a browser session. match.by says whether the query was a URL, a domain or a name; treat a name match as a search and resolve the checkout URL before quoting. The response returns what a user earns there. The answer is the same for live and sandbox keys. store is the exact storefront: a marketplace seller’s page resolves to the marketplace, and a URL that names a regional storefront (nike.com/gb/, amazon.ca) resolves to that storefront. alternatives lists the store’s other regional storefronts, a seller’s own listing, or other stores matching a name. store_id is the OpenStock merchant ID that /v1/merchants/search returns. country is the storefront’s own country, from the URL, the store’s domain or where the store sells, so it can differ from the country asked for; cashback is offered on US storefronts. Discovery previews rates and native attribution. active means a cashback path is available, not that funds are reserved. sponsored_checkout describes the separate OpenStock-funded report path; request a funded quote using the actual storefront_url and country before promising an amount. not_eligible and unknown stores cannot be quoted; retry unknown shortly. A miss answers 200 with store null. **Errors** | Status | Code | When | What to do | | --- | --- | --- | --- | | 400 | `VALIDATION_ERROR` | A field is missing, malformed or out of range. The message names the field. | Fix the request; do not retry it unchanged. | | 400 | `MODE_MISMATCH` | The body asks for the other ledger than the key is bound to. | Omit `mode`: a key with a mode decides the ledger. | | 503 | `STORES_UNAVAILABLE` | The store directory could not be read. | Retry with bounded backoff. | #### The store behind a product page A shopper is on a Nike product page. Discovery returns Nike US and a quote-required rate preview; it reserves no funding. Ask with a `limit` for Nike’s other storefronts, then quote the actual checkout URL before promising cashback. Complete request: ```bash curl -sS -X POST https://api.openstock.sh/v1/cashback/stores \ -H "Authorization: Bearer $OPENSTOCK_API_KEY" \ -H "Content-Type: application/json" \ -d '{"query":"https://www.nike.com/t/air-force-1-07-mens-shoes-jBrhbr","country":"US","limit":0}' ``` Complete response example: ```json { "mode": "live", "livemode": true, "match": { "by": "url" }, "store": { "store_id": "01g4s4gvb1kdc8kz69cm5q2b4f", "catalog_ref": null, "name": "Nike", "url": "https://www.nike.com/", "domain": "nike.com", "country": "US", "popularity_rank": 16, "status": "active", "reason": null, "tracking_available": true, "cashback": { "type": "percentage", "user_rate": 8, "user_amount": null, "currency": "USD", "basis": "quote_required", "max_per_order": { "amount": 10000, "currency": "USD" }, "estimated_usd": false, "fx_rate": null, "fx_as_of": null, "verified_at": "2026-11-03T14:00:00.000Z" }, "attribution": "report", "requires_browser_context": false, "sponsored_checkout_available": true, "sponsored_checkout": { "quote_required": true, "funding": "openstock", "attribution": "report", "requires_browser_context": false, "rate": { "type": "percentage", "value": 8 }, "max_per_order": { "amount": 10000, "currency": "USD" } }, "checkout": { "recommended": "funded", "agent_api_checkout": true }, "attribution_window": { "kind": "not_required", "duration_seconds": null }, "terms": [ "OpenStock funds this cashback offer. Request a quote for the exact eligible subtotal before checkout.", "Report the completed purchase with its quote and payment attestation. No browser session or tracking link is required for this offer.", "Cashback clears after the 30-day hold. OpenStock covers ordinary reversals after release." ] }, "alternatives": [] } ``` #### A store attributed by report Walmart is eligible for an OpenStock-funded 8% offer, capped at $100 per order. Commit an exact quote before checkout, then report the paid order with that quote and purchase evidence. No tracking link, code or browser context is required for the funded quote. Complete request: ```bash curl -sS -X POST https://api.openstock.sh/v1/cashback/stores \ -H "Authorization: Bearer $OPENSTOCK_API_KEY" \ -H "Content-Type: application/json" \ -d '{"query":"walmart.com","country":"US","limit":0}' ``` Complete response example: ```json { "mode": "live", "livemode": true, "match": { "by": "domain" }, "store": { "store_id": "01g4s4frn4vbdpd0ntckz32dtx", "catalog_ref": null, "name": "Walmart", "url": "https://www.walmart.com/", "domain": "walmart.com", "country": "US", "popularity_rank": 2, "status": "active", "reason": null, "tracking_available": true, "cashback": { "type": "percentage", "user_rate": 8, "user_amount": null, "currency": "USD", "basis": "quote_required", "max_per_order": { "amount": 10000, "currency": "USD" }, "estimated_usd": false, "fx_rate": null, "fx_as_of": null, "verified_at": "2026-11-03T14:00:00.000Z" }, "attribution": "report", "requires_browser_context": false, "sponsored_checkout_available": true, "sponsored_checkout": { "quote_required": true, "funding": "openstock", "attribution": "report", "requires_browser_context": false, "rate": { "type": "percentage", "value": 8 }, "max_per_order": { "amount": 10000, "currency": "USD" } }, "checkout": { "recommended": "funded", "agent_api_checkout": true }, "attribution_window": { "kind": "not_required", "duration_seconds": null }, "terms": [ "OpenStock funds this cashback offer. Request a quote for the exact eligible subtotal before checkout.", "Report the completed purchase with its quote and payment attestation. No browser session or tracking link is required for this offer.", "Cashback clears after the 30-day hold. OpenStock covers ordinary reversals after release." ] }, "alternatives": [] } ``` #### A native link offer alongside a funded agent checkout The native Brooklinen offer requires a tracked browser context. The separate sponsored_checkout preview supports a funded report without that browser requirement, with a $100 cap. Request a quote for the exact eligible basket before committing the reward. Complete request: ```bash curl -sS -X POST https://api.openstock.sh/v1/cashback/stores \ -H "Authorization: Bearer $OPENSTOCK_API_KEY" \ -H "Content-Type: application/json" \ -d '{"query":"https://www.brooklinen.com/","country":"US","limit":0}' ``` Complete response example: ```json { "mode": "live", "livemode": true, "match": { "by": "url" }, "store": { "store_id": "01g4s5d0h956te86ff90h6xts4", "catalog_ref": null, "name": "Brooklinen", "url": "https://www.brooklinen.com/", "domain": "brooklinen.com", "country": "US", "popularity_rank": 117, "status": "active", "reason": null, "tracking_available": true, "cashback": { "type": "percentage", "user_rate": 15, "user_amount": null, "currency": "USD", "basis": "quote_required", "max_per_order": null, "estimated_usd": false, "fx_rate": null, "fx_as_of": null, "verified_at": "2026-11-03T14:00:00.000Z" }, "attribution": "link", "requires_browser_context": true, "sponsored_checkout_available": true, "sponsored_checkout": { "quote_required": true, "funding": "openstock", "attribution": "report", "requires_browser_context": false, "rate": { "type": "percentage", "value": 15 }, "max_per_order": { "amount": 10000, "currency": "USD" } }, "checkout": { "recommended": "funded", "agent_api_checkout": true }, "attribution_window": { "kind": "timed", "duration_seconds": 86400 }, "terms": [ "Open the activation link and complete checkout in that same browser session.", "Cashback applies to eligible purchases. The store may exclude some products, categories and promotions.", "Cashback is credited once the store pays OpenStock for the order, and no sooner than 30 days after the purchase. Stores usually pay 45 to 90 days after the sale." ] }, "alternatives": [] } ``` #### A seller page resolves to the marketplace Amazon does not offer cashback through OpenStock. A seller’s page resolves to Amazon. Alternatives can include other country storefronts; the seller is not a separate cashback store. Complete request: ```bash curl -sS -X POST https://api.openstock.sh/v1/cashback/stores \ -H "Authorization: Bearer $OPENSTOCK_API_KEY" \ -H "Content-Type: application/json" \ -d '{"query":"https://www.amazon.com/stores/NorthwindCandleCo/page/0A1B2C3D","country":"US","limit":1}' ``` Complete response example: ```json { "mode": "live", "livemode": true, "match": { "by": "url" }, "store": { "store_id": "01g4s5cnbzp85hwwxqgrky3cr7", "catalog_ref": null, "name": "Amazon", "url": "https://www.amazon.com/", "domain": "amazon.com", "country": "US", "popularity_rank": 1, "status": "not_eligible", "reason": "merchant_policy", "tracking_available": false, "cashback": null, "attribution": null, "requires_browser_context": false, "sponsored_checkout_available": false, "sponsored_checkout": null, "checkout": { "recommended": null, "agent_api_checkout": false }, "attribution_window": { "kind": "not_required", "duration_seconds": null }, "terms": [ "This store does not offer cashback through OpenStock." ] }, "alternatives": [ { "store_id": "01j164zt1wh0kvxqyaw0h240nd", "catalog_ref": null, "name": "Amazon", "url": "https://www.amazon.ca/", "domain": "amazon.ca", "country": "CA", "popularity_rank": null, "status": "not_eligible", "reason": "unsupported_country", "tracking_available": false, "cashback": null, "attribution": null, "requires_browser_context": false, "sponsored_checkout_available": false, "sponsored_checkout": null, "checkout": { "recommended": null, "agent_api_checkout": false }, "attribution_window": { "kind": "not_required", "duration_seconds": null }, "terms": [ "OpenStock cashback is offered on US storefronts." ], "kind": "regional" } ] } ``` Request body: - `mode` (`live` | `sandbox`, optional) — Which ledger to use. Defaults to the mode your API key is bound to (os_live_ keys read live, os_test_ keys read sandbox), otherwise sandbox. A bound key rejects the other mode with 400 MODE_MISMATCH. - `query` (string, required) — The URL the shopper is on, a domain, or a store name. A URL’s path can name a regional storefront or a marketplace seller. - `country` (string, optional) [default "US"] — The shopper’s country. A URL that names its own storefront country keeps it. - `limit` (integer, optional) [range 0–20; default 5] — The most alternatives to return. Response `200` — The storefront and its alternatives - `mode` (`live` | `sandbox`, required) - `livemode` (boolean, required) — True when this response comes from the live ledger. Every cashback response carries it so a client can never mistake simulated money for real money. - `match` (object, required) — How the query was matched. A URL or domain names one storefront. A name is a search: it can match a different store with a similar name, so confirm the store with the shopper or resolve the checkout URL before quoting. A quote re-resolves its storefront_url before committing funds, so a name match can never fund the wrong store. - `by` (`url` | `domain` | `name`, required) - `store` (object | null, required) — The exact storefront the query names, or null when nothing matches. - `store_id` (string | null, required) — OpenStock merchant ID: the same ID /v1/merchants/search returns for the store. It can be shared by countries; preserve the actual storefront URL and country when requesting a quote. Null for a catalog listing OpenStock cannot track. - `catalog_ref` (string | null, required) — Reference of a catalog listing OpenStock cannot track (store_id null); null otherwise. - `name` (string, required) - `url` (string, required) — The storefront’s home page. - `domain` (string | null, required) - `country` (string, required) — The storefront’s country. - `popularity_rank` (integer | null, required) — Traffic rank across stores, 1 = most visited. - `status` (`active` | `not_eligible` | `unknown`, required) — active: a cashback path is available; discovery is a preview, not a funded commitment. Request a quote before promising sponsored cashback. not_eligible: no qualifying offer for this storefront. unknown: the rate could not be confirmed just now; retry shortly. - `reason` (`merchant_policy` | `unsupported_country` | `unsupported_store` | `rate_unavailable` | `null`, required) — Why a store is not active. merchant_policy: the store does not offer cashback through OpenStock. unsupported_country: cashback is offered on US storefronts. unsupported_store: OpenStock cannot track purchases at this listing. rate_unavailable: the rate could not be confirmed just now. - `tracking_available` (boolean, required) — True exactly when status is active. - `cashback` (object | null, required) - `type` (`percentage` | `fixed`, required) - `user_rate` (number | null, required) [range −∞–100] — Percentage of eligible merchandise. Get a committed quote before checkout for an exact funded amount. Null for type fixed. - `user_amount` (object | null, required) — What the user earns per order, for type fixed. Null for type percentage. - `amount` (integer, required) [range 0–∞] - `currency` (`USD`, required) - `currency` (`USD`, required) - `basis` (`quote_required` | `guaranteed` | `flat`, required) — quote_required: preview only; request a funded quote for your eligible subtotal before promising cashback. guaranteed is retained for historical compatibility and is not emitted by discovery. flat: a fixed amount per qualifying native order. - `max_per_order` (object | null, required) — The most one order earns, when the store caps it. - `amount` (integer, required) [range 0–∞] - `currency` (`USD`, required) - `estimated_usd` (boolean, required) — True when user_amount converts a fixed amount the store pays in another currency, at fx_rate. - `fx_rate` (number | null, required) — USD per unit of the original currency, when estimated. - `fx_as_of` (string | null, required) — The day of fx_rate (YYYY-MM-DD), when estimated. - `verified_at` (string, required) — When the underlying offer or OpenStock-funded policy was last checked or updated; never refreshed merely because this response was requested. - `attribution` (`link` | `code` | `report` | `null`, required) — Native or default attribution path. link: open the activation link and check out in that same browser session. code: apply the user’s code at checkout. report: obtain a funded quote, then report the paid purchase. Sponsored checkout below uses its own report attribution, regardless of a native link or code. - `requires_browser_context` (boolean, required) — True when the purchase must be completed in the browser session that opened the activation link. Open the link in the shopper’s real browser: a bare HTTP client can be challenged or blocked before it reaches the store. - `sponsored_checkout_available` (boolean, required) — Request /v1/cashback/quotes to reserve OpenStock-funded cashback for browser or API checkout, with no dependency on the native attribution method above. - `sponsored_checkout` (object | null, required) — Preview of the separate OpenStock-funded checkout offer. A successful /v1/cashback/quotes request reserves backing and commits exact cents. Browser and merchant-API checkout are supported; native link tracking is unnecessary for this quoted purchase. Null when no sponsored quote can be requested. - `quote_required` (`true`, required) - `funding` (`openstock`, required) - `attribution` (`report`, required) - `requires_browser_context` (`false`, required) - `rate` (object, required) - `type` (`percentage`, required) - `value` (number, required) [range −∞–100] - `max_per_order` (object, required) — USD in cents. - `amount` (integer, required) [range 0–∞] - `currency` (`USD`, required) - `attribution_window` (object, required) — Native attribution window. Unknown is not a same-session guarantee. Sponsored quotes have their own explicit checkout deadline. - `kind` (`timed` | `same_session` | `unknown` | `not_required`, required) - `duration_seconds` (integer | null, required) - `checkout` (object, required) — Which attribution path to integrate for this store, chosen for an agent that completes checkout itself. - `recommended` (`funded` | `native_link` | `native_code` | `null`, required) — The path to use at this store. funded: request /v1/cashback/quotes and report the paid order; it earns for merchant-API and browser checkout alike and is preferred whenever sponsored_checkout is available, even where a native link exists. native_link: only a checkout completed in the browser session that opened the activation link earns. native_code: apply the user’s generated code at checkout. Null when the store is not active. - `agent_api_checkout` (boolean, required) — True when the recommended path earns without a browser session, so an agent paying through the merchant’s API can use it. - `terms` (array of string, required) - `alternatives` (array of object, required) - Every field of `store`, and: - `kind` (`regional` | `seller` | `program` | `similar`, required) — regional: the same store’s storefront in another country. seller: an independent seller’s page on a marketplace. program: a catalog listing that matches the query. similar: another store whose name matches. ### POST /v1/cashback/catalog **Enumerate the merchant discovery catalog** · operationId `listCashbackCatalog` Read every indexed merchant with a primary domain and the selected country in its sales-country list, including merchants without popularity rankings, each with its funded eligibility, rate and cap evaluated under the current policy. Follow next_cursor until null; there is no fixed sample-size limit. This index read fetches no native offers and reserves no cashback. catalog.funded_eligible_entries and excluded_entries say how much of the index can be quoted; for named coverage of the top US retailers use POST /v1/cashback/coverage. The country filter describes the index, not a checkout URL: resolve the actual URL with POST /v1/cashback/stores and obtain a funded quote before promising cashback. Pages are ordered by store_id and observe a changing index, not a frozen snapshot. The catalog is the same for sandbox and live keys. **Errors** | Status | Code | When | What to do | | --- | --- | --- | --- | | 400 | `INVALID_CURSOR` | The cursor is malformed or belongs to another country. | Keep the country unchanged and pass the returned next_cursor verbatim. | | 503 | `CATALOG_UNAVAILABLE` | The merchant index cannot be read. | Retry the same page shortly. | #### Browse the full indexed US merchant inventory Illustrative page and counts. Every entry carries its evaluated funded eligibility and cap; Amazon is excluded by policy. Discovery gives each store’s rate. Follow next_cursor until null, and resolve the actual checkout URL before requesting a funded quote. Complete request: ```bash curl -sS -X POST https://api.openstock.sh/v1/cashback/catalog \ -H "Authorization: Bearer $OPENSTOCK_API_KEY" \ -H "Content-Type: application/json" \ -d '{"country":"US","limit":100}' ``` Complete response example: ```json { "mode": "sandbox", "livemode": false, "country": "US", "items": [ { "store_id": "01g4s4gvb1kdc8kz69cm5q2b4f", "name": "Nike", "storefront_url": "https://www.nike.com/", "domain": "www.nike.com", "popularity_rank": 1, "funded": { "eligible": true, "max_per_order": { "amount": 10000, "currency": "USD" } } }, { "store_id": "01g4s5cnbzp85hwwxqgrky3cr7", "name": "Amazon", "storefront_url": "https://www.amazon.com/", "domain": "www.amazon.com", "popularity_rank": 2, "funded": { "eligible": false, "reason": "merchant_policy" } } ], "next_cursor": null, "catalog": { "indexed_entries": 2, "funded_eligible_entries": 1, "excluded_entries": 1, "house_rate": { "percent": 8, "max_per_order": { "amount": 10000, "currency": "USD" } }, "observed_at": "2026-11-04T12:00:00.000Z", "counted_at": "2026-11-04T11:00:00.000Z", "scope": "merchant_index", "funded_eligibility_evaluated": true, "coverage": "/v1/cashback/coverage", "snapshot": false } } ``` Request body: - `country` (string, optional) [default "US"] — Filter by the countries recorded in the merchant index. This does not establish the country or cashback eligibility of a particular checkout URL. - `limit` (integer, optional) [range 1–500; default 100] - `cursor` (string, optional) Response `200` — Indexed merchants, observed count and the next position - `country` (string, required) - `items` (array of object, required) - `store_id` (string, required) - `name` (string, required) - `storefront_url` (string, required) - `domain` (string, required) - `popularity_rank` (integer | null, required) - `funded` (object | object, required) — Whether a funded quote can be requested at this store under the current policy, with the cap it would carry, or the reason it cannot. Evaluated for every entry; live discovery gives the rate, and a successful quote is the commitment for a specific checkout URL. - `eligible` (`true`, required) - `max_per_order` (object, required) — The most one order earns on the funded path under the current policy. The rate comes from discovery: the funded rate where the store has no native offer, else the store’s own rate. - `amount` (integer, required) [range 0–∞] - `currency` (`USD`, required) - `next_cursor` (string | null, required) — Continue with this cursor and the same country until null. A page limit is not a catalog-size limit. - `catalog` (object, required) - `indexed_entries` (integer, required) [range 0–∞] — Number of merchant IDs with a nonempty primary domain and membership in the selected country at counted_at. Includes unranked merchants. Not a count of unique storefronts or of all US retailers. - `funded_eligible_entries` (integer, required) [range 0–∞] — How many of the indexed entries can be quoted at the funded rate under the current policy: every indexed US store except the excluded ones. - `excluded_entries` (integer, required) [range 0–∞] — Indexed entries the policy excludes from funded cashback, such as Amazon. - `house_rate` (object, required) — The OpenStock-funded rate and per-order cap an eligible store earns where it has no native offer of its own. Stores with a native offer earn that offer’s rate, which discovery shows. - `percent` (number, required) [range −∞–100] - `max_per_order` (object, required) - `amount` (integer, required) [range 0–∞] - `currency` (`USD`, required) - `observed_at` (string, required) — When this page was read from the index. - `counted_at` (string, required) — When indexed_entries, funded_eligible_entries and excluded_entries were counted. The index is counted about hourly; a page is read at observed_at. - `scope` (`merchant_index`, required) - `funded_eligibility_evaluated` (`true`, required) - `coverage` (`/v1/cashback/coverage`, required) — Named coverage of the top US retailers by traffic, each with its live status, rate and checkout path. Use it instead of a market-share percentage, which the index cannot express. - `snapshot` (`false`, required) — Each page observes the current index, not a frozen export. Entries may change during enumeration. Retain the pages, observation times and counts for an audit of the run. Results are ordered by store_id, independent of popularity rank. - `mode` (`sandbox` | `live`, required) - `livemode` (boolean, required) ### POST /v1/cashback/coverage **Named coverage of the top US retailers** · operationId `listCashbackCoverage` Resolves the top US retailers by traffic, plus well-known specialty storefronts, exactly as POST /v1/cashback/stores would: each with its status, the recommended checkout path, the rate on that path and its cap. A named list that can be checked store by store. It is resolved live and refreshed hourly; generated_at says when. The answer is the same for live and sandbox keys. **Errors** | Status | Code | When | What to do | | --- | --- | --- | --- | | 503 | `COVERAGE_UNAVAILABLE` | The retailers could not be resolved just now. | Retry shortly; the list is cached once it resolves. | #### The top US retailers, resolved live Three of the named retailers. Nike and Walmart can be quoted at the funded 8% with a $100 cap through merchant-API checkout; Amazon is excluded by policy. Resolve a specific checkout URL with /v1/cashback/stores before quoting. Complete request: ```bash curl -sS -X POST https://api.openstock.sh/v1/cashback/coverage \ -H "Authorization: Bearer $OPENSTOCK_API_KEY" \ -H "Content-Type: application/json" \ -d '{"country":"US"}' ``` Complete response example: ```json { "mode": "sandbox", "livemode": false, "country": "US", "basis": "top_us_retailers_by_traffic", "generated_at": "2026-11-04T12:00:00.000Z", "summary": { "retailers": 3, "eligible": 2, "not_eligible": 1, "unknown": 0, "funded_quote_available": 2 }, "retailers": [ { "name": "Amazon", "url": "https://www.amazon.com/", "store_id": "01g4s5cnbzp85hwwxqgrky3cr7", "status": "not_eligible", "reason": "merchant_policy", "checkout": { "recommended": null, "agent_api_checkout": false }, "rate": null, "max_per_order": null, "funded_quote_available": false }, { "name": "Walmart", "url": "https://www.walmart.com/", "store_id": "01g4s4frn4vbdpd0ntckz32dtx", "status": "active", "reason": null, "checkout": { "recommended": "funded", "agent_api_checkout": true }, "rate": { "type": "percentage", "value": 8 }, "max_per_order": { "amount": 10000, "currency": "USD" }, "funded_quote_available": true }, { "name": "Nike", "url": "https://www.nike.com/", "store_id": "01g4s4gvb1kdc8kz69cm5q2b4f", "status": "active", "reason": null, "checkout": { "recommended": "funded", "agent_api_checkout": true }, "rate": { "type": "percentage", "value": 8 }, "max_per_order": { "amount": 10000, "currency": "USD" }, "funded_quote_available": true } ] } ``` Request body: - `mode` (`live` | `sandbox`, optional) - `country` (string, optional) [default "US"] — The shopper’s country. Cashback is offered on US storefronts. Response `200` — The named retailers and their current cashback status - `basis` (`top_us_retailers_by_traffic`, required) — The named list is the top US retailers by traffic plus well-known specialty storefronts, each resolved live: a coverage statement that can be checked store by store. - `generated_at` (string, required) — When these retailers were last resolved. Coverage is refreshed at most hourly; resolve a specific checkout URL with POST /v1/cashback/stores for the current answer. - `summary` (object, required) - `retailers` (integer, required) [range 0–∞] - `eligible` (integer, required) [range 0–∞] - `not_eligible` (integer, required) [range 0–∞] - `unknown` (integer, required) [range 0–∞] - `funded_quote_available` (integer, required) [range 0–∞] - `retailers` (array of object, required) - `name` (string, required) - `url` (string, required) — The US storefront’s home page. - `store_id` (string | null, required) - `status` (`active` | `not_eligible` | `unknown`, required) - `reason` (`merchant_policy` | `unsupported_country` | `unsupported_store` | `rate_unavailable` | `null`, required) - `checkout` (object, required) - `recommended` (`funded` | `native_link` | `native_code` | `null`, required) - `agent_api_checkout` (boolean, required) - `rate` (object | null, required) — What the user earns on the recommended path, as a percentage of eligible merchandise. A quote commits the exact cents. - `type` (`percentage`, required) - `value` (number, required) [range −∞–100] - `max_per_order` (object | null, required) - `amount` (integer, required) [range 0–∞] - `currency` (`USD`, required) - `funded_quote_available` (boolean, required) — True when /v1/cashback/quotes can commit an OpenStock-funded reward here without a browser session. - `mode` (`live` | `sandbox`, required) - `livemode` (boolean, required) - `country` (string, required) ### POST /v1/cashback/quotes **Commit an exact OpenStock-funded cashback amount before checkout** · operationId `createCashbackQuote` Send the actual storefront_url, its explicit country from discovery, store_id and eligible merchandise subtotal in USD cents. Eligibility is resolved again from the URL, including regional paths; a US country value cannot override a foreign storefront. The returned quote fixes the cashback amount and checkout deadline and reserves its backing. OpenStock funds this offer, independently of the store’s native tracking method; both browser and merchant-API checkout can qualify. Submit the completed order with quote_id and purchase evidence. Identical retries replay the original commitment even after rates change; a changed storefront, basket or checkout context under the same key is a conflict. Sandbox quotes simulate the same contract and never reserve real money. **Errors** | Status | Code | When | What to do | | --- | --- | --- | --- | | 400 | `VALIDATION_ERROR` | A field is missing, malformed or out of range. The message names the field. | Fix the request; do not retry it unchanged. | | 403 | `PARTNER_ACCOUNT_REQUIRED` | The key is not attached to a partner account, so it has no users. | Use the live or sandbox key issued for your account. | | 409 | `IDEMPOTENCY_CONFLICT` | The key already identifies another basket or checkout context. | Use the original body for a retry; use a new key for a changed basket. | | 409 | `STORE_NOT_ELIGIBLE` | Store eligibility, quote validity or the checkout context prevents a commitment. | Discover eligibility and obtain a fresh quote before checkout. | | 409 | `QUOTE_EXPIRED` | Store eligibility, quote validity or the checkout context prevents a commitment. | Discover eligibility and obtain a fresh quote before checkout. | | 409 | `QUOTE_UNAVAILABLE` | Store eligibility, quote validity or the checkout context prevents a commitment. | Discover eligibility and obtain a fresh quote before checkout. | | 503 | `GUARANTEE_UNAVAILABLE` | Backing cannot be reserved or the quote service is unavailable. | Retry the same request; do not promise cashback without a successful quote. | #### Commit $8 cashback for a $100 eligible basket OpenStock funds the commitment. A merchant-API checkout needs no tracking cookie. The quote fixes the amount before purchase. Complete request: ```bash curl -sS -X POST https://api.openstock.sh/v1/cashback/quotes \ -H "Authorization: Bearer $OPENSTOCK_API_KEY" \ -H "Content-Type: application/json" \ -d '{"store_id":"01g4s4gvb1kdc8kz69cm5q2b4f","user_id":"u_9f86d081884c7d65","storefront_url":"https://www.nike.com/","country":"US","eligible_amount":10000,"checkout_mode":"merchant_api","expected_checkout_seconds":259200,"idempotency_key":"u_9f86d081884c7d65:order-8812:quote"}' ``` Complete response example: ```json { "quote_id": "qt_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "store_id": "01g4s4gvb1kdc8kz69cm5q2b4f", "storefront_url": "https://www.nike.com/", "country": "US", "eligible_amount": { "amount": 10000, "currency": "USD" }, "cashback": { "amount": 800, "currency": "USD" }, "rate": { "type": "percentage", "value": 8 }, "max_per_order": { "amount": 10000, "currency": "USD" }, "funding": "openstock", "attribution": "report", "requires_browser_context": false, "checkout_mode": "merchant_api", "checkout_expires_at": "2026-11-06T15:04:05.000Z", "report_expires_at": "2026-11-20T15:04:05.000Z", "created_at": "2026-11-03T15:04:05.000Z", "hold_days": 30, "terms_version": "openstock-funded-v1", "terms": [ "OpenStock funds this cashback offer. Request a quote for the exact eligible subtotal before checkout.", "Report the completed purchase with its quote and payment attestation. No browser session or tracking link is required for this offer.", "Cashback clears after the 30-day hold. OpenStock covers ordinary reversals after release." ], "livemode": true } ``` Request body: - `store_id` (string, required) - `storefront_url` (string, required) — Actual storefront or product URL used for checkout. Preserve regional paths such as /gb/. Eligibility is resolved again from this URL; store_id alone does not identify a country. - `user_id` (string, required) - `country` (`US`, required) — Explicit storefront country from discovery; currently only US storefronts qualify. - `eligible_amount` (integer, required) [range 1–100000000] — Merchandise subtotal after discounts, in USD cents. Exclude tax, shipping and gift cards. The completed order must have this eligible subtotal. - `checkout_mode` (`browser` | `merchant_api`, optional) [default "browser"] - `expected_checkout_seconds` (integer, optional) [range 60–604800; default 259200] - `idempotency_key` (string, required) Response `200` — Funded commitment for one qualifying purchase - `quote_id` (string, required) - `store_id` (string, required) - `storefront_url` (string, optional) — Validated storefront URL, excluding query parameters and fragments. Present on new quotes; historical commitments remain readable. - `country` (`US`, required) - `eligible_amount` (object, required) - `amount` (integer, required) [range 0–∞] - `currency` (`USD`, required) - `cashback` (object, required) - `amount` (integer, required) [range 0–∞] - `currency` (`USD`, required) - `rate` (object, required) - `type` (`percentage`, required) - `value` (number, required) [range −∞–100] - `max_per_order` (object, required) - `amount` (integer, required) [range 0–∞] - `currency` (`USD`, required) - `funding` (`openstock`, required) - `attribution` (`report`, required) - `requires_browser_context` (`false`, required) - `checkout_mode` (`browser` | `merchant_api`, required) - `checkout_expires_at` (string, required) - `report_expires_at` (string, required) - `created_at` (string, required) - `hold_days` (`30`, required) - `terms_version` (string, required) - `terms` (array of string, required) - `livemode` (boolean, required) ### POST /v1/cashback-savings **Find stores and cashback offers (deprecated)** · operationId `findCashbackSavings` Deprecated: use POST /v1/cashback/stores, which answers the same resolver in the current store shape. It keeps working until a sunset date announced in advance. items is the exact storefront for the query first, then its alternatives (regional storefronts, a marketplace seller’s listing, or other stores matching a name); omit query to page through the most visited stores that sell in the requested country. country is the storefront’s own country. id is the store’s catalog ID where it has one, else its OpenStock merchant ID for a US storefront; pass it as store_id to the sandbox. status live means the store earns cashback; not_eligible means it does not; catalog_only means its rate could not be confirmed just now, with the response header X-OpenStock-Live-Quotes set to `unavailable`. tracking_available is true for a store you can activate by link with a live key, and always false in sandbox mode, where purchases are simulated. source is always network and program_id always null. **Errors** | Status | Code | When | What to do | | --- | --- | --- | --- | | 400 | `VALIDATION_ERROR` | A field is missing, malformed or out of range. The message names the field. | Fix the request; do not retry it unchanged. | | 400 | `MODE_MISMATCH` | The body asks for the other ledger than the key is bound to. | Omit `mode`: a key with a mode decides the ledger. | | 400 | `INVALID_CURSOR` | The cursor came from a different query, country or mode. | Repeat the search that returned the cursor. | | 503 | `CASHBACK_UNAVAILABLE` | The catalog could not be read. | Retry with bounded backoff. | #### Find a store’s native tracking offer This native tracking example shows Brooklinen. Rates are illustrative of a configured offer; discovery is the source for current availability. For a funded agent checkout, request an exact quote through /v1/cashback/quotes. Complete request: ```bash curl -sS -X POST https://api.openstock.sh/v1/cashback-savings \ -H "Authorization: Bearer $OPENSTOCK_API_KEY" \ -H "Content-Type: application/json" \ -d '{"query":"brooklinen.com","country":"US","limit":1}' ``` Complete response example: ```json { "mode": "live", "livemode": true, "items": [ { "id": "cbs_9c1f6e3b8a2d4f7e0b5c3a9d1e8f2b6c4a7d0e3f5b8c1a9e2d6f4b0c7a3e5d18", "name": "Brooklinen", "store_url": "https://www.brooklinen.com/", "merchant_id": "01g4s5d0h956te86ff90h6xts4", "country": "US", "cashback": { "type": "percentage", "value": 15, "source": "network", "basis": "quote_required" }, "status": "live", "tracking_available": true, "program_id": null, "terms": [ "Open the activation link and complete checkout in that same browser session.", "Cashback applies to eligible purchases. The store may exclude some products, categories and promotions.", "Cashback is credited once the store pays OpenStock for the order, and no sooner than 30 days after the purchase. Stores usually pay 45 to 90 days after the sale." ], "rate_updated_at": "2026-11-03T14:00:00.000Z" } ], "next_cursor": null } ``` Request body: - `mode` (`live` | `sandbox`, optional) — Which ledger to use. Defaults to the mode your API key is bound to (os_live_ keys read live, os_test_ keys read sandbox), otherwise sandbox. A bound key rejects the other mode with 400 MODE_MISMATCH. - `query` (string, optional) — Exact domain or URL, or merchant name prefix. Omit to browse the catalog. - `country` (string, optional) [default "US"] - `limit` (integer, optional) [range 1–20; default 10] - `cursor` (string, optional) Response `200` — Stores with status live (earns cashback), catalog_only (rate not confirmed just now) or not_eligible - `mode` (`live` | `sandbox`, required) - `livemode` (boolean, required) — True when this response comes from the live ledger. Every cashback response carries it so a client can never mistake simulated money for real money. - `items` (array of object, required) - `id` (string, required) - `name` (string, required) - `store_url` (string, required) - `merchant_id` (string | null, required) - `country` (string, required) - `cashback` (object | null, required) — What the user earns at this store. Null when the store does not offer cashback through OpenStock (status not_eligible). - `type` (`percentage` | `fixed`, required) - `value` (number, required) [range 0–∞] - `currency` (string, optional) - `source` (`network` | `openstock` | `example`, required) - `basis` (`quote_required` | `guaranteed` | `fixed` | `example`, required) - `max_per_order` (object, optional) — The most one order earns, when the store caps it. Absent when it does not. - `amount` (integer, required) [range 0–∞] - `currency` (`USD`, required) - `status` (`live` | `catalog_only` | `example` | `not_eligible`, required) - `tracking_available` (boolean, required) - `program_id` (string | null, required) — Always null; kept for existing integrations. - `terms` (array of string, required) - `rate_updated_at` (string | null, required) - `next_cursor` (string | null, required) ### POST /v1/cashback/activate **Create a tracked purchase link for a user** · operationId `activateCashback` Use the OpenStock store ID from store discovery (or the /v1/cashback-savings result’s id) as store_id; pass its program_id to pin the quoted program. The user ID (or its wallet_id alias) belongs to your partner account; API key rotation keeps the same wallet. Idempotency keys are per user: retry with the same user, idempotency_key and purchase context, and expect the same key with another user to activate a separate click. Open the returned OpenStock URL in a real browser profile and complete checkout in that same profile; it forwards to the store with the click attached. A bare HTTP client is not enough: store and network pages may challenge or block it, and it attributes nothing. At a store whose attribution is link, a purchase report never earns without this tracked visit, so open the link in the browser that checks out. A report earns on its own only at a store whose attribution is report; at a code store, the order needs the user’s code. Following the URL alone never credits money. A store that offers no cashback through OpenStock answers 409 STORE_NOT_ELIGIBLE; a store with no tracked link answers 409 PROGRAM_UNAVAILABLE. Rates and eligibility are rechecked when activating, and the quoted rate is frozen on the click. **Errors** | Status | Code | When | What to do | | --- | --- | --- | --- | | 409 | `CHECKOUT_WINDOW_UNSUPPORTED` | The requested checkout duration exceeds the verified native window, or that window is unknown. | Request an OpenStock-funded quote if eligible. | | 400 | `VALIDATION_ERROR` | A field is missing, malformed or out of range. The message names the field. | Fix the request; do not retry it unchanged. | | 403 | `PARTNER_ACCOUNT_REQUIRED` | The key is not attached to a partner account, so it has no users. | Use the live or sandbox key issued for your account. | | 403 | `LIVE_KEY_REQUIRED` | A sandbox key tried to activate real cashback. | Activate with your `os_live_` key; rehearse with a sandbox link. | | 409 | `STORE_UNAVAILABLE` | The store_id is not one discovery returned. | Use an `id` from discovery. | | 409 | `PROGRAM_UNAVAILABLE` | The store has no live program for this country right now, or the program_id is no longer the store’s. | Discover the store again and activate what it returns; do not retry the same body. | | 409 | `IDEMPOTENCY_CONFLICT` | The key was used before for this user with a different store, program, country or destination. | Use a new idempotency_key for a new purchase. | | 409 | `INVALID_DESTINATION` | destination_url is not on the store’s site. | Send a URL on the store’s own domain, or omit it. | | 503 | `ACTIVATION_UNAVAILABLE` | The quote or the click record could not be written. | Retry with the same body and idempotency_key. | #### Activate a native Brooklinen link for one user A live key records a click for the user and returns the link to open in the browser that will check out. The quote is frozen on the click. Complete request: ```bash curl -sS -X POST https://api.openstock.sh/v1/cashback/activate \ -H "Authorization: Bearer $OPENSTOCK_API_KEY" \ -H "Content-Type: application/json" \ -d '{"store_id":"cbs_9c1f6e3b8a2d4f7e0b5c3a9d1e8f2b6c4a7d0e3f5b8c1a9e2d6f4b0c7a3e5d18","user_id":"u_9f86d081884c7d65","country":"US","idempotency_key":"u_9f86d081884c7d65:order-8812:activate"}' ``` Complete response example: ```json { "click_id": "cx01jbz8k2m4q6s8u0w2y4a6c8e0", "url": "https://api.openstock.sh/cashback/go/cx01jbz8k2m4q6s8u0w2y4a6c8e0", "cashback": { "type": "percentage", "value": 15, "source": "network", "basis": "quote_required" }, "terms": [ "Cashback applies to eligible purchases. The store may exclude some products, categories and promotions.", "Cashback is credited once the store pays OpenStock for the order, and no sooner than 30 days after the purchase. Stores usually pay 45 to 90 days after the sale." ], "attribution_window_days": 1, "attribution_window": { "kind": "timed", "duration_seconds": 86400 }, "requires_browser_context": true, "livemode": true } ``` Request body: - `store_id` (string, required) — The store to activate: its OpenStock store ID (the id store discovery and /v1/merchants/search return), or a store id from /v1/cashback-savings. - `program_id` (string | null, optional) — The program_id discovery returned. Optional: without it, or with null as /v1/cashback-savings now returns, the store’s current program is used. - `user_id` (string, optional) — Opaque user ID within your authenticated partner account. An email address is rejected with 400. - `wallet_id` (string, optional) — Alias of user_id, the same ID you send as wallet_id to /v1/merchants/codes and /v1/wallets/read. Send either one. - `country` (string, required) - `destination_url` (string, optional) - `expected_checkout_seconds` (integer, optional) [range 1–2592000] — If supplied, activation is refused unless the verified native attribution window covers this duration. Sponsored quotes support longer or API-driven checkout independently. - `idempotency_key` (string, required) Response `200` — Durably recorded click and the OpenStock link that forwards to the store with it - `click_id` (string, required) - `url` (string, required) - `cashback` (object, required) - `type` (`percentage` | `fixed`, required) - `value` (number, required) [range 0–∞] - `currency` (string, optional) - `source` (`network` | `openstock` | `example`, required) - `basis` (`quote_required` | `guaranteed` | `fixed` | `example`, required) - `max_per_order` (object, optional) — The most one order earns, when the store caps it. Absent when it does not. - `amount` (integer, required) [range 0–∞] - `currency` (`USD`, required) - `terms` (array of string, required) - `attribution_window_days` (integer | null, required) — Native attribution days, when verified. Null means unknown, never an implied same-session promise. Prefer attribution_window. - `attribution_window` (object, required) - `kind` (`timed` | `same_session` | `unknown`, required) - `duration_seconds` (integer | null, required) - `requires_browser_context` (`true`, required) - `livemode` (`true`, required) ### POST /v1/cashback/sandbox/purchases **Simulate a purchase, credit, or refund without spending money** · operationId `simulateCashbackPurchase` Sandbox only. Creates fake USD purchases at the rate store discovery shows for the store, with no product exclusions. Pass a store_id from /v1/cashback/stores, or an id from /v1/cashback-savings. A store that is not active answers 409 STORE_NOT_ELIGIBLE. The first purchase fixes its commission for later status changes. Paid simulations credit immediately; pending ones can later be paid, then reversed. Reuse the same order_id and amounts with a NEW idempotency_key to change status. Reuse the SAME key for retries. Sandbox funds are not real money. Read them with /v1/wallets/read and your sandbox key; live wallets never include them. **Errors** | Status | Code | When | What to do | | --- | --- | --- | --- | | 403 | `PARTNER_ACCOUNT_REQUIRED` | The key is not attached to a partner account, so it has no users. | Use the live or sandbox key issued for your account. | | 403 | `SANDBOX_KEY_REQUIRED` | A live key called a sandbox simulation. | Call it with your `os_test_` key. | | 409 | `STORE_NOT_ELIGIBLE` | The store is not eligible, as Amazon is. | Pick a store whose status allows cashback. | | 409 | `STORE_UNAVAILABLE` | The store_id is not one discovery returned. | Use a `store_id` from discovery. | | 409 | `ORDER_CONFLICT` | The order_id was used before with a different store, user or amount. | Keep the order fields unchanged; use a new idempotency_key only for a new status. | | 409 | `IDEMPOTENCY_CONFLICT` | The idempotency_key was used before for a different request. | Keep the order fields unchanged; use a new idempotency_key only for a new status. | | 409 | `INVALID_TRANSITION` | The status change is not allowed, such as reinstating a reversed purchase. | Keep the order fields unchanged; use a new idempotency_key only for a new status. | | 409 | `INVALID_INPUT` | The order details are inconsistent. | Keep the order fields unchanged; use a new idempotency_key only for a new status. | | 409 | `BALANCE_LIMIT` | The simulated balance would exceed the sandbox limit. | Keep the order fields unchanged; use a new idempotency_key only for a new status. | | 503 | `SANDBOX_UNAVAILABLE` | The sandbox ledger could not be written. | Retry with the same body and idempotency_key. | #### Simulate a paid purchase A sandbox key records a $100 purchase at the store’s rate and credits it at once. Complete request: ```bash curl -sS -X POST https://api.openstock.sh/v1/cashback/sandbox/purchases \ -H "Authorization: Bearer $OPENSTOCK_API_KEY" \ -H "Content-Type: application/json" \ -d '{"user_id":"u_9f86d081884c7d65","store_id":"cbs_9c1f6e3b8a2d4f7e0b5c3a9d1e8f2b6c4a7d0e3f5b8c1a9e2d6f4b0c7a3e5d18","order_id":"order-8812","order_amount":10000,"country":"US","status":"paid","idempotency_key":"u_9f86d081884c7d65:order-8812:paid"}' ``` Complete response example: ```json { "mode": "sandbox", "livemode": false, "balance": { "amount": 1500, "currency": "USD", "scale": 2 }, "items": [ { "id": "sandbox_4f0b6c2a9d8e1f3b5a7c9e0d2b4f6a8c1e3d5b7f9a0c2e4d6b8f0a1c3e5d7b9f", "merchant_id": "cbs_9c1f6e3b8a2d4f7e0b5c3a9d1e8f2b6c4a7d0e3f5b8c1a9e2d6f4b0c7a3e5d18", "order_id": "order-8812", "status": "credited", "purchased_at": "2026-11-03T15:04:05.000Z", "order_amount": { "amount": 10000, "currency": "USD", "scale": 2 }, "network_status": "paid", "commission": { "amount": 1500, "currency": "USD", "scale": 2 }, "credited_amount": { "amount": 1500, "currency": "USD", "scale": 2 }, "reversal": null, "estimated": false, "report_id": null, "partner_order_id": null, "click_id": null } ], "next_cursor": null } ``` Request body: - `user_id` (string, optional) — Opaque user ID within your authenticated partner account. An email address is rejected with 400. - `wallet_id` (string, optional) — Alias of user_id, the same ID you send as wallet_id to /v1/merchants/codes and /v1/wallets/read. Send either one. - `store_id` (string, required) — A store_id from /v1/cashback/stores, or an id from /v1/cashback-savings. - `order_id` (string, required) - `order_amount` (integer, required) [range 1–100000000] — Simulated USD order in cents. 10000 is $100. It earns the rate store discovery shows for the store; a store that is not active cannot be simulated. - `country` (string, optional) [default "US"] - `idempotency_key` (string, required) - `status` (`pending` | `paid` | `reversed`, optional) [default "paid"] Response `200` — The simulated purchase and isolated sandbox balance - `mode` (`live` | `sandbox`, required) - `livemode` (boolean, required) — True when this response comes from the live ledger. Every cashback response carries it so a client can never mistake simulated money for real money. - `balance` (object, required) - `amount` (integer, required) - `currency` (string, required) - `scale` (`2`, required) - `reserved` (object, optional) - `amount` (integer, required) - `currency` (string, required) - `scale` (`2`, required) - `transfer_pending` (object, optional) - `amount` (integer, required) - `currency` (string, required) - `scale` (`2`, required) - `transferred` (object, optional) - `amount` (integer, required) - `currency` (string, required) - `scale` (`2`, required) - `items` (array of object | object, required) - `id` (string, required) - `merchant_id` (string, required) - `order_id` (string, required) - `status` (string, required) - `purchased_at` (string, required) - `order_amount` (object | null, required) - `amount` (integer, required) - `currency` (string, required) - `scale` (`2`, required) - `network_status` (string | null, required) - `commission` (object | null, required) — What the purchase earns the user, in USD. A funded purchase has committed cents during its hold, subject to eligible hold-period refunds; native purchases without a quote can remain estimates pending confirmation. After a reversal, the purchase retains its prior credit for the audit trail. Use wallet balances for transfer availability. - `amount` (integer, required) - `currency` (string, required) - `scale` (`2`, required) - `credited_amount` (object | null, required) — What currently stands credited to the balance for this purchase: zero once it has been reversed. - `amount` (integer, required) - `currency` (string, required) - `scale` (`2`, required) - `reversal` (object | null, required) — Present once the purchase has been reversed: the amount taken back, why, and when. - `amount` (object, required) - `amount` (integer, required) - `currency` (string, required) - `scale` (`2`, required) - `reason` (string, required) — Why the cashback was taken back. order_reversed: the store reversed the sale, for a return, a cancellation or a declined order. - `at` (string, required) - `estimated` (boolean, optional) — True when the amount is still an estimate. Accepted funded quotes are false during the hold because their cents are committed, subject to eligible refunds. This flag does not indicate spendability; use wallet balances. - `report_id` (string | null, optional) — The report_id of your /v1/cashback/purchases/report call this purchase carries, if any. - `partner_order_id` (string | null, optional) — The order_id you reported for this purchase, if any. - `click_id` (string | null, optional) — The click that attributed this purchase, when one did. - `next_cursor` (string | null, required) ### POST /v1/cashback/sandbox/links **Create a private hosted test checkout link** · operationId `createSandboxCashbackLink` Creates a sandbox-only checkout for one user, store, order, and USD amount. The rate store discovery shows for the store is fixed at creation. Links expire in one hour. GET and preview never credit. A human presses Simulate purchase; an agent POSTs the returned completion body. Completion is idempotent and never places a real order. Keep the URL and completion token private. A store that is not active answers 409 STORE_NOT_ELIGIBLE. **Errors** | Status | Code | When | What to do | | --- | --- | --- | --- | | 403 | `PARTNER_ACCOUNT_REQUIRED` | The key is not attached to a partner account, so it has no users. | Use the live or sandbox key issued for your account. | | 403 | `SANDBOX_KEY_REQUIRED` | A live key called a sandbox simulation. | Call it with your `os_test_` key. | | 403 | `PARTNER_ACCOUNT_UNAVAILABLE` | The partner account was closed. | Contact OpenStock support. | | 409 | `STORE_NOT_ELIGIBLE` | The store is not eligible, as Amazon is. | Pick a store whose status allows cashback. | | 409 | `STORE_UNAVAILABLE` | The store_id is not one discovery returned. | Use a `store_id` from discovery. | | 409 | `IDEMPOTENCY_CONFLICT` | The key was used before for a different checkout. | Retry with the original body, or use a new key. | | 409 | `LINK_EXPIRED` | The retried link is more than an hour old. | Create a new link with a new idempotency_key. | | 503 | `SANDBOX_UNAVAILABLE` | The link could not be recorded. | Retry with the same body and idempotency_key. | #### A hosted test checkout at Brooklinen A sandbox key creates a private checkout for a $100 order. `commission` is the exact credit the wallet will show once the checkout completes. Complete request: ```bash curl -sS -X POST https://api.openstock.sh/v1/cashback/sandbox/links \ -H "Authorization: Bearer $OPENSTOCK_API_KEY" \ -H "Content-Type: application/json" \ -d '{"user_id":"u_9f86d081884c7d65","store_id":"cbs_9c1f6e3b8a2d4f7e0b5c3a9d1e8f2b6c4a7d0e3f5b8c1a9e2d6f4b0c7a3e5d18","order_id":"order-8812","order_amount":10000,"country":"US","idempotency_key":"u_9f86d081884c7d65:order-8812:link"}' ``` Complete response example: ```json { "mode": "sandbox", "livemode": false, "url": "https://api.openstock.sh/cashback/sandbox/checkout#eyJhbGciOiJIUzI1NiJ9.example.signature", "click_id": "cx01jbz8k2m4q6s8u0w2y4a6c8e0", "expires_at": "2026-11-03T16:04:05.000Z", "cashback": { "type": "percentage", "value": 15, "source": "network", "basis": "quote_required" }, "commission": { "amount": 1500, "currency": "USD", "scale": 2 }, "completion": { "url": "https://api.openstock.sh/cashback/sandbox/checkout", "method": "POST", "body": { "token": "eyJhbGciOiJIUzI1NiJ9.example.signature", "action": "complete" } } } ``` Request body: - `user_id` (string, optional) — Opaque user ID within your authenticated partner account. An email address is rejected with 400. - `wallet_id` (string, optional) — Alias of user_id, the same ID you send as wallet_id to /v1/merchants/codes and /v1/wallets/read. Send either one. - `store_id` (string, required) — A store_id from /v1/cashback/stores, or an id from /v1/cashback-savings. - `order_id` (string, required) - `order_amount` (integer, required) [range 1–100000000] — Simulated USD order in cents. 10000 is $100. It earns the rate store discovery shows for the store; a store that is not active cannot be simulated. - `country` (string, optional) [default "US"] - `idempotency_key` (string, required) Response `200` — Hosted sandbox URL and agent JSON completion instructions - `mode` (`sandbox`, required) - `livemode` (`false`, required) - `click_id` (string | null, required) — The click this checkout stands for. Send it with /v1/cashback/purchases/report after the checkout completes, as you would a live click_id. - `url` (string, required) - `expires_at` (string, required) - `cashback` (object, required) - `type` (`percentage` | `fixed`, required) - `value` (number, required) [range 0–∞] - `currency` (string, optional) - `source` (`network` | `openstock` | `example`, required) - `basis` (`quote_required` | `guaranteed` | `fixed` | `example`, required) - `max_per_order` (object, optional) — The most one order earns, when the store caps it. Absent when it does not. - `amount` (integer, required) [range 0–∞] - `currency` (`USD`, required) - `commission` (object, required) - `amount` (integer, required) - `currency` (string, required) - `scale` (`2`, required) - `completion` (object, required) - `url` (string, required) - `method` (`POST`, required) - `body` (object, required) - `token` (string, required) - `action` (`complete`, required) ### POST /cashback/sandbox/checkout **Preview or complete a hosted test checkout** · operationId `completeSandboxCheckout` The `completion.url` a sandbox link returns. Send its `completion.body` as JSON, without your API key: the signed token in the body authorizes this one checkout. `action: "preview"` returns the receipt with status `ready` and changes nothing; `action: "complete"` records the test purchase and credits the user once, however often it is repeated. A person can instead open the link’s `url` and press **Simulate purchase**; opening it alone credits nothing. **Errors** | Status | Code | When | What to do | | --- | --- | --- | --- | | 400 | `INVALID_CHECKOUT_REQUEST` | The body is not `{token, action}`. | Send `completion.body` exactly as the link returned it. | | 400 | `INVALID_CHECKOUT_LINK` | The token is altered or more than an hour old. | Create a new link. | | 403 | `PARTNER_ACCOUNT_UNAVAILABLE` | The partner account was closed after the link was created. | Contact OpenStock support. | | 409 | `CHECKOUT_CONFLICT` | The order was recorded before with other details. | Create a new link with a new order_id. | | 503 | `SANDBOX_UNAVAILABLE` | The sandbox ledger could not be written. | Retry the same request. | #### Complete a hosted test checkout POST `completion.body` from the link response, without your API key. Repeating it returns the same receipt and credits once. Complete request: ```bash curl -sS -X POST https://api.openstock.sh/cashback/sandbox/checkout \ -H "Content-Type: application/json" \ -d '{"token":"eyJhbGciOiJIUzI1NiJ9.example.signature","action":"complete"}' ``` Complete response example: ```json { "mode": "sandbox", "livemode": false, "status": "credited", "store_id": "cbs_9c1f6e3b8a2d4f7e0b5c3a9d1e8f2b6c4a7d0e3f5b8c1a9e2d6f4b0c7a3e5d18", "store_name": "Brooklinen", "order_id": "order-8812", "order_amount": { "amount": 10000, "currency": "USD", "scale": 2 }, "cashback": { "type": "percentage", "value": 15, "source": "network", "basis": "quote_required" }, "commission": { "amount": 1500, "currency": "USD", "scale": 2 }, "credited_amount": { "amount": 1500, "currency": "USD", "scale": 2 }, "expires_at": "2026-11-03T16:04:05.000Z" } ``` Request body: - `token` (string, required) - `action` (`preview` | `complete`, required) Response `200` — The receipt for this test checkout - `mode` (`sandbox`, required) - `livemode` (`false`, required) - `status` (`ready` | `credited` | `reversed`, required) — ready after a preview; credited once the test purchase is recorded; reversed if it was reversed since. - `store_id` (string, required) - `store_name` (string, required) - `order_id` (string, required) - `order_amount` (object, required) - `amount` (integer, required) - `currency` (`USD`, required) - `scale` (`2`, required) - `cashback` (object, required) - `type` (`percentage` | `fixed`, required) - `value` (number, required) [range 0–∞] - `currency` (string, optional) - `source` (`network` | `openstock` | `example`, required) - `basis` (`quote_required` | `guaranteed` | `fixed` | `example`, required) - `max_per_order` (object, optional) — The most one order earns, when the store caps it. Absent when it does not. - `amount` (integer, required) [range 0–∞] - `currency` (`USD`, required) - `commission` (object, required) — The credit this test purchase earns the user. - `amount` (integer, required) - `currency` (`USD`, required) - `scale` (`2`, required) - `credited_amount` (object, required) — What stands credited now: zero after a preview. - `amount` (integer, required) - `currency` (`USD`, required) - `scale` (`2`, required) - `expires_at` (string, required) ### GET /cashback/go/{click_id} **Follow an activated cashback link** · operationId `followCashbackLink` The `url` that activation returns. Open it in the browser that will check out: it forwards to the store with the click attached, and the store attributes the purchase to that click. It needs no API key and is safe to hand to the user’s browser or your agent’s. **Errors** | Status | Code | When | What to do | | --- | --- | --- | --- | | 404 | `NOT_FOUND` | The click id is unknown. | Activate again and open the new link. | | 503 | `LINK_UNAVAILABLE` | The click could not be resolved. | Reload the link after a few seconds. | Response `302` — Forwards to the store with the click attached ### POST /v1/wallets/read **Batch wallet balances, pending and all purchases, and transactions** · operationId `readWallets` Read up to 20 queries using your original wallet_id (user_id is accepted as an alias). Reads never create wallets. Each query succeeds or fails independently. Balances and credit history use consistent reads. Pending purchases are current mutable order records, with a short indexing delay; they are not cashback credits. purchases lists every purchase with its status, credit and any reversal record. Only purchases with resolved wallet ownership are listed. Pages are oldest first; follow next_cursor even when items is empty. History includes all recorded cashback credits, reversals and adjustments. Reserved is cashback held before release; it cannot be transferred. Available is cleared at OpenStock, not yet received or spendable in the partner wallet; transfer_pending is reserved for a payout, and transferred is acknowledged as received by the partner. Funded amounts have estimated:false during the hold, and ordinary late reversals after release are absorbed by OpenStock. A sandbox (os_test_) key reads the simulated ledger in the same shape; a live (os_live_) key reads the live ledger. Every result carries livemode. Use signed webhooks and /v1/events/read for updates. **Errors** | Status | Code | When | What to do | | --- | --- | --- | --- | | 400 | `VALIDATION_ERROR` | A field is missing, malformed or out of range. The message names the field. | Fix the request; do not retry it unchanged. | #### Balance and purchase history in one call Two queries for one user: the available balance and the purchase history with each purchase’s credit and any reversal. Complete request: ```bash curl -sS -X POST https://api.openstock.sh/v1/wallets/read \ -H "Authorization: Bearer $OPENSTOCK_API_KEY" \ -H "Content-Type: application/json" \ -d '{"queries":[{"query_id":"balance","user_id":"u_9f86d081884c7d65","type":"balance"},{"query_id":"purchases","user_id":"u_9f86d081884c7d65","type":"purchases","limit":20}]}' ``` Complete response example: ```json { "results": [ { "query_id": "balance", "wallet_id": "u_9f86d081884c7d65", "livemode": true, "data": { "type": "balance", "available": { "amount": 1500, "currency": "USD" }, "reserved": { "amount": 0, "currency": "USD" } } }, { "query_id": "purchases", "wallet_id": "u_9f86d081884c7d65", "livemode": true, "data": { "type": "purchases", "items": [ { "id": "pur_01jbz9a3c5e7g9j1l3n5q7s9u1", "merchant_id": "01g4s5d0h956te86ff90h6xts4", "order_id": "NK-40281877", "order_amount": { "amount": 10000, "currency": "USD" }, "purchased_at": "2026-11-03T15:04:05.000Z", "updated_at": "2026-12-18T15:04:05.000Z", "status": "credited", "cashback": { "amount": 1500, "currency": "USD" }, "credited_amount": { "amount": 1500, "currency": "USD" }, "reversal": null, "estimated": false, "report_id": null, "partner_order_id": null, "click_id": "cx01jbz8k2m4q6s8u0w2y4a6c8e0" } ], "next_cursor": null } } ] } ``` #### A user who has not earned yet Reads never create wallets: a user with no quote or purchase yet answers wallet_not_found inside a 200. Complete request: ```bash curl -sS -X POST https://api.openstock.sh/v1/wallets/read \ -H "Authorization: Bearer $OPENSTOCK_API_KEY" \ -H "Content-Type: application/json" \ -d '{"queries":[{"query_id":"balance","user_id":"u_9f86d081884c7d65","type":"balance"}]}' ``` Complete response example: ```json { "results": [ { "query_id": "balance", "wallet_id": "u_9f86d081884c7d65", "livemode": true, "data": null, "error": { "code": "wallet_not_found", "message": "Wallet not found." } } ] } ``` #### One query fails, the rest answer Each query succeeds or fails on its own. Retry the failed query. Complete request: ```bash curl -sS -X POST https://api.openstock.sh/v1/wallets/read \ -H "Authorization: Bearer $OPENSTOCK_API_KEY" \ -H "Content-Type: application/json" \ -d '{"queries":[{"query_id":"balance","user_id":"u_9f86d081884c7d65","type":"balance"}]}' ``` Complete response example: ```json { "results": [ { "query_id": "balance", "wallet_id": "u_9f86d081884c7d65", "livemode": true, "data": null, "error": { "code": "wallet_unavailable", "message": "The wallet service is unavailable. Retry this query." } } ] } ``` #### A key with no partner account Wallets belong to a partner account; a key without one reads none. Complete request: ```bash curl -sS -X POST https://api.openstock.sh/v1/wallets/read \ -H "Authorization: Bearer $OPENSTOCK_API_KEY" \ -H "Content-Type: application/json" \ -d '{"queries":[{"query_id":"balance","user_id":"u_9f86d081884c7d65","type":"balance"}]}' ``` Complete response example: ```json { "results": [ { "query_id": "balance", "wallet_id": "u_9f86d081884c7d65", "livemode": true, "data": null, "error": { "code": "partner_account_required", "message": "A partner account is required to read wallets." } } ] } ``` Request body: - `queries` (array of object, required) [1–20 items] - `query_id` (string, required) - `wallet_id` (string, optional) — Your original user/wallet ID, scoped to your partner account. Use the same ID supplied to merchant offers. - `user_id` (string, optional) — Alias of wallet_id, the same ID the cashback endpoints call user_id. Send either one. - `type` (`balance` | `pending_purchases` | `purchases` | `transactions`, required) - `limit` (integer, optional) [range 1–100; default 20] — Page size for purchases or transactions; ignored for balance. - `cursor` (string, optional) — Opaque next_cursor from the same wallet and read type. Omit for the first page. Response `200` — Independent results correlated by query_id. Missing wallets return wallet_not_found - `results` (array of object, required) - `data` (object | object | object | object | null, required) - `type` (`balance`, required) - `available` (object, required) — Cleared OpenStock balance eligible for transfer. It is not money received or allocated in the partner wallet; follow transfer status and allocated_at for those milestones. - `amount` (integer, required) [range 0–∞] — Amount in the currency’s minor units (USD cents, for example). - `currency` (`USD`, required) - `reserved` (object, required) — Cashback held until its release conditions are met. Not transferable. - `amount` (integer, required) [range 0–∞] — Amount in the currency’s minor units (USD cents, for example). - `currency` (`USD`, required) - `transfer_pending` (object, optional) — Cashback reserved for outgoing transfers, separate from the purchase hold. - `amount` (integer, required) [range 0–∞] — Amount in the currency’s minor units (USD cents, for example). - `currency` (`USD`, required) - `transferred` (object, optional) — Cashback whose receipt the partner acknowledged. - `amount` (integer, required) [range 0–∞] — Amount in the currency’s minor units (USD cents, for example). - `currency` (`USD`, required) - `error` (object, optional) - `code` (`partner_account_required` | `wallet_not_found` | `wallet_unavailable`, required) - `message` (string, required) - `query_id` (string, required) - `wallet_id` (string, required) - `livemode` (boolean, required) — True when the result comes from the live ledger. A sandbox (os_test_) key reads the simulated ledger. ### POST /v1/transfers **Reserve cleared cashback for transfer** · operationId `createWalletTransfer` Requires transfers:write. Amount is USD cents. Reserves funds once for the receiving account you verified. Processing is asynchronous. sent means dispatched; acknowledge only after receipt. Sandbox transfers require explicit simulation. **Errors** | Status | Code | When | What to do | | --- | --- | --- | --- | | 400 | `VALIDATION_ERROR` | A required field is missing or invalid. | Correct the named field. | | 400 | `KEY_MODE_REQUIRED` | The key has no bound mode. | Use an os_live_ or os_test_ key for this account. | | 403 | `PARTNER_ACCOUNT_REQUIRED` | The key has no partner account. | Use a key assigned to your partner account. | | 503 | `SETTLEMENT_UNAVAILABLE` | The settlement service could not complete the operation. | Retry with the same idempotency key; read the transfer to reconcile uncertain outcomes. | | 403 | `WALLET_OWNERSHIP_CONFLICT` | The wallet belongs to another partner account. | Use a user identifier belonging to your partner account. | | 404 | `WALLET_NOT_FOUND` | The user has no wallet in this account and mode. | Use the original opaque user identifier and the matching account and mode. | | 409 | `INSUFFICIENT_BALANCE` | The request exceeds cleared, unreserved cashback. | Read the balance and transfer only available funds. | | 409 | `IDEMPOTENCY_CONFLICT` | The key was already used with a different user or amount. | Retry the original request unchanged; use a new key for a new transfer. | | 503 | `SETTLEMENT_NOT_CONFIGURED` | The receiving account is not verified, or settlement is paused. | Check readiness for the blocker, then retry with the same idempotency key. | #### Reserve $8 of cleared sandbox cashback HTTP 202 accepts an asynchronous transfer. It does not mean a bank or user wallet has received money. Complete request: ```bash curl -sS -X POST https://api.openstock.sh/v1/transfers \ -H "Authorization: Bearer $OPENSTOCK_API_KEY" \ -H "Content-Type: application/json" \ -d '{"user_id":"u_9f86d081884c7d65","amount":800,"currency":"USD","idempotency_key":"user-order-8812:transfer"}' ``` Complete response example: ```json { "transfer": { "id": "tr_example_001", "credit_key": "tr_example_001", "user_id": "u_9f86d081884c7d65", "amount": { "amount": 800, "currency": "USD" }, "status": "reserved", "reissue": { "count": 0, "history": [] }, "provider_reference": null, "allocated_at": null, "receipt": null, "allocation": null, "evidence_status": { "receipt": "none", "allocation": "none" }, "created_at": "2026-11-03T15:04:05.000Z", "updated_at": "2026-11-03T15:04:05.000Z", "livemode": false } } ``` Request body: - `user_id` (string, required) - `amount` (integer, required) - `currency` (`USD`, optional) [default "USD"] - `idempotency_key` (string, required) Response `202` — Transfer reserved or replayed - `transfer` (object, required) - `id` (string, required) - `credit_key` (string, required) — Key your user-wallet credit by this value, the transfer id. It never changes: a transfer the bank returns after you allocated it is re-sent under the same id, so a retry cannot credit the user twice. - `user_id` (string | null, required) - `amount` (object, required) - `amount` (integer, required) [range 0–∞] - `currency` (`USD`, required) - `status` (`reserved` | `processing` | `sent` | `reconciling` | `succeeded` | `failed` | `returned`, required) — reserved and processing: held for dispatch. sent: the payout rail reports sending; receipt is not confirmed. reconciling: the dispatch outcome is uncertain; funds stay reserved. succeeded: you acknowledged receipt. failed or returned before allocation: available funds are restored. A return or cancellation after allocation goes back to processing and is re-sent, see reissue; only after three re-sends does it stop as returned, for OpenStock to settle by hand, with the credit still standing. - `reissue` (object, required) — Bank returns or cancellations after your allocation, each re-sent by OpenStock on this same transfer (reason returned_after_allocation or failed_after_allocation). The user keeps the reward and you carry no shortfall; acknowledge receipt of the re-sent money as usual. - `count` (integer, required) [range 0–∞] - `history` (array of object, required) - `returned_at` (string, required) - `provider_reference` (string | null, required) - `reason` (string, required) - `provider_reference` (string | null, required) — The payout rail’s reconciliation reference once dispatched. Sandbox references start with simulated_ and are simulation identifiers, never evidence of a real bank payment. - `allocated_at` (string | null, required) - `receipt` (object | null, required) — Partner-supplied bank receipt reference, receipt time, and the exact received amount/provider reference. References are reconciliation evidence supplied by the partner, not independent confirmation by OpenStock. - `reference` (string, required) - `received_at` (string, required) - `amount` (object, required) - `amount` (integer, required) - `currency` (`USD`, required) - `provider_reference` (string, required) - `allocation` (object | null, required) — Partner-supplied transaction reference and time from its committed user-wallet credit. Send only after posting the credit exactly once in the receiving wallet. - `reference` (string, required) - `allocated_at` (string, required) - `evidence_status` (object, required) — none: no acknowledgment; attested: legacy boolean acknowledgment without a stored external reference; referenced: immutable partner-supplied reconciliation reference. unknown: an older returned transfer has no retained receipt acknowledgment history. None of these statuses independently verifies a bank receipt or wallet credit. - `receipt` (`none` | `attested` | `referenced` | `unknown`, required) - `allocation` (`none` | `attested` | `referenced`, required) - `created_at` (string, required) - `updated_at` (string, required) - `livemode` (boolean, required) ### POST /v1/transfers/read **Read transfers and per-user allocations** · operationId `readWalletTransfers` Requires transfers:read. Read one ID or paginate the partner manifest. allocated_at remains null until user allocation is acknowledged. **Errors** | Status | Code | When | What to do | | --- | --- | --- | --- | | 400 | `VALIDATION_ERROR` | A required field is missing or invalid. | Correct the named field. | | 400 | `KEY_MODE_REQUIRED` | The key has no bound mode. | Use an os_live_ or os_test_ key for this account. | | 403 | `PARTNER_ACCOUNT_REQUIRED` | The key has no partner account. | Use a key assigned to your partner account. | | 503 | `SETTLEMENT_UNAVAILABLE` | The settlement service could not complete the operation. | Retry with the same idempotency key; read the transfer to reconcile uncertain outcomes. | | 404 | `TRANSFER_NOT_FOUND` | The transfer is missing from this account and mode. | Use the transfer ID returned for this partner and ledger. | | 400 | `INVALID_CURSOR` | The cursor is malformed or belongs to another account or operation. | Use the returned cursor unchanged. | #### Read the transfer manifest The opaque cursor paginates transfers scoped to this partner and key mode. Complete request: ```bash curl -sS -X POST https://api.openstock.sh/v1/transfers/read \ -H "Authorization: Bearer $OPENSTOCK_API_KEY" \ -H "Content-Type: application/json" \ -d '{"limit":20}' ``` Complete response example: ```json { "items": [ { "id": "tr_example_001", "credit_key": "tr_example_001", "user_id": "u_9f86d081884c7d65", "amount": { "amount": 800, "currency": "USD" }, "status": "reserved", "reissue": { "count": 0, "history": [] }, "provider_reference": null, "allocated_at": null, "receipt": null, "allocation": null, "evidence_status": { "receipt": "none", "allocation": "none" }, "created_at": "2026-11-03T15:04:05.000Z", "updated_at": "2026-11-03T15:04:05.000Z", "livemode": false } ], "next_cursor": null } ``` Request body: - `transfer_id` (string, optional) - `limit` (integer, optional) [range 1–100; default 20] - `cursor` (string, optional) Response `200` — Partner and mode scoped transfers - `items` (array of object, required) - `id` (string, required) - `credit_key` (string, required) — Key your user-wallet credit by this value, the transfer id. It never changes: a transfer the bank returns after you allocated it is re-sent under the same id, so a retry cannot credit the user twice. - `user_id` (string | null, required) - `amount` (object, required) - `amount` (integer, required) [range 0–∞] - `currency` (`USD`, required) - `status` (`reserved` | `processing` | `sent` | `reconciling` | `succeeded` | `failed` | `returned`, required) — reserved and processing: held for dispatch. sent: the payout rail reports sending; receipt is not confirmed. reconciling: the dispatch outcome is uncertain; funds stay reserved. succeeded: you acknowledged receipt. failed or returned before allocation: available funds are restored. A return or cancellation after allocation goes back to processing and is re-sent, see reissue; only after three re-sends does it stop as returned, for OpenStock to settle by hand, with the credit still standing. - `reissue` (object, required) — Bank returns or cancellations after your allocation, each re-sent by OpenStock on this same transfer (reason returned_after_allocation or failed_after_allocation). The user keeps the reward and you carry no shortfall; acknowledge receipt of the re-sent money as usual. - `count` (integer, required) [range 0–∞] - `history` (array of object, required) - `returned_at` (string, required) - `provider_reference` (string | null, required) - `reason` (string, required) - `provider_reference` (string | null, required) — The payout rail’s reconciliation reference once dispatched. Sandbox references start with simulated_ and are simulation identifiers, never evidence of a real bank payment. - `allocated_at` (string | null, required) - `receipt` (object | null, required) — Partner-supplied bank receipt reference, receipt time, and the exact received amount/provider reference. References are reconciliation evidence supplied by the partner, not independent confirmation by OpenStock. - `reference` (string, required) - `received_at` (string, required) - `amount` (object, required) - `amount` (integer, required) - `currency` (`USD`, required) - `provider_reference` (string, required) - `allocation` (object | null, required) — Partner-supplied transaction reference and time from its committed user-wallet credit. Send only after posting the credit exactly once in the receiving wallet. - `reference` (string, required) - `allocated_at` (string, required) - `evidence_status` (object, required) — none: no acknowledgment; attested: legacy boolean acknowledgment without a stored external reference; referenced: immutable partner-supplied reconciliation reference. unknown: an older returned transfer has no retained receipt acknowledgment history. None of these statuses independently verifies a bank receipt or wallet credit. - `receipt` (`none` | `attested` | `referenced` | `unknown`, required) - `allocation` (`none` | `attested` | `referenced`, required) - `created_at` (string, required) - `updated_at` (string, required) - `livemode` (boolean, required) - `next_cursor` (string | null, required) ### POST /v1/transfers/acknowledge **Acknowledge receipt and user allocation** · operationId `acknowledgeWalletTransfer` Requires transfers:write. received:true attests account receipt. allocated:true additionally attests user allocation. Replays never send another payment. A transfer that was re-sent after a return is acknowledged with the receipt of its current attempt. **Errors** | Status | Code | When | What to do | | --- | --- | --- | --- | | 400 | `VALIDATION_ERROR` | A required field is missing or invalid. | Correct the named field. | | 400 | `KEY_MODE_REQUIRED` | The key has no bound mode. | Use an os_live_ or os_test_ key for this account. | | 403 | `PARTNER_ACCOUNT_REQUIRED` | The key has no partner account. | Use a key assigned to your partner account. | | 503 | `SETTLEMENT_UNAVAILABLE` | The settlement service could not complete the operation. | Retry with the same idempotency key; read the transfer to reconcile uncertain outcomes. | | 404 | `TRANSFER_NOT_FOUND` | The transfer is missing from this account and mode. | Use the transfer ID returned for this partner and ledger. | | 409 | `INVALID_TRANSFER_TRANSITION` | The current transfer status cannot accept the requested transition. | Read the transfer; acknowledge only after it is sent and actually received. | | 409 | `RECEIPT_REQUIRED` | The transfer was re-sent after a return and the acknowledgment carries no receipt. | Match the re-sent money on your statement and include receipt with its provider_reference. | | 409 | `RECEIPT_MISMATCH` | The receipt does not match the transfer amount or provider reference. | Reconcile the actual bank receipt against this transfer before acknowledging. | | 409 | `RECONCILIATION_CONFLICT` | An acknowledgment supplies different evidence for an already referenced receipt or allocation. | Read the stored transfer and retry the exact original evidence. | | 409 | `INVALID_RECONCILIATION_EVIDENCE` | Evidence chronology or receipt/allocation requirements are invalid. | Use actual receipt and wallet-credit times; allocation requires a referenced receipt and allocated true. | #### Confirm receipt before allocating to a user Receipt changes sent to succeeded; allocated_at stays null until allocation is acknowledged separately. Complete request: ```bash curl -sS -X POST https://api.openstock.sh/v1/transfers/acknowledge \ -H "Authorization: Bearer $OPENSTOCK_API_KEY" \ -H "Content-Type: application/json" \ -d '{"transfer_id":"tr_example_001","received":true,"allocated":false}' ``` Complete response example: ```json { "transfer": { "id": "tr_example_001", "credit_key": "tr_example_001", "user_id": "u_9f86d081884c7d65", "amount": { "amount": 800, "currency": "USD" }, "status": "succeeded", "reissue": { "count": 0, "history": [] }, "provider_reference": "simulated_tr_example_001", "allocated_at": null, "receipt": null, "allocation": null, "evidence_status": { "receipt": "attested", "allocation": "none" }, "created_at": "2026-11-03T15:04:05.000Z", "updated_at": "2026-11-03T15:04:05.000Z", "livemode": false } } ``` #### Confirm user wallet allocation Use only after your own wallet ledger has allocated the received funds. Complete request: ```bash curl -sS -X POST https://api.openstock.sh/v1/transfers/acknowledge \ -H "Authorization: Bearer $OPENSTOCK_API_KEY" \ -H "Content-Type: application/json" \ -d '{"transfer_id":"tr_example_001","received":true,"allocated":true,"receipt":{"reference":"sandbox-bank-receipt-001","received_at":"2026-11-03T15:04:05.500Z","amount":{"amount":800,"currency":"USD"},"provider_reference":"simulated_tr_example_001"},"allocation":{"reference":"sandbox-wallet-credit-001","allocated_at":"2026-11-03T15:04:06.000Z"}}' ``` Complete response example: ```json { "transfer": { "id": "tr_example_001", "credit_key": "tr_example_001", "user_id": "u_9f86d081884c7d65", "amount": { "amount": 800, "currency": "USD" }, "status": "succeeded", "reissue": { "count": 0, "history": [] }, "provider_reference": "simulated_tr_example_001", "allocated_at": "2026-11-03T15:04:06.000Z", "receipt": { "reference": "sandbox-bank-receipt-001", "received_at": "2026-11-03T15:04:05.500Z", "amount": { "amount": 800, "currency": "USD" }, "provider_reference": "simulated_tr_example_001" }, "allocation": { "reference": "sandbox-wallet-credit-001", "allocated_at": "2026-11-03T15:04:06.000Z" }, "evidence_status": { "receipt": "referenced", "allocation": "referenced" }, "created_at": "2026-11-03T15:04:05.000Z", "updated_at": "2026-11-03T15:04:06.000Z", "livemode": false } } ``` Request body: - `transfer_id` (string, required) - `received` (`true`, required) - `allocated` (boolean, optional) [default false] - `receipt` (object, optional) — Partner-supplied bank receipt reference, receipt time, and the exact received amount/provider reference. References are reconciliation evidence supplied by the partner, not independent confirmation by OpenStock. - `reference` (string, required) - `received_at` (string, required) - `amount` (object, required) - `amount` (integer, required) - `currency` (`USD`, required) - `provider_reference` (string, required) - `allocation` (object, optional) — Partner-supplied transaction reference and time from its committed user-wallet credit. Send only after posting the credit exactly once in the receiving wallet. - `reference` (string, required) - `allocated_at` (string, required) Response `200` — Receipt/allocation recorded - `transfer` (object, required) - `id` (string, required) - `credit_key` (string, required) — Key your user-wallet credit by this value, the transfer id. It never changes: a transfer the bank returns after you allocated it is re-sent under the same id, so a retry cannot credit the user twice. - `user_id` (string | null, required) - `amount` (object, required) - `amount` (integer, required) [range 0–∞] - `currency` (`USD`, required) - `status` (`reserved` | `processing` | `sent` | `reconciling` | `succeeded` | `failed` | `returned`, required) — reserved and processing: held for dispatch. sent: the payout rail reports sending; receipt is not confirmed. reconciling: the dispatch outcome is uncertain; funds stay reserved. succeeded: you acknowledged receipt. failed or returned before allocation: available funds are restored. A return or cancellation after allocation goes back to processing and is re-sent, see reissue; only after three re-sends does it stop as returned, for OpenStock to settle by hand, with the credit still standing. - `reissue` (object, required) — Bank returns or cancellations after your allocation, each re-sent by OpenStock on this same transfer (reason returned_after_allocation or failed_after_allocation). The user keeps the reward and you carry no shortfall; acknowledge receipt of the re-sent money as usual. - `count` (integer, required) [range 0–∞] - `history` (array of object, required) - `returned_at` (string, required) - `provider_reference` (string | null, required) - `reason` (string, required) - `provider_reference` (string | null, required) — The payout rail’s reconciliation reference once dispatched. Sandbox references start with simulated_ and are simulation identifiers, never evidence of a real bank payment. - `allocated_at` (string | null, required) - `receipt` (object | null, required) — Partner-supplied bank receipt reference, receipt time, and the exact received amount/provider reference. References are reconciliation evidence supplied by the partner, not independent confirmation by OpenStock. - `reference` (string, required) - `received_at` (string, required) - `amount` (object, required) - `amount` (integer, required) - `currency` (`USD`, required) - `provider_reference` (string, required) - `allocation` (object | null, required) — Partner-supplied transaction reference and time from its committed user-wallet credit. Send only after posting the credit exactly once in the receiving wallet. - `reference` (string, required) - `allocated_at` (string, required) - `evidence_status` (object, required) — none: no acknowledgment; attested: legacy boolean acknowledgment without a stored external reference; referenced: immutable partner-supplied reconciliation reference. unknown: an older returned transfer has no retained receipt acknowledgment history. None of these statuses independently verifies a bank receipt or wallet credit. - `receipt` (`none` | `attested` | `referenced` | `unknown`, required) - `allocation` (`none` | `attested` | `referenced`, required) - `created_at` (string, required) - `updated_at` (string, required) - `livemode` (boolean, required) ### POST /v1/events/read **Replay cashback and transfer events** · operationId `readWalletEvents` Requires events:read. Deduplicate stable event IDs. Persist resume_cursor at the end and poll from it to recover missed webhooks. **Errors** | Status | Code | When | What to do | | --- | --- | --- | --- | | 400 | `VALIDATION_ERROR` | A required field is missing or invalid. | Correct the named field. | | 400 | `KEY_MODE_REQUIRED` | The key has no bound mode. | Use an os_live_ or os_test_ key for this account. | | 403 | `PARTNER_ACCOUNT_REQUIRED` | The key has no partner account. | Use a key assigned to your partner account. | | 503 | `SETTLEMENT_UNAVAILABLE` | The settlement service could not complete the operation. | Retry with the same idempotency key; read the transfer to reconcile uncertain outcomes. | | 400 | `INVALID_CURSOR` | The cursor is malformed or belongs to another account or operation. | Use the returned cursor unchanged. | #### Replay a transfer reservation event Deduplicate the stable event ID. Persist resume_cursor after applying the page and continue from it when polling. Complete request: ```bash curl -sS -X POST https://api.openstock.sh/v1/events/read \ -H "Authorization: Bearer $OPENSTOCK_API_KEY" \ -H "Content-Type: application/json" \ -d '{"limit":50}' ``` Complete response example: ```json { "items": [ { "id": "tr_example_001:0", "type": "transfer.reserved", "user_id": "u_9f86d081884c7d65", "reference_id": "tr_example_001", "amount": { "amount": 800, "currency": "USD" }, "revision": 0, "created_at": "2026-11-03T15:04:05.000Z", "livemode": false } ], "next_cursor": null, "resume_cursor": "WyJwYV9leGFtcGxlIiwxXQ==" } ``` Request body: - `limit` (integer, optional) [range 1–100; default 50] - `cursor` (string, optional) Response `200` — Ordered event page - `items` (array of object, required) - `id` (string, required) - `type` (string, required) - `user_id` (string | null, required) - `reference_id` (string, required) - `amount` (object, required) - `amount` (integer, required) [range 0–∞] - `currency` (`USD`, required) - `revision` (integer, required) - `created_at` (string, required) — ISO 8601 UTC in event replay responses and newly created webhook deliveries. Already persisted pre-v1.5 webhook retry bodies may retain Unix milliseconds; normalize only after verifying the raw body signature. - `reason` (string, optional) - `livemode` (boolean, required) - `next_cursor` (string | null, required) - `resume_cursor` (string | null, required) ### GET /v1/settlement/readiness **Inspect this key and account’s settlement readiness** · operationId `readSettlementReadiness` Requires wallets:read. Reports, for this key’s ledger, whether transfers can be requested (configuration_ready with any blockers and who resolves each), the receiving account and its verification deposit, the onboarding checklist, and what has been verified: for a live key, bank_receipt is verified once you confirmed the deposit, and user_wallet_credit once a transfer carries your allocation, read from the live ledger (cached ten minutes). A sandbox key is ready as soon as it has the transfer scopes; it also reports the same account’s live configuration in live_account. Never sends money. No bank details or credentials are returned. **Errors** | Status | Code | When | What to do | | --- | --- | --- | --- | | 503 | `SETTLEMENT_READINESS_UNAVAILABLE` | The configuration could not be read. | Retry shortly; readiness never moves money. | #### A sandbox key after rehearsing the receiving account The sandbox ledger is ready with no blockers. live_account shows the same account’s live state: one partner-owned step remains. Complete request: ```bash curl -sS https://api.openstock.sh/v1/settlement/readiness \ -H "Authorization: Bearer $OPENSTOCK_API_KEY" ``` Complete response example: ```json { "mode": "sandbox", "livemode": false, "configuration_ready": true, "blockers": [], "next_steps": [], "permissions": { "source": "explicit", "scopes": [ "cashback:read", "cashback:write", "wallets:read", "transfers:read", "transfers:write", "events:read" ], "cashback_only": true, "requests_per_minute": 300 }, "settlement": { "payout_method": "usd_bank_transfer", "destination_type": "partner_receiving_account", "enabled": true, "daily_enabled": true, "destination_verified": true, "destination": { "id": "dst_test_bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", "type": "usd_bank_account", "account_holder_name": "Example Wallet, Inc.", "account_last4": "6789", "status": "verified", "verification": { "amount": { "amount": 100, "currency": "USD" }, "status": "confirmed", "provider_reference": "simulated_dst_test_bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", "sent_at": "2026-11-04T15:04:05.000Z", "confirmed_at": "2026-11-04T15:06:00.000Z" }, "sandbox_statement": { "reference": "OSV3F9A1C2", "amount": { "amount": 100, "currency": "USD" }, "received_at": "2026-11-04T15:04:05.000Z" }, "submitted_at": "2026-11-04T15:04:05.000Z", "verified_at": "2026-11-04T15:06:00.000Z", "livemode": false } }, "wallet_credit": { "performed_by": "partner", "requires_bank_receipt": true, "credit_key": "transfer.id", "acknowledgment_endpoint": "/v1/transfers/acknowledge", "returns_after_allocation": "reissued_by_openstock" }, "verification": { "bank_receipt": "simulated", "user_wallet_credit": "simulated" }, "onboarding": { "complete": false, "steps": [ { "id": "credentials", "owner": "openstock", "status": "done", "how": "A sandbox key on your partner account with the transfer scopes; the live key is issued alongside it." }, { "id": "receiving_account", "owner": "partner", "status": "done", "how": "POST /v1/settlement/destination with the USD bank account that receives settlement." }, { "id": "verification_deposit", "owner": "openstock", "status": "done", "how": "OpenStock sends a $1.00 deposit to the new account with a reference starting OSV. While it reads pending, replay POST /v1/settlement/destination with the same idempotency_key until it reads sent." }, { "id": "confirm_deposit", "owner": "partner", "status": "done", "how": "POST /v1/settlement/destination/verify with the reference and amount from your statement. This is the live proof of bank delivery." }, { "id": "first_allocation", "owner": "partner", "status": "pending", "how": "Acknowledge the first transfer with allocated:true after crediting the user once, keyed by the transfer id." } ] }, "live_account": { "configuration_ready": false, "blockers": [ "destination_unverified" ], "next_steps": [ { "blocker": "destination_unverified", "owner": "partner", "action": "Submit your receiving account with POST /v1/settlement/destination, then confirm the $1.00 verification deposit with POST /v1/settlement/destination/verify." } ], "destination_verified": false } } ``` Response `200` — This ledger’s readiness, the onboarding checklist and what has been verified - `mode` (`live` | `sandbox` | `null`, required) - `livemode` (boolean, required) - `configuration_ready` (boolean, required) — This ledger can accept transfer requests: the key has the transfer scopes, settlement is enabled and the receiving account is verified. The sandbox pays a simulated receiving account until one is submitted, so a sandbox key is ready as soon as it has the scopes. configuration_ready is not itself proof of a bank receipt or a user-wallet credit; verification below says what has been checked. - `blockers` (array of `partner_account_required` | `transfers_read_scope_required` | `transfers_write_scope_required` | `destination_unverified` | `settlement_disabled`, required) — What still stops transfers on this ledger. Empty when configuration_ready is true. next_steps says who resolves each one. - `next_steps` (array of object, required) - `blocker` (`partner_account_required` | `transfers_read_scope_required` | `transfers_write_scope_required` | `destination_unverified` | `settlement_disabled`, required) - `owner` (`partner` | `openstock`, required) — Who completes this step. - `action` (string, required) — What resolves the blocker, in one sentence. - `permissions` (object, required) - `source` (`explicit` | `legacy`, required) - `scopes` (array of string, required) - `cashback_only` (boolean, required) - `requests_per_minute` (integer, required) - `settlement` (object, required) - `payout_method` (`usd_bank_transfer`, required) — OpenStock-funded USD bank transfers to your receiving account. The sandbox ledger moves no money and simulates the same states. - `destination_type` (`partner_receiving_account`, required) - `enabled` (boolean, required) - `daily_enabled` (boolean, required) - `destination_verified` (boolean, required) - `destination` (object | null, required) — The receiving account this ledger pays, submitted through POST /v1/settlement/destination. Null when none has been submitted. The sandbox pays a simulated account and reports destination_verified true whether or not one was rehearsed. - `id` (string, required) - `type` (`usd_bank_account`, required) - `account_holder_name` (string, required) - `account_last4` (string, required) - `status` (`pending_verification` | `verified` | `replaced`, required) — pending_verification until you confirm the verification deposit; verified enables settlement to this account; replaced when a later destination was verified. - `verification` (object, required) - `amount` (object, required) - `amount` (integer, required) [range 0–∞] - `currency` (`USD`, required) - `status` (`pending` | `sent` | `failed` | `confirmed`, required) — The $1.00 deposit OpenStock sends to the new account. pending: not sent yet, and a replay of the submission with the same idempotency_key sends it; sent: OpenStock’s payout rail reports sending it, and its ten-character bank reference starting OSV is on its way to your statement; confirmed: you confirmed the reference and amount, which verifies the destination. The live API never returns the reference itself. - `provider_reference` (string | null, required) — The payout rail’s reference for the deposit once it is dispatched. Sandbox references start with simulated_. - `sent_at` (string | null, required) - `confirmed_at` (string | null, required) - `sandbox_statement` (object | null, required) — Sandbox only: the simulated bank statement line for the verification deposit, so the confirmation step can be rehearsed. Null for a live destination, whose reference appears only on the real statement. - `reference` (string, required) - `amount` (object, required) - `amount` (integer, required) [range 0–∞] - `currency` (`USD`, required) - `received_at` (string, required) - `submitted_at` (string, required) - `verified_at` (string | null, required) - `livemode` (boolean, required) - `wallet_credit` (object, required) - `performed_by` (`partner`, required) - `requires_bank_receipt` (`true`, required) - `credit_key` (`transfer.id`, required) — Key each user-wallet credit by the OpenStock transfer id. A transfer is re-sent under the same id after a bank return, so the key never changes and a retry cannot credit twice. - `acknowledgment_endpoint` (`/v1/transfers/acknowledge`, required) - `returns_after_allocation` (`reissued_by_openstock`, required) — A transfer returned by the bank after you allocated it to the user is re-sent by OpenStock on the same transfer. The user keeps the reward; you never unwind a credit and carry no shortfall. - `verification` (object, required) - `bank_receipt` (`verified` | `pending_confirmation` | `awaiting_destination` | `simulated`, required) — verified: you confirmed a live verification deposit from your bank statement, so OpenStock has delivered real USD to this account. - `user_wallet_credit` (`verified` | `awaiting_first_allocation` | `awaiting_destination` | `simulated`, required) — verified: at least one live transfer carries your allocation acknowledgment. - `onboarding` (object, required) - `complete` (boolean, required) - `steps` (array of object, required) - `id` (`credentials` | `receiving_account` | `verification_deposit` | `confirm_deposit` | `first_allocation`, required) - `owner` (`partner` | `openstock`, required) — Who completes this step. - `status` (`done` | `pending` | `blocked`, required) - `how` (string, required) - `live_account` (object | null, required) — For a sandbox key: the same account’s live settlement configuration, so the live go-live state can be inspected while rehearsing. Null for a live key. - `configuration_ready` (boolean, required) - `blockers` (array of `partner_account_required` | `transfers_read_scope_required` | `transfers_write_scope_required` | `destination_unverified` | `settlement_disabled`, required) - `next_steps` (array of object, required) - `blocker` (`partner_account_required` | `transfers_read_scope_required` | `transfers_write_scope_required` | `destination_unverified` | `settlement_disabled`, required) - `owner` (`partner` | `openstock`, required) — Who completes this step. - `action` (string, required) — What resolves the blocker, in one sentence. - `destination_verified` (boolean, required) ### POST /v1/settlement/destination **Connect the receiving account OpenStock pays** · operationId `submitSettlementDestination` Requires transfers:write. Registers the USD bank account that receives this ledger’s transfers and sends it a $1.00 verification deposit funded by OpenStock, with a reference that only the statement shows. The account details are registered on OpenStock’s payout rail as the recipient; OpenStock keeps the recipient id, the last four digits and keyed digests of the request. The deposit reads pending until it is sent. Confirm its reference and amount from your bank statement with POST /v1/settlement/destination/verify; that verifies the account, switches settlement on and completes the live proof of bank delivery. The sandbox simulates the bank, marks the deposit sent at once and prints its statement line in sandbox_statement so the whole step can be rehearsed. Replaying the same idempotency_key returns the same destination and re-reads the deposit’s status; a new key for the same bank account continues that account’s verification rather than sending another deposit; at most three new accounts can start verification in 30 days. **Errors** | Status | Code | When | What to do | | --- | --- | --- | --- | | 400 | `VALIDATION_ERROR` | A required field is missing or invalid. | Correct the named field. | | 400 | `KEY_MODE_REQUIRED` | The key has no bound mode. | Use an os_live_ or os_test_ key for this account. | | 403 | `PARTNER_ACCOUNT_REQUIRED` | The key has no partner account. | Use a key assigned to your partner account. | | 409 | `IDEMPOTENCY_CONFLICT` | The key was already used with different account details. | Use a new idempotency key for a different receiving account. | | 409 | `DEPOSIT_LIMIT_REACHED` | Three different accounts already started verification in the last 30 days. | Confirm the pending account from its statement line, or ask OpenStock to lift the limit. | | 503 | `SETTLEMENT_UNAVAILABLE` | The destination could not be recorded. | Retry with the same idempotency key; a replay never creates a second deposit. | #### Connect the receiving account and start its verification deposit The sandbox simulates the bank: the $1.00 deposit is sent at once and sandbox_statement shows the statement line to confirm. A live destination carries no sandbox_statement; its reference appears only on the real bank statement, and its deposit reads pending until it is sent. Complete request: ```bash curl -sS -X POST https://api.openstock.sh/v1/settlement/destination \ -H "Authorization: Bearer $OPENSTOCK_API_KEY" \ -H "Content-Type: application/json" \ -d '{"type":"usd_bank_account","account_holder_name":"Example Wallet, Inc.","legal_type":"business","bank":{"routing_number":"021000021","account_number":"000123456789","account_type":"checking"},"address":{"country":"US","first_line":"1 Main St","city":"Palo Alto","state":"CA","post_code":"94301"},"idempotency_key":"receiving-account:1"}' ``` Complete response example: ```json { "destination": { "id": "dst_test_bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", "type": "usd_bank_account", "account_holder_name": "Example Wallet, Inc.", "account_last4": "6789", "status": "pending_verification", "verification": { "amount": { "amount": 100, "currency": "USD" }, "status": "sent", "provider_reference": "simulated_dst_test_bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", "sent_at": "2026-11-04T15:04:05.000Z", "confirmed_at": null }, "sandbox_statement": { "reference": "OSV3F9A1C2", "amount": { "amount": 100, "currency": "USD" }, "received_at": "2026-11-04T15:04:05.000Z" }, "submitted_at": "2026-11-04T15:04:05.000Z", "verified_at": null, "livemode": false } } ``` Request body: - `type` (`usd_bank_account`, optional) [default "usd_bank_account"] - `account_holder_name` (string, required) — The legal name on the receiving account, as the bank holds it. - `legal_type` (`business` | `private`, optional) [default "business"] - `bank` (object, required) — Registered on OpenStock’s payout rail as the recipient. OpenStock stores only the recipient id and the last four digits. - `routing_number` (string, required) — Nine-digit ABA routing number. - `account_number` (string, required) — US account number, digits only. - `account_type` (`checking` | `savings`, optional) [default "checking"] - `address` (object, required) — The account holder’s address. - `country` (`US`, optional) [default "US"] - `first_line` (string, required) - `city` (string, required) - `state` (string, required) — Two-letter state code. - `post_code` (string, required) - `idempotency_key` (string, required) — Replaying the same key returns the same destination. A new key with different account details replaces the current destination once the new one is verified. Response `201` — The receiving account and its verification deposit - `destination` (object | null, required) — The receiving account this ledger pays, submitted through POST /v1/settlement/destination. Null when none has been submitted. The sandbox pays a simulated account and reports destination_verified true whether or not one was rehearsed. - `id` (string, required) - `type` (`usd_bank_account`, required) - `account_holder_name` (string, required) - `account_last4` (string, required) - `status` (`pending_verification` | `verified` | `replaced`, required) — pending_verification until you confirm the verification deposit; verified enables settlement to this account; replaced when a later destination was verified. - `verification` (object, required) - `amount` (object, required) - `amount` (integer, required) [range 0–∞] - `currency` (`USD`, required) - `status` (`pending` | `sent` | `failed` | `confirmed`, required) — The $1.00 deposit OpenStock sends to the new account. pending: not sent yet, and a replay of the submission with the same idempotency_key sends it; sent: OpenStock’s payout rail reports sending it, and its ten-character bank reference starting OSV is on its way to your statement; confirmed: you confirmed the reference and amount, which verifies the destination. The live API never returns the reference itself. - `provider_reference` (string | null, required) — The payout rail’s reference for the deposit once it is dispatched. Sandbox references start with simulated_. - `sent_at` (string | null, required) - `confirmed_at` (string | null, required) - `sandbox_statement` (object | null, required) — Sandbox only: the simulated bank statement line for the verification deposit, so the confirmation step can be rehearsed. Null for a live destination, whose reference appears only on the real statement. - `reference` (string, required) - `amount` (object, required) - `amount` (integer, required) [range 0–∞] - `currency` (`USD`, required) - `received_at` (string, required) - `submitted_at` (string, required) - `verified_at` (string | null, required) - `livemode` (boolean, required) ### POST /v1/settlement/destination/verify **Confirm the verification deposit from your bank statement** · operationId `verifySettlementDestination` Requires transfers:write. Send the reference and exact amount of the verification deposit as your bank statement shows them. A match verifies the receiving account, enables daily and on-demand settlement to it, and records that OpenStock delivered real USD to your account. Replays return the verified destination. The sandbox accepts the reference printed in sandbox_statement. **Errors** | Status | Code | When | What to do | | --- | --- | --- | --- | | 400 | `VALIDATION_ERROR` | A required field is missing or invalid. | Correct the named field. | | 400 | `KEY_MODE_REQUIRED` | The key has no bound mode. | Use an os_live_ or os_test_ key for this account. | | 403 | `PARTNER_ACCOUNT_REQUIRED` | The key has no partner account. | Use a key assigned to your partner account. | | 404 | `DESTINATION_NOT_FOUND` | The id belongs to another account or ledger, or does not exist. | Use the id the submission returned for this key. | | 409 | `DESTINATION_REPLACED` | A newer destination was verified after this one. | Read /v1/settlement/readiness for the current destination. | | 409 | `VERIFICATION_NOT_SENT` | The deposit has not been sent yet. | Replay the submission with the same idempotency_key and body until the deposit reads sent, then confirm it from your statement. | | 409 | `VERIFICATION_FAILED` | The deposit was returned or cancelled by the bank. | Check the account details and submit again with a new idempotency_key. | | 409 | `VERIFICATION_MISMATCH` | The reference or the amount differs from the deposit. | Copy the full OSV reference and the exact cents from the statement line. | | 503 | `SETTLEMENT_UNAVAILABLE` | The destination could not be recorded. | Retry with the same idempotency key; a replay never creates a second deposit. | #### Confirm the deposit from the statement and verify the account The reference and amount match the deposit, so the account is verified and settlement to it is switched on. Replays return the verified account. Complete request: ```bash curl -sS -X POST https://api.openstock.sh/v1/settlement/destination/verify \ -H "Authorization: Bearer $OPENSTOCK_API_KEY" \ -H "Content-Type: application/json" \ -d '{"destination_id":"dst_test_bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb","reference":"OSV3F9A1C2","amount":{"amount":100,"currency":"USD"}}' ``` Complete response example: ```json { "destination": { "id": "dst_test_bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", "type": "usd_bank_account", "account_holder_name": "Example Wallet, Inc.", "account_last4": "6789", "status": "verified", "verification": { "amount": { "amount": 100, "currency": "USD" }, "status": "confirmed", "provider_reference": "simulated_dst_test_bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", "sent_at": "2026-11-04T15:04:05.000Z", "confirmed_at": "2026-11-04T15:06:00.000Z" }, "sandbox_statement": { "reference": "OSV3F9A1C2", "amount": { "amount": 100, "currency": "USD" }, "received_at": "2026-11-04T15:04:05.000Z" }, "submitted_at": "2026-11-04T15:04:05.000Z", "verified_at": "2026-11-04T15:06:00.000Z", "livemode": false } } ``` Request body: - `destination_id` (string, required) - `reference` (string, required) — The reference on the verification deposit as your bank statement shows it. Live deposits carry a reference starting with OSV that the API never returns; the sandbox prints its simulated statement line in the destination response. - `amount` (object, required) — The exact amount received, in USD cents. - `amount` (integer, required) - `currency` (`USD`, required) Response `200` — The verified receiving account - The same `SettlementDestinationResponse` object as `POST /v1/settlement/destination` returns. ### POST /v1/cashback/sandbox/transfers/advance **Simulate a transfer outcome** · operationId `advanceSandboxTransfer` Sandbox-only, requires cashback:write. Simulates dispatch, uncertainty or failure without contacting a bank. Use the normal acknowledge endpoint after sent. **Errors** | Status | Code | When | What to do | | --- | --- | --- | --- | | 400 | `VALIDATION_ERROR` | A required field is missing or invalid. | Correct the named field. | | 400 | `KEY_MODE_REQUIRED` | The key has no bound mode. | Use an os_live_ or os_test_ key for this account. | | 403 | `PARTNER_ACCOUNT_REQUIRED` | The key has no partner account. | Use a key assigned to your partner account. | | 503 | `SETTLEMENT_UNAVAILABLE` | The settlement service could not complete the operation. | Retry with the same idempotency key; read the transfer to reconcile uncertain outcomes. | | 404 | `TRANSFER_NOT_FOUND` | The transfer is missing from this account and mode. | Use the transfer ID returned for this partner and ledger. | | 409 | `INVALID_TRANSFER_TRANSITION` | The current transfer status cannot accept the requested transition. | Read the transfer; acknowledge only after it is sent and actually received. | | 403 | `SANDBOX_ONLY` | A live key called the simulation route. | Use a dedicated sandbox key. | #### Simulate the bank sending a transfer Uses a sandbox key and contacts no bank. The normal acknowledgment endpoint then simulates partner receipt and allocation. Complete request: ```bash curl -sS -X POST https://api.openstock.sh/v1/cashback/sandbox/transfers/advance \ -H "Authorization: Bearer $OPENSTOCK_API_KEY" \ -H "Content-Type: application/json" \ -d '{"transfer_id":"tr_example_001","status":"sent"}' ``` Complete response example: ```json { "transfer": { "id": "tr_example_001", "credit_key": "tr_example_001", "user_id": "u_9f86d081884c7d65", "amount": { "amount": 800, "currency": "USD" }, "status": "sent", "reissue": { "count": 0, "history": [] }, "provider_reference": "simulated_tr_example_001", "allocated_at": null, "receipt": null, "allocation": null, "evidence_status": { "receipt": "none", "allocation": "none" }, "created_at": "2026-11-03T15:04:05.000Z", "updated_at": "2026-11-03T15:04:05.000Z", "livemode": false } } ``` #### A bank return after allocation is re-sent on the same transfer The partner had acknowledged receipt and allocated the money to its user. The simulated return does not end the transfer: it goes back to processing with a new attempt, the user keeps the reward, allocated_at stays, and the partner acknowledges receipt of the re-sent money under the same credit key. Complete request: ```bash curl -sS -X POST https://api.openstock.sh/v1/cashback/sandbox/transfers/advance \ -H "Authorization: Bearer $OPENSTOCK_API_KEY" \ -H "Content-Type: application/json" \ -d '{"transfer_id":"tr_example_001","status":"returned"}' ``` Complete response example: ```json { "transfer": { "id": "tr_example_001", "credit_key": "tr_example_001", "user_id": "u_9f86d081884c7d65", "amount": { "amount": 800, "currency": "USD" }, "status": "processing", "reissue": { "count": 1, "history": [ { "returned_at": "2026-11-05T09:00:00.000Z", "provider_reference": "simulated_tr_example_001", "reason": "returned_after_allocation" } ] }, "provider_reference": null, "allocated_at": "2026-11-03T15:04:06.000Z", "receipt": null, "allocation": { "reference": "sandbox-wallet-credit-001", "allocated_at": "2026-11-03T15:04:06.000Z" }, "evidence_status": { "receipt": "none", "allocation": "referenced" }, "created_at": "2026-11-03T15:04:05.000Z", "updated_at": "2026-11-05T09:00:00.000Z", "livemode": false } } ``` Request body: - `transfer_id` (string, required) - `status` (`processing` | `sent` | `reconciling` | `failed` | `returned`, required) Response `200` — Simulated transfer state - `transfer` (object, required) - `id` (string, required) - `credit_key` (string, required) — Key your user-wallet credit by this value, the transfer id. It never changes: a transfer the bank returns after you allocated it is re-sent under the same id, so a retry cannot credit the user twice. - `user_id` (string | null, required) - `amount` (object, required) - `amount` (integer, required) [range 0–∞] - `currency` (`USD`, required) - `status` (`reserved` | `processing` | `sent` | `reconciling` | `succeeded` | `failed` | `returned`, required) — reserved and processing: held for dispatch. sent: the payout rail reports sending; receipt is not confirmed. reconciling: the dispatch outcome is uncertain; funds stay reserved. succeeded: you acknowledged receipt. failed or returned before allocation: available funds are restored. A return or cancellation after allocation goes back to processing and is re-sent, see reissue; only after three re-sends does it stop as returned, for OpenStock to settle by hand, with the credit still standing. - `reissue` (object, required) — Bank returns or cancellations after your allocation, each re-sent by OpenStock on this same transfer (reason returned_after_allocation or failed_after_allocation). The user keeps the reward and you carry no shortfall; acknowledge receipt of the re-sent money as usual. - `count` (integer, required) [range 0–∞] - `history` (array of object, required) - `returned_at` (string, required) - `provider_reference` (string | null, required) - `reason` (string, required) - `provider_reference` (string | null, required) — The payout rail’s reconciliation reference once dispatched. Sandbox references start with simulated_ and are simulation identifiers, never evidence of a real bank payment. - `allocated_at` (string | null, required) - `receipt` (object | null, required) — Partner-supplied bank receipt reference, receipt time, and the exact received amount/provider reference. References are reconciliation evidence supplied by the partner, not independent confirmation by OpenStock. - `reference` (string, required) - `received_at` (string, required) - `amount` (object, required) - `amount` (integer, required) - `currency` (`USD`, required) - `provider_reference` (string, required) - `allocation` (object | null, required) — Partner-supplied transaction reference and time from its committed user-wallet credit. Send only after posting the credit exactly once in the receiving wallet. - `reference` (string, required) - `allocated_at` (string, required) - `evidence_status` (object, required) — none: no acknowledgment; attested: legacy boolean acknowledgment without a stored external reference; referenced: immutable partner-supplied reconciliation reference. unknown: an older returned transfer has no retained receipt acknowledgment history. None of these statuses independently verifies a bank receipt or wallet credit. - `receipt` (`none` | `attested` | `referenced` | `unknown`, required) - `allocation` (`none` | `attested` | `referenced`, required) - `created_at` (string, required) - `updated_at` (string, required) - `livemode` (boolean, required) ### POST /v1/merchants/search **Batch merchant search** · operationId `searchMerchants` Search for merchants by name (fuzzy) or domain (exact match). Up to 50 queries per request. Each query carries its own `query_id` that is echoed back so callers can correlate responses. Each result contains an `items` array with matched merchants. Name queries return up to `limit` items per result (default 5, max 20). Misses return a single item with `id: null` — there are no 404s. #### Resolve Brooklinen and inspect delivery Brooklinen resolved by domain, with measured delivery times and popularity rank. Run the request for current values. Complete request: ```bash curl -sS -X POST https://api.openstock.sh/v1/merchants/search \ -H "Authorization: Bearer $OPENSTOCK_API_KEY" \ -H "Content-Type: application/json" \ -d '{"queries":[{"query_id":"brooklinen","type":"domain","value":"brooklinen.com","limit":1}]}' ``` Complete response example: ```json { "results": [ { "query_id": "brooklinen", "items": [ { "id": "01g4s5d0h956te86ff90h6xts4", "name": "Brooklinen", "domains": [ "brooklinen.com" ], "popularity_rank": null, "estimated_shipping": { "unit": "days", "median": 6, "q1": 3, "q3": 10, "basis": "measured_delivery", "sample_size": null } } ] } ] } ``` #### Understand a network delivery estimate A merchant with no order data of its own gets the network default, labelled network_default so you can phrase it as "typically". Complete request: ```bash curl -sS -X POST https://api.openstock.sh/v1/merchants/search \ -H "Authorization: Bearer $OPENSTOCK_API_KEY" \ -H "Content-Type: application/json" \ -d '{"queries":[{"query_id":"network-estimate","type":"domain","value":"example.invalid","limit":1}]}' ``` Complete response example: ```json { "results": [ { "query_id": "network-estimate", "items": [ { "id": "example-merchant", "name": "Example Goods", "domains": [ "example.invalid" ], "popularity_rank": null, "estimated_shipping": { "unit": "days", "median": 4, "q1": 3, "q3": 5, "basis": "network_default", "sample_size": null } } ] } ] } ``` #### Handle an unknown merchant Complete miss response: search returns one null-ID item, not an empty items array or a 404. Complete request: ```bash curl -sS -X POST https://api.openstock.sh/v1/merchants/search \ -H "Authorization: Bearer $OPENSTOCK_API_KEY" \ -H "Content-Type: application/json" \ -d '{"queries":[{"query_id":"unknown","type":"domain","value":"unknown-merchant.invalid","limit":1}]}' ``` Complete response example: ```json { "results": [ { "query_id": "unknown", "items": [ { "id": null, "name": null, "domains": [], "popularity_rank": null, "estimated_shipping": null } ] } ] } ``` Request body: - `queries` (array of object, required) [1–50 items] — Batch of search queries (1–50). Each query returns a result with an `items` array. Name queries with `limit > 1` may yield multiple items. Misses return an `items` array with a single entry where `id` is null. - `query_id` (string, required) — Caller-supplied opaque identifier correlated back in results - `type` (`name` | `domain`, required) — "name" triggers fuzzy search; "domain" is an exact-match lookup - `value` (string, required) — Search term: a merchant name fragment, or for `domain` a domain or any URL on it — scheme, `www.`, path and query are ignored - `region` (string, optional) — Optional ISO 3166-1 alpha-2 region filter (name queries only) - `limit` (integer, optional) [range 1–20; default 5] — Maximum number of results to return for this query (name queries only, domain queries always return at most one result). Defaults to 5. Response `200` — Per-query results. Each result has an `items` array. A name query with limit > 1 may produce multiple items. Misses have id: null - `results` (array of object, required) - `query_id` (string, required) - `items` (array of object, required) [1–∞ items] — Matched merchants for this query, best first. Name queries are ordered by exact prefix match, then by `popularity_rank`, so `items[0]` is the merchant to use unless the shopper said otherwise. Always contains at least one entry; misses return a single entry with `id: null`. - `id` (string | null, required) — OpenStock merchant ID, or null when not found - `name` (string | null, required) — Merchant display name, or null when no match - `domains` (array of string, required) — Merchant domains - `popularity_rank` (integer | null, required) — Rank by shopper traffic across OpenStock’s stores, 1 = most visited. When several merchants share a name (there are three "Adidas"), the one with the lowest rank is almost always the one the shopper means. Null for unranked merchants. - `estimated_shipping` (object | null, required) — Shipping time statistics. Present for every matched merchant that ships physical goods — check `basis` to see whether it is this merchant’s own data or the network default. Null for merchants where delivery does not apply (travel, food delivery, restaurants, telecom, finance, software, streaming, tickets) and on a miss (`id: null`). - `unit` (`days`, required) — Unit for all shipping time values in this object - `median` (number, required) — Median days from order to delivery - `q1` (number | null, required) — First quartile (25th percentile) days to deliver, or null when unknown - `q3` (number | null, required) — Third quartile (75th percentile) days to deliver, or null when unknown - `basis` (`measured_delivery` | `processing_plus_transit_estimate` | `network_default`, required) — Where the numbers come from. `measured_delivery`: observed order-to-delivery times for this merchant. `processing_plus_transit_estimate`: the merchant’s observed order-to-dispatch time plus an assumed 2 days in transit. `network_default`: we have no order data for this merchant yet, so this is what most US stores in the network deliver in (3–5 days); phrase it as "typically", not as this merchant’s figure. - `sample_size` (integer | null, required) — Orders the figures were computed from, or null when the source does not report it. Treat small samples with caution. Response `400` — Invalid request body or query cap exceeded (max 50 queries) - Invalid request body: `VALIDATION_ERROR`, queries: Too small: expected array to have >=1 items - Malformed JSON: `MALFORMED_JSON`, Request body must be valid JSON Response `401` — Missing or invalid API key - Missing bearer key: `MISSING_AUTH`, Authorization header is required. Use: Authorization: Bearer <api_key> - Invalid or revoked key: `INVALID_API_KEY`, The provided API key is not valid. ### POST /v1/merchants/codes **Batch merchant offer codes** · operationId `getMerchantCodes` Request merchant-backed and observed offers for up to 20 merchants. Each result includes ranked codes, cashback when available, and an activation link. Read each item’s source, single_use, conditions and description; partnered alone does not establish code availability. A null code is a codeless offer, not a successfully issued coupon. Use min_probability and limit to filter codes; suppressed_code_count reports removed items. Empty items with a non-null activation_url means the store resolved but has no qualifying code. A null activation_url is a miss-shaped result, also returned for an unavailable per-merchant lookup. idempotency_key is required: use an opaque value unique to the partner, shopper/session and merchant, and reuse it when retrying issuance. It deduplicates code issuance; it does not freeze the entire response or extend code validity. wallet_id optionally binds offer and purchase attribution to a user ID within the authenticated partner account. Wallet failures return a per-query error; retry with the same idempotency_key. shopper_name is optional: a first name to carry on the face of a freshly minted code (as in <prefix>-RORY-4O8HHBUN-CN); a replay returns the code already minted. #### Generated offer — Brooklinen A code generated at Brooklinen for this request. The example code is a placeholder; run the request with your own idempotency key for a live one, and keep that key for retries. Complete request: ```bash curl -sS -X POST https://api.openstock.sh/v1/merchants/codes \ -H "Authorization: Bearer $OPENSTOCK_API_KEY" \ -H "Content-Type: application/json" \ -d '{"queries":[{"query_id":"brooklinen","merchant_id":"01g4s5d0h956te86ff90h6xts4","idempotency_key":"replace-with-your-unique-shopping-session-key","limit":1}]}' ``` Complete response example: ```json { "results": [ { "query_id": "brooklinen", "cashback": { "value_type": "percent", "value_amount": 3 }, "partnered": true, "activation_url": "https://api.openstock.sh/mr/01g4s5d0h956te86ff90h6xts4?ref=openstock", "suppressed_code_count": 0, "items": [ { "code": "EXAMPLE-PLACEHOLDER", "source": "generated", "probability": 1, "single_use": true, "value_type": "percent", "value_amount": 15, "currency": null, "conditions": [], "minimum_subtotal": null, "minimum_subtotal_currency": null, "combines_with": { "order_discounts": false, "product_discounts": false, "shipping_discounts": false }, "restricted_to_collections": false, "customer_restricted": false, "redirect_url": "https://api.openstock.sh/mr/01g4s5d0h956te86ff90h6xts4?code=EXAMPLE-PLACEHOLDER&ref=openstock", "expires_at": null, "last_success": null, "description": "15% off eligible items; merchant exclusions may apply.", "apply_count": null, "success_count": null } ] } ] } ``` #### Generated offer with the shopper’s name The Brooklinen issuance with shopper_name set: the minted code carries the shopper’s first name so it reads as theirs. The example code is a placeholder; a replay under the same idempotency key returns the code already minted, name or not. Complete request: ```bash curl -sS -X POST https://api.openstock.sh/v1/merchants/codes \ -H "Authorization: Bearer $OPENSTOCK_API_KEY" \ -H "Content-Type: application/json" \ -d '{"queries":[{"query_id":"brooklinen","merchant_id":"01g4s5d0h956te86ff90h6xts4","idempotency_key":"replace-with-your-unique-shopping-session-key","shopper_name":"Rory","limit":1}]}' ``` Complete response example: ```json { "results": [ { "query_id": "brooklinen", "cashback": { "value_type": "percent", "value_amount": 3 }, "partnered": true, "activation_url": "https://api.openstock.sh/mr/01g4s5d0h956te86ff90h6xts4?ref=openstock", "suppressed_code_count": 0, "items": [ { "code": "EXAMPLE-RORY-EXAMPLE0-CN", "source": "generated", "probability": 1, "single_use": true, "value_type": "percent", "value_amount": 15, "currency": null, "conditions": [], "minimum_subtotal": null, "minimum_subtotal_currency": null, "combines_with": { "order_discounts": false, "product_discounts": false, "shipping_discounts": false }, "restricted_to_collections": false, "customer_restricted": false, "redirect_url": "https://api.openstock.sh/mr/01g4s5d0h956te86ff90h6xts4?code=EXAMPLE-RORY-EXAMPLE0-CN&ref=openstock", "expires_at": null, "last_success": null, "description": "15% off eligible items; merchant exclusions may apply.", "apply_count": null, "success_count": null } ] } ] } ``` #### Observed public code A public code at Nike with its measured probability, last success and lifetime counters. Run the request for current codes. Complete request: ```bash curl -sS -X POST https://api.openstock.sh/v1/merchants/codes \ -H "Authorization: Bearer $OPENSTOCK_API_KEY" \ -H "Content-Type: application/json" \ -d '{"queries":[{"query_id":"nike","merchant_id":"01g4s4gvb1kdc8kz69cm5q2b4f","idempotency_key":"replace-with-your-unique-shopping-session-key","limit":3}]}' ``` Complete response example: ```json { "results": [ { "query_id": "nike", "cashback": null, "partnered": false, "activation_url": "https://api.openstock.sh/mr/01g4s4gvb1kdc8kz69cm5q2b4f?ref=openstock", "suppressed_code_count": 0, "items": [ { "code": "EXAMPLE-PUBLIC-CODE", "source": "observed", "probability": 0.42, "single_use": false, "value_type": "percent", "value_amount": 20, "currency": null, "conditions": [ "product_restricted" ], "minimum_subtotal": null, "minimum_subtotal_currency": null, "combines_with": null, "restricted_to_collections": null, "customer_restricted": null, "redirect_url": null, "expires_at": null, "last_success": "2026-09-10T21:14:03.000Z", "description": "20% off selected products", "apply_count": 1834, "success_count": 611 } ] } ] } ``` #### Cashback with no qualifying code min_probability filtered every code out, and the shopper still earns cashback through activation_url. Complete request: ```bash curl -sS -X POST https://api.openstock.sh/v1/merchants/codes \ -H "Authorization: Bearer $OPENSTOCK_API_KEY" \ -H "Content-Type: application/json" \ -d '{"queries":[{"query_id":"nike","merchant_id":"01g4s4gvb1kdc8kz69cm5q2b4f","idempotency_key":"replace-with-your-unique-shopping-session-key","min_probability":0.5,"limit":3}]}' ``` Complete response example: ```json { "results": [ { "query_id": "nike", "cashback": { "value_type": "percent", "value_amount": 3 }, "partnered": false, "activation_url": "https://api.openstock.sh/mr/01g4s4gvb1kdc8kz69cm5q2b4f?ref=openstock", "suppressed_code_count": 1, "items": [] } ] } ``` #### A wallet-bound code with a sandbox key A code bound to a user earns live cashback, so a sandbox (os_test_) key gets a per-query error and no code. Request it with your os_live_ key. Complete request: ```bash curl -sS -X POST https://api.openstock.sh/v1/merchants/codes \ -H "Authorization: Bearer $OPENSTOCK_API_KEY" \ -H "Content-Type: application/json" \ -d '{"queries":[{"query_id":"brooklinen","merchant_id":"01g4s5d0h956te86ff90h6xts4","idempotency_key":"u_9f86d081884c7d65:order-8812:code","wallet_id":"u_9f86d081884c7d65"}]}' ``` Complete response example: ```json { "results": [ { "query_id": "brooklinen", "cashback": null, "partnered": false, "activation_url": null, "suppressed_code_count": 0, "items": [], "error": { "code": "live_key_required", "message": "This key is bound to the sandbox ledger and codes bound to a wallet earn live cashback. Use your live (os_live_) key." } } ] } ``` #### Unknown merchant A merchant_id that matched nothing: empty items, null activation_url and cashback, partnered false. Complete request: ```bash curl -sS -X POST https://api.openstock.sh/v1/merchants/codes \ -H "Authorization: Bearer $OPENSTOCK_API_KEY" \ -H "Content-Type: application/json" \ -d '{"queries":[{"query_id":"unknown","merchant_id":"unknown-merchant","idempotency_key":"replace-with-your-unique-shopping-session-key"}]}' ``` Complete response example: ```json { "results": [ { "query_id": "unknown", "cashback": null, "partnered": false, "activation_url": null, "suppressed_code_count": 0, "items": [] } ] } ``` Request body: - `queries` (array of object, required) [1–20 items] — Batch of codes queries (1–20); query_id unique within the batch - `wallet_id` (string, optional) — Opaque user ID within your partner account. Omit for existing non-wallet behavior. - `query_id` (string, required) — Caller-supplied opaque identifier correlated back in results - `merchant_id` (string, required) — OpenStock merchant ID obtained from the search endpoint - `idempotency_key` (string, required) — Required opaque issuance key. Namespace it by partner, shopper/session and merchant; reuse it when retrying the same intended issuance. Do not send raw email or reuse a key across shoppers. It deduplicates issuance, not the entire response, and does not renew an expired or used code. - `shopper_name` (string, optional) — Shopper's first name. When given, a code minted for this request carries it, e.g. <prefix>-RORY-4O8HHBUN-CN, so it reads as the shopper’s own. Only the first word is used and only when it is letters; anything else is ignored, as is a name the code has no room for. It applies at first issuance: a replay under the same idempotency_key returns the code already minted. Never send an email or phone. - `issue_code` (boolean, optional) — Send false to read a store’s offer without issuing a code. A store that would mint a single-use code for this request returns its offer with `code: null`, and no code is minted or taken from a pool. Omit it, or send true, to have the code issued. - `min_probability` (number, optional) [range 0–1] — Drop codes whose `probability` is below this threshold. Omit to receive every code. A value around 0.5 keeps only codes that usually work at checkout. - `limit` (integer, optional) [range 1–20] — Maximum number of codes to return for this query, taken from the top of the ranked list. Omit to receive up to 20. Response `200` — Per-query results. Each result has an `items` array of codes. Misses return an empty `items` array - `results` (array of object, required) - `error` (object, optional) — Explicit per-query wallet failure; other queries can succeed independently. - `code` (string, required) - `message` (string, required) - `query_id` (string, required) - `cashback` (object | null, required) — Cashback available through activation_url, subject to merchant eligibility and attribution. It is independent of the codes array and can remain available when no code qualifies. Null when unavailable; do not imply cashback on an ineligible or untracked order. - `value_type` (`percent`, required) - `value_amount` (number, required) — Percent of the order value returned to the shopper as cashback - `partnered` (boolean, required) — Whether this merchant has a direct partnership with OpenStock. It does not guarantee an available code or successful issuance. Inspect each item’s source, code, single_use and eligibility. False on unknown or unavailable merchant results. - `activation_url` (string | null, required) — Attributed link to the merchant, set for every merchant in the network and independent of `items`. This is how an empty `items` is told apart from an unknown merchant: a non-null `activation_url` means we know the store and the link is available even though no code qualified. Null is a miss-shaped response: the merchant was unknown or the per-merchant lookup was unavailable. - `suppressed_code_count` (number, required) — How many codes your `min_probability` or `limit` removed from `items`. A zero-length `items` with a non-zero count here means codes exist but none cleared your threshold — not that the merchant has nothing. - `items` (array of object, required) — Offers sorted best-first by probability, with merchant-backed tiers ahead on ties. Inspect code, source and eligibility before selecting an item; a null code is codeless. Empty when no offer qualifies, the merchant is unknown, or its lookup is unavailable. - `code` (string | null, required) — Promo code string, or null for codeless offers - `probability` (number, required) [range 0–1] — Reliability score from 0–1. Observed public codes use recent checkout attempts, weighted toward newer activity and discounted for sparse successes. Merchant-backed offers are assigned 1; this is not evidence that a specific cart is eligible or that a null code was successfully issued. Read source, code, conditions and description together. The score usually differs from success_count / apply_count, which is a lifetime ratio. - `single_use` (boolean, required) — True when the code can be used for one order only - `source` (`generated` | `merchant_issued` | `observed`, required) — Provenance: generated means minted through the merchant integration or claimed from a merchant code pool. A retry may reuse an existing code, and some pools contain reusable codes; inspect single_use. merchant_issued is a configured merchant code or codeless offer, including a fallback when issuance is unavailable. observed is a public code scored from checkout activity. Source alone does not establish eligibility or that the code will apply. - `value_type` (`percent` | `fixed` | `free_shipping` | `unknown`, required) — How the discount value is expressed. Minted and campaign codes carry the merchant-configured value; public codes are parsed from their description and fall back to "unknown" when the copy does not state a value. - `value_amount` (number | null, required) — Numeric discount amount; semantics depend on value_type (e.g. 10 = 10% or $10) - `currency` (string | null, required) — ISO 4217 currency code, present when value_type is "fixed" - `conditions` (array of string, required) — Condition tags extracted from merchant configuration or offer descriptions, e.g. minimum_subtotal, product_restricted, customer_restricted, applies_on_subscription. Tags are not exhaustive: read description and merchant terms too. An empty array does not establish unrestricted eligibility. up_to means the value is a ceiling, not the saving on every eligible purchase. The structured fields below (minimum_subtotal, combines_with, restricted_to_collections, customer_restricted) carry the figures and booleans the tags only hint at. - `minimum_subtotal` (number | null, required) — Minimum order subtotal the code requires, in `minimum_subtotal_currency`. For merchant-configured and minted codes this is the campaign setting: null means the merchant set no minimum. For observed public codes it is read from the offer copy ("$35 off orders of $175+") and null means the copy states none, not that there is none. - `minimum_subtotal_currency` (string | null, required) — ISO 4217 currency of `minimum_subtotal`; null whenever `minimum_subtotal` is null. - `combines_with` (object | null, required) — The merchant-configured combination rules of a merchant-configured or minted code (Shopify’s combinesWith), stated for every such code: all false means the code is the only discount the checkout will take. Null for observed public codes, whose rules are not known. - `order_discounts` (boolean, required) — Whether the code can be applied together with another order-level discount code or automatic discount. - `product_discounts` (boolean, required) — Whether the code can be applied together with a product-level discount. - `shipping_discounts` (boolean, required) — Whether the code can be applied together with a shipping discount. - `restricted_to_collections` (boolean | null, required) — True when a merchant-configured or minted code applies only to specific collections (the `product_restricted` tag), false when it applies storewide. Null for observed public codes. - `customer_restricted` (boolean | null, required) — True when the code is limited to particular customers: a merchant-configured customer segment, or offer copy that says first order or new customers. False when a merchant-configured or minted code has no such limit; null when an observed public code’s copy does not say. - `redirect_url` (string | null, required) — Link to the store that attributes the purchase; null when unavailable - `expires_at` (number | null, required) — Unix timestamp (ms) when the code expires, or null when no expiry is reported. Null does not prove unlimited validity. - `last_success` (string | null, required) — ISO 8601 UTC timestamp of the most recent successful checkout with this code, or null when never observed - `description` (string | null, required) — Human-readable description of the offer or null - `apply_count` (number | null, required) — All-time number of checkout attempts with this code since we first saw it, or null when not tracked (campaign and minted codes). Lifetime volume, not recent reliability — use `probability` for that. A high count with a low `probability` is a code that used to work and has since been retired by the merchant. - `success_count` (number | null, required) — All-time number of those attempts that yielded a saving, or null when not tracked. Pair with `apply_count` for the lifetime ratio; pair `last_success` with `probability` for whether it works today. - `avg_saving_percent` (number | null, optional) — Average percentage a public code took off the cart at the checkouts it worked at, or null when none is recorded. An observed effective saving, not the code’s configured discount (a fixed $10 code averages a percentage too): value_type and value_amount stay what the description states, unknown when it states none, so present this as an estimate ("about 15% off on recent orders"), never as the code’s rule. - `avg_saving_amount` (number | null, optional) — Average amount (USD) a public code took off at the checkouts it worked at, or null when none is recorded. An observed average like avg_saving_percent, never promoted into value_type or value_amount. Response `400` — Invalid request body, missing idempotency_key, or query cap exceeded (max 20) - Invalid request body: `VALIDATION_ERROR`, queries: Too small: expected array to have >=1 items - Malformed JSON: `MALFORMED_JSON`, Request body must be valid JSON Response `401` — Missing or invalid API key - Missing bearer key: `MISSING_AUTH`, Authorization header is required. Use: Authorization: Bearer <api_key> - Invalid or revoked key: `INVALID_API_KEY`, The provided API key is not valid. ### POST /v1/products/search **Batch product search** · operationId `searchProducts` Find live listings for a product by name: current price, regular price, image and the store’s product page, for up to 10 queries per request. Each listing names its store; when the store resolves to an OpenStock merchant, `merchant.id` is its OpenStock merchant ID to pass to /v1/merchants/codes and `activation_url` is an attributed link that lands on the product page. Listings come from a product feed refreshed roughly daily (see `updated_at`); confirm the price at the store before promising it. Size and colour variants of one product at one store are collapsed to one listing, an in-stock one when there is one. #### Price and image for a named product The Hoka Clifton 10 as listed by a network store: live price against the regular price, the product image, the store’s product page and an attributed link to it. Prices and the merchant id are illustrative; run the request for current listings. Complete request: ```bash curl -sS -X POST https://api.openstock.sh/v1/products/search \ -H "Authorization: Bearer $OPENSTOCK_API_KEY" \ -H "Content-Type: application/json" \ -d '{"queries":[{"query_id":"hoka","query":"Hoka Clifton 10","limit":1,"currency":"USD"}]}' ``` Complete response example: ```json { "results": [ { "query_id": "hoka", "items": [ { "id": "1414142329916416499", "name": "HOKA Clifton 10", "brand": "HOKA", "image_url": "https://cdn.shopify.com/s/files/1/0095/4420/4367/files/hoka_1162031CTNS_W042.jpg", "url": "https://www.dtlr.com/products/hoka-clifton-10-1162031-ctns-pink", "price": 59.98, "regular_price": 150, "currency": "USD", "on_sale": true, "discount_percent": 60, "availability": "in_stock", "merchant": { "id": "01h0example0dtlr0merchant0id", "name": "DTLR", "domain": "dtlr.com" }, "activation_url": "https://api.openstock.sh/mr/01h0example0dtlr0merchant0id?ref=openstock&origin=open-stock&href=https%3A%2F%2Fwww.dtlr.com%2Fproducts%2Fhoka-clifton-10-1162031-ctns-pink", "updated_at": "2026-10-25T04:17:45Z" } ] } ] } ``` #### The brand’s own store first With `store`, the brand’s own listing leads: Hill House Home’s Ellie Nap Dress from hillhousehome.com, ahead of the resellers the open search ranks first. Prices and the merchant id are illustrative. Complete request: ```bash curl -sS -X POST https://api.openstock.sh/v1/products/search \ -H "Authorization: Bearer $OPENSTOCK_API_KEY" \ -H "Content-Type: application/json" \ -d '{"queries":[{"query_id":"nap-dress","query":"Ellie Nap Dress","store":"Hill House Home","limit":1,"currency":"USD"}]}' ``` Complete response example: ```json { "results": [ { "query_id": "nap-dress", "items": [ { "id": "1414142329916417777", "name": "The Ellie Nap Dress | Cognac Gingham / XS | Hill House Home", "brand": "Hill House Home", "image_url": "https://cdn.shopify.com/s/files/1/0102/8030/9339/files/ellie-nap-dress-cognac-gingham.jpg", "url": "https://hillhousehome.com/products/the-ellie-nap-dress", "price": 178, "regular_price": 178, "currency": "USD", "on_sale": false, "discount_percent": 0, "availability": "in_stock", "merchant": { "id": "01h0example0hillhouse0merchant", "name": "Hill House Home", "domain": "hillhousehome.com" }, "activation_url": "https://api.openstock.sh/mr/01h0example0hillhouse0merchant?ref=openstock&origin=open-stock&href=https%3A%2F%2Fhillhousehome.com%2Fproducts%2Fthe-ellie-nap-dress", "updated_at": "2026-10-25T04:17:45Z" } ] } ] } ``` #### Listing at a store outside the network A real listing from a store OpenStock has no merchant record for: `merchant.id` and `activation_url` are null, so link the shopper to `url` and skip the codes call. Complete request: ```bash curl -sS -X POST https://api.openstock.sh/v1/products/search \ -H "Authorization: Bearer $OPENSTOCK_API_KEY" \ -H "Content-Type: application/json" \ -d '{"queries":[{"query_id":"sheets","query":"linen sheet set","limit":1,"currency":"USD"}]}' ``` Complete response example: ```json { "results": [ { "query_id": "sheets", "items": [ { "id": "9876543210987654321", "name": "Stonewashed Linen Sheet Set", "brand": null, "image_url": "https://cdn.example-linens.invalid/sheet-set.jpg", "url": "https://www.example-linens.invalid/products/stonewashed-sheet-set", "price": 189, "regular_price": 189, "currency": "USD", "on_sale": false, "discount_percent": 0, "availability": "in_stock", "merchant": { "id": null, "name": "Example Linens", "domain": "example-linens.invalid" }, "activation_url": null, "updated_at": "2026-10-25T04:17:45Z" } ] } ] } ``` #### Nothing matched A query the feed has no listing for returns an empty items array, not a 404 and not a null item. Complete request: ```bash curl -sS -X POST https://api.openstock.sh/v1/products/search \ -H "Authorization: Bearer $OPENSTOCK_API_KEY" \ -H "Content-Type: application/json" \ -d '{"queries":[{"query_id":"unknown","query":"zzqxv plorbit 9931","limit":5,"currency":"USD"}]}' ``` Complete response example: ```json { "results": [ { "query_id": "unknown", "items": [] } ] } ``` Request body: - `queries` (array of object, required) [1–10 items] — Batch of product searches (1–10); query_id unique within the batch. Each query returns a result with an `items` array, empty when nothing matched. - `query_id` (string, required) — Caller-supplied opaque identifier correlated back in results - `query` (string, required) — What the shopper is looking for, matched against product names: a brand and model ("Hoka Clifton 10"), a brand and category ("Brooklinen sheets"), or a product name. Not a merchant name on its own. - `store` (string, optional) — The brand’s own store, by name, when the shopper wants it from the source: that store’s listings come first, then other stores selling the product. Use the name the store trades under, with its own capitalisation ("Hill House Home", "HOKA"); the match is exact. Without it, results are in the feed’s relevance order, where resellers with short listing names often outrank the brand’s own site. - `limit` (integer, optional) [range 1–20; default 5] — Maximum number of listings to return for this query, in the feed’s relevance order. Defaults to 5. - `currency` (string, optional) [default "USD"] — ISO 4217 currency of the listings to return. Defaults to USD. - `on_sale` (boolean, optional) — When true, only listings currently priced below their regular price are returned. Response `200` — Per-query results in request order. Each result has an `items` array of listings in the feed’s relevance order; empty when nothing matched - `results` (array of object, required) - `query_id` (string, required) - `items` (array of object, required) — Listings matching the query in the feed’s relevance order, at most `limit`. Size and colour variants of one product at one store are collapsed to one listing, an in-stock one when there is one. Empty when nothing matched. - `id` (string, required) — Listing identifier in the product feed; stable for a store’s listing - `name` (string, required) — Product name as listed by the store - `brand` (string | null, required) — Brand as listed by the store, or null when the feed does not carry one - `image_url` (string | null, required) — Primary product image hosted by the store or its CDN, or null when none is listed. Hotlink it or proxy it; it is not hosted by OpenStock. - `url` (string, required) — The store’s own product page. Unattributed: prefer `activation_url` when it is set. - `price` (number, required) — Current price in `currency` major units (dollars, not cents), as last refreshed from the store feed. See `updated_at` for freshness. - `regular_price` (number | null, required) — The store’s regular price before any sale, in `currency` major units; equal to `price` when the listing is not on sale, null when the feed does not report one. - `currency` (string, required) — ISO 4217 currency of `price` and `regular_price` - `on_sale` (boolean, required) — Whether the store marks the listing as on sale; when the feed does not say, true when `price` is below `regular_price`. - `discount_percent` (number | null, required) — Percentage saving against `regular_price` as the feed reports it, or null when it reports none. This is the store’s own markdown, not an OpenStock code. - `availability` (`in_stock` | `out_of_stock` | `preorder` | `backorder` | `unknown`, required) — Stock status at the last feed refresh. `unknown` when the store does not report it. - `merchant` (object, required) - `id` (string | null, required) — OpenStock merchant ID of the store selling this listing, when the store is in OpenStock. Pass it to /v1/merchants/codes for codes and cashback at that store. Null when the store is not in OpenStock; the listing is still real. - `name` (string, required) — Store name as reported by the product feed - `domain` (string, required) — Hostname of the product page, without `www.` - `activation_url` (string | null, required) — Attributed link to this product page, so the shopper earns any cashback the store offers (see /v1/merchants/codes). Lands on the product page when the store supports deep links, otherwise on the store’s attributed landing page. Null when the store is not in OpenStock; use `url` then. - `updated_at` (string | null, required) — ISO 8601 UTC time the feed last refreshed this listing’s price and availability, or null when not reported. Prices are refreshed roughly daily; confirm at the store before promising a price. Response `400` — Invalid request body or query cap exceeded (max 10 queries) - Invalid request body: `VALIDATION_ERROR`, queries: Too small: expected array to have >=1 items - Malformed JSON: `MALFORMED_JSON`, Request body must be valid JSON Response `401` — Missing or invalid API key - Missing bearer key: `MISSING_AUTH`, Authorization header is required. Use: Authorization: Bearer <api_key> - Invalid or revoked key: `INVALID_API_KEY`, The provided API key is not valid. Response `503` — The product feed did not answer (outage or rate limit). Nothing in the batch was answered; retry the whole request with backoff - Product feed did not answer: `PRODUCTS_UNAVAILABLE`, Product search is temporarily unavailable. Retry the request with backoff. ### POST /v1/shoppers/history **Batch shopper purchase and browsing history** · operationId `getShopperHistory` Look up merchant-level purchase and browsing history for authorized shoppers identified by SHA-256 hash of their normalised (lowercase-trimmed) email address. Never send raw email addresses. Up to 20 queries per request. Each result contains a flat `items` array of merchant interactions, purchases first; unknown shoppers return an empty `items` array. Use history only within your authorized integration. #### Purchases and visits A shopper with two purchases and a visit, purchases first. Send the SHA-256 of an authorized shopper’s normalized email for a live lookup. Complete request: ```bash curl -sS -X POST https://api.openstock.sh/v1/shoppers/history \ -H "Authorization: Bearer $OPENSTOCK_API_KEY" \ -H "Content-Type: application/json" \ -d '{"queries":[{"query_id":"example-shopper","email_sha256":"3a32f737ca25fb3d367dd3c8aaa91e9bf73f31445b0377a8de073eb33276dcb8"}]}' ``` Complete response example: ```json { "results": [ { "query_id": "example-shopper", "items": [ { "merchant_id": "01g4s5d0h956te86ff90h6xts4", "merchant_name": "Brooklinen", "type": "purchased" }, { "merchant_id": "01g4s5dc138qsnh4egsjys8g9c", "merchant_name": "Everlane", "type": "purchased" }, { "merchant_id": "01g4s4gvb1kdc8kz69cm5q2b4f", "merchant_name": "Nike", "type": "visited" } ] } ] } ``` #### Shopper not seen A shopper we have not seen: empty items. Complete request: ```bash curl -sS -X POST https://api.openstock.sh/v1/shoppers/history \ -H "Authorization: Bearer $OPENSTOCK_API_KEY" \ -H "Content-Type: application/json" \ -d '{"queries":[{"query_id":"example-shopper","email_sha256":"3a32f737ca25fb3d367dd3c8aaa91e9bf73f31445b0377a8de073eb33276dcb8"}]}' ``` Complete response example: ```json { "results": [ { "query_id": "example-shopper", "items": [] } ] } ``` Request body: - `queries` (array of object, required) [1–20 items] — Batch of shopper-history queries (1–20) - `query_id` (string, required) — Caller-supplied opaque identifier correlated back in results - `email_sha256` (string, required) — SHA-256 of the lowercase, trimmed email address, as 64 hex characters in either case. Never send the raw email. Response `200` — Per-query shopper history. Each result has a flat `items` array of merchant interactions. Unknown shoppers return an empty array - `results` (array of object, required) - `query_id` (string, required) - `items` (array of object, required) — Merchant interactions for this shopper, purchases first. Empty for a shopper we have not seen. - `merchant_id` (string, required) — OpenStock merchant ID - `merchant_name` (string, required) - `type` (`visited` | `purchased`, required) — "purchased" when an order was observed at the merchant; "visited" when only browsing sessions were observed. Purchased merchants are listed first. Response `400` — Invalid request body, malformed email_sha256, or query cap exceeded (max 20) - Invalid request body: `VALIDATION_ERROR`, queries: Too small: expected array to have >=1 items - Malformed JSON: `MALFORMED_JSON`, Request body must be valid JSON Response `401` — Missing or invalid API key - Missing bearer key: `MISSING_AUTH`, Authorization header is required. Use: Authorization: Bearer <api_key> - Invalid or revoked key: `INVALID_API_KEY`, The provided API key is not valid. ### GET /health **Health check** · operationId `getHealth` Returns API dependency health and fresh funded-cashback sandbox-flow/wallet readiness. The scheduled flow discovers the actual storefront, creates a funded quote, reports a synthetic paid order, verifies committed held cashback, fully refunds it and verifies the hold is zero. It does not test merchant payment or bank settlement. Checks are cached for 30 seconds and bounded by a five-second timeout. Readiness requires cashback-funded-checkout and cashback-wallet observations within 15 minutes; missing or stale evidence returns 503. Health requests only read this evidence and never create purchases. Aggregate status is not a dependency, so recovery cannot latch on a prior health failure. Response `200` — Service is healthy - `ok` (boolean, required) — Whether the service is healthy. False, with HTTP 503, when any cashback component is down. - `environment` (string, required) — The deployment this Worker runs in. It is not the ledger: one deployment serves both ledgers, and the key prefix (os_live_ or os_test_) selects which one a request uses. - `ledgers` (array of `live` | `sandbox`, required) — The ledgers this deployment serves. Every cashback response carries livemode so simulated money is never mistaken for real money; gate on livemode and the key prefix, never on environment. - `components` (object, required) — Store catalog, live quotes and wallet service reads, plus fresh cashback-funded-checkout and cashback-wallet observations from the status monitor. The funded sandbox flow verifies quote, synthetic purchase report, held wallet funds and full-refund cleanup; it does not prove merchant payment or bank settlement. The readiness component never consumes aggregate API health and never creates purchases during a health request. - `catalog` (object, required) - `ok` (boolean, required) - `checked_at` (string, required) - `detail` (`timeout` | `unavailable` | `stale` | `unobserved`, optional) — Why the component is down, when it is. - `live_quotes` (object, required) - `ok` (boolean, required) - `checked_at` (string, required) - `detail` (`timeout` | `unavailable` | `stale` | `unobserved`, optional) — Why the component is down, when it is. - `wallet` (object, required) - `ok` (boolean, required) - `checked_at` (string, required) - `detail` (`timeout` | `unavailable` | `stale` | `unobserved`, optional) — Why the component is down, when it is. - `cashback_readiness` (object, required) - `ok` (boolean, required) - `checked_at` (string, required) - `detail` (`timeout` | `unavailable` | `stale` | `unobserved`, optional) — Why the component is down, when it is. Response `503` — At least one cashback component is down ## Links - Interactive reference: https://api.openstock.sh/docs - OpenAPI: https://api.openstock.sh/openapi.json - Text guide: https://api.openstock.sh/llms-full.txt - Live demo: https://openstock.sh/demo - Status: https://status.openstock.sh