# MCP server for your store (cope-mcp) Source: https://docs.cope.com/ai-agents/merchant-assistant Let Claude, Cursor or another MCP client read your COPE store: orders, payments, refunds, invoices, products, offers, subscriptions and webhook deliveries. # MCP server for your store (cope-mcp) `cope-mcp` is an MCP server you run on your own computer. It lets your AI assistant read your COPE store through the public API, using your API key. You can then ask things like *"what did we sell last week?"*, *"did the refund for this order go through?"* or *"which webhook deliveries failed today?"*. It **only reads** unless you turn changes on. With changes on, it can refund a payment, change a subscription, create, send or cancel an offer, and create or change a product, and it asks **you** to confirm each change before anything happens. See [Making changes](#making-changes). ## Set it up The server is published on npm as [`cope-mcp`](https://www.npmjs.com/package/cope-mcp). 1. In the COPE dashboard, create an API key under **Settings → API Keys** and choose **Read only**. See [API key integrations](/api-reference/api-key-integrations). 2. Add the server to your MCP client. For Claude Desktop, add this to `claude_desktop_config.json`: ```json theme={"theme":{"light":"github-light","dark":"github-dark"}} { "mcpServers": { "cope": { "command": "npx", "args": ["-y", "cope-mcp@0.1.6"], "env": { "COPE_API_KEY": "ck_live_..." } } } } ``` Pin the version, as in `@0.1.6` above, so an update never runs unless you choose it. The server needs Node.js 20 or later. | Variable | Required | Meaning | | - | - | - | | `COPE_API_KEY` | Yes | Your live API key (`ck_live_...`) | | `COPE_MCP_PII` | No | `masked` (default) or `full`. See [Buyer data](#buyer-data) | | `COPE_MCP_WRITES` | No | `off` (default) or `on`. See [Making changes](#making-changes) | ## Tools | Tool | Reads | | - | - | | `list_orders`, `get_order` | Orders, with line items and payments. Completed orders only, unless you ask for drafts, pending or failed checkouts, each with its latest card decline | | `list_payments`, `get_payment` | Sale payments. Settled sales only, unless you ask for trial, pending or failed ones. Filter by payment method, buyer email, creation date, the date money moved, or one subscription (its first charge and every renewal) | | `list_refunds`, `get_refund` | Refunds, and on request the reversals of refunds that failed after they were paid out. Filter by status, payment method or date | | `list_chargebacks`, `get_chargeback` | Chargebacks, and the reversals that returned their money when a dispute was won, each naming its dispute | | `get_dispute` | A dispute, by its processor's id: its state, reason and evidence deadline | | `list_invoices`, `get_invoice` | Invoices | | `list_products`, `get_product` | Products and their payment plans | | `get_currencies` | The currencies the store can price a plan in, the one COPE stamps on a plan sent without a currency, and COPE's exchange rate into them from each platform currency the store cannot sell in | | `list_offers`, `get_offer` | Offers sent to buyers | | `get_checkout` | A checkout created from your server, and its order once paid | | `list_subscriptions` | The subscriptions that changed in a time window, oldest change first, for a sync | | `get_subscription`, `list_subscription_changes` | A subscription and its price or plan changes | | `list_webhook_endpoints`, `list_webhook_deliveries` | Webhook endpoints and delivery history | Lists return at most 25 items per page, and each result says how many pages there are. `list_subscriptions` is the exception: up to 100 a page, followed by `next_cursor` while `has_more` is true, and only changes at least 120 seconds old. ## Making changes Changes are off by default. To turn them on, set `COPE_MCP_WRITES` to `on` and use a **full-access** key; a read-only key refuses every change. | Tool | Changes | | - | - | | `refund_payment` | Refunds a payment in full or in part. The money goes back to the buyer | | `cancel_subscription` | Cancels a subscription now, or at the end of the period already paid for | | `pause_subscription`, `resume_subscription` | Pauses or resumes a subscription's renewals | | `change_subscription_plan` | Moves a subscription to another payment plan, from its next billing cycle | | `change_subscription_price` | Changes a subscription's recurring amount, from its next billing cycle | | `create_offer` | Creates an offer: a price for one product made out to one buyer, as a private checkout link you send yourself. Nobody is notified. The same offer asked for twice within a day returns the first one | | `send_offer`, `resend_offer`, `cancel_offer` | Emails an offer's link to its buyer the first time, emails it again (at most every 5 minutes), or cancels an active offer (final) | | `create_product`, `update_product` | Creates a product (it starts in review, not on sale) or changes a product's name, headline, internal name, URL, withdrawal and refund periods (for buyers in the EU, the UK and Switzerland, and for buyers elsewhere; `-1` is none) or net-price flag. **An update takes the product off sale and back to review** unless COPE trusts your business with product changes | **Every change asks you first.** Your MCP client shows exactly what will happen, for example *"Refund 12.50 EUR of payment pay\_… to j\*\*\*@example.com (50.00 EUR is still refundable)?"*. Nothing changes unless you tick the box and accept. If what the question shows changed while you were deciding, you are asked again. If your client cannot show such a question, changes are refused. **A network problem does not make a change twice.** Each change carries a key derived from what you confirmed and the current state, and COPE applies one key once. If the answer is lost, your assistant is told the change may or may not have been made and should look before asking again. If it was made, the next question shows the new state, so a second refund is always a new question you answer yourself. `send_offer`, `resend_offer` and `cancel_offer` carry no key, because COPE takes none on them; the offer's own state guards them instead. Each is checked against the offer before you are asked, sent once, and never retried. If its answer is lost, your assistant is told to read the offer: a send or a cancel that went through shows in the offer's state, and a resend is not repeated for you, so a lost answer cannot become a second email. ## Buyer data Everything the server returns passes through your assistant's AI provider. By default, buyers' names, email addresses, phone numbers, VAT IDs, company names, addresses and card digits are masked, for example `j***@example.com` and `J. D.`. Set `COPE_MCP_PII=full` only if your agreement with that provider covers your buyers' personal data. ## Questions about COPE itself This server reads your store. For questions about how COPE works, also add the docs search MCP server at `https://docs.cope.com/mcp`, which needs no key. See [MCP for AI shopping agents (cope-sdk/mcp)](/ai-agents/shopping-agents#give-your-ai-tools-these-docs). ## Security * **Use a read-only key** unless you turned changes on. It reads what you can and changes nothing, so a leaked key cannot write. Keep the key out of shared configuration files. If it leaks, or you stop using the server, deactivate or delete it in the dashboard; it stops working within 60 seconds. * The key is sent only to COPE's API and never appears in tool results or error messages. * Results contain text your buyers and team wrote, such as product descriptions and names. The server labels every result as data, not instructions. Still, review what your assistant proposes before you act on it. # MCP for AI shopping agents (cope-sdk/mcp) Source: https://docs.cope.com/ai-agents/shopping-agents Mount an MCP endpoint on your own server so a buyer's AI agent can build a cart in your store and hand the buyer a COPE checkout link. # MCP for AI shopping agents (cope-sdk/mcp) A buyer can ask an AI agent to shop for them. With the MCP endpoint in the Checkout SDK, that agent can find your products, build a cart and prepare a checkout in your store, then give the buyer a link to COPE's checkout page. The buyer accepts your terms there themselves, waives their right of withdrawal when a product in the cart does not ship (a digital product), and pays. An agent cannot accept terms, waive a right or pay on the buyer's behalf. The endpoint runs on your server, under your domain, with your publishable key. It speaks the [Model Context Protocol](https://modelcontextprotocol.io) (MCP), which AI agents use to call tools. ## Requirements * A COPE publishable key (`cope_pk_...`). * The success and cancel URLs you use for checkout, registered as redirect URLs in the COPE dashboard. * A server that runs Node.js 20 or later, Bun, Deno, Cloudflare Workers or a Next.js route handler. ## Install The endpoint ships in the Checkout SDK, published on npm as [`cope-sdk`](https://www.npmjs.com/package/cope-sdk), under the `cope-sdk/mcp` entry point. ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}} npm install cope-sdk @modelcontextprotocol/server zod npm install @modelcontextprotocol/node # only for node:http or Express ``` ## Create a cart key The endpoint gives agents an encrypted handle for each cart, so an agent never holds the cart's secret. Create a 32-byte key for that once, and store it as a server-side secret: ```typescript theme={"theme":{"light":"github-light","dark":"github-dark"}} import { generateCartRefKey } from "cope-sdk/mcp" console.log(generateCartRefKey()) ``` Keep this key out of browsers and source control. Anyone holding it can open and change the carts its handles point to. ## Mount the endpoint On Node.js: ```typescript theme={"theme":{"light":"github-light","dark":"github-dark"}} import { createServer } from "node:http" import { createCopeMcpNodeHandler } from "cope-sdk/mcp/node" const mcp = createCopeMcpNodeHandler({ publishableKey: process.env.COPE_PUBLISHABLE_KEY!, cartRefKeys: [process.env.COPE_CART_REF_KEY!], checkout: { successUrl: "https://shop.example.com/thanks", cancelUrl: "https://shop.example.com/cart", }, allowedHosts: ["shop.example.com"], }) createServer((req, res) => { if (req.url?.startsWith("/mcp")) return void mcp(req, res) res.statusCode = 404 res.end() }).listen(3000) ``` On Bun, Deno, Cloudflare Workers or a Next.js route handler, use the fetch handler instead. It does not need `@modelcontextprotocol/node`: ```typescript theme={"theme":{"light":"github-light","dark":"github-dark"}} import { createCopeMcpHandler } from "cope-sdk/mcp" const mcp = createCopeMcpHandler({ publishableKey: process.env.COPE_PUBLISHABLE_KEY!, cartRefKeys: [process.env.COPE_CART_REF_KEY!], checkout: { successUrl: "https://shop.example.com/thanks", cancelUrl: "https://shop.example.com/cart", }, allowedHosts: ["shop.example.com"], }) export function POST(request: Request) { return mcp.fetch(request) } ``` Agents then connect to `https://shop.example.com/mcp`. ## Options | Option | Required | Meaning | | - | - | - | | `publishableKey` | Yes | Your `cope_pk_...` key | | `cartRefKeys` | Yes | Cart keys, base64 or base64url, 32 bytes each. The first one encrypts and all of them decrypt | | `checkout` | Yes | `successUrl` and `cancelUrl` for the checkout page. Both must be registered redirect URLs | | `allowedHosts` | Yes | Host names the endpoint answers to. Requests for any other host are refused | | `allowedOrigins` | No | Browser origins allowed to call the endpoint. Agents that call it from a server are not affected | | `rateLimit` | No | `{ perClientPerMinute, perStorePerMinute }`, 120 and 1200 by default, or `false` if you limit requests yourself. Counted in memory, per process | | `clientKey` | No | How to tell clients apart for the per-client limit, for example from a trusted proxy's header | ## Tools | Tool | What the agent can do | | - | - | | `get_product` | Read a product and its prices. The payment methods it lists are those offered for a one-time purchase | | `create_cart` | Start a cart. Returns a `cartRef` that the other cart tools take | | `get_cart` | Read the cart with current prices. It also lists the payment methods the cart can be paid with, as COPE decides them: on a subscription, instalment or trial cart, only those that renew | | `add_line`, `update_line`, `remove_line` | Change what is in the cart | | `apply_promo_code`, `remove_promo_code` | Apply or remove a promo code | | `set_buyer_identity` | Record who is buying and where: email, name, country, postal code, company and VAT ID. Country and postal code decide tax | | `start_checkout` | Prepare the checkout and return the link for the buyer, with `buyerNext`: what the buyer does on the checkout page (accept the terms and, if the page asks them to, waive the right of withdrawal, which it can only for a cart with a product that does not ship) and that the agent cannot do it for them. Calling it again returns the same checkout | When a tool fails, its result includes a `guidance` string telling the agent what to do next. ## Rotate the cart key 1. Add a new key at the front of `cartRefKeys` and deploy. New handles use it, and existing handles still work. 2. After your longest-lived carts have expired, remove the old key and deploy again. ## Give your AI tools these docs If you build with an AI coding assistant, point it at these docs rather than pasting pages: | Resource | URL | | - | - | | Page index for AI tools | `https://docs.cope.com/llms.txt` | | Every page in one file | `https://docs.cope.com/llms-full.txt` | | Docs search MCP server | `https://docs.cope.com/mcp` | The MCP server searches these docs from any MCP client. It reads documentation only and needs no key. ## Security * The endpoint uses only your publishable key, the same key your storefront already exposes. * Terms, consents and payment happen on COPE's checkout page, in the buyer's own browser. # API key integrations Source: https://docs.cope.com/api-reference/api-key-integrations Create, store, rotate, deactivate, and delete COPE public API keys safely. # API key integrations API key integrations let server-side vendor systems call the COPE public API for one COPE business. Each key has a mode, a public prefix, a secret shown only once, an active state, and last-used metadata. ## Lifecycle | Action | Guidance | | - | - | | Create | Create a named integration in the COPE dashboard and copy the secret immediately. | | Store | Store the full token in a server-side secret manager. Do not expose secret keys in browsers or mobile apps. | | Rotate | Create a replacement key, deploy it, confirm traffic, then deactivate the previous key. | | Deactivate | Deactivated keys stop authenticating within 60 seconds. Activate the key again to restore it. | | Delete | Delete keys that are no longer needed after confirming no clients use them. A deleted key stops authenticating within 60 seconds and cannot be restored. | ## Key format New keys use the format `ck_live__`: a 12-character alphanumeric prefix that identifies the key and is safe to display, and a 48-character lowercase hexadecimal secret that is shown only once. Keys issued earlier in the format `cope_sk_live__` keep working unchanged. ## Where keys are managed Create, activate, deactivate, and delete API keys in the COPE dashboard under **Settings → API Keys**. The full token is shown only once, when the key is created. COPE does not store it and cannot show it again. Keys are managed only in the dashboard. The public API has no key-management endpoints, so an API key cannot create, activate, deactivate, or delete keys. ## Access Choose the access when you create a key. It cannot be changed later: create a new key instead. | Access | What the key can do | | - | - | | Full access | Read and change, through the public API, what the person who created it can in that business. | | Read only | Read, through the public API, what the person who created it can, and change nothing. Every write answers `403 insufficient_scope`. Use it for reporting, exports and AI assistants. | Either way, a key never reaches more than its creator can. If their role in the business narrows, or they leave it, the key narrows or stops working with them. # Authentication Source: https://docs.cope.com/api-reference/authentication Use a Bearer API key from the COPE vendor dashboard to authenticate every request. # Authentication Every request must carry an `Authorization: Bearer ` header. ```http theme={"theme":{"light":"github-light","dark":"github-dark"}} Authorization: Bearer ck_live_xxxxxxxxxxxx_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ``` The public API accepts API keys only. Dashboard sign-in tokens are refused with `401 invalid_token_format`. ## Key format New keys use the format `ck_live__`. | Component | Value | | - | - | | Type and mode | `ck_live` (constant) | | Prefix | 12-character alphanumeric identifier, safe to display | | Secret | 48 lowercase hexadecimal characters, shown only once on creation | Keys issued earlier in the format `cope_sk_live__` keep working unchanged. You do not need to replace them. Live keys produce real side effects. Test-mode keys are reserved for a future test mode and are not accepted yet. ## Getting a key 1. Sign in to the COPE vendor dashboard. 2. Open **Settings → API Keys**. 3. Click **Create API key**, give the key a name, and copy the secret token that appears. 4. The secret is shown **only once** — store it securely. It cannot be retrieved later. ## Read-only keys A key is created with **Full access** or **Read only**, and keeps it: to change it, create a new key. A read-only key can make every read its creator can make through the public API. Every write it sends answers `403 insufficient_scope` and changes nothing. Use one for reporting, exports and AI assistants. See [API key integrations](./api-key-integrations#access). ## Rotation and revocation * Issue a new integration, switch the client to the new key, then deactivate the previous one from the same dashboard view. * Deactivated and deleted keys stop authenticating within 60 seconds. * Keys are scoped to one business. Use separate integrations for separate businesses rather than sharing a key across them. ## Failure modes | Response code | Meaning | | - | - | | `401 missing_authorization` | `Authorization` header missing or malformed. | | `401 invalid_token_format` | Bearer payload is not a COPE API key (`ck_live__`, or `cope_sk_live__` for a key issued earlier). | | `401 invalid_token` | Key not found, deactivated, the secret does not match the stored digest, or test mode was requested before it is available. | | `403 insufficient_scope` | The key's access does not cover this operation, such as a write sent with a read-only key. | # List chargebacks Source: https://docs.cope.com/api-reference/chargebacks/list-chargebacks /api-reference/commerce-v1.openapi.json get /v1/commerce/chargebacks Lists the business's chargebacks and chargeback reversals, newest first by `created_at`. A chargeback is a negative movement taken from you when a buyer disputed a sale; a reversal is the positive movement that returned it when the dispute was won. Each names its dispute by the processor's id, readable at GET /v1/commerce/disputes/{processor_id}. This resource follows the API convention: `{object, id}` references, `amount_minor_units`, millisecond UTC timestamps. Requires the `payments` permission at `read`. An API key holds a permission at the lower of its own level (`read` for a read-only key) and its holder's role; a key without it is refused with 403. # Retrieve a chargeback Source: https://docs.cope.com/api-reference/chargebacks/retrieve-a-chargeback /api-reference/commerce-v1.openapi.json get /v1/commerce/chargebacks/{id} Retrieves a chargeback or a chargeback reversal by id; `payment_type` says which. Requires the `payments` permission at `read`. An API key holds a permission at the lower of its own level (`read` for a read-only key) and its holder's role; a key without it is refused with 403. # Create a checkout Source: https://docs.cope.com/api-reference/checkouts/create-a-checkout /api-reference/commerce-v1.openapi.json post /v1/commerce/checkouts Creates a checkout from your server with its product, plan, buyer email and your reference fixed, and returns its `checkout_url` for you to send the buyer to. On that page the buyer cannot change the email you set; the other details stay theirs to correct. Your `metadata` and `external_reference` cannot be changed by the buyer and arrive on the order's webhooks. **`checkout_url` comes only with the create response.** The checkout stores a digest of its token, so retrieving the checkout does not return it; a repeat of the create with the same `Idempotency-Key` within 24 hours replays that response, link included. **`Idempotency-Key` is required.** A repeat with the same key answers with the same checkout. Ids are COPE's public ids: a line's `plan_id` is the plan's `plan_` id; an integer is refused with `validation_error` (422). A `success_url` or `cancel_url` must be one you registered as a redirect URL, or the request is refused with `invalid_redirect_url` (422). A key COPE reserves inside `metadata` is refused with `reserved_metadata_key` (422), and a member this operation does not take with `invalid_request` (400). To confirm a payment, retrieve the checkout by its `chk_` id and read `order`, rather than matching on `external_reference`. Requires the `orders` permission at `write`. An API key holds a permission at the lower of its own level (`read` for a read-only key) and its holder's role; a key without it is refused with 403. # Retrieve a checkout Source: https://docs.cope.com/api-reference/checkouts/retrieve-a-checkout /api-reference/commerce-v1.openapi.json get /v1/commerce/checkouts/{id} Returns a checkout you created. `order` names the order the buyer's payment made once it succeeded, and is null until then; `status` reads `completed` whenever `order` is set. A checkout expires 30 minutes after it was created. Requires the `orders` permission at `read`. An API key holds a permission at the lower of its own level (`read` for a read-only key) and its holder's role; a key without it is refused with 403. # Create a webhook delivery replay job Source: https://docs.cope.com/api-reference/create-a-webhook-delivery-replay-job /api-reference/account-platform-webhooks-v1.openapi.json post /v1/webhooks/replay-jobs # Create a webhook endpoint Source: https://docs.cope.com/api-reference/create-a-webhook-endpoint /api-reference/account-platform-webhooks-v1.openapi.json post /v1/webhooks/endpoints # Retrieve sellable currencies Source: https://docs.cope.com/api-reference/currencies/retrieve-sellable-currencies /api-reference/commerce-v1.openapi.json get /v1/commerce/currencies Returns the currencies this business can price a payment plan in. `sellable_currencies` is the set `payment_plans[].currency` accepts on `POST /v1/commerce/products` today; any other code is refused with 422. `default_currency` is the one COPE stamps on a plan sent without a currency, and is `null` when the business has no sellable currency yet or several and no declared default. `platform_currencies` lists every currency COPE can charge in. For each platform currency the business cannot sell in, `exchange_rates` carries the current platform rate into each currency it can, so a catalog priced in the former can be converted with the same rate checkout uses. The list is empty when the business already sells in every platform currency. Rates are a convenience next to the currency facts: when the rate provider is unavailable the response is still 200 and `exchange_rates` is empty. `rate` is a decimal string at full precision; `quoted_at` is when COPE answered. Requires the `products` permission at `read`. An API key holds a permission at the lower of its own level (`read` for a read-only key) and its holder's role; a key without it is refused with 403. # Delete a webhook endpoint Source: https://docs.cope.com/api-reference/delete-a-webhook-endpoint /api-reference/account-platform-webhooks-v1.openapi.json delete /v1/webhooks/endpoints/{id} # Retrieve a dispute Source: https://docs.cope.com/api-reference/disputes/retrieve-a-dispute /api-reference/commerce-v1.openapi.json get /v1/commerce/disputes/{id} Retrieves one of your disputes by its processor's id (Stripe `du_...`, PayPal `PP-D-...`), the `dispute.processor_id` a chargeback carries. COPE publishes no id of its own for a dispute. Any other id answers 404. Requires the `payments` permission at `read`. An API key holds a permission at the lower of its own level (`read` for a read-only key) and its holder's role; a key without it is refused with 403. # Errors Source: https://docs.cope.com/api-reference/errors COPE public API errors use RFC 9457 application/problem+json envelopes with stable codes. # Errors COPE public API errors use RFC 9457 `application/problem+json`. The `code` field is stable and should drive client behavior. ## Envelope ```json theme={"theme":{"light":"github-light","dark":"github-dark"}} { "code": "validation_failed", "detail": "Request validation failed", "errors": [ { "code": "missing", "detail": "Name is required", "param": "name" } ], "request_id": "0b6e3f2a-8c4d-4f1e-9a7b-5d2c8e1f4a90", "status": 422, "title": "Validation Failed", "type": "https://docs.cope.com/errors/validation_failed" } ``` Each entry of `errors` carries a snake\_case machine code in `code` (for example `blank`, `too_short`, `inclusion`, or `invalid` when no more specific code applies) and a sentence for people in `detail`, and `param` names the field it is about when there is one. Branch on `code`; the wording of `detail` may change. When the problem lists `errors`, the top-level `detail` summarises them. ## Common codes | Code | Status | Meaning | | - | - | - | | `missing_authorization` | 401 | The `Authorization` header is missing or is not a Bearer token. | | `invalid_token_format` | 401 | The Bearer value is not a COPE API key. | | `invalid_token` | 401 | The credential is invalid, revoked, inactive, or uses an unsupported mode. | | `insufficient_scope` | 403 | The API key's permissions do not cover this operation. | | `forbidden` | 403 | The API key is valid but is not permitted to perform this operation. | | `unauthorized` | 401 | The request reached COPE without a usable credential. Send it again; if it persists, quote `request_id`. | | `unknown_version` | 404 | The requested API major version is not supported. | | `unknown_public_route` | 404 | The route is not released in the public API. | | `not_found` | 404 | The requested resource was not found or is not visible to the authenticated business. | | `invalid_request` | 400 | The request shape is malformed or includes unsupported fields. | | `idempotency_key_required` | 400 | The operation requires an `Idempotency-Key` header and none was sent. | | `invalid_idempotency_key` | 400 | The `Idempotency-Key` is longer than 255 characters, is not valid UTF-8, or contains a NUL byte. | | `idempotency_conflict` | 409 | The `Idempotency-Key` was reused with a different body, or the first request carrying it is still processing. Repeat the second case unchanged. | | `payload_too_large` | 413 | The request body is larger than the API accepts. Do not retry the same body. | | `invalid_parameter` | 422 | A query or body parameter has an invalid value. | | `validation_failed` | 422 | One or more fields failed validation. Inspect `errors[]`. | | `invalid_state` | 422 | The requested command is not valid for the resource state. | | `rate_limited` | 429 | Too many requests. Retry with backoff. | | `internal_error` | 500 | COPE could not complete the request because of an internal error. Retry with backoff, and quote `request_id` if it persists. | | `idempotency_error` | 500 | Two requests reused an expired `Idempotency-Key` at the same moment and the outcome could not be resolved. Send the request again. | | `impersonation_not_supported` | 501 | The public API does not accept impersonated requests. Send the request as the integration itself. | | `upstream_error` | 502 | The service behind this route could not be reached. Retry with backoff. | | `service_unavailable` | 503 | COPE cannot serve the request temporarily. Retry with backoff. | | `user_not_ready` | 503 | The API key is valid but its user is not available to this API yet. Retry after the `Retry-After` seconds. | | `tenant_not_ready` | 503 | The API key is valid but its business is not available to this API yet. Retry after the `Retry-After` seconds. | | `gateway_timeout` | 504 | The request did not complete in time, and a write may still have been applied. Retry with backoff, sending the same `Idempotency-Key` on a write. | Endpoint-specific codes are documented in each operation when they differ from the common catalog. A problem's `type` is `https://docs.cope.com/errors/` followed by its `code`. ## Codes by operation Codes that only some operations answer, with the status each is answered under. | Code | Status | Meaning | | - | - | - | | `above_maximum_charge` | 422 | The order total is above the most a single payment can charge. | | `below_minimum_charge` | 422 | The order total is below COPE's minimum charge for its currency. | | `business_checkout_hold` | 403 | This business is temporarily unable to accept checkout payments. | | `charge_amount_unavailable` | 503 | The checkout total could not be resolved. Retry with backoff. | | `checkout_locale_not_allowed` | 422 | The checkout language is not enabled for this business. | | `chunk_fully_refunded` | 422 | That line of the payment is already fully refunded. | | `chunk_not_found` | 422 | That line is not part of this payment. | | `cooldown_active` | 429 | The offer was sent recently and cannot be sent again yet. Retry after `retry_after_seconds`. | | `embed_origin_not_allowed` | 422 | `embed_origin` is not a registered, enabled origin for this business. | | `forbidden_field` | 422 | The request sets a field this endpoint does not accept. | | `idempotency_key_spent` | 409 | The payment recovery link this `Idempotency-Key` created has expired or was used. Send a new key. | | `insufficient_seller_balance` | 422 | The seller's balance cannot fund a refund right now. | | `invalid_method` | 403 | The credential is not authorized for this method on this route. | | `invalid_redirect_url` | 422 | `success_url` or `cancel_url` is not a registered redirect URL. | | `invalid_route` | 403 | The credential is not authorized for this route. | | `invalid_signature` | 401 | The request could not be authenticated. | | `missing_idempotency_key` | 400 | The operation requires an `Idempotency-Key` header and none was sent. | | `missing_tax_location` | 422 | The buyer's tax location is missing, so tax could not be calculated. | | `mixed_seller_cart` | 422 | The products are sold by different sellers and cannot be bought in one checkout. | | `mixed_trial_cart` | 422 | A product with a free trial is bought on its own and cannot share a checkout with other products. | | `mixed_vat_mode_cart` | 422 | The products are taxed under different VAT modes and cannot be bought in one checkout. | | `no_processor_id` | 422 | The payment carries no processor reference, so it cannot be refunded. | | `not_saleable` | 422 | A product or payment plan cannot be bought; the error's `block_reason` says why. | | `payment_fully_refunded` | 422 | The payment is already fully refunded. | | `payment_not_found` | 422 | The payment could not be loaded. | | `payment_not_sale` | 422 | Only a sale can be refunded. | | `payment_not_succeeded` | 422 | The payment never succeeded, so it cannot be refunded. | | `payment_provider_unconfirmed` | 502 | The payment provider did not confirm the change. Read the subscription before retrying. | | `payment_recovery_not_available` | 422 | The subscription cannot take a new payment method through a link: it is not trialing, active or overdue. | | `paypal_merchant_not_found` | 422 | The seller no longer has an active PayPal account connected to COPE. | | `plan_not_available` | 422 | The subscription cannot be moved to that plan. | | `preview_failed` | 422 | The offer's tax preview could not be calculated. | | `product_has_active_offers` | 422 | The product has open offers and cannot be deleted. | | `product_has_orders` | 422 | The product has orders and cannot be deleted. | | `product_location_conflict` | 409 | A concurrent request added the same ship-from address. Retry the request. | | `product_not_approved` | 422 | The product must be approved before it can be published. | | `product_unavailable` | 422 | The product cannot be sold now. | | `promo_code_conflict` | 409 | A concurrent request changed this promo code's products. Retry the request. | | `refund_amount_must_be_positive` | 422 | The refund amount must be greater than zero. | | `refund_exceeds_limit` | 422 | The amount is more than is left to refund on this payment. | | `refund_in_progress` | 503 | Another refund of this payment is in progress, so no refund was attempted. Retry shortly. | | `refund_not_available` | 422 | The payment cannot be refunded; `detail` says why. | | `refund_recording_failed` | 502 | The processor executed the refund but it could not be recorded. Retry the exact same request. | | `refund_rejected` | 502 | The processor did not confirm the refund; nothing was refunded. | | `refund_window_expired` | 422 | The refund window for this payment has closed. | | `reserved_metadata_key` | 422 | `metadata` holds a key COPE reserves for itself. | | `sale_not_yet_booked` | 503 | The sale is not yet recorded in the ledger, so no refund was attempted. Retry shortly. | | `seller_balance_unavailable` | 503 | The seller's balance could not be confirmed, so no refund was attempted. Retry shortly. | | `subscription_not_eligible` | 422 | The subscription cannot be changed this way in its current state. | | `tax_address_invalid` | 422 | Tax could not be calculated for this address. | | `tax_calculation_failed` | 500 | Tax could not be calculated. | | `tax_provider_failed` | 424 | The tax provider could not calculate tax. | | `tax_request_rejected` | 422 | The tax provider rejected the request. | | `tax_service_unavailable` | 503 | Tax calculation is temporarily unavailable. Retry with backoff. | | `too_close_to_renewal` | 422 | The subscription's next renewal is 60 minutes away or less, or already due, so this change is refused until that renewal has billed. | | `too_many_payment_recovery_links` | 429 | Ten payment recovery links were created for this subscription in the last 24 hours. | | `unsupported_checkout_locale` | 422 | The checkout language is not one COPE supports. | | `unsupported_media_type` | 415 | The body was sent as a media type this endpoint does not read. | | `upload_not_completed` | 409 | The upload has not finished. | | `validation_error` | 422 | The request failed validation; `errors[]` names each field. | | `vendor_not_payout_eligible` | 422 | The business cannot take payments yet. | ## Request IDs Every response from the API carries an `X-Request-Id` header, and every error body repeats it as `request_id`. Send your own `X-Request-Id` (1 to 128 letters, digits, `_`, `@` or `-`) to have COPE use it; otherwise COPE generates one. Quote it when you contact support. A replayed write, one answered from an earlier request with the same `Idempotency-Key`, carries `Idempotent-Replayed: true`. ## Send a User-Agent Send a `User-Agent` header on every request; any value that names your integration will do, such as `my-shop-sync/1.4`. COPE's network edge may refuse a request without one before it reaches the API: the response is a `403` whose body is not `application/problem+json` and which carries no `X-Request-Id`. Most HTTP clients send a `User-Agent` by default; set one explicitly if yours does not. # List invoices Source: https://docs.cope.com/api-reference/invoices/list-invoices /api-reference/commerce-v1.openapi.json get /v1/commerce/invoices Requires the `payments` permission at `read`. An API key holds a permission at the lower of its own level (`read` for a read-only key) and its holder's role; a key without it is refused with 403. # Retrieve an invoice Source: https://docs.cope.com/api-reference/invoices/retrieve-an-invoice /api-reference/commerce-v1.openapi.json get /v1/commerce/invoices/{id} Requires the `payments` permission at `read`. An API key holds a permission at the lower of its own level (`read` for a read-only key) and its holder's role; a key without it is refused with 403. # List public webhook event types Source: https://docs.cope.com/api-reference/list-public-webhook-event-types /api-reference/account-platform-webhooks-v1.openapi.json get /v1/webhooks/event-types # List webhook deliveries Source: https://docs.cope.com/api-reference/list-webhook-deliveries /api-reference/account-platform-webhooks-v1.openapi.json get /v1/webhooks/deliveries # List webhook endpoint event subscriptions Source: https://docs.cope.com/api-reference/list-webhook-endpoint-event-subscriptions /api-reference/account-platform-webhooks-v1.openapi.json get /v1/webhooks/endpoints/{id}/event-subscriptions # List webhook endpoints Source: https://docs.cope.com/api-reference/list-webhook-endpoints /api-reference/account-platform-webhooks-v1.openapi.json get /v1/webhooks/endpoints # Cancel an offer Source: https://docs.cope.com/api-reference/offers/cancel-an-offer /api-reference/commerce-v1.openapi.json post /v1/commerce/offers/{id}/cancel Cancels an `active` offer and returns it. The buyer's link stops offering checkout and shows a cancelled offer instead, so a cancelled offer can no longer be paid. Only an `active` offer can be cancelled: one already ordered, already cancelled, or lapsed is refused with 422 `invalid_state`. Cancellation is final — there is no re-activation, and a new offer has to be created. The optional `cancellation_reason` is stored with the offer and read back as `cancelled_reason`. It is for your own records; nothing is sent to the buyer. It is the only member the body accepts: any other member, any parameter sent in the query string, and a `cancellation_reason` that is not a string (`null` included) are refused with 400 `invalid_request`, and a reason longer than 500 characters with 422 `validation_failed`. Nothing is cancelled when a request is refused. Requires the `orders` permission at `write`. An API key holds a permission at the lower of its own level (`read` for a read-only key) and its holder's role; a key without it is refused with 403. # Create an offer Source: https://docs.cope.com/api-reference/offers/create-an-offer /api-reference/commerce-v1.openapi.json post /v1/commerce/offers Prices one product for one named buyer and returns a private checkout link made out to them. The price, the quantity and the buyer are settled here and are read-only on the offer page, so everything the order will need has to be supplied in this request. The offer accepts the payment methods the product already accepts; they cannot be chosen per offer. Creating an offer does not notify the buyer — the link comes back as `public_url` and is yours to send. The body is read exactly as written. A member this reference does not list, at any depth, is refused with 400 `invalid_request` rather than ignored, and so is a value of the wrong JSON type — `"24900"` is not read as the integer 24900 — and any parameter sent in the query string. The one member read without being listed is the name the first edition of this reference gave `product_id`, still accepted in its place. An explicit `null` for any member, at any depth, is read as leaving it out. A body that names no `product_id` is a 400 too; 404 means the product named is not one you can sell. ### Choosing a payment plan `pricing.plan_type` decides the rest of the body. Send the fields its row asks for; every other field under `pricing` is optional under all three plan types. | `plan_type` | What the buyer is charged | Send alongside `plan_type` and `price_minor_units` | | --- | --- | --- | | `one_time` | `price_minor_units`, once. | nothing | | `subscription` | `price_minor_units` now, then `recurring_amount_minor_units` every billing period until the subscription is cancelled. | `recurring_amount_minor_units`, `interval`, `interval_count` | | `installment` | `price_minor_units` now, then `recurring_amount_minor_units` every billing period until `installment_count` payments have been made in total, counting the first. | `recurring_amount_minor_units`, `interval`, `interval_count`, `installment_count` | The billing period is `interval` × `interval_count` — `month` × 3 bills quarterly — and a single period may not be longer than two years. `second_payment_in`, `trial_days`, `shipping_price_minor_units` and `custom_plan_name` stay optional under every plan type. `installment` is accepted only from sellers enabled for installment sales; `one_time` and `subscription` are open to every seller. The `currency` is the one line in the examples below that is not yours to copy: it must be one the seller can actually be paid in, which means a currency COPE charges in that is also the currency of one of the seller's payout bank accounts. The currencies of the product's own payment plans are not considered. The examples are priced in EUR, and a seller whose payout accounts are all in USD is refused with 422 `validation_failed`, `errors[].param` `pricing.currency`, naming the currencies they can use — no offer is created. Send theirs. Without `pricing.trial_days`, the buyer gets the product's own free trial (`trial_period_days`), whatever the `plan_type`, `one_time` included. Send `trial_days: 0` for no trial. ### Opening the offer inside your own page By default the buyer follows `public_url`, which redirects them to the offer's checkout on COPE. Send `embed_origin` instead and the same checkout can be framed in your own page: the offer comes back with an `embed_url` and `embed_origin` echoing the one origin allowed to frame it. Both are absent — not null — on an offer that cannot be framed, and `public_url` keeps working either way. Hand both to the Checkout SDK's `mountCheckout` rather than building the iframe yourself: the framed page waits for a mount handshake from its parent before it starts, so a bare `