# Mercemur Docs
Mercemur gives every merchant three doors into the same store: a REST API to call
from code, an MCP server so an AI agent can act on it directly, and a CLI to edit a
storefront as files on your own machine. All three are governed by the same secret
key and the same scopes, one grant, whichever door you use.
## Start here
574 operations across catalogue, orders, customers, pricing, and money. Call it
from any platform that can send an HTTP request.
Point an AI client, Claude Desktop, an IDE, another agent, at one endpoint and it
can read and write your live storefront.
Pull your storefront to disk, edit it in your own editor with live preview, and
publish when you're ready.
REST API base URL for every request: `https://api.mercemur.com/api/v1` · MCP
endpoint: `https://mcp.mercemur.com/mcp`
## The REST API in detail
Create a key and make your first call in under five minutes.
Every endpoint, with a playground you can fire against your own store.
Understand throttling and how to back off correctly.
## Authentication and security
Secret keys, how to create them, and how to rotate one safely.
Read, write and delete are separate grants. 154 scopes across 68 families.
One envelope for every refusal, at every status.
## Making requests
Every write takes an `Idempotency-Key`. Retry safely.
Cursor paging, forward only, signed and bound to the route that issued it.
Every amount is an integer in the currency's minor unit.
## The four things that are not guessable from one endpoint
If you read nothing else, read these. They are the conventions that a single
example request will not teach you, and each one has bitten an integration.
`1999` in a `usd` field is 19.99 USD. There are no fractional amounts anywhere
in this API, and no field accepts a decimal. Currencies with no minor unit,
such as JPY, take the whole number directly. See [Money](/requests/money).
`write_products` does **not** let a key read your catalogue, and deleting is a
third grant again: `write_products:delete`. A key that keeps records up to date
cannot destroy them unless you tick Delete as well. See [Scopes](/authentication/scopes).
Not optional, and not only for retries. A request without the header is refused
with `idempotency_key_required`. Replaying the same key returns the stored
response rather than executing twice. See [Idempotency](/requests/idempotency).
There is no `page` or `offset` parameter. You send `?after=` with the
`page.next_cursor` from the previous response **for that same endpoint**. A
cursor from a different collection is refused. See [Pagination](/requests/pagination).
## Branch on `code`, never on `message`
Every refusal on this API, at every status, has the same body:
```json
{
"error": {
"code": "insufficient_scope",
"message": "this api key requires the write_products scope"
}
}
```
The `code` is the contract and is safe to switch on. The `message` is English prose
for a human reading a log, and its wording is not part of this contract. See
[Error envelope](/errors/envelope).
# Replace the store's assistant configuration
`PUT /api/v1/agent-config`
## Headers
- `Idempotency-Key` (string, required) — A unique key per logical write. Replaying a request with the same key returns the first response byte for byte instead of applying the write twice.
## Request body
Required.
- `expected_updated_at` (string | null, required) — The updated_at you last read. Required, because the config is a singleton written by this route AND by the merchant's dashboard: a write naming no version silently reverts whatever moved under it and answers 200 to both parties. A mismatch is 409 config_modified. null asserts that this store has never saved a config, which is the only way a first write can name a version that does not exist, and it is refused once a row does exist.
- `enabled` (boolean, required) — The master switch. The storefront widget renders on exactly this, so false means shoppers see nothing whatever else is set.
- `agent_name` (string, required) — The assistant's display name, at most 60 characters. "" for the default.
- `greeting` (string, required) — The opening line, at most 280 characters. "" for the default.
- `persona_instructions` (string, required) — The merchant's voice, at most 2000 characters. It shapes TONE only: the server appends its safety rules on top, so a persona can never remove a guardrail.
- `follow_up_questions` (boolean, required) — Switches on a server-authored block that asks clarifying questions.
- `objection_handling` (boolean, required) — Switches on a server-authored block that answers hesitation.
- `handoff_message` (string, required) — What the shopper is told when a conversation goes to a human, at most 280 characters. "" for the built-in text.
- `skill_product_discovery` (boolean, required) — Gates search, recommendation and product detail together. GROUPED rather than one toggle per tool, because an assistant that could recommend a product but not detail it is half broken in a way no single switch names.
- `skill_add_to_cart` (boolean, required) — Gates reading and writing the shopper's cart, together.
- `skill_order_status` (boolean, required) — Gates order lookup.
- `suggested_prompts` (array of string, required) — The merchant's starter chips. Send [] for none; the key is required either way, because dropping it would clear them. NORMALISED RATHER THAN REFUSED on write: at most six, each truncated to 80 characters, blanks dropped. Read the response back rather than assuming what you sent was stored verbatim.
## Responses
- `200` — Success
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the write_sales_agent scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `409` — The request is well formed and the store's current state refuses it.
EVERY WRITE CAN ANSWER TWO OF THESE, whatever it does:
`idempotency_key_reused`, this Idempotency-Key already served a different
method, path or body. The key namespace is per store and not per endpoint, so a
key built from a business id collides across routes; use a fresh key per
logical write.
`idempotency_key_in_progress`, an identical request is still running. Retry
after a short delay; exactly one of the racing calls will have applied.
`not_configured` means the merchant has not set something up yet, with
`resource` naming what. The remaining codes are the per-route state rules named
on the operation.
- `413` — The request body exceeded the cap named in the message. `code` is
`payload_too_large`. Nothing was read and nothing was recorded, so the same
Idempotency-Key may be reused once the body is smaller.
- `415` — The body was not declared as `application/json`. `code` is
`unsupported_media_type`.
This API reads ONE media type. The `+json` structured suffixes are refused
too, because they name semantics (merge-patch in particular) this API does
not implement, and reading such a body as plain JSON would be a silent
misreading. A write that carries NO body needs no Content-Type at all.
- `422` — An id INSIDE the request resolves to nothing on this store. `code` is
`unprocessable_reference`, `resource` names the kind of thing that did not
resolve and `field` names where it arrived, so the fix is mechanical.
Distinct from 404, which is about the url, and from 400, which is about the
bytes. The message stays generic about WHY the id did not resolve: an id owned
by another merchant must read identically to one that never existed.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request PUT \
--url 'https://api.mercemur.com/api/v1/agent-config' \
--header 'Authorization: Bearer '
```
# Retrieve agent config
`GET /api/v1/agent-config`
How this store's assistant is configured: whether it runs at all, its name, greeting and persona, the two instruction directives, the three skill groups, and the merchant's starter chips. A SINGLETON, so there is no id and no page block. A STORE THAT HAS NEVER CONFIGURED THE ASSISTANT IS NOT A 404. It answers the documented defaults, which are what the assistant is actually running with: enabled true, no custom voice, both directives and all three skills on. Its updated_at is null, because there is no row to have a version, and that null is what you send back as expected_updated_at on your first write. enabled is the whole gate. The storefront widget renders on exactly this, so false means shoppers see nothing whatever else is set. persona_instructions is published here and withheld from the storefront's own shopper-facing config. It shapes tone only: the server always appends its safety rules on top, so a persona can never remove a guardrail.
## Responses
- `200` — Success
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the read_sales_agent scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request GET \
--url 'https://api.mercemur.com/api/v1/agent-config' \
--header 'Authorization: Bearer '
```
# List a conversation's messages
`GET /api/v1/agent-conversations/{conversationId}/messages`
One conversation's transcript, OLDEST FIRST. This is the only list on this API that ascends, and it ascends because a transcript has one legible order: a client reading newest-first would have to buffer the whole thread before it could render a single exchange in sequence. TOOL TURNS ARE NEVER SERVED. The assistant's internal tool calls are how an answer was produced rather than part of the conversation, and they are excluded in the query so a page is never short. role is user for the shopper and assistant for the store. A HUMAN staff reply is stored as assistant too, deliberately, so the shopper's widget renders it as a message from the store; read author_user_id to tell a person's answer from the assistant's. rating is the shopper's own 1-5 stars, and null when they have not rated the reply. It is never 0.
## Path parameters
- `conversationId` (string, required)
## Query parameters
- `limit` (integer) — Rows per page. Out of range is a 400 rather than a silent clamp, so a client asking for more than 100 learns it did not get it.
- `after` (string) — The next_cursor from the previous page. Opaque: decode nothing from it and construct nothing by hand, since its encoding is not part of this contract. Omit it to read the first page.
## Responses
- `200` — Success
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the read_sales_agent scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `404` — The resource this url addresses does not exist, or never did on this store.
`resource` names the kind of thing that was missing and is the half to branch
on: the code is `not_found` on newer routes and a per-entity spelling on
routes that shipped before that rule, and the two mean the same thing.
A 404 is ALWAYS about the url. An id inside the request body that resolves to
nothing is 422 `unprocessable_reference` instead, so the two cases stay
distinguishable. An id that belongs to a different merchant reads exactly like
one that never existed.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request GET \
--url 'https://api.mercemur.com/api/v1/agent-conversations/{conversationId}/messages' \
--header 'Authorization: Bearer '
```
# List agent conversations
`GET /api/v1/agent-conversations`
Every chat a shopper has had with this store's AI assistant, newest first. ONE LIST COVERS THE WHOLE INBOX. The dashboard shows active by default, hides closed, and offers a third "all" mode; here that is ?status=, and omitting it returns everything. PAGED BY CREATION TIME, NOT BY updated_at, even though the dashboard sorts on updated_at. Every reply, takeover, assignment and status change rewrites that column, so a client walking the list while shoppers are chatting would skip conversations that jumped ahead of its position and repeat ones that fell behind it. created_at never moves. THE TRANSCRIPT IS NOT EMBEDDED. A conversation's message count is unbounded, so an inline array would be a page with no cursor. Read /api/v1/agent-conversations/{conversationId}/messages. external_id is deliberately not published. It is the shopper's WhatsApp or Instagram handle, and you can already answer them through the messages route, which delivers on their channel AND records the reply in the merchant's own transcript.
## Query parameters
- `status` (active | closed) — active is the merchant's working inbox, closed is the archive. Omit it for both, which the dashboard can only ask for as status=all. A value outside this set is a 400 rather than an ignored filter, because a closed conversation served as part of an unfiltered page reads as one still waiting on a reply.
- `handoff_state` (bot | human) — human is the queue that matters operationally: the assistant has stopped answering those and a real person is waiting.
- `channel` (website | whatsapp | instagram) — Where the shopper reached this store. It also decides where a reply is delivered.
- `assigned_to` (string) — One teammate's conversations, by store user id. The id is CHECKED against the store roster: a user who is not a member is a 400, not an empty page, because an empty page is indistinguishable from "this teammate has no conversations" and a filter naming a renamed or offboarded teammate would otherwise report no work forever. An EMPTY value is a 400 rather than "no filter": a client building the query from a variable it forgot to set would otherwise receive the whole inbox and read it as one person's workload. There is no way to ask for the unassigned ones here.
- `updated_after` (string (date-time)) — Conversations touched at or after this RFC3339 instant, for reconciling incrementally instead of re-reading the whole list. Supplying it CHANGES THE ORDER of this endpoint: the default walk descends created_at, and this one climbs updated_at, because that is the only ordering in which a keyset walk over a column every reply rewrites cannot skip a row. A conversation that changes mid-walk moves forward past your position and is returned again, so the walk is AT LEAST ONCE: apply the state of each row you receive and a repeat costs nothing. A cursor from one ordering is refused by the other, since the same position means something different in each.
- `limit` (integer) — Rows per page. Out of range is a 400 rather than a silent clamp, so a client asking for more than 100 learns it did not get it.
- `after` (string) — The next_cursor from the previous page. Opaque: decode nothing from it and construct nothing by hand, since its encoding is not part of this contract. Omit it to read the first page.
## Responses
- `200` — Success
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the read_sales_agent scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request GET \
--url 'https://api.mercemur.com/api/v1/agent-conversations' \
--header 'Authorization: Bearer '
```
# Replace a conversation's status, handoff and owner
`PUT /api/v1/agent-conversations/{conversationId}`
## Path parameters
- `conversationId` (string, required)
## Headers
- `Idempotency-Key` (string, required) — A unique key per logical write. Replaying a request with the same key returns the first response byte for byte instead of applying the write twice.
## Request body
Required.
- `status` (active | closed, required) — closed is BOOKKEEPING, not deletion. The transcript, the owner and the handoff state all survive it and reopening restores the conversation to the merchant's inbox. It is the reversible archive this family offers instead of a destructive delete, and there is no delete on a conversation at all.
- `handoff_state` (bot | human, required) — Who is REPLYING. human means the assistant STOPS ANSWERING that shopper: nothing replies until a person writes one, so setting it is a commitment rather than a label. Setting it does NOT assign the conversation to anybody, which is the one place this differs from the dashboard's take-over button: that button assigns to whoever clicked it, and an api key is not a person.
- `assigned_to` (string | null, required) — Who OWNS the conversation, by store user id, or null for nobody. Ownership, not takeover. REQUIRED AS A KEY even though its value may be null, because a full replace that dropped it would silently take the teammate who owns a thread off it and answer 200. The id is checked against this store's roster; a user from another store is a 400 invalid_assignee.
## Responses
- `200` — Success
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the write_sales_agent scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `404` — The resource this url addresses does not exist, or never did on this store.
`resource` names the kind of thing that was missing and is the half to branch
on: the code is `not_found` on newer routes and a per-entity spelling on
routes that shipped before that rule, and the two mean the same thing.
A 404 is ALWAYS about the url. An id inside the request body that resolves to
nothing is 422 `unprocessable_reference` instead, so the two cases stay
distinguishable. An id that belongs to a different merchant reads exactly like
one that never existed.
- `409` — The request is well formed and the store's current state refuses it.
EVERY WRITE CAN ANSWER TWO OF THESE, whatever it does:
`idempotency_key_reused`, this Idempotency-Key already served a different
method, path or body. The key namespace is per store and not per endpoint, so a
key built from a business id collides across routes; use a fresh key per
logical write.
`idempotency_key_in_progress`, an identical request is still running. Retry
after a short delay; exactly one of the racing calls will have applied.
`not_configured` means the merchant has not set something up yet, with
`resource` naming what. The remaining codes are the per-route state rules named
on the operation.
- `413` — The request body exceeded the cap named in the message. `code` is
`payload_too_large`. Nothing was read and nothing was recorded, so the same
Idempotency-Key may be reused once the body is smaller.
- `415` — The body was not declared as `application/json`. `code` is
`unsupported_media_type`.
This API reads ONE media type. The `+json` structured suffixes are refused
too, because they name semantics (merge-patch in particular) this API does
not implement, and reading such a body as plain JSON would be a silent
misreading. A write that carries NO body needs no Content-Type at all.
- `422` — An id INSIDE the request resolves to nothing on this store. `code` is
`unprocessable_reference`, `resource` names the kind of thing that did not
resolve and `field` names where it arrived, so the fix is mechanical.
Distinct from 404, which is about the url, and from 400, which is about the
bytes. The message stays generic about WHY the id did not resolve: an id owned
by another merchant must read identically to one that never existed.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request PUT \
--url 'https://api.mercemur.com/api/v1/agent-conversations/{conversationId}' \
--header 'Authorization: Bearer '
```
# Reply to a shopper as the store
`POST /api/v1/agent-conversations/{conversationId}/messages`
## Path parameters
- `conversationId` (string, required)
## Headers
- `Idempotency-Key` (string, required) — A unique key per logical write. Replaying a request with the same key returns the first response byte for byte instead of applying the write twice.
## Request body
Required.
- `content` (string, required) — The message text. Required and refused when blank: an empty reply is delivered to the shopper as an empty message rather than ignored.
- `author_user_id` (string | null) — The teammate this reply is from, by store user id, or null for an unattributed one. Optional, and null is the honest default for an automation: an api key is not a person. Name a real author when you are relaying one, because a shopper's star rating attributes to whoever is named here, and attributing a human's answer to the assistant folds it into the assistant's average. The id is checked against this store's roster.
## Responses
- `201` — Created
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the write_sales_agent scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `404` — The resource this url addresses does not exist, or never did on this store.
`resource` names the kind of thing that was missing and is the half to branch
on: the code is `not_found` on newer routes and a per-entity spelling on
routes that shipped before that rule, and the two mean the same thing.
A 404 is ALWAYS about the url. An id inside the request body that resolves to
nothing is 422 `unprocessable_reference` instead, so the two cases stay
distinguishable. An id that belongs to a different merchant reads exactly like
one that never existed.
- `409` — The request is well formed and the store's current state refuses it.
EVERY WRITE CAN ANSWER TWO OF THESE, whatever it does:
`idempotency_key_reused`, this Idempotency-Key already served a different
method, path or body. The key namespace is per store and not per endpoint, so a
key built from a business id collides across routes; use a fresh key per
logical write.
`idempotency_key_in_progress`, an identical request is still running. Retry
after a short delay; exactly one of the racing calls will have applied.
`not_configured` means the merchant has not set something up yet, with
`resource` naming what. The remaining codes are the per-route state rules named
on the operation.
- `413` — The request body exceeded the cap named in the message. `code` is
`payload_too_large`. Nothing was read and nothing was recorded, so the same
Idempotency-Key may be reused once the body is smaller.
- `415` — The body was not declared as `application/json`. `code` is
`unsupported_media_type`.
This API reads ONE media type. The `+json` structured suffixes are refused
too, because they name semantics (merge-patch in particular) this API does
not implement, and reading such a body as plain JSON would be a silent
misreading. A write that carries NO body needs no Content-Type at all.
- `422` — An id INSIDE the request resolves to nothing on this store. `code` is
`unprocessable_reference`, `resource` names the kind of thing that did not
resolve and `field` names where it arrived, so the fix is mechanical.
Distinct from 404, which is about the url, and from 400, which is about the
bytes. The message stays generic about WHY the id did not resolve: an id owned
by another merchant must read identically to one that never existed.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request POST \
--url 'https://api.mercemur.com/api/v1/agent-conversations/{conversationId}/messages' \
--header 'Authorization: Bearer '
```
# Retrieve an agent conversation
`GET /api/v1/agent-conversations/{conversationId}`
One conversation, without its messages. A conversation id that is not this store's is a 404.
## Path parameters
- `conversationId` (string, required)
## Responses
- `200` — Success
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the read_sales_agent scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `404` — The resource this url addresses does not exist, or never did on this store.
`resource` names the kind of thing that was missing and is the half to branch
on: the code is `not_found` on newer routes and a per-entity spelling on
routes that shipped before that rule, and the two mean the same thing.
A 404 is ALWAYS about the url. An id inside the request body that resolves to
nothing is 422 `unprocessable_reference` instead, so the two cases stay
distinguishable. An id that belongs to a different merchant reads exactly like
one that never existed.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request GET \
--url 'https://api.mercemur.com/api/v1/agent-conversations/{conversationId}' \
--header 'Authorization: Bearer '
```
# List agent knowledge sources
`GET /api/v1/agent-knowledge-sources`
What the merchant has taught the assistant: FAQ dumps and policy documents, newest first. THE SOURCE TEXT IS NOT PUBLISHED, here or anywhere. The stored row keeps a title and a chunk count; what the assistant answers from is the embedded chunks, and no copy of the original is kept to serve. Keep your own copy of anything you send. chunk_count is how many embedded pieces a source produced, which is the honest measure of how much the assistant learned from it. Zero means the ingest found nothing usable. This list covers only what the MERCHANT added. The store's own catalogue, pages and blog posts are indexed by a separate sweep and are not resources here.
## Query parameters
- `kind` (faq | doc) — faq is chunked as question and answer pairs, doc as prose under its title. Omit it for both. A value outside this set is a 400 rather than an ignored filter.
- `updated_after` (string (date-time)) — Sources touched at or after this RFC3339 instant, for reconciling a knowledge corpus incrementally instead of re-reading it on every run. It composes with kind. Supplying it CHANGES THE ORDER of this endpoint: the default walk descends created_at, and this one climbs updated_at. That difference is the whole point here, because updated_at on a source moves on RE-INGEST, which is the event you most need to hear about: the default walk is keyed on created_at precisely so a re-ingest cannot shuffle a row across a boundary you already passed, and the ascending walk is the ordering where that same movement is safe, since a row can only move forward past your position and be returned again. The walk is AT LEAST ONCE. A cursor from one ordering is refused by the other.
- `limit` (integer) — Rows per page. Out of range is a 400 rather than a silent clamp, so a client asking for more than 100 learns it did not get it.
- `after` (string) — The next_cursor from the previous page. Opaque: decode nothing from it and construct nothing by hand, since its encoding is not part of this contract. Omit it to read the first page.
## Responses
- `200` — Success
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the read_sales_agent scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request GET \
--url 'https://api.mercemur.com/api/v1/agent-knowledge-sources' \
--header 'Authorization: Bearer '
```
# Remove a knowledge source
`DELETE /api/v1/agent-knowledge-sources/{sourceId}`
Remove a knowledge source and the embedded chunks behind it. TAKES write_sales_agent:delete ON TOP OF write_sales_agent, and there is no reversible twin to offer instead. The row keeps a title and a chunk count and never the text, so the merchant's own FAQ or policy wording is gone with it and the only copy left is wherever they wrote it originally. What that looks like afterwards is worse than an error: the assistant keeps answering, confidently, from whatever remains, and a shopper asking about the deleted returns policy gets the model's guess instead of the merchant's words. 204 on success. A source id this store does not own is a 404 rather than a silent 204, so a mistyped id cannot read as a removal that never happened.
## Path parameters
- `sourceId` (string, required)
## Headers
- `Idempotency-Key` (string, required) — A unique key per logical write. Replaying a request with the same key returns the first response byte for byte instead of applying the write twice.
## Responses
- `204` — Success. The response has no body.
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks a required scope. `code` is `insufficient_scope`. This route is gated TWICE, on write_sales_agent and then on write_sales_agent:delete, and the message names whichever gate refused. A key holding neither is refused naming write_sales_agent, because that gate runs first: seeing the parent named does NOT mean the qualifier would have been enough. Ask the merchant for both. The qualifier cannot be granted on its own in any case, since it narrows the parent rather than replacing it.
- `404` — The resource this url addresses does not exist, or never did on this store.
`resource` names the kind of thing that was missing and is the half to branch
on: the code is `not_found` on newer routes and a per-entity spelling on
routes that shipped before that rule, and the two mean the same thing.
A 404 is ALWAYS about the url. An id inside the request body that resolves to
nothing is 422 `unprocessable_reference` instead, so the two cases stay
distinguishable. An id that belongs to a different merchant reads exactly like
one that never existed.
- `409` — The request is well formed and the store's current state refuses it.
EVERY WRITE CAN ANSWER TWO OF THESE, whatever it does:
`idempotency_key_reused`, this Idempotency-Key already served a different
method, path or body. The key namespace is per store and not per endpoint, so a
key built from a business id collides across routes; use a fresh key per
logical write.
`idempotency_key_in_progress`, an identical request is still running. Retry
after a short delay; exactly one of the racing calls will have applied.
`not_configured` means the merchant has not set something up yet, with
`resource` naming what. The remaining codes are the per-route state rules named
on the operation.
- `413` — The request body exceeded the cap named in the message. `code` is
`payload_too_large`. Nothing was read and nothing was recorded, so the same
Idempotency-Key may be reused once the body is smaller.
- `415` — The body was not declared as `application/json`. `code` is
`unsupported_media_type`.
This API reads ONE media type. The `+json` structured suffixes are refused
too, because they name semantics (merge-patch in particular) this API does
not implement, and reading such a body as plain JSON would be a silent
misreading. A write that carries NO body needs no Content-Type at all.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request DELETE \
--url 'https://api.mercemur.com/api/v1/agent-knowledge-sources/{sourceId}' \
--header 'Authorization: Bearer '
```
# Retrieve an agent knowledge source
`GET /api/v1/agent-knowledge-sources/{sourceId}`
One knowledge source. A source id that is not this store's is a 404.
## Path parameters
- `sourceId` (string, required)
## Responses
- `200` — Success
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the read_sales_agent scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `404` — The resource this url addresses does not exist, or never did on this store.
`resource` names the kind of thing that was missing and is the half to branch
on: the code is `not_found` on newer routes and a per-entity spelling on
routes that shipped before that rule, and the two mean the same thing.
A 404 is ALWAYS about the url. An id inside the request body that resolves to
nothing is 422 `unprocessable_reference` instead, so the two cases stay
distinguishable. An id that belongs to a different merchant reads exactly like
one that never existed.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request GET \
--url 'https://api.mercemur.com/api/v1/agent-knowledge-sources/{sourceId}' \
--header 'Authorization: Bearer '
```
# Teach the assistant a source
`POST /api/v1/agent-knowledge-sources`
## Headers
- `Idempotency-Key` (string, required) — A unique key per logical write. Replaying a request with the same key returns the first response byte for byte instead of applying the write twice.
## Request body
Required.
- `kind` (faq | doc, required) — faq is chunked as question and answer pairs, doc as prose under its title. REQUIRED WITH NO DEFAULT: guessing would chunk a policy document as question and answer pairs, and the merchant would find out months later from the answers the assistant gives.
- `title` (string, required) — How the merchant will recognise this source. At most 200 characters.
- `text` (string, required) — The source material, at most 100000 characters. Ingest input rather than a stored field.
## Responses
- `201` — Created
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the write_sales_agent scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `409` — The request is well formed and the store's current state refuses it.
EVERY WRITE CAN ANSWER TWO OF THESE, whatever it does:
`idempotency_key_reused`, this Idempotency-Key already served a different
method, path or body. The key namespace is per store and not per endpoint, so a
key built from a business id collides across routes; use a fresh key per
logical write.
`idempotency_key_in_progress`, an identical request is still running. Retry
after a short delay; exactly one of the racing calls will have applied.
`not_configured` means the merchant has not set something up yet, with
`resource` naming what. The remaining codes are the per-route state rules named
on the operation.
- `413` — The request body exceeded the cap named in the message. `code` is
`payload_too_large`. Nothing was read and nothing was recorded, so the same
Idempotency-Key may be reused once the body is smaller.
- `415` — The body was not declared as `application/json`. `code` is
`unsupported_media_type`.
This API reads ONE media type. The `+json` structured suffixes are refused
too, because they name semantics (merge-patch in particular) this API does
not implement, and reading such a body as plain JSON would be a silent
misreading. A write that carries NO body needs no Content-Type at all.
- `422` — An id INSIDE the request resolves to nothing on this store. `code` is
`unprocessable_reference`, `resource` names the kind of thing that did not
resolve and `field` names where it arrived, so the fix is mechanical.
Distinct from 404, which is about the url, and from 400, which is about the
bytes. The message stays generic about WHY the id did not resolve: an id owned
by another merchant must read identically to one that never existed.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request POST \
--url 'https://api.mercemur.com/api/v1/agent-knowledge-sources' \
--header 'Authorization: Bearer '
```
# List agent messages
`GET /api/v1/agent-messages`
Every agent message in the store, newest first, each carrying the conversation it belongs to. THIS IS THE BATCH TRANSCRIPT READ. Without the filter it is a single paged sweep across ALL conversations, so reconciling a store's chat history is one walk that you group by conversation_id yourself, NOT one request per thread. An audit of this API reported a missing batch route on the assumption that transcripts could only be read one conversation at a time; they cannot, and this is the route that already answers it. ?conversation_id= narrows it to a single thread when that is what you want. An EMPTY value is refused rather than read as "every conversation", because a client building the query from a variable it forgot to set would otherwise receive the whole store's transcript and read it as one thread. PAIR IT WITH GET /api/v1/agent-conversations, which carries the thread's status, assignee and handoff state. This route carries the words; that one carries what the thread IS.
## Query parameters
- `conversation_id` (string) — One conversation's turns. Omit it to read every conversation in the store, which is what this endpoint exists for: the per-conversation transcript was the only way to read messages, so reconciling N conversations cost 1+N requests against a rate budget this whole family shares. An EMPTY value is a 400 rather than "no filter", so a client building the query from a variable it forgot to set does not receive the whole store's transcript and read it as one thread.
- `limit` (integer) — Rows per page. Out of range is a 400 rather than a silent clamp, so a client asking for more than 100 learns it did not get it.
- `after` (string) — The next_cursor from the previous page. Opaque: decode nothing from it and construct nothing by hand, since its encoding is not part of this contract. Omit it to read the first page.
## Responses
- `200` — Success
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the read_sales_agent scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request GET \
--url 'https://api.mercemur.com/api/v1/agent-messages' \
--header 'Authorization: Bearer '
```
# Create a blog category
`POST /api/v1/blog-categories`
## Headers
- `Idempotency-Key` (string, required) — A unique key per logical write. Replaying a request with the same key returns the first response byte for byte instead of applying the write twice.
## Request body
Required.
- `slug` (string, required) — Required. NORMALISED server-side to lowercase letters, digits and single hyphens, so the stored value may differ from what you sent; read it back from the response rather than assuming. Unique per store.
- `name` (string, required) — Required. Trimmed, and a blank name is a 400.
- `description` (string | null) — Optional. Null and absent mean the same thing here, since there is nothing stored to leave alone.
- `sort_order` (integer) — Optional, defaults to 0, which is what every category has until a merchant orders them. It is the storefront widget's display ordering and NOT the order the list pages in: that is (created_at, id), because this field is rewritten by the patch and a walk over it would drop or repeat a row mid-sync. Sort on it client-side.
## Responses
- `201` — Created
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the write_blogs scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `409` — The request is well formed and the store's current state refuses it.
EVERY WRITE CAN ANSWER TWO OF THESE, whatever it does:
`idempotency_key_reused`, this Idempotency-Key already served a different
method, path or body. The key namespace is per store and not per endpoint, so a
key built from a business id collides across routes; use a fresh key per
logical write.
`idempotency_key_in_progress`, an identical request is still running. Retry
after a short delay; exactly one of the racing calls will have applied.
`not_configured` means the merchant has not set something up yet, with
`resource` naming what. The remaining codes are the per-route state rules named
on the operation.
- `413` — The request body exceeded the cap named in the message. `code` is
`payload_too_large`. Nothing was read and nothing was recorded, so the same
Idempotency-Key may be reused once the body is smaller.
- `415` — The body was not declared as `application/json`. `code` is
`unsupported_media_type`.
This API reads ONE media type. The `+json` structured suffixes are refused
too, because they name semantics (merge-patch in particular) this API does
not implement, and reading such a body as plain JSON would be a silent
misreading. A write that carries NO body needs no Content-Type at all.
- `422` — An id INSIDE the request resolves to nothing on this store. `code` is
`unprocessable_reference`, `resource` names the kind of thing that did not
resolve and `field` names where it arrived, so the fix is mechanical.
Distinct from 404, which is about the url, and from 400, which is about the
bytes. The message stays generic about WHY the id did not resolve: an id owned
by another merchant must read identically to one that never existed.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request POST \
--url 'https://api.mercemur.com/api/v1/blog-categories' \
--header 'Authorization: Bearer '
```
# List blog categories
`GET /api/v1/blog-categories`
The store's blog categories: the navigation labels posts are filed under. This is what makes the category id inlined on every post dereferenceable, which is the reason a bare category_id scalar was refused on the post resource. NO VISIBILITY GATE, unlike /blog-posts. A draft post is unreleased editorial; a category is a label with no draft state and no status column, so there is nothing here to withhold from a key that can already page the posts naming it inline. THE INLINE REFERENCE ON A POST IS DELIBERATELY NARROWER and stays that way: it carries id, slug and name, and the rest of the category lives here. Publishing the whole category in both places would freeze two representations of one relationship, and neither could then be withdrawn. sort_order IS NOT THE PAGING ORDER. This list pages on (created_at, id), because sort_order and name are both rewritten by PATCH /blog-categories/{blogCategoryId} and a walk over either drops or repeats a row when an edit crosses a page boundary mid-sync. Sort on sort_order client-side. THERE IS NO post_count AND NO posts ARRAY. A category with 2,000 posts would serialise 2,000 ids into one row of a list, and a count would mean published posts under read_blogs and every post under write_blogs, so one field would mean two things. Page GET /api/v1/blog-posts instead; every post names its category.
## Query parameters
- `updated_after` (string (date-time)) — Blog categories touched at or after this RFC3339 instant, for reconciling incrementally instead of re-reading the whole list. Supplying it CHANGES THE ORDER of this endpoint: the default walk descends created_at, and this one climbs updated_at, because that is the only ordering in which a keyset walk over a column the merchant keeps rewriting cannot skip a row. A RENAME IS THE COMMON CASE here: the slug is what a storefront URL carries and PATCH rewrites it freely, so a client that misses one keeps publishing links that no longer resolve. A category edited mid-walk moves forward past your position and is returned again, so the walk is AT LEAST ONCE: apply the state of each row you receive and a repeat costs nothing. The bound is INCLUSIVE, so resuming from the newest updated_at you hold re-delivers the rows sharing that instant rather than dropping the ones your last page did not reach. A cursor belongs to ONE ordering and is refused by the other.
- `limit` (integer) — Rows per page. Out of range is a 400 rather than a silent clamp, so a client asking for more than 100 learns it did not get it.
- `after` (string) — The next_cursor from the previous page. Opaque: decode nothing from it and construct nothing by hand, since its encoding is not part of this contract. Omit it to read the first page.
## Responses
- `200` — Success
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the read_blogs scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request GET \
--url 'https://api.mercemur.com/api/v1/blog-categories' \
--header 'Authorization: Bearer '
```
# Retrieve a blog category
`GET /api/v1/blog-categories/{blogCategoryId}`
One blog category, keyed on the IMMUTABLE id rather than the slug. The patch route rewrites slugs freely, so a slug-addressed route would publish an identifier that stops resolving the moment a merchant renames a category. THE SAME SHAPE THE LIST SERVES, and the same shape both writes answer with, so a row taken off a page can be re-read on its own. A 404 IS DELIBERATELY GENERIC and covers three conditions at once: no such id, an id belonging to another store, and a malformed id. Separating them would make this route an existence oracle over another merchant's category ids.
## Path parameters
- `blogCategoryId` (string, required)
## Responses
- `200` — Success
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the read_blogs scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `404` — The resource this url addresses does not exist, or never did on this store.
`resource` names the kind of thing that was missing and is the half to branch
on: the code is `not_found` on newer routes and a per-entity spelling on
routes that shipped before that rule, and the two mean the same thing.
A 404 is ALWAYS about the url. An id inside the request body that resolves to
nothing is 422 `unprocessable_reference` instead, so the two cases stay
distinguishable. An id that belongs to a different merchant reads exactly like
one that never existed.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request GET \
--url 'https://api.mercemur.com/api/v1/blog-categories/{blogCategoryId}' \
--header 'Authorization: Bearer '
```
# Update a blog category
`PATCH /api/v1/blog-categories/{blogCategoryId}`
## Path parameters
- `blogCategoryId` (string, required)
## Headers
- `Idempotency-Key` (string, required) — A unique key per logical write. Replaying a request with the same key returns the first response byte for byte instead of applying the write twice.
## Request body
Required.
- `slug` (string) — Normalised server-side. Renaming it CHANGES THE STOREFRONT URL for this category, and nothing redirects the old one.
- `name` (string) — Trimmed, and a blank name is a 400.
- `description` (string | null) — Send null to clear it. Omit to leave it alone.
- `sort_order` (integer) — Not nullable here. Omit it to leave the ordering alone.
- `expected_updated_at` (string (date-time)) — OPTIONAL precondition. Send back the updated_at you read and the write is refused with 409 category_modified if the category moved since, instead of silently reverting whoever edited it in between. Omit it to keep last-write-wins. It is compared at the precision you send, so a millisecond timestamp satisfies a microsecond one.
## Responses
- `200` — Success
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the write_blogs scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `404` — The resource this url addresses does not exist, or never did on this store.
`resource` names the kind of thing that was missing and is the half to branch
on: the code is `not_found` on newer routes and a per-entity spelling on
routes that shipped before that rule, and the two mean the same thing.
A 404 is ALWAYS about the url. An id inside the request body that resolves to
nothing is 422 `unprocessable_reference` instead, so the two cases stay
distinguishable. An id that belongs to a different merchant reads exactly like
one that never existed.
- `409` — The request is well formed and the store's current state refuses it.
EVERY WRITE CAN ANSWER TWO OF THESE, whatever it does:
`idempotency_key_reused`, this Idempotency-Key already served a different
method, path or body. The key namespace is per store and not per endpoint, so a
key built from a business id collides across routes; use a fresh key per
logical write.
`idempotency_key_in_progress`, an identical request is still running. Retry
after a short delay; exactly one of the racing calls will have applied.
`not_configured` means the merchant has not set something up yet, with
`resource` naming what. The remaining codes are the per-route state rules named
on the operation.
- `413` — The request body exceeded the cap named in the message. `code` is
`payload_too_large`. Nothing was read and nothing was recorded, so the same
Idempotency-Key may be reused once the body is smaller.
- `415` — The body was not declared as `application/json`. `code` is
`unsupported_media_type`.
This API reads ONE media type. The `+json` structured suffixes are refused
too, because they name semantics (merge-patch in particular) this API does
not implement, and reading such a body as plain JSON would be a silent
misreading. A write that carries NO body needs no Content-Type at all.
- `422` — An id INSIDE the request resolves to nothing on this store. `code` is
`unprocessable_reference`, `resource` names the kind of thing that did not
resolve and `field` names where it arrived, so the fix is mechanical.
Distinct from 404, which is about the url, and from 400, which is about the
bytes. The message stays generic about WHY the id did not resolve: an id owned
by another merchant must read identically to one that never existed.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request PATCH \
--url 'https://api.mercemur.com/api/v1/blog-categories/{blogCategoryId}' \
--header 'Authorization: Bearer '
```
# Archive a blog post
`POST /api/v1/blog-posts/{postId}/archive`
## Path parameters
- `postId` (string, required)
## Headers
- `Idempotency-Key` (string, required) — A unique key per logical write. Replaying a request with the same key returns the first response byte for byte instead of applying the write twice.
## Request body
Type: object
## Responses
- `200` — Success
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the write_blogs scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `404` — The resource this url addresses does not exist, or never did on this store.
`resource` names the kind of thing that was missing and is the half to branch
on: the code is `not_found` on newer routes and a per-entity spelling on
routes that shipped before that rule, and the two mean the same thing.
A 404 is ALWAYS about the url. An id inside the request body that resolves to
nothing is 422 `unprocessable_reference` instead, so the two cases stay
distinguishable. An id that belongs to a different merchant reads exactly like
one that never existed.
- `409` — The request is well formed and the store's current state refuses it.
EVERY WRITE CAN ANSWER TWO OF THESE, whatever it does:
`idempotency_key_reused`, this Idempotency-Key already served a different
method, path or body. The key namespace is per store and not per endpoint, so a
key built from a business id collides across routes; use a fresh key per
logical write.
`idempotency_key_in_progress`, an identical request is still running. Retry
after a short delay; exactly one of the racing calls will have applied.
`not_configured` means the merchant has not set something up yet, with
`resource` naming what. The remaining codes are the per-route state rules named
on the operation.
- `413` — The request body exceeded the cap named in the message. `code` is
`payload_too_large`. Nothing was read and nothing was recorded, so the same
Idempotency-Key may be reused once the body is smaller.
- `415` — The body was not declared as `application/json`. `code` is
`unsupported_media_type`.
This API reads ONE media type. The `+json` structured suffixes are refused
too, because they name semantics (merge-patch in particular) this API does
not implement, and reading such a body as plain JSON would be a silent
misreading. A write that carries NO body needs no Content-Type at all.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request POST \
--url 'https://api.mercemur.com/api/v1/blog-posts/{postId}/archive' \
--header 'Authorization: Bearer '
```
# Create a blog post
`POST /api/v1/blog-posts`
## Headers
- `Idempotency-Key` (string, required) — A unique key per logical write. Replaying a request with the same key returns the first response byte for byte instead of applying the write twice.
## Request body
Required.
- `slug` (string, required) — The storefront path segment. Unique per store.
- `title` (string, required)
- `excerpt` (string | null)
- `body` (object | null) — A ProseMirror JSON document, NOT html and not a string. It is stored byte for byte after a size check: there is no node allowlist, no mark allowlist and no URL scheme check inside it, so anything rendering it must apply its own.
- `cover_image_url` (string | null) — An absolute http(s) url under 2048 characters.
- `author_name` (string | null)
- `author_bio` (string | null)
- `tags` (array of string)
- `reading_time_minutes` (integer | null) — Merchant-supplied. Nothing computes it.
- `seo_meta_title` (string | null)
- `seo_meta_description` (string | null)
- `seo_og_image_url` (string | null)
- `category_id` (string | null) — A blog category in this store. An id from another store is a 400 rather than a filed post.
## Responses
- `201` — Created
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the write_blogs scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `409` — The request is well formed and the store's current state refuses it.
EVERY WRITE CAN ANSWER TWO OF THESE, whatever it does:
`idempotency_key_reused`, this Idempotency-Key already served a different
method, path or body. The key namespace is per store and not per endpoint, so a
key built from a business id collides across routes; use a fresh key per
logical write.
`idempotency_key_in_progress`, an identical request is still running. Retry
after a short delay; exactly one of the racing calls will have applied.
`not_configured` means the merchant has not set something up yet, with
`resource` naming what. The remaining codes are the per-route state rules named
on the operation.
- `413` — The request body exceeded the cap named in the message. `code` is
`payload_too_large`. Nothing was read and nothing was recorded, so the same
Idempotency-Key may be reused once the body is smaller.
- `415` — The body was not declared as `application/json`. `code` is
`unsupported_media_type`.
This API reads ONE media type. The `+json` structured suffixes are refused
too, because they name semantics (merge-patch in particular) this API does
not implement, and reading such a body as plain JSON would be a silent
misreading. A write that carries NO body needs no Content-Type at all.
- `422` — An id INSIDE the request resolves to nothing on this store. `code` is
`unprocessable_reference`, `resource` names the kind of thing that did not
resolve and `field` names where it arrived, so the fix is mechanical.
Distinct from 404, which is about the url, and from 400, which is about the
bytes. The message stays generic about WHY the id did not resolve: an id owned
by another merchant must read identically to one that never existed.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request POST \
--url 'https://api.mercemur.com/api/v1/blog-posts' \
--header 'Authorization: Bearer '
```
# List blog posts
`GET /api/v1/blog-posts`
## Query parameters
- `slug` (string) — Resolves a storefront URL segment to a post. Unique per store, so it returns at most one row.
- `status` (draft | published | archived) — Posts in one state. REQUIRES write_blogs, because it selects among a store's unpublished work; a key holding read_blogs alone receives a 403 rather than a silently published-only page. An unrecognised value is a 400 naming the accepted set.
- `updated_after` (string (date-time)) — Posts touched at or after this RFC3339 instant, for reconciling incrementally instead of re-reading every post body on every sync. Supplying it CHANGES THE ORDER of this endpoint: the default walk descends created_at, and this one climbs updated_at. It is NOT ordered by published_at, which is the field you would reach for first and the one ordering that cannot work: unpublishing clears it and republishing re-stamps it, so a keyset walk over published_at moves a row backwards across your cursor and drops it. updated_at is rewritten by those same actions but only ever forwards, so a post edited mid-walk moves forward past your position and is returned again. The walk is AT LEAST ONCE: apply the state of each row you receive and a repeat costs nothing, while a miss means serving stale body content you have no way to discover is stale. THE VISIBILITY GATE STILL APPLIES: a read_blogs key walks published posts only, exactly as on the default list, and drafts never appear on either. The bound is INCLUSIVE, so resuming from the newest updated_at you hold re-delivers the rows sharing that instant. A cursor belongs to ONE ordering and is refused by the other.
- `limit` (integer) — Rows per page. Out of range is a 400 rather than a silent clamp, so a client asking for more than 100 learns it did not get it.
- `after` (string) — The next_cursor from the previous page. Opaque: decode nothing from it and construct nothing by hand, since its encoding is not part of this contract. Omit it to read the first page.
## Responses
- `200` — Success
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the read_blogs scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request GET \
--url 'https://api.mercemur.com/api/v1/blog-posts' \
--header 'Authorization: Bearer '
```
# Publish a blog post
`POST /api/v1/blog-posts/{postId}/publish`
## Path parameters
- `postId` (string, required)
## Headers
- `Idempotency-Key` (string, required) — A unique key per logical write. Replaying a request with the same key returns the first response byte for byte instead of applying the write twice.
## Request body
Type: object
## Responses
- `200` — Success
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the write_blogs scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `404` — The resource this url addresses does not exist, or never did on this store.
`resource` names the kind of thing that was missing and is the half to branch
on: the code is `not_found` on newer routes and a per-entity spelling on
routes that shipped before that rule, and the two mean the same thing.
A 404 is ALWAYS about the url. An id inside the request body that resolves to
nothing is 422 `unprocessable_reference` instead, so the two cases stay
distinguishable. An id that belongs to a different merchant reads exactly like
one that never existed.
- `409` — The request is well formed and the store's current state refuses it.
EVERY WRITE CAN ANSWER TWO OF THESE, whatever it does:
`idempotency_key_reused`, this Idempotency-Key already served a different
method, path or body. The key namespace is per store and not per endpoint, so a
key built from a business id collides across routes; use a fresh key per
logical write.
`idempotency_key_in_progress`, an identical request is still running. Retry
after a short delay; exactly one of the racing calls will have applied.
`not_configured` means the merchant has not set something up yet, with
`resource` naming what. The remaining codes are the per-route state rules named
on the operation.
- `413` — The request body exceeded the cap named in the message. `code` is
`payload_too_large`. Nothing was read and nothing was recorded, so the same
Idempotency-Key may be reused once the body is smaller.
- `415` — The body was not declared as `application/json`. `code` is
`unsupported_media_type`.
This API reads ONE media type. The `+json` structured suffixes are refused
too, because they name semantics (merge-patch in particular) this API does
not implement, and reading such a body as plain JSON would be a silent
misreading. A write that carries NO body needs no Content-Type at all.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request POST \
--url 'https://api.mercemur.com/api/v1/blog-posts/{postId}/publish' \
--header 'Authorization: Bearer '
```
# Retrieve a blog post
`GET /api/v1/blog-posts/{postId}`
## Path parameters
- `postId` (string, required)
## Responses
- `200` — Success
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the read_blogs scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `404` — The resource this url addresses does not exist, or never did on this store.
`resource` names the kind of thing that was missing and is the half to branch
on: the code is `not_found` on newer routes and a per-entity spelling on
routes that shipped before that rule, and the two mean the same thing.
A 404 is ALWAYS about the url. An id inside the request body that resolves to
nothing is 422 `unprocessable_reference` instead, so the two cases stay
distinguishable. An id that belongs to a different merchant reads exactly like
one that never existed.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request GET \
--url 'https://api.mercemur.com/api/v1/blog-posts/{postId}' \
--header 'Authorization: Bearer '
```
# Unpublish a blog post
`POST /api/v1/blog-posts/{postId}/unpublish`
## Path parameters
- `postId` (string, required)
## Headers
- `Idempotency-Key` (string, required) — A unique key per logical write. Replaying a request with the same key returns the first response byte for byte instead of applying the write twice.
## Request body
Type: object
## Responses
- `200` — Success
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the write_blogs scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `404` — The resource this url addresses does not exist, or never did on this store.
`resource` names the kind of thing that was missing and is the half to branch
on: the code is `not_found` on newer routes and a per-entity spelling on
routes that shipped before that rule, and the two mean the same thing.
A 404 is ALWAYS about the url. An id inside the request body that resolves to
nothing is 422 `unprocessable_reference` instead, so the two cases stay
distinguishable. An id that belongs to a different merchant reads exactly like
one that never existed.
- `409` — The request is well formed and the store's current state refuses it.
EVERY WRITE CAN ANSWER TWO OF THESE, whatever it does:
`idempotency_key_reused`, this Idempotency-Key already served a different
method, path or body. The key namespace is per store and not per endpoint, so a
key built from a business id collides across routes; use a fresh key per
logical write.
`idempotency_key_in_progress`, an identical request is still running. Retry
after a short delay; exactly one of the racing calls will have applied.
`not_configured` means the merchant has not set something up yet, with
`resource` naming what. The remaining codes are the per-route state rules named
on the operation.
- `413` — The request body exceeded the cap named in the message. `code` is
`payload_too_large`. Nothing was read and nothing was recorded, so the same
Idempotency-Key may be reused once the body is smaller.
- `415` — The body was not declared as `application/json`. `code` is
`unsupported_media_type`.
This API reads ONE media type. The `+json` structured suffixes are refused
too, because they name semantics (merge-patch in particular) this API does
not implement, and reading such a body as plain JSON would be a silent
misreading. A write that carries NO body needs no Content-Type at all.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request POST \
--url 'https://api.mercemur.com/api/v1/blog-posts/{postId}/unpublish' \
--header 'Authorization: Bearer '
```
# Update a blog post
`PATCH /api/v1/blog-posts/{postId}`
## Path parameters
- `postId` (string, required)
## Headers
- `Idempotency-Key` (string, required) — A unique key per logical write. Replaying a request with the same key returns the first response byte for byte instead of applying the write twice.
## Request body
Required.
- `expected_updated_at` (string (date-time))
- `slug` (string)
- `title` (string)
- `excerpt` (string | null)
- `body` (object | null)
- `cover_image_url` (string | null)
- `author_name` (string | null)
- `author_bio` (string | null)
- `tags` (array of string)
- `reading_time_minutes` (integer)
- `seo_meta_title` (string | null)
- `seo_meta_description` (string | null)
- `seo_og_image_url` (string | null)
- `category_id` (string | null)
## Responses
- `200` — Success
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the write_blogs scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `404` — The resource this url addresses does not exist, or never did on this store.
`resource` names the kind of thing that was missing and is the half to branch
on: the code is `not_found` on newer routes and a per-entity spelling on
routes that shipped before that rule, and the two mean the same thing.
A 404 is ALWAYS about the url. An id inside the request body that resolves to
nothing is 422 `unprocessable_reference` instead, so the two cases stay
distinguishable. An id that belongs to a different merchant reads exactly like
one that never existed.
- `409` — The request is well formed and the store's current state refuses it.
EVERY WRITE CAN ANSWER TWO OF THESE, whatever it does:
`idempotency_key_reused`, this Idempotency-Key already served a different
method, path or body. The key namespace is per store and not per endpoint, so a
key built from a business id collides across routes; use a fresh key per
logical write.
`idempotency_key_in_progress`, an identical request is still running. Retry
after a short delay; exactly one of the racing calls will have applied.
`not_configured` means the merchant has not set something up yet, with
`resource` naming what. The remaining codes are the per-route state rules named
on the operation.
- `413` — The request body exceeded the cap named in the message. `code` is
`payload_too_large`. Nothing was read and nothing was recorded, so the same
Idempotency-Key may be reused once the body is smaller.
- `415` — The body was not declared as `application/json`. `code` is
`unsupported_media_type`.
This API reads ONE media type. The `+json` structured suffixes are refused
too, because they name semantics (merge-patch in particular) this API does
not implement, and reading such a body as plain JSON would be a silent
misreading. A write that carries NO body needs no Content-Type at all.
- `422` — An id INSIDE the request resolves to nothing on this store. `code` is
`unprocessable_reference`, `resource` names the kind of thing that did not
resolve and `field` names where it arrived, so the fix is mechanical.
Distinct from 404, which is about the url, and from 400, which is about the
bytes. The message stays generic about WHY the id did not resolve: an id owned
by another merchant must read identically to one that never existed.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request PATCH \
--url 'https://api.mercemur.com/api/v1/blog-posts/{postId}' \
--header 'Authorization: Bearer '
```
# Add a component variant to a bundle
`POST /api/v1/bundles/{bundleId}/items`
## Path parameters
- `bundleId` (string, required)
## Headers
- `Idempotency-Key` (string, required) — A unique key per logical write. Replaying a request with the same key returns the first response byte for byte instead of applying the write twice.
## Request body
Required.
- `variant_id` (string, required) — Required. A product variant in THIS store, the same id the products resource publishes inside its variants array. It is checked under Row-Level Security rather than by a foreign key alone, so a variant belonging to another merchant reads as absent and answers 422 variant_not_found rather than resolving. A bundle id that names nothing is a 404 instead, so the two halves of the URL are distinguishable.
- `quantity` (integer, required) — Required, with no default. How many of this variant ONE bundle contains, never a stock figure and never a number of bundles. An omitted quantity would read as zero, which the column refuses, so it is asked for rather than guessed. A value outside the range is a 400.
## Responses
- `200` — Success
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the write_bundles scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `404` — The resource this url addresses does not exist, or never did on this store.
`resource` names the kind of thing that was missing and is the half to branch
on: the code is `not_found` on newer routes and a per-entity spelling on
routes that shipped before that rule, and the two mean the same thing.
A 404 is ALWAYS about the url. An id inside the request body that resolves to
nothing is 422 `unprocessable_reference` instead, so the two cases stay
distinguishable. An id that belongs to a different merchant reads exactly like
one that never existed.
- `409` — The request is well formed and the store's current state refuses it.
EVERY WRITE CAN ANSWER TWO OF THESE, whatever it does:
`idempotency_key_reused`, this Idempotency-Key already served a different
method, path or body. The key namespace is per store and not per endpoint, so a
key built from a business id collides across routes; use a fresh key per
logical write.
`idempotency_key_in_progress`, an identical request is still running. Retry
after a short delay; exactly one of the racing calls will have applied.
`not_configured` means the merchant has not set something up yet, with
`resource` naming what. The remaining codes are the per-route state rules named
on the operation.
- `413` — The request body exceeded the cap named in the message. `code` is
`payload_too_large`. Nothing was read and nothing was recorded, so the same
Idempotency-Key may be reused once the body is smaller.
- `415` — The body was not declared as `application/json`. `code` is
`unsupported_media_type`.
This API reads ONE media type. The `+json` structured suffixes are refused
too, because they name semantics (merge-patch in particular) this API does
not implement, and reading such a body as plain JSON would be a silent
misreading. A write that carries NO body needs no Content-Type at all.
- `422` — An id INSIDE the request resolves to nothing on this store. `code` is
`unprocessable_reference`, `resource` names the kind of thing that did not
resolve and `field` names where it arrived, so the fix is mechanical.
Distinct from 404, which is about the url, and from 400, which is about the
bytes. The message stays generic about WHY the id did not resolve: an id owned
by another merchant must read identically to one that never existed.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request POST \
--url 'https://api.mercemur.com/api/v1/bundles/{bundleId}/items' \
--header 'Authorization: Bearer '
```
# Change how many of a variant a bundle contains
`PATCH /api/v1/bundles/{bundleId}/items/{variantId}`
## Path parameters
- `bundleId` (string, required)
- `variantId` (string, required)
## Headers
- `Idempotency-Key` (string, required) — A unique key per logical write. Replaying a request with the same key returns the first response byte for byte instead of applying the write twice.
## Request body
Required.
- `quantity` (integer, required) — Required. How many of the variant named in the path ONE bundle contains. There is no way to say zero: the column refuses it, and removing a component is not published on this API.
## Responses
- `200` — Success
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the write_bundles scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `404` — The resource this url addresses does not exist, or never did on this store.
`resource` names the kind of thing that was missing and is the half to branch
on: the code is `not_found` on newer routes and a per-entity spelling on
routes that shipped before that rule, and the two mean the same thing.
A 404 is ALWAYS about the url. An id inside the request body that resolves to
nothing is 422 `unprocessable_reference` instead, so the two cases stay
distinguishable. An id that belongs to a different merchant reads exactly like
one that never existed.
- `409` — The request is well formed and the store's current state refuses it.
EVERY WRITE CAN ANSWER TWO OF THESE, whatever it does:
`idempotency_key_reused`, this Idempotency-Key already served a different
method, path or body. The key namespace is per store and not per endpoint, so a
key built from a business id collides across routes; use a fresh key per
logical write.
`idempotency_key_in_progress`, an identical request is still running. Retry
after a short delay; exactly one of the racing calls will have applied.
`not_configured` means the merchant has not set something up yet, with
`resource` naming what. The remaining codes are the per-route state rules named
on the operation.
- `413` — The request body exceeded the cap named in the message. `code` is
`payload_too_large`. Nothing was read and nothing was recorded, so the same
Idempotency-Key may be reused once the body is smaller.
- `415` — The body was not declared as `application/json`. `code` is
`unsupported_media_type`.
This API reads ONE media type. The `+json` structured suffixes are refused
too, because they name semantics (merge-patch in particular) this API does
not implement, and reading such a body as plain JSON would be a silent
misreading. A write that carries NO body needs no Content-Type at all.
- `422` — An id INSIDE the request resolves to nothing on this store. `code` is
`unprocessable_reference`, `resource` names the kind of thing that did not
resolve and `field` names where it arrived, so the fix is mechanical.
Distinct from 404, which is about the url, and from 400, which is about the
bytes. The message stays generic about WHY the id did not resolve: an id owned
by another merchant must read identically to one that never existed.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request PATCH \
--url 'https://api.mercemur.com/api/v1/bundles/{bundleId}/items/{variantId}' \
--header 'Authorization: Bearer '
```
# Create a bundle
`POST /api/v1/bundles`
## Headers
- `Idempotency-Key` (string, required) — A unique key per logical write. Replaying a request with the same key returns the first response byte for byte instead of applying the write twice.
## Request body
Required.
- `title` (string, required) — Required, and TRUNCATED AT 200 BYTES rather than refused, matching the dashboard. A published API that silently shortens input has to admit it, so read the response back if your titles run long. Blank or whitespace is a 400.
- `price_minor` (integer, required) — Required. The bundle's AUTHORITATIVE set price in INTEGER MINOR UNITS of currency_code (1299 is 12.99 in a two-decimal currency), never derived from what the components are worth separately. THIS is the number a shopper is charged, and the cart allocates it across whatever components the bundle has at the time, so it is also what decides what each component contributes per unit.
- `currency_code` (string, required) — Required, and it is what makes price_minor readable. Accepted in any case and STORED LOWERCASE, so a client sending "USD" reads back "usd"; the read contract is already frozen on the stored form. Validated against the ISO 4217 catalogue, so an unknown code is a 400 rather than an unreadable amount.
- `status` (active | disabled) — Optional, defaulting to active, which is the column's own default. This is the reversible withdrawal this family offers instead of a delete: disabled takes the bundle out of sale and keeps every component, and one more patch puts it back.
## Responses
- `201` — Created
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the write_bundles scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `409` — The request is well formed and the store's current state refuses it.
EVERY WRITE CAN ANSWER TWO OF THESE, whatever it does:
`idempotency_key_reused`, this Idempotency-Key already served a different
method, path or body. The key namespace is per store and not per endpoint, so a
key built from a business id collides across routes; use a fresh key per
logical write.
`idempotency_key_in_progress`, an identical request is still running. Retry
after a short delay; exactly one of the racing calls will have applied.
`not_configured` means the merchant has not set something up yet, with
`resource` naming what. The remaining codes are the per-route state rules named
on the operation.
- `413` — The request body exceeded the cap named in the message. `code` is
`payload_too_large`. Nothing was read and nothing was recorded, so the same
Idempotency-Key may be reused once the body is smaller.
- `415` — The body was not declared as `application/json`. `code` is
`unsupported_media_type`.
This API reads ONE media type. The `+json` structured suffixes are refused
too, because they name semantics (merge-patch in particular) this API does
not implement, and reading such a body as plain JSON would be a silent
misreading. A write that carries NO body needs no Content-Type at all.
- `422` — An id INSIDE the request resolves to nothing on this store. `code` is
`unprocessable_reference`, `resource` names the kind of thing that did not
resolve and `field` names where it arrived, so the fix is mechanical.
Distinct from 404, which is about the url, and from 400, which is about the
bytes. The message stays generic about WHY the id did not resolve: an id owned
by another merchant must read identically to one that never existed.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request POST \
--url 'https://api.mercemur.com/api/v1/bundles' \
--header 'Authorization: Bearer '
```
# List bundles
`GET /api/v1/bundles`
## Query parameters
- `status` (string) — Bundles in one state. An unrecognised value is a 400 naming the accepted set rather than an empty page.
- `updated_after` (string (date-time)) — Bundles touched at or after this RFC3339 instant. A bundle's STATUS and its component set decide what a shopper can buy and at what price, and both are edited long after creation, so a cached copy keeps offering one the merchant has disabled or re-costed. Supplying it CHANGES THE ORDER of this endpoint: the default walk descends created_at, and this one climbs updated_at, which is the only ordering in which a keyset walk over a mutable column cannot skip a row. A bundle edited mid-walk moves forward past your position and is returned again, so the walk is AT LEAST ONCE. The bound is INCLUSIVE, so resuming from the newest updated_at you hold re-delivers the rows sharing that instant. A cursor belongs to ONE ordering and is refused by the other. THE ONE CAVEAT: this tracks the BUNDLE row, and the component join carries no timestamp of its own, so adding or removing a component does not move the bundle here unless the same write touches the parent. Reconcile components from the bundle's detail read.
- `limit` (integer) — Rows per page. Out of range is a 400 rather than a silent clamp, so a client asking for more than 100 learns it did not get it.
- `after` (string) — The next_cursor from the previous page. Opaque: decode nothing from it and construct nothing by hand, since its encoding is not part of this contract. Omit it to read the first page.
## Responses
- `200` — Success
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the read_bundles scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request GET \
--url 'https://api.mercemur.com/api/v1/bundles' \
--header 'Authorization: Bearer '
```
# Remove a component from a bundle
`DELETE /api/v1/bundles/{bundleId}/items/{variantId}`
## Path parameters
- `bundleId` (string, required)
- `variantId` (string, required)
## Headers
- `Idempotency-Key` (string, required) — A unique key per logical write. Replaying a request with the same key returns the first response byte for byte instead of applying the write twice.
## Request body
Type: object
## Responses
- `200` — Success
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks a required scope. `code` is `insufficient_scope`. This route is gated TWICE, on write_bundles and then on write_bundles:delete, and the message names whichever gate refused. A key holding neither is refused naming write_bundles, because that gate runs first: seeing the parent named does NOT mean the qualifier would have been enough. Ask the merchant for both. The qualifier cannot be granted on its own in any case, since it narrows the parent rather than replacing it.
- `404` — The resource this url addresses does not exist, or never did on this store.
`resource` names the kind of thing that was missing and is the half to branch
on: the code is `not_found` on newer routes and a per-entity spelling on
routes that shipped before that rule, and the two mean the same thing.
A 404 is ALWAYS about the url. An id inside the request body that resolves to
nothing is 422 `unprocessable_reference` instead, so the two cases stay
distinguishable. An id that belongs to a different merchant reads exactly like
one that never existed.
- `409` — The request is well formed and the store's current state refuses it.
EVERY WRITE CAN ANSWER TWO OF THESE, whatever it does:
`idempotency_key_reused`, this Idempotency-Key already served a different
method, path or body. The key namespace is per store and not per endpoint, so a
key built from a business id collides across routes; use a fresh key per
logical write.
`idempotency_key_in_progress`, an identical request is still running. Retry
after a short delay; exactly one of the racing calls will have applied.
`not_configured` means the merchant has not set something up yet, with
`resource` naming what. The remaining codes are the per-route state rules named
on the operation.
- `413` — The request body exceeded the cap named in the message. `code` is
`payload_too_large`. Nothing was read and nothing was recorded, so the same
Idempotency-Key may be reused once the body is smaller.
- `415` — The body was not declared as `application/json`. `code` is
`unsupported_media_type`.
This API reads ONE media type. The `+json` structured suffixes are refused
too, because they name semantics (merge-patch in particular) this API does
not implement, and reading such a body as plain JSON would be a silent
misreading. A write that carries NO body needs no Content-Type at all.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request DELETE \
--url 'https://api.mercemur.com/api/v1/bundles/{bundleId}/items/{variantId}' \
--header 'Authorization: Bearer '
```
# Retrieve a bundle
`GET /api/v1/bundles/{bundleId}`
## Path parameters
- `bundleId` (string, required)
## Responses
- `200` — Success
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the read_bundles scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `404` — The resource this url addresses does not exist, or never did on this store.
`resource` names the kind of thing that was missing and is the half to branch
on: the code is `not_found` on newer routes and a per-entity spelling on
routes that shipped before that rule, and the two mean the same thing.
A 404 is ALWAYS about the url. An id inside the request body that resolves to
nothing is 422 `unprocessable_reference` instead, so the two cases stay
distinguishable. An id that belongs to a different merchant reads exactly like
one that never existed.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request GET \
--url 'https://api.mercemur.com/api/v1/bundles/{bundleId}' \
--header 'Authorization: Bearer '
```
# Update a bundle's title, price, currency or status
`PATCH /api/v1/bundles/{bundleId}`
## Path parameters
- `bundleId` (string, required)
## Headers
- `Idempotency-Key` (string, required) — A unique key per logical write. Replaying a request with the same key returns the first response byte for byte instead of applying the write twice.
## Request body
Required.
- `title` (string) — Truncated at 200 bytes, as on the create. Present but blank or whitespace is a 400 naming the key rather than a stored empty title: omit the key to leave it unchanged.
- `price_minor` (integer) — The set price in INTEGER MINOR UNITS of the bundle's currency. Absolute, never a delta, and re-divided across the components at the next cart recompute.
- `currency_code` (string) — Stored lowercase and validated against the ISO 4217 catalogue. Present but blank is a 400. Re-denominating a bundle does NOT convert price_minor: the same integer is then read in the new currency's minor units, so send both keys together when you mean to move markets.
- `status` (active | disabled) — disabled withdraws the bundle from sale and keeps every component, which is this family's reversible stand-in for a delete. active puts it back.
## Responses
- `200` — Success
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the write_bundles scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `404` — The resource this url addresses does not exist, or never did on this store.
`resource` names the kind of thing that was missing and is the half to branch
on: the code is `not_found` on newer routes and a per-entity spelling on
routes that shipped before that rule, and the two mean the same thing.
A 404 is ALWAYS about the url. An id inside the request body that resolves to
nothing is 422 `unprocessable_reference` instead, so the two cases stay
distinguishable. An id that belongs to a different merchant reads exactly like
one that never existed.
- `409` — The request is well formed and the store's current state refuses it.
EVERY WRITE CAN ANSWER TWO OF THESE, whatever it does:
`idempotency_key_reused`, this Idempotency-Key already served a different
method, path or body. The key namespace is per store and not per endpoint, so a
key built from a business id collides across routes; use a fresh key per
logical write.
`idempotency_key_in_progress`, an identical request is still running. Retry
after a short delay; exactly one of the racing calls will have applied.
`not_configured` means the merchant has not set something up yet, with
`resource` naming what. The remaining codes are the per-route state rules named
on the operation.
- `413` — The request body exceeded the cap named in the message. `code` is
`payload_too_large`. Nothing was read and nothing was recorded, so the same
Idempotency-Key may be reused once the body is smaller.
- `415` — The body was not declared as `application/json`. `code` is
`unsupported_media_type`.
This API reads ONE media type. The `+json` structured suffixes are refused
too, because they name semantics (merge-patch in particular) this API does
not implement, and reading such a body as plain JSON would be a silent
misreading. A write that carries NO body needs no Content-Type at all.
- `422` — An id INSIDE the request resolves to nothing on this store. `code` is
`unprocessable_reference`, `resource` names the kind of thing that did not
resolve and `field` names where it arrived, so the fix is mechanical.
Distinct from 404, which is about the url, and from 400, which is about the
bytes. The message stays generic about WHY the id did not resolve: an id owned
by another merchant must read identically to one that never existed.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request PATCH \
--url 'https://api.mercemur.com/api/v1/bundles/{bundleId}' \
--header 'Authorization: Bearer '
```
# List carriers
`GET /api/v1/carriers`
## Query parameters
- `limit` (integer) — Rows per page. Out of range is a 400 rather than a silent clamp, so a client asking for more than 100 learns it did not get it.
- `after` (string) — The next_cursor from the previous page. Opaque: decode nothing from it and construct nothing by hand, since its encoding is not part of this contract. Omit it to read the first page.
## Responses
- `200` — Success
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the read_carriers scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request GET \
--url 'https://api.mercemur.com/api/v1/carriers' \
--header 'Authorization: Bearer '
```
# Retrieve a carrier
`GET /api/v1/carriers/{carrierCode}`
## Path parameters
- `carrierCode` (string, required)
## Responses
- `200` — Success
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the read_carriers scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `404` — The resource this url addresses does not exist, or never did on this store.
`resource` names the kind of thing that was missing and is the half to branch
on: the code is `not_found` on newer routes and a per-entity spelling on
routes that shipped before that rule, and the two mean the same thing.
A 404 is ALWAYS about the url. An id inside the request body that resolves to
nothing is 422 `unprocessable_reference` instead, so the two cases stay
distinguishable. An id that belongs to a different merchant reads exactly like
one that never existed.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request GET \
--url 'https://api.mercemur.com/api/v1/carriers/{carrierCode}' \
--header 'Authorization: Bearer '
```
# Lift a cart-recovery suppression
`DELETE /api/v1/cart-recovery-optouts/{email}`
## Path parameters
- `email` (string, required)
## Headers
- `Idempotency-Key` (string, required) — A unique key per logical write. Replaying a request with the same key returns the first response byte for byte instead of applying the write twice.
## Request body
Type: object
## Responses
- `204` — Success. The response has no body.
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the write_cart_recovery scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `404` — The resource this url addresses does not exist, or never did on this store.
`resource` names the kind of thing that was missing and is the half to branch
on: the code is `not_found` on newer routes and a per-entity spelling on
routes that shipped before that rule, and the two mean the same thing.
A 404 is ALWAYS about the url. An id inside the request body that resolves to
nothing is 422 `unprocessable_reference` instead, so the two cases stay
distinguishable. An id that belongs to a different merchant reads exactly like
one that never existed.
- `409` — The request is well formed and the store's current state refuses it.
EVERY WRITE CAN ANSWER TWO OF THESE, whatever it does:
`idempotency_key_reused`, this Idempotency-Key already served a different
method, path or body. The key namespace is per store and not per endpoint, so a
key built from a business id collides across routes; use a fresh key per
logical write.
`idempotency_key_in_progress`, an identical request is still running. Retry
after a short delay; exactly one of the racing calls will have applied.
`not_configured` means the merchant has not set something up yet, with
`resource` naming what. The remaining codes are the per-route state rules named
on the operation.
- `413` — The request body exceeded the cap named in the message. `code` is
`payload_too_large`. Nothing was read and nothing was recorded, so the same
Idempotency-Key may be reused once the body is smaller.
- `415` — The body was not declared as `application/json`. `code` is
`unsupported_media_type`.
This API reads ONE media type. The `+json` structured suffixes are refused
too, because they name semantics (merge-patch in particular) this API does
not implement, and reading such a body as plain JSON would be a silent
misreading. A write that carries NO body needs no Content-Type at all.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request DELETE \
--url 'https://api.mercemur.com/api/v1/cart-recovery-optouts/{email}' \
--header 'Authorization: Bearer '
```
# List cart recovery optouts
`GET /api/v1/cart-recovery-optouts`
The store's SUPPRESSION list: every address that asked this merchant to stop mailing them. It is published so you can honour the same suppressions in your own sending. It is not a mailing list, and treating it as a source of contactable people inverts its entire meaning. THERE IS NO GET BY ADDRESS because ?email= answers the same question better. "Is this address suppressed" returns an empty page when it is not, which is the correct answer; a 404 would be an error status for a perfectly normal outcome and every client would have to treat it as success. Addresses are stored lowercased and trimmed. Normalise the same way before comparing, or a mixed-case address reads as absent and mail goes to someone who asked a merchant to stop.
## Query parameters
- `email` (string) — Exact match, not a prefix search, so this list cannot be enumerated by guessing. It is how you ask whether one address is suppressed before a send: an address that is not returns an EMPTY PAGE rather than a 404, because "nobody suppressed" is a normal answer and not an error. The value is lowercased and trimmed before it is matched, so case does not matter here. A malformed address is also an empty page rather than a 400: on a filter that is a question with a correct answer.
- `reason` (unsubscribe | bounce | complaint | manual) — Filter by why the address was suppressed. An unrecognised value is a 400 rather than an empty page: "no address was suppressed for that reason" and "there is no such reason" are different facts, and a client told the former concludes the complaints it forwarded never arrived.
- `limit` (integer) — Rows per page. Out of range is a 400 rather than a silent clamp, so a client asking for more than 100 learns it did not get it.
- `after` (string) — The next_cursor from the previous page. Opaque: decode nothing from it and construct nothing by hand, since its encoding is not part of this contract. Omit it to read the first page.
## Responses
- `200` — Success
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the read_cart_recovery scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request GET \
--url 'https://api.mercemur.com/api/v1/cart-recovery-optouts' \
--header 'Authorization: Bearer '
```
# Suppress an address from cart-recovery mail
`POST /api/v1/cart-recovery-optouts`
Suppresses an address, so this store's recovery mail never reaches it again. This is how an ESP forwards its own unsubscribes, bounces and complaints into the store's list. RE-ADDING AN ALREADY-SUPPRESSED ADDRESS IS NOT AN ERROR and does not move it. You get back the ORIGINAL reason and timestamp, so a complaint recorded last month is not restamped as today's manual entry, and a webhook redelivery cannot turn into a retry storm. THERE IS NO WAY TO REMOVE A SUPPRESSION THROUGH THIS API, deliberately. Removing one re-enrols a person who explicitly asked to stop, so no scope buys it; the merchant can do it from their own dashboard.
## Headers
- `Idempotency-Key` (string, required) — A unique key per logical write. Replaying a request with the same key returns the first response byte for byte instead of applying the write twice.
## Request body
Required.
- `email` (string, required) — The address to suppress. Lowercased and trimmed before it is stored, so it will come back normalised whatever you send.
- `reason` (unsubscribe | bounce | complaint | manual, required) — Why the address is suppressed, and REQUIRED rather than defaulted. An unrecognised value is a 400 here, while the merchant's dashboard coerces one to "manual": that default is reasonable for a person typing in a form and a trap for a machine, because a misspelled or omitted "complaint" would file every complaint as a manual removal, the store's compliance export would report none, and nothing anywhere would say so. unsubscribe and complaint are the shopper's own decision and must be honoured everywhere; bounce is a delivery fact that may be revisited, and manual is the merchant's own entry.
## Responses
- `201` — Created
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the write_cart_recovery scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `409` — The request is well formed and the store's current state refuses it.
EVERY WRITE CAN ANSWER TWO OF THESE, whatever it does:
`idempotency_key_reused`, this Idempotency-Key already served a different
method, path or body. The key namespace is per store and not per endpoint, so a
key built from a business id collides across routes; use a fresh key per
logical write.
`idempotency_key_in_progress`, an identical request is still running. Retry
after a short delay; exactly one of the racing calls will have applied.
`not_configured` means the merchant has not set something up yet, with
`resource` naming what. The remaining codes are the per-route state rules named
on the operation.
- `413` — The request body exceeded the cap named in the message. `code` is
`payload_too_large`. Nothing was read and nothing was recorded, so the same
Idempotency-Key may be reused once the body is smaller.
- `415` — The body was not declared as `application/json`. `code` is
`unsupported_media_type`.
This API reads ONE media type. The `+json` structured suffixes are refused
too, because they name semantics (merge-patch in particular) this API does
not implement, and reading such a body as plain JSON would be a silent
misreading. A write that carries NO body needs no Content-Type at all.
- `422` — An id INSIDE the request resolves to nothing on this store. `code` is
`unprocessable_reference`, `resource` names the kind of thing that did not
resolve and `field` names where it arrived, so the fix is mechanical.
Distinct from 404, which is about the url, and from 400, which is about the
bytes. The message stays generic about WHY the id did not resolve: an id owned
by another merchant must read identically to one that never existed.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request POST \
--url 'https://api.mercemur.com/api/v1/cart-recovery-optouts' \
--header 'Authorization: Bearer '
```
# Replace the cart-recovery settings
`PUT /api/v1/cart-recovery-settings`
Replaces the whole programme document. Read it, edit what you received, send it back. THE CADENCE IS IN MINUTES and must strictly increase. The background scan spaces each stage from the PREVIOUS SEND rather than from the idle moment, so delays that are out of order produce a negative gap and the stage fires immediately after its predecessor, mailing one shopper three times in a minute. Out-of-order or non-positive delays are refused with 400.
## Headers
- `Idempotency-Key` (string, required) — A unique key per logical write. Replaying a request with the same key returns the first response byte for byte instead of applying the write twice.
## Request body
Required.
- `expected_updated_at` (string | null, required) — The updated_at you last read. Required, because these settings are a singleton written by this route AND by the merchant's dashboard: a write naming no version silently reverts whatever moved under it, answers 200 to both parties, and surfaces only as recovery mail on the old cadence hours later. A mismatch is 409 settings_modified. null asserts that this store has never saved settings, which is the only way a first write can name a version that does not exist, and it is refused once a row does exist.
- `enabled` (boolean, required) — The single switch. False and the background scan skips this store entirely, however good the cadence is.
- `stage1_minutes` (integer, required) — MINUTES after the cart goes idle for the first recovery email. Read as hours it would mail a shopper sixty times sooner than intended, which is why stage1_hours is refused by name.
- `stage2_minutes` (integer, required) — MINUTES after the cart goes idle for the second email. Must be greater than stage1_minutes.
- `stage3_minutes` (integer, required) — MINUTES after the cart goes idle for the third email. Must be greater than stage2_minutes. All three must be positive and STRICTLY INCREASING: the scan spaces each stage from the previous SEND, so a gap computed from out-of-order delays is negative and the stage fires immediately after its predecessor.
- `sender_name` (string | null, required) — The display name on the recovery email, null to fall back to the store's notification defaults. It is NOT the from address: that lives on the store's notification provider settings, which this family neither reads nor writes, and sender_email is refused by name for that reason.
- `discount_code` (string | null, required) — The promotion code the recovery email carries, null for none. One code per store, mailed in plaintext to every abandoning shopper, so it is published on the read as well.
## Responses
- `200` — Success
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the write_cart_recovery scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `409` — The request is well formed and the store's current state refuses it.
EVERY WRITE CAN ANSWER TWO OF THESE, whatever it does:
`idempotency_key_reused`, this Idempotency-Key already served a different
method, path or body. The key namespace is per store and not per endpoint, so a
key built from a business id collides across routes; use a fresh key per
logical write.
`idempotency_key_in_progress`, an identical request is still running. Retry
after a short delay; exactly one of the racing calls will have applied.
`not_configured` means the merchant has not set something up yet, with
`resource` naming what. The remaining codes are the per-route state rules named
on the operation.
- `413` — The request body exceeded the cap named in the message. `code` is
`payload_too_large`. Nothing was read and nothing was recorded, so the same
Idempotency-Key may be reused once the body is smaller.
- `415` — The body was not declared as `application/json`. `code` is
`unsupported_media_type`.
This API reads ONE media type. The `+json` structured suffixes are refused
too, because they name semantics (merge-patch in particular) this API does
not implement, and reading such a body as plain JSON would be a silent
misreading. A write that carries NO body needs no Content-Type at all.
- `422` — An id INSIDE the request resolves to nothing on this store. `code` is
`unprocessable_reference`, `resource` names the kind of thing that did not
resolve and `field` names where it arrived, so the fix is mechanical.
Distinct from 404, which is about the url, and from 400, which is about the
bytes. The message stays generic about WHY the id did not resolve: an id owned
by another merchant must read identically to one that never existed.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request PUT \
--url 'https://api.mercemur.com/api/v1/cart-recovery-settings' \
--header 'Authorization: Bearer '
```
# Retrieve cart recovery settings
`GET /api/v1/cart-recovery-settings`
The abandoned-cart programme: whether it is on, how long after a cart goes idle each of the three recovery emails is sent, and the sender name and discount code that mail carries. A store that has never saved settings reads back the DISABLED DEFAULT rather than a 404. The programme exists for every store and is off until switched on, and a 404 would say the feature is unavailable on this platform, which is a different and wrong conclusion.
## Responses
- `200` — Success
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the read_cart_recovery scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request GET \
--url 'https://api.mercemur.com/api/v1/cart-recovery-settings' \
--header 'Authorization: Bearer '
```
# Retrieve cart recovery stats
`GET /api/v1/cart-recovery-stats`
How many recovery emails were dispatched and how many of those carts came back, over the store's whole history. RECOVERED REVENUE IS DELIBERATELY NOT PUBLISHED. The stored amount carries no currency beside it, so in a multi-region store summing it adds one currency's minor units to another's and yields a single number no caller could tell was nonsense. Recovery RATE is derivable from these two counts, needs no currency, and is the figure a cadence is actually tuned against.
## Responses
- `200` — Success
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the read_cart_recovery scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request GET \
--url 'https://api.mercemur.com/api/v1/cart-recovery-stats' \
--header 'Authorization: Bearer '
```
# List carts
`GET /api/v1/carts`
## Query parameters
- `customer_id` (string) — Narrows the list to rows matching this customer_id. Omit it for every row. This route reads no query parameter beyond the ones listed here: an unrecognised one is a 400 rather than being ignored, and so is the same parameter sent twice.
- `status` (string) — Narrows the list to rows matching this status. Omit it for every row. This route reads no query parameter beyond the ones listed here: an unrecognised one is a 400 rather than being ignored, and so is the same parameter sent twice.
- `limit` (integer) — Rows per page. Out of range is a 400 rather than a silent clamp, so a client asking for more than 100 learns it did not get it.
- `after` (string) — The next_cursor from the previous page. Opaque: decode nothing from it and construct nothing by hand, since its encoding is not part of this contract. Omit it to read the first page.
## Responses
- `200` — Success
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the read_carts scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request GET \
--url 'https://api.mercemur.com/api/v1/carts' \
--header 'Authorization: Bearer '
```
# Retrieve a cart
`GET /api/v1/carts/{cartId}`
## Path parameters
- `cartId` (string, required)
## Responses
- `200` — Success
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the read_carts scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `404` — The resource this url addresses does not exist, or never did on this store.
`resource` names the kind of thing that was missing and is the half to branch
on: the code is `not_found` on newer routes and a per-entity spelling on
routes that shipped before that rule, and the two mean the same thing.
A 404 is ALWAYS about the url. An id inside the request body that resolves to
nothing is 422 `unprocessable_reference` instead, so the two cases stay
distinguishable. An id that belongs to a different merchant reads exactly like
one that never existed.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request GET \
--url 'https://api.mercemur.com/api/v1/carts/{cartId}' \
--header 'Authorization: Bearer '
```
# Create a category
`POST /api/v1/categories`
## Headers
- `Idempotency-Key` (string, required) — A unique key per logical write. Replaying a request with the same key returns the first response byte for byte instead of applying the write twice.
## Request body
Required.
- `name` (string, required)
- `handle` (string, required)
- `parent_id` (string | null) — Omit or send null for a root category. A category created here is INACTIVE, so it cannot appear under a hidden parent; activate it once its parent is visible.
## Responses
- `201` — Created
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the write_categories scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `409` — The request is well formed and the store's current state refuses it.
EVERY WRITE CAN ANSWER TWO OF THESE, whatever it does:
`idempotency_key_reused`, this Idempotency-Key already served a different
method, path or body. The key namespace is per store and not per endpoint, so a
key built from a business id collides across routes; use a fresh key per
logical write.
`idempotency_key_in_progress`, an identical request is still running. Retry
after a short delay; exactly one of the racing calls will have applied.
`not_configured` means the merchant has not set something up yet, with
`resource` naming what. The remaining codes are the per-route state rules named
on the operation.
- `413` — The request body exceeded the cap named in the message. `code` is
`payload_too_large`. Nothing was read and nothing was recorded, so the same
Idempotency-Key may be reused once the body is smaller.
- `415` — The body was not declared as `application/json`. `code` is
`unsupported_media_type`.
This API reads ONE media type. The `+json` structured suffixes are refused
too, because they name semantics (merge-patch in particular) this API does
not implement, and reading such a body as plain JSON would be a silent
misreading. A write that carries NO body needs no Content-Type at all.
- `422` — An id INSIDE the request resolves to nothing on this store. `code` is
`unprocessable_reference`, `resource` names the kind of thing that did not
resolve and `field` names where it arrived, so the fix is mechanical.
Distinct from 404, which is about the url, and from 400, which is about the
bytes. The message stays generic about WHY the id did not resolve: an id owned
by another merchant must read identically to one that never existed.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request POST \
--url 'https://api.mercemur.com/api/v1/categories' \
--header 'Authorization: Bearer '
```
# Delete a category
`DELETE /api/v1/categories/{categoryId}`
## Path parameters
- `categoryId` (string, required)
## Headers
- `Idempotency-Key` (string, required) — A unique key per logical write. Replaying a request with the same key returns the first response byte for byte instead of applying the write twice.
## Responses
- `204` — Success. The response has no body.
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks a required scope. `code` is `insufficient_scope`. This route is gated TWICE, on write_categories and then on write_categories:delete, and the message names whichever gate refused. A key holding neither is refused naming write_categories, because that gate runs first: seeing the parent named does NOT mean the qualifier would have been enough. Ask the merchant for both. The qualifier cannot be granted on its own in any case, since it narrows the parent rather than replacing it.
- `404` — The resource this url addresses does not exist, or never did on this store.
`resource` names the kind of thing that was missing and is the half to branch
on: the code is `not_found` on newer routes and a per-entity spelling on
routes that shipped before that rule, and the two mean the same thing.
A 404 is ALWAYS about the url. An id inside the request body that resolves to
nothing is 422 `unprocessable_reference` instead, so the two cases stay
distinguishable. An id that belongs to a different merchant reads exactly like
one that never existed.
- `409` — The request is well formed and the store's current state refuses it.
EVERY WRITE CAN ANSWER TWO OF THESE, whatever it does:
`idempotency_key_reused`, this Idempotency-Key already served a different
method, path or body. The key namespace is per store and not per endpoint, so a
key built from a business id collides across routes; use a fresh key per
logical write.
`idempotency_key_in_progress`, an identical request is still running. Retry
after a short delay; exactly one of the racing calls will have applied.
`not_configured` means the merchant has not set something up yet, with
`resource` naming what. The remaining codes are the per-route state rules named
on the operation.
- `413` — The request body exceeded the cap named in the message. `code` is
`payload_too_large`. Nothing was read and nothing was recorded, so the same
Idempotency-Key may be reused once the body is smaller.
- `415` — The body was not declared as `application/json`. `code` is
`unsupported_media_type`.
This API reads ONE media type. The `+json` structured suffixes are refused
too, because they name semantics (merge-patch in particular) this API does
not implement, and reading such a body as plain JSON would be a silent
misreading. A write that carries NO body needs no Content-Type at all.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request DELETE \
--url 'https://api.mercemur.com/api/v1/categories/{categoryId}' \
--header 'Authorization: Bearer '
```
# Hide a category from shoppers
`POST /api/v1/categories/{categoryId}/deactivate`
## Path parameters
- `categoryId` (string, required)
## Headers
- `Idempotency-Key` (string, required) — A unique key per logical write. Replaying a request with the same key returns the first response byte for byte instead of applying the write twice.
## Request body
Type: object
## Responses
- `200` — Success
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the write_categories scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `404` — The resource this url addresses does not exist, or never did on this store.
`resource` names the kind of thing that was missing and is the half to branch
on: the code is `not_found` on newer routes and a per-entity spelling on
routes that shipped before that rule, and the two mean the same thing.
A 404 is ALWAYS about the url. An id inside the request body that resolves to
nothing is 422 `unprocessable_reference` instead, so the two cases stay
distinguishable. An id that belongs to a different merchant reads exactly like
one that never existed.
- `409` — The request is well formed and the store's current state refuses it.
EVERY WRITE CAN ANSWER TWO OF THESE, whatever it does:
`idempotency_key_reused`, this Idempotency-Key already served a different
method, path or body. The key namespace is per store and not per endpoint, so a
key built from a business id collides across routes; use a fresh key per
logical write.
`idempotency_key_in_progress`, an identical request is still running. Retry
after a short delay; exactly one of the racing calls will have applied.
`not_configured` means the merchant has not set something up yet, with
`resource` naming what. The remaining codes are the per-route state rules named
on the operation.
- `413` — The request body exceeded the cap named in the message. `code` is
`payload_too_large`. Nothing was read and nothing was recorded, so the same
Idempotency-Key may be reused once the body is smaller.
- `415` — The body was not declared as `application/json`. `code` is
`unsupported_media_type`.
This API reads ONE media type. The `+json` structured suffixes are refused
too, because they name semantics (merge-patch in particular) this API does
not implement, and reading such a body as plain JSON would be a silent
misreading. A write that carries NO body needs no Content-Type at all.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request POST \
--url 'https://api.mercemur.com/api/v1/categories/{categoryId}/deactivate' \
--header 'Authorization: Bearer '
```
# List a category's products
`GET /api/v1/categories/{categoryId}/products`
## Path parameters
- `categoryId` (string, required)
## Query parameters
- `limit` (integer) — Rows per page. Out of range is a 400 rather than a silent clamp, so a client asking for more than 100 learns it did not get it.
- `after` (string) — The next_cursor from the previous page. Opaque: decode nothing from it and construct nothing by hand, since its encoding is not part of this contract. Omit it to read the first page.
## Responses
- `200` — Success
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the read_categories scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `404` — The resource this url addresses does not exist, or never did on this store.
`resource` names the kind of thing that was missing and is the half to branch
on: the code is `not_found` on newer routes and a per-entity spelling on
routes that shipped before that rule, and the two mean the same thing.
A 404 is ALWAYS about the url. An id inside the request body that resolves to
nothing is 422 `unprocessable_reference` instead, so the two cases stay
distinguishable. An id that belongs to a different merchant reads exactly like
one that never existed.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request GET \
--url 'https://api.mercemur.com/api/v1/categories/{categoryId}/products' \
--header 'Authorization: Bearer '
```
# List categories
`GET /api/v1/categories`
## Query parameters
- `is_active` (boolean) — Narrows to live or hidden categories. Read STRICTLY: exactly true or false, or omitted. An unrecognised value is a 400 rather than "no filter", because an integrator with a typo would otherwise receive every category, believe they had asked for only the live ones, and never learn otherwise.
- `updated_after` (string (date-time)) — Categories touched at or after this RFC3339 instant, for reconciling incrementally instead of re-reading the whole taxonomy. Supplying it CHANGES THE ORDER of this endpoint: the default walk descends created_at, and this one climbs updated_at, because that is the only ordering in which a keyset walk over a column the merchant keeps rewriting cannot skip a row. A category renamed, re-ranked or re-parented mid-walk moves forward past your position and is returned again, so the walk is AT LEAST ONCE: apply the state of each row you receive and a repeat costs nothing, while a miss would be storefront navigation silently diverging from what the merchant set. The bound is INCLUSIVE, so resuming from the newest updated_at you hold re-delivers the rows sharing that instant rather than dropping the ones your last page did not reach. A cursor belongs to ONE ordering and is refused by the other. ARCHIVED CATEGORIES LEAVE THIS WALK SILENTLY, as they leave the default list: it tells you what changed, not what went away.
- `limit` (integer) — Rows per page. Out of range is a 400 rather than a silent clamp, so a client asking for more than 100 learns it did not get it.
- `after` (string) — The next_cursor from the previous page. Opaque: decode nothing from it and construct nothing by hand, since its encoding is not part of this contract. Omit it to read the first page.
## Responses
- `200` — Success
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the read_categories scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request GET \
--url 'https://api.mercemur.com/api/v1/categories' \
--header 'Authorization: Bearer '
```
# Make a category visible to shoppers
`POST /api/v1/categories/{categoryId}/activate`
## Path parameters
- `categoryId` (string, required)
## Headers
- `Idempotency-Key` (string, required) — A unique key per logical write. Replaying a request with the same key returns the first response byte for byte instead of applying the write twice.
## Request body
Type: object
## Responses
- `200` — Success
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the write_categories scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `404` — The resource this url addresses does not exist, or never did on this store.
`resource` names the kind of thing that was missing and is the half to branch
on: the code is `not_found` on newer routes and a per-entity spelling on
routes that shipped before that rule, and the two mean the same thing.
A 404 is ALWAYS about the url. An id inside the request body that resolves to
nothing is 422 `unprocessable_reference` instead, so the two cases stay
distinguishable. An id that belongs to a different merchant reads exactly like
one that never existed.
- `409` — The request is well formed and the store's current state refuses it.
EVERY WRITE CAN ANSWER TWO OF THESE, whatever it does:
`idempotency_key_reused`, this Idempotency-Key already served a different
method, path or body. The key namespace is per store and not per endpoint, so a
key built from a business id collides across routes; use a fresh key per
logical write.
`idempotency_key_in_progress`, an identical request is still running. Retry
after a short delay; exactly one of the racing calls will have applied.
`not_configured` means the merchant has not set something up yet, with
`resource` naming what. The remaining codes are the per-route state rules named
on the operation.
- `413` — The request body exceeded the cap named in the message. `code` is
`payload_too_large`. Nothing was read and nothing was recorded, so the same
Idempotency-Key may be reused once the body is smaller.
- `415` — The body was not declared as `application/json`. `code` is
`unsupported_media_type`.
This API reads ONE media type. The `+json` structured suffixes are refused
too, because they name semantics (merge-patch in particular) this API does
not implement, and reading such a body as plain JSON would be a silent
misreading. A write that carries NO body needs no Content-Type at all.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request POST \
--url 'https://api.mercemur.com/api/v1/categories/{categoryId}/activate' \
--header 'Authorization: Bearer '
```
# Move a category and set its position
`POST /api/v1/categories/{categoryId}/move`
## Path parameters
- `categoryId` (string, required)
## Headers
- `Idempotency-Key` (string, required) — A unique key per logical write. Replaying a request with the same key returns the first response byte for byte instead of applying the write twice.
## Request body
Required.
- `parent_id` (string | null, required) — The destination parent. An ACTIVE category cannot be moved under a HIDDEN one: the storefront will not render that branch, so the move is refused rather than silently producing an unreachable node.
- `rank` (integer, required) — Position among the destination's children, clamped to the ends. The siblings are renumbered around it.
## Responses
- `200` — Success
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the write_categories scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `404` — The resource this url addresses does not exist, or never did on this store.
`resource` names the kind of thing that was missing and is the half to branch
on: the code is `not_found` on newer routes and a per-entity spelling on
routes that shipped before that rule, and the two mean the same thing.
A 404 is ALWAYS about the url. An id inside the request body that resolves to
nothing is 422 `unprocessable_reference` instead, so the two cases stay
distinguishable. An id that belongs to a different merchant reads exactly like
one that never existed.
- `409` — The request is well formed and the store's current state refuses it.
EVERY WRITE CAN ANSWER TWO OF THESE, whatever it does:
`idempotency_key_reused`, this Idempotency-Key already served a different
method, path or body. The key namespace is per store and not per endpoint, so a
key built from a business id collides across routes; use a fresh key per
logical write.
`idempotency_key_in_progress`, an identical request is still running. Retry
after a short delay; exactly one of the racing calls will have applied.
`not_configured` means the merchant has not set something up yet, with
`resource` naming what. The remaining codes are the per-route state rules named
on the operation.
- `413` — The request body exceeded the cap named in the message. `code` is
`payload_too_large`. Nothing was read and nothing was recorded, so the same
Idempotency-Key may be reused once the body is smaller.
- `415` — The body was not declared as `application/json`. `code` is
`unsupported_media_type`.
This API reads ONE media type. The `+json` structured suffixes are refused
too, because they name semantics (merge-patch in particular) this API does
not implement, and reading such a body as plain JSON would be a silent
misreading. A write that carries NO body needs no Content-Type at all.
- `422` — An id INSIDE the request resolves to nothing on this store. `code` is
`unprocessable_reference`, `resource` names the kind of thing that did not
resolve and `field` names where it arrived, so the fix is mechanical.
Distinct from 404, which is about the url, and from 400, which is about the
bytes. The message stays generic about WHY the id did not resolve: an id owned
by another merchant must read identically to one that never existed.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request POST \
--url 'https://api.mercemur.com/api/v1/categories/{categoryId}/move' \
--header 'Authorization: Bearer '
```
# Restore a deleted category
`POST /api/v1/categories/{categoryId}/restore`
## Path parameters
- `categoryId` (string, required)
## Headers
- `Idempotency-Key` (string, required) — A unique key per logical write. Replaying a request with the same key returns the first response byte for byte instead of applying the write twice.
## Request body
Type: object
## Responses
- `200` — Success
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks a required scope. `code` is `insufficient_scope`. This route is gated TWICE, on write_categories and then on write_categories:delete, and the message names whichever gate refused. A key holding neither is refused naming write_categories, because that gate runs first: seeing the parent named does NOT mean the qualifier would have been enough. Ask the merchant for both. The qualifier cannot be granted on its own in any case, since it narrows the parent rather than replacing it.
- `404` — The resource this url addresses does not exist, or never did on this store.
`resource` names the kind of thing that was missing and is the half to branch
on: the code is `not_found` on newer routes and a per-entity spelling on
routes that shipped before that rule, and the two mean the same thing.
A 404 is ALWAYS about the url. An id inside the request body that resolves to
nothing is 422 `unprocessable_reference` instead, so the two cases stay
distinguishable. An id that belongs to a different merchant reads exactly like
one that never existed.
- `409` — The request is well formed and the store's current state refuses it.
EVERY WRITE CAN ANSWER TWO OF THESE, whatever it does:
`idempotency_key_reused`, this Idempotency-Key already served a different
method, path or body. The key namespace is per store and not per endpoint, so a
key built from a business id collides across routes; use a fresh key per
logical write.
`idempotency_key_in_progress`, an identical request is still running. Retry
after a short delay; exactly one of the racing calls will have applied.
`not_configured` means the merchant has not set something up yet, with
`resource` naming what. The remaining codes are the per-route state rules named
on the operation.
- `413` — The request body exceeded the cap named in the message. `code` is
`payload_too_large`. Nothing was read and nothing was recorded, so the same
Idempotency-Key may be reused once the body is smaller.
- `415` — The body was not declared as `application/json`. `code` is
`unsupported_media_type`.
This API reads ONE media type. The `+json` structured suffixes are refused
too, because they name semantics (merge-patch in particular) this API does
not implement, and reading such a body as plain JSON would be a silent
misreading. A write that carries NO body needs no Content-Type at all.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request POST \
--url 'https://api.mercemur.com/api/v1/categories/{categoryId}/restore' \
--header 'Authorization: Bearer '
```
# Retrieve a category
`GET /api/v1/categories/{categoryId}`
## Path parameters
- `categoryId` (string, required)
## Responses
- `200` — Success
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the read_categories scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `404` — The resource this url addresses does not exist, or never did on this store.
`resource` names the kind of thing that was missing and is the half to branch
on: the code is `not_found` on newer routes and a per-entity spelling on
routes that shipped before that rule, and the two mean the same thing.
A 404 is ALWAYS about the url. An id inside the request body that resolves to
nothing is 422 `unprocessable_reference` instead, so the two cases stay
distinguishable. An id that belongs to a different merchant reads exactly like
one that never existed.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request GET \
--url 'https://api.mercemur.com/api/v1/categories/{categoryId}' \
--header 'Authorization: Bearer '
```
# Update a category
`PATCH /api/v1/categories/{categoryId}`
## Path parameters
- `categoryId` (string, required)
## Headers
- `Idempotency-Key` (string, required) — A unique key per logical write. Replaying a request with the same key returns the first response byte for byte instead of applying the write twice.
## Request body
Required.
- `name` (string)
- `handle` (string)
## Responses
- `200` — Success
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the write_categories scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `404` — The resource this url addresses does not exist, or never did on this store.
`resource` names the kind of thing that was missing and is the half to branch
on: the code is `not_found` on newer routes and a per-entity spelling on
routes that shipped before that rule, and the two mean the same thing.
A 404 is ALWAYS about the url. An id inside the request body that resolves to
nothing is 422 `unprocessable_reference` instead, so the two cases stay
distinguishable. An id that belongs to a different merchant reads exactly like
one that never existed.
- `409` — The request is well formed and the store's current state refuses it.
EVERY WRITE CAN ANSWER TWO OF THESE, whatever it does:
`idempotency_key_reused`, this Idempotency-Key already served a different
method, path or body. The key namespace is per store and not per endpoint, so a
key built from a business id collides across routes; use a fresh key per
logical write.
`idempotency_key_in_progress`, an identical request is still running. Retry
after a short delay; exactly one of the racing calls will have applied.
`not_configured` means the merchant has not set something up yet, with
`resource` naming what. The remaining codes are the per-route state rules named
on the operation.
- `413` — The request body exceeded the cap named in the message. `code` is
`payload_too_large`. Nothing was read and nothing was recorded, so the same
Idempotency-Key may be reused once the body is smaller.
- `415` — The body was not declared as `application/json`. `code` is
`unsupported_media_type`.
This API reads ONE media type. The `+json` structured suffixes are refused
too, because they name semantics (merge-patch in particular) this API does
not implement, and reading such a body as plain JSON would be a silent
misreading. A write that carries NO body needs no Content-Type at all.
- `422` — An id INSIDE the request resolves to nothing on this store. `code` is
`unprocessable_reference`, `resource` names the kind of thing that did not
resolve and `field` names where it arrived, so the fix is mechanical.
Distinct from 404, which is about the url, and from 400, which is about the
bytes. The message stays generic about WHY the id did not resolve: an id owned
by another merchant must read identically to one that never existed.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request PATCH \
--url 'https://api.mercemur.com/api/v1/categories/{categoryId}' \
--header 'Authorization: Bearer '
```
# Add or remove products in a collection
`POST /api/v1/collections/{collectionId}/products`
## Path parameters
- `collectionId` (string, required)
## Headers
- `Idempotency-Key` (string, required) — A unique key per logical write. Replaying a request with the same key returns the first response byte for byte instead of applying the write twice.
## Request body
Required.
- `add` (array of string)
- `remove` (array of string)
## Responses
- `200` — Success
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the write_collections scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `404` — The resource this url addresses does not exist, or never did on this store.
`resource` names the kind of thing that was missing and is the half to branch
on: the code is `not_found` on newer routes and a per-entity spelling on
routes that shipped before that rule, and the two mean the same thing.
A 404 is ALWAYS about the url. An id inside the request body that resolves to
nothing is 422 `unprocessable_reference` instead, so the two cases stay
distinguishable. An id that belongs to a different merchant reads exactly like
one that never existed.
- `409` — The request is well formed and the store's current state refuses it.
EVERY WRITE CAN ANSWER TWO OF THESE, whatever it does:
`idempotency_key_reused`, this Idempotency-Key already served a different
method, path or body. The key namespace is per store and not per endpoint, so a
key built from a business id collides across routes; use a fresh key per
logical write.
`idempotency_key_in_progress`, an identical request is still running. Retry
after a short delay; exactly one of the racing calls will have applied.
`not_configured` means the merchant has not set something up yet, with
`resource` naming what. The remaining codes are the per-route state rules named
on the operation.
- `413` — The request body exceeded the cap named in the message. `code` is
`payload_too_large`. Nothing was read and nothing was recorded, so the same
Idempotency-Key may be reused once the body is smaller.
- `415` — The body was not declared as `application/json`. `code` is
`unsupported_media_type`.
This API reads ONE media type. The `+json` structured suffixes are refused
too, because they name semantics (merge-patch in particular) this API does
not implement, and reading such a body as plain JSON would be a silent
misreading. A write that carries NO body needs no Content-Type at all.
- `422` — An id INSIDE the request resolves to nothing on this store. `code` is
`unprocessable_reference`, `resource` names the kind of thing that did not
resolve and `field` names where it arrived, so the fix is mechanical.
Distinct from 404, which is about the url, and from 400, which is about the
bytes. The message stays generic about WHY the id did not resolve: an id owned
by another merchant must read identically to one that never existed.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request POST \
--url 'https://api.mercemur.com/api/v1/collections/{collectionId}/products' \
--header 'Authorization: Bearer '
```
# Create a collection
`POST /api/v1/collections`
## Headers
- `Idempotency-Key` (string, required) — A unique key per logical write. Replaying a request with the same key returns the first response byte for byte instead of applying the write twice.
## Request body
Required.
- `handle` (string, required) — The storefront URL segment. Unique per store, and a live link: changing it later breaks any URL already shared.
- `title` (string, required)
- `description` (string | null)
- `metadata` (object) — The merchant's own free-form bag.
## Responses
- `201` — Created
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the write_collections scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `409` — The request is well formed and the store's current state refuses it.
EVERY WRITE CAN ANSWER TWO OF THESE, whatever it does:
`idempotency_key_reused`, this Idempotency-Key already served a different
method, path or body. The key namespace is per store and not per endpoint, so a
key built from a business id collides across routes; use a fresh key per
logical write.
`idempotency_key_in_progress`, an identical request is still running. Retry
after a short delay; exactly one of the racing calls will have applied.
`not_configured` means the merchant has not set something up yet, with
`resource` naming what. The remaining codes are the per-route state rules named
on the operation.
- `413` — The request body exceeded the cap named in the message. `code` is
`payload_too_large`. Nothing was read and nothing was recorded, so the same
Idempotency-Key may be reused once the body is smaller.
- `415` — The body was not declared as `application/json`. `code` is
`unsupported_media_type`.
This API reads ONE media type. The `+json` structured suffixes are refused
too, because they name semantics (merge-patch in particular) this API does
not implement, and reading such a body as plain JSON would be a silent
misreading. A write that carries NO body needs no Content-Type at all.
- `422` — An id INSIDE the request resolves to nothing on this store. `code` is
`unprocessable_reference`, `resource` names the kind of thing that did not
resolve and `field` names where it arrived, so the fix is mechanical.
Distinct from 404, which is about the url, and from 400, which is about the
bytes. The message stays generic about WHY the id did not resolve: an id owned
by another merchant must read identically to one that never existed.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request POST \
--url 'https://api.mercemur.com/api/v1/collections' \
--header 'Authorization: Bearer '
```
# Delete a collection
`DELETE /api/v1/collections/{collectionId}`
## Path parameters
- `collectionId` (string, required)
## Headers
- `Idempotency-Key` (string, required) — A unique key per logical write. Replaying a request with the same key returns the first response byte for byte instead of applying the write twice.
## Responses
- `204` — Success. The response has no body.
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks a required scope. `code` is `insufficient_scope`. This route is gated TWICE, on write_collections and then on write_collections:delete, and the message names whichever gate refused. A key holding neither is refused naming write_collections, because that gate runs first: seeing the parent named does NOT mean the qualifier would have been enough. Ask the merchant for both. The qualifier cannot be granted on its own in any case, since it narrows the parent rather than replacing it.
- `404` — The resource this url addresses does not exist, or never did on this store.
`resource` names the kind of thing that was missing and is the half to branch
on: the code is `not_found` on newer routes and a per-entity spelling on
routes that shipped before that rule, and the two mean the same thing.
A 404 is ALWAYS about the url. An id inside the request body that resolves to
nothing is 422 `unprocessable_reference` instead, so the two cases stay
distinguishable. An id that belongs to a different merchant reads exactly like
one that never existed.
- `409` — The request is well formed and the store's current state refuses it.
EVERY WRITE CAN ANSWER TWO OF THESE, whatever it does:
`idempotency_key_reused`, this Idempotency-Key already served a different
method, path or body. The key namespace is per store and not per endpoint, so a
key built from a business id collides across routes; use a fresh key per
logical write.
`idempotency_key_in_progress`, an identical request is still running. Retry
after a short delay; exactly one of the racing calls will have applied.
`not_configured` means the merchant has not set something up yet, with
`resource` naming what. The remaining codes are the per-route state rules named
on the operation.
- `413` — The request body exceeded the cap named in the message. `code` is
`payload_too_large`. Nothing was read and nothing was recorded, so the same
Idempotency-Key may be reused once the body is smaller.
- `415` — The body was not declared as `application/json`. `code` is
`unsupported_media_type`.
This API reads ONE media type. The `+json` structured suffixes are refused
too, because they name semantics (merge-patch in particular) this API does
not implement, and reading such a body as plain JSON would be a silent
misreading. A write that carries NO body needs no Content-Type at all.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request DELETE \
--url 'https://api.mercemur.com/api/v1/collections/{collectionId}' \
--header 'Authorization: Bearer '
```
# List a collection's products
`GET /api/v1/collections/{collectionId}/products`
## Path parameters
- `collectionId` (string, required)
## Query parameters
- `limit` (integer) — Rows per page. Out of range is a 400 rather than a silent clamp, so a client asking for more than 100 learns it did not get it.
- `after` (string) — The next_cursor from the previous page. Opaque: decode nothing from it and construct nothing by hand, since its encoding is not part of this contract. Omit it to read the first page.
## Responses
- `200` — Success
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the read_collections scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `404` — The resource this url addresses does not exist, or never did on this store.
`resource` names the kind of thing that was missing and is the half to branch
on: the code is `not_found` on newer routes and a per-entity spelling on
routes that shipped before that rule, and the two mean the same thing.
A 404 is ALWAYS about the url. An id inside the request body that resolves to
nothing is 422 `unprocessable_reference` instead, so the two cases stay
distinguishable. An id that belongs to a different merchant reads exactly like
one that never existed.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request GET \
--url 'https://api.mercemur.com/api/v1/collections/{collectionId}/products' \
--header 'Authorization: Bearer '
```
# List collections
`GET /api/v1/collections`
The store's collections, newest first. ARCHIVED COLLECTIONS ARE INCLUDED BY DEFAULT. That is long-standing behaviour and it is not changing: withdrawing them from the unfiltered page would silently alter what every deployed integration receives, and a response cannot be taken back on this API. Send ?status=active for live collections only, or ?status=archived for the archived ones. An unrecognised value is a 400 rather than an empty page, which would otherwise read as "this merchant has no collections". ?handle= resolves a storefront URL segment to a collection. It is unique per store, so it returns at most one row, and it is the only identifier an integrator holding a live URL has.
## Query parameters
- `handle` (string) — Resolves a storefront URL segment to a collection. It is unique per store, so it returns at most one row, and it is the only identifier an integrator holding a live URL has. The route itself keys on the immutable id, because a handle is rewritten whenever a merchant renames a collection.
- `status` (active | archived) — Narrows to live or archived collections. ARCHIVED ARE INCLUDED BY DEFAULT and that is not changing: withdrawing them from the unfiltered page would silently alter what every deployed integration receives. An unrecognised value is a 400 rather than an empty page, which would otherwise read as "this merchant has no collections".
- `updated_after` (string (date-time)) — Collections touched at or after this RFC3339 instant, for reconciling incrementally instead of re-reading the whole list. Supplying it CHANGES THE ORDER of this endpoint: the default walk descends created_at, and this one climbs updated_at, because that is the only ordering in which a keyset walk over a column the merchant keeps rewriting cannot skip a row. A collection edited mid-walk moves forward past your position and is returned again, so the walk is AT LEAST ONCE: apply the state of each row you receive and a repeat costs nothing, while a miss would be a storefront category silently diverging from what the merchant set. The bound is INCLUSIVE, so resuming from the newest updated_at you hold re-delivers the rows sharing that instant rather than dropping the ones your last page did not reach. A cursor belongs to ONE ordering and is refused by the other, since the same position means something different in each.
- `limit` (integer) — Rows per page. Out of range is a 400 rather than a silent clamp, so a client asking for more than 100 learns it did not get it.
- `after` (string) — The next_cursor from the previous page. Opaque: decode nothing from it and construct nothing by hand, since its encoding is not part of this contract. Omit it to read the first page.
## Responses
- `200` — Success
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the read_collections scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request GET \
--url 'https://api.mercemur.com/api/v1/collections' \
--header 'Authorization: Bearer '
```
# Remove a collection from the storefront without deleting it
`POST /api/v1/collections/{collectionId}/archive`
## Path parameters
- `collectionId` (string, required)
## Headers
- `Idempotency-Key` (string, required) — A unique key per logical write. Replaying a request with the same key returns the first response byte for byte instead of applying the write twice.
## Request body
Type: object
## Responses
- `200` — Success
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the write_collections scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `404` — The resource this url addresses does not exist, or never did on this store.
`resource` names the kind of thing that was missing and is the half to branch
on: the code is `not_found` on newer routes and a per-entity spelling on
routes that shipped before that rule, and the two mean the same thing.
A 404 is ALWAYS about the url. An id inside the request body that resolves to
nothing is 422 `unprocessable_reference` instead, so the two cases stay
distinguishable. An id that belongs to a different merchant reads exactly like
one that never existed.
- `409` — The request is well formed and the store's current state refuses it.
EVERY WRITE CAN ANSWER TWO OF THESE, whatever it does:
`idempotency_key_reused`, this Idempotency-Key already served a different
method, path or body. The key namespace is per store and not per endpoint, so a
key built from a business id collides across routes; use a fresh key per
logical write.
`idempotency_key_in_progress`, an identical request is still running. Retry
after a short delay; exactly one of the racing calls will have applied.
`not_configured` means the merchant has not set something up yet, with
`resource` naming what. The remaining codes are the per-route state rules named
on the operation.
- `413` — The request body exceeded the cap named in the message. `code` is
`payload_too_large`. Nothing was read and nothing was recorded, so the same
Idempotency-Key may be reused once the body is smaller.
- `415` — The body was not declared as `application/json`. `code` is
`unsupported_media_type`.
This API reads ONE media type. The `+json` structured suffixes are refused
too, because they name semantics (merge-patch in particular) this API does
not implement, and reading such a body as plain JSON would be a silent
misreading. A write that carries NO body needs no Content-Type at all.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request POST \
--url 'https://api.mercemur.com/api/v1/collections/{collectionId}/archive' \
--header 'Authorization: Bearer '
```
# Replace a collection's metadata document
`PUT /api/v1/collections/{collectionId}/metadata`
## Path parameters
- `collectionId` (string, required)
## Headers
- `Idempotency-Key` (string, required) — A unique key per logical write. Replaying a request with the same key returns the first response byte for byte instead of applying the write twice.
## Request body
Required.
- `expected_updated_at` (string (date-time)) — OPTIONAL precondition. Because this replaces the WHOLE document, the instruction below (read the current value and send it back with your change) is a read-modify-write race unless you assert a version: the loser silently drops the winner's keys and receives a 200, and one of those keys is the storefront tile's cover image. Send back the updated_at you read and a stale write is refused 409 collection_modified. Omit it and the write behaves exactly as it always has; it is optional because this route shipped without it. Compared at the precision you express, so a millisecond timestamp satisfies a microsecond one.
- `metadata` (object, required) — REPLACES the whole document rather than merging into it. Read the current value first and send it back with your change, or keys the merchant set elsewhere are dropped.
## Responses
- `200` — Success
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the write_collections scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `404` — The resource this url addresses does not exist, or never did on this store.
`resource` names the kind of thing that was missing and is the half to branch
on: the code is `not_found` on newer routes and a per-entity spelling on
routes that shipped before that rule, and the two mean the same thing.
A 404 is ALWAYS about the url. An id inside the request body that resolves to
nothing is 422 `unprocessable_reference` instead, so the two cases stay
distinguishable. An id that belongs to a different merchant reads exactly like
one that never existed.
- `409` — The request is well formed and the store's current state refuses it.
EVERY WRITE CAN ANSWER TWO OF THESE, whatever it does:
`idempotency_key_reused`, this Idempotency-Key already served a different
method, path or body. The key namespace is per store and not per endpoint, so a
key built from a business id collides across routes; use a fresh key per
logical write.
`idempotency_key_in_progress`, an identical request is still running. Retry
after a short delay; exactly one of the racing calls will have applied.
`not_configured` means the merchant has not set something up yet, with
`resource` naming what. The remaining codes are the per-route state rules named
on the operation.
- `413` — The request body exceeded the cap named in the message. `code` is
`payload_too_large`. Nothing was read and nothing was recorded, so the same
Idempotency-Key may be reused once the body is smaller.
- `415` — The body was not declared as `application/json`. `code` is
`unsupported_media_type`.
This API reads ONE media type. The `+json` structured suffixes are refused
too, because they name semantics (merge-patch in particular) this API does
not implement, and reading such a body as plain JSON would be a silent
misreading. A write that carries NO body needs no Content-Type at all.
- `422` — An id INSIDE the request resolves to nothing on this store. `code` is
`unprocessable_reference`, `resource` names the kind of thing that did not
resolve and `field` names where it arrived, so the fix is mechanical.
Distinct from 404, which is about the url, and from 400, which is about the
bytes. The message stays generic about WHY the id did not resolve: an id owned
by another merchant must read identically to one that never existed.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request PUT \
--url 'https://api.mercemur.com/api/v1/collections/{collectionId}/metadata' \
--header 'Authorization: Bearer '
```
# Restore an archived collection to the storefront
`POST /api/v1/collections/{collectionId}/unarchive`
## Path parameters
- `collectionId` (string, required)
## Headers
- `Idempotency-Key` (string, required) — A unique key per logical write. Replaying a request with the same key returns the first response byte for byte instead of applying the write twice.
## Request body
Type: object
## Responses
- `200` — Success
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the write_collections scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `404` — The resource this url addresses does not exist, or never did on this store.
`resource` names the kind of thing that was missing and is the half to branch
on: the code is `not_found` on newer routes and a per-entity spelling on
routes that shipped before that rule, and the two mean the same thing.
A 404 is ALWAYS about the url. An id inside the request body that resolves to
nothing is 422 `unprocessable_reference` instead, so the two cases stay
distinguishable. An id that belongs to a different merchant reads exactly like
one that never existed.
- `409` — The request is well formed and the store's current state refuses it.
EVERY WRITE CAN ANSWER TWO OF THESE, whatever it does:
`idempotency_key_reused`, this Idempotency-Key already served a different
method, path or body. The key namespace is per store and not per endpoint, so a
key built from a business id collides across routes; use a fresh key per
logical write.
`idempotency_key_in_progress`, an identical request is still running. Retry
after a short delay; exactly one of the racing calls will have applied.
`not_configured` means the merchant has not set something up yet, with
`resource` naming what. The remaining codes are the per-route state rules named
on the operation.
- `413` — The request body exceeded the cap named in the message. `code` is
`payload_too_large`. Nothing was read and nothing was recorded, so the same
Idempotency-Key may be reused once the body is smaller.
- `415` — The body was not declared as `application/json`. `code` is
`unsupported_media_type`.
This API reads ONE media type. The `+json` structured suffixes are refused
too, because they name semantics (merge-patch in particular) this API does
not implement, and reading such a body as plain JSON would be a silent
misreading. A write that carries NO body needs no Content-Type at all.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request POST \
--url 'https://api.mercemur.com/api/v1/collections/{collectionId}/unarchive' \
--header 'Authorization: Bearer '
```
# Retrieve a collection
`GET /api/v1/collections/{collectionId}`
## Path parameters
- `collectionId` (string, required)
## Responses
- `200` — Success
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the read_collections scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `404` — The resource this url addresses does not exist, or never did on this store.
`resource` names the kind of thing that was missing and is the half to branch
on: the code is `not_found` on newer routes and a per-entity spelling on
routes that shipped before that rule, and the two mean the same thing.
A 404 is ALWAYS about the url. An id inside the request body that resolves to
nothing is 422 `unprocessable_reference` instead, so the two cases stay
distinguishable. An id that belongs to a different merchant reads exactly like
one that never existed.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request GET \
--url 'https://api.mercemur.com/api/v1/collections/{collectionId}' \
--header 'Authorization: Bearer '
```
# Update a collection
`PATCH /api/v1/collections/{collectionId}`
## Path parameters
- `collectionId` (string, required)
## Headers
- `Idempotency-Key` (string, required) — A unique key per logical write. Replaying a request with the same key returns the first response byte for byte instead of applying the write twice.
## Request body
Required.
- `handle` (string)
- `title` (string)
- `description` (string | null)
## Responses
- `200` — Success
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the write_collections scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `404` — The resource this url addresses does not exist, or never did on this store.
`resource` names the kind of thing that was missing and is the half to branch
on: the code is `not_found` on newer routes and a per-entity spelling on
routes that shipped before that rule, and the two mean the same thing.
A 404 is ALWAYS about the url. An id inside the request body that resolves to
nothing is 422 `unprocessable_reference` instead, so the two cases stay
distinguishable. An id that belongs to a different merchant reads exactly like
one that never existed.
- `409` — The request is well formed and the store's current state refuses it.
EVERY WRITE CAN ANSWER TWO OF THESE, whatever it does:
`idempotency_key_reused`, this Idempotency-Key already served a different
method, path or body. The key namespace is per store and not per endpoint, so a
key built from a business id collides across routes; use a fresh key per
logical write.
`idempotency_key_in_progress`, an identical request is still running. Retry
after a short delay; exactly one of the racing calls will have applied.
`not_configured` means the merchant has not set something up yet, with
`resource` naming what. The remaining codes are the per-route state rules named
on the operation.
- `413` — The request body exceeded the cap named in the message. `code` is
`payload_too_large`. Nothing was read and nothing was recorded, so the same
Idempotency-Key may be reused once the body is smaller.
- `415` — The body was not declared as `application/json`. `code` is
`unsupported_media_type`.
This API reads ONE media type. The `+json` structured suffixes are refused
too, because they name semantics (merge-patch in particular) this API does
not implement, and reading such a body as plain JSON would be a silent
misreading. A write that carries NO body needs no Content-Type at all.
- `422` — An id INSIDE the request resolves to nothing on this store. `code` is
`unprocessable_reference`, `resource` names the kind of thing that did not
resolve and `field` names where it arrived, so the fix is mechanical.
Distinct from 404, which is about the url, and from 400, which is about the
bytes. The message stays generic about WHY the id did not resolve: an id owned
by another merchant must read identically to one that never existed.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request PATCH \
--url 'https://api.mercemur.com/api/v1/collections/{collectionId}' \
--header 'Authorization: Bearer '
```
# Retrieve commerce schema
`GET /api/v1/commerce-schema`
## Responses
- `200` — Success
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the read_storefront scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request GET \
--url 'https://api.mercemur.com/api/v1/commerce-schema' \
--header 'Authorization: Bearer '
```
# Add a location to a company
`POST /api/v1/companies/{companyId}/locations`
## Path parameters
- `companyId` (string, required)
## Headers
- `Idempotency-Key` (string, required) — A unique key per logical write. Replaying a request with the same key returns the first response byte for byte instead of applying the write twice.
## Request body
Required.
- `name` (string, required) — Required and must not be blank. Your label for the site, such as "Head Office" or "Bristol Depot".
- `customer_group_id` (string | null) — THE NEGOTIATED-PRICING POINTER, and the one field on this family that costs a second scope. Naming it, or clearing it with null, decides what every buyer at this location is charged, so it requires write_pricing IN ADDITION TO write_companies and answers 403 insufficient_scope without both. The id must name a customer group in THIS store; anything else is 422, because the database foreign key does not enforce the tenant. Null means no negotiated pricing, which is the ordinary state of a location buying at the store's list prices.
- `address_line_1` (string | null) — Optional. Clearable with null.
- `address_line_2` (string | null) — Optional. Clearable with null.
- `city` (string | null) — Optional. Clearable with null.
- `region` (string | null) — Optional. Clearable with null.
- `postal_code` (string | null) — Optional. Clearable with null.
- `country_code` (string | null) — Optional. Stored and served exactly as sent, with no case normalisation, so a read never disagrees with the write that preceded it.
- `phone` (string | null) — Optional. Clearable with null.
- `tax_registration_id` (string | null) — The BUYER's own registration (VAT, GSTIN, ABN). Per location rather than per company, because a group trading in two countries registers separately in each.
- `payment_terms_days` (integer | null) — NULL AND ZERO ARE DIFFERENT ANSWERS AND THIS API KEEPS THEM APART. Null means no terms have been agreed; 0 means DUE ON RECEIPT. Omitting the key leaves it null rather than defaulting to 0, because a default would state a term nobody negotiated and put every unconfigured account on the strictest one. Negative values are a 400.
- `is_default` (boolean) — Optional, defaults to false. Setting it true DEMOTES whichever location currently holds the flag, in the same transaction, because at most one default is allowed per company. It therefore changes a location this call never named.
## Responses
- `201` — Created
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the write_companies scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `404` — The resource this url addresses does not exist, or never did on this store.
`resource` names the kind of thing that was missing and is the half to branch
on: the code is `not_found` on newer routes and a per-entity spelling on
routes that shipped before that rule, and the two mean the same thing.
A 404 is ALWAYS about the url. An id inside the request body that resolves to
nothing is 422 `unprocessable_reference` instead, so the two cases stay
distinguishable. An id that belongs to a different merchant reads exactly like
one that never existed.
- `409` — The request is well formed and the store's current state refuses it.
EVERY WRITE CAN ANSWER TWO OF THESE, whatever it does:
`idempotency_key_reused`, this Idempotency-Key already served a different
method, path or body. The key namespace is per store and not per endpoint, so a
key built from a business id collides across routes; use a fresh key per
logical write.
`idempotency_key_in_progress`, an identical request is still running. Retry
after a short delay; exactly one of the racing calls will have applied.
`not_configured` means the merchant has not set something up yet, with
`resource` naming what. The remaining codes are the per-route state rules named
on the operation.
- `413` — The request body exceeded the cap named in the message. `code` is
`payload_too_large`. Nothing was read and nothing was recorded, so the same
Idempotency-Key may be reused once the body is smaller.
- `415` — The body was not declared as `application/json`. `code` is
`unsupported_media_type`.
This API reads ONE media type. The `+json` structured suffixes are refused
too, because they name semantics (merge-patch in particular) this API does
not implement, and reading such a body as plain JSON would be a silent
misreading. A write that carries NO body needs no Content-Type at all.
- `422` — An id INSIDE the request resolves to nothing on this store. `code` is
`unprocessable_reference`, `resource` names the kind of thing that did not
resolve and `field` names where it arrived, so the fix is mechanical.
Distinct from 404, which is about the url, and from 400, which is about the
bytes. The message stays generic about WHY the id did not resolve: an id owned
by another merchant must read identically to one that never existed.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request POST \
--url 'https://api.mercemur.com/api/v1/companies/{companyId}/locations' \
--header 'Authorization: Bearer '
```
# Authorise an existing customer to buy on a company account
`POST /api/v1/companies/{companyId}/contacts`
## Path parameters
- `companyId` (string, required)
## Headers
- `Idempotency-Key` (string, required) — A unique key per logical write. Replaying a request with the same key returns the first response byte for byte instead of applying the write twice.
## Request body
Required.
- `customer_id` (string, required) — Required. The id of an EXISTING customer in this store, as returned by GET /api/v1/customers. It is the only thing this API publishes about the person: resolve their name and email through the customers API with read_customers.
- `is_primary` (boolean) — Optional, defaults to false. Setting it true DEMOTES whichever contact currently holds the flag, in the same transaction, because at most one primary is allowed per company.
## Responses
- `201` — Created
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the write_companies scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `404` — The resource this url addresses does not exist, or never did on this store.
`resource` names the kind of thing that was missing and is the half to branch
on: the code is `not_found` on newer routes and a per-entity spelling on
routes that shipped before that rule, and the two mean the same thing.
A 404 is ALWAYS about the url. An id inside the request body that resolves to
nothing is 422 `unprocessable_reference` instead, so the two cases stay
distinguishable. An id that belongs to a different merchant reads exactly like
one that never existed.
- `409` — The request is well formed and the store's current state refuses it.
EVERY WRITE CAN ANSWER TWO OF THESE, whatever it does:
`idempotency_key_reused`, this Idempotency-Key already served a different
method, path or body. The key namespace is per store and not per endpoint, so a
key built from a business id collides across routes; use a fresh key per
logical write.
`idempotency_key_in_progress`, an identical request is still running. Retry
after a short delay; exactly one of the racing calls will have applied.
`not_configured` means the merchant has not set something up yet, with
`resource` naming what. The remaining codes are the per-route state rules named
on the operation.
- `413` — The request body exceeded the cap named in the message. `code` is
`payload_too_large`. Nothing was read and nothing was recorded, so the same
Idempotency-Key may be reused once the body is smaller.
- `415` — The body was not declared as `application/json`. `code` is
`unsupported_media_type`.
This API reads ONE media type. The `+json` structured suffixes are refused
too, because they name semantics (merge-patch in particular) this API does
not implement, and reading such a body as plain JSON would be a silent
misreading. A write that carries NO body needs no Content-Type at all.
- `422` — An id INSIDE the request resolves to nothing on this store. `code` is
`unprocessable_reference`, `resource` names the kind of thing that did not
resolve and `field` names where it arrived, so the fix is mechanical.
Distinct from 404, which is about the url, and from 400, which is about the
bytes. The message stays generic about WHY the id did not resolve: an id owned
by another merchant must read identically to one that never existed.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request POST \
--url 'https://api.mercemur.com/api/v1/companies/{companyId}/contacts' \
--header 'Authorization: Bearer '
```
# Change whether a contact is the account's primary buyer
`PATCH /api/v1/companies/{companyId}/contacts/{companyContactId}`
## Path parameters
- `companyId` (string, required)
- `companyContactId` (string, required)
## Headers
- `Idempotency-Key` (string, required) — A unique key per logical write. Replaying a request with the same key returns the first response byte for byte instead of applying the write twice.
## Request body
Required.
- `is_primary` (boolean, required) — Required: a patch naming nothing else has nothing to do. Setting it true demotes whichever contact currently holds the flag, in the same transaction.
## Responses
- `200` — Success
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the write_companies scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `404` — The resource this url addresses does not exist, or never did on this store.
`resource` names the kind of thing that was missing and is the half to branch
on: the code is `not_found` on newer routes and a per-entity spelling on
routes that shipped before that rule, and the two mean the same thing.
A 404 is ALWAYS about the url. An id inside the request body that resolves to
nothing is 422 `unprocessable_reference` instead, so the two cases stay
distinguishable. An id that belongs to a different merchant reads exactly like
one that never existed.
- `409` — The request is well formed and the store's current state refuses it.
EVERY WRITE CAN ANSWER TWO OF THESE, whatever it does:
`idempotency_key_reused`, this Idempotency-Key already served a different
method, path or body. The key namespace is per store and not per endpoint, so a
key built from a business id collides across routes; use a fresh key per
logical write.
`idempotency_key_in_progress`, an identical request is still running. Retry
after a short delay; exactly one of the racing calls will have applied.
`not_configured` means the merchant has not set something up yet, with
`resource` naming what. The remaining codes are the per-route state rules named
on the operation.
- `413` — The request body exceeded the cap named in the message. `code` is
`payload_too_large`. Nothing was read and nothing was recorded, so the same
Idempotency-Key may be reused once the body is smaller.
- `415` — The body was not declared as `application/json`. `code` is
`unsupported_media_type`.
This API reads ONE media type. The `+json` structured suffixes are refused
too, because they name semantics (merge-patch in particular) this API does
not implement, and reading such a body as plain JSON would be a silent
misreading. A write that carries NO body needs no Content-Type at all.
- `422` — An id INSIDE the request resolves to nothing on this store. `code` is
`unprocessable_reference`, `resource` names the kind of thing that did not
resolve and `field` names where it arrived, so the fix is mechanical.
Distinct from 404, which is about the url, and from 400, which is about the
bytes. The message stays generic about WHY the id did not resolve: an id owned
by another merchant must read identically to one that never existed.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request PATCH \
--url 'https://api.mercemur.com/api/v1/companies/{companyId}/contacts/{companyContactId}' \
--header 'Authorization: Bearer '
```
# Create a B2B company account
`POST /api/v1/companies`
## Headers
- `Idempotency-Key` (string, required) — A unique key per logical write. Replaying a request with the same key returns the first response byte for byte instead of applying the write twice.
## Request body
Required.
- `name` (string, required) — Required and must not be blank. The account's legal or trading name. Not unique: a merchant may hold two accounts under one name.
- `external_id` (string | null) — YOUR key from the ERP or CRM that owns this list, not ours. Unique per store when present, which is what makes a re-run of an interrupted sync converge. A blank or whitespace value is normalised to absent rather than stored, so an empty spreadsheet cell does not occupy the index and collide with the next such row.
- `status` (active | inactive) — Optional, defaults to active. inactive is the REVERSIBLE withdrawal: it stops an account trading and is undone with one PATCH, which is why an account-sync integration never needs the delete qualifier.
- `metadata` (object) — Your own free-form bag. It REPLACES wholesale rather than merging, so a client can delete a key. Send {} to empty it: null is refused, because the column is NOT NULL and accepting null would be a second spelling of the same act.
## Responses
- `201` — Created
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the write_companies scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `409` — The request is well formed and the store's current state refuses it.
EVERY WRITE CAN ANSWER TWO OF THESE, whatever it does:
`idempotency_key_reused`, this Idempotency-Key already served a different
method, path or body. The key namespace is per store and not per endpoint, so a
key built from a business id collides across routes; use a fresh key per
logical write.
`idempotency_key_in_progress`, an identical request is still running. Retry
after a short delay; exactly one of the racing calls will have applied.
`not_configured` means the merchant has not set something up yet, with
`resource` naming what. The remaining codes are the per-route state rules named
on the operation.
- `413` — The request body exceeded the cap named in the message. `code` is
`payload_too_large`. Nothing was read and nothing was recorded, so the same
Idempotency-Key may be reused once the body is smaller.
- `415` — The body was not declared as `application/json`. `code` is
`unsupported_media_type`.
This API reads ONE media type. The `+json` structured suffixes are refused
too, because they name semantics (merge-patch in particular) this API does
not implement, and reading such a body as plain JSON would be a silent
misreading. A write that carries NO body needs no Content-Type at all.
- `422` — An id INSIDE the request resolves to nothing on this store. `code` is
`unprocessable_reference`, `resource` names the kind of thing that did not
resolve and `field` names where it arrived, so the fix is mechanical.
Distinct from 404, which is about the url, and from 400, which is about the
bytes. The message stays generic about WHY the id did not resolve: an id owned
by another merchant must read identically to one that never existed.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request POST \
--url 'https://api.mercemur.com/api/v1/companies' \
--header 'Authorization: Bearer '
```
# Delete a B2B company account and everything under it
`DELETE /api/v1/companies/{companyId}`
Removes the company account AND EVERYTHING UNDER IT. This is a HARD delete and it CASCADES: every location and every contact belonging to the company goes with it, in the same transaction, with no confirmation step and no way to recover them through this API. Nothing else in the schema references a company, so the blast radius is exactly that hierarchy, but it is larger than the URL suggests and it is stated here rather than discovered. COUNT THE CHILDREN FIRST if you need to know what you are about to remove. GET /api/v1/companies/{companyId}/locations and /contacts both page, and this route answers 204 with no body, so the counts cannot come back with the response. NEEDS BOTH GRANTS. The qualified scope named above is refused to a key holding write_companies alone, so ask the merchant for both. A CROSS-TENANT ID IS A 404, never a 403: the delete is scoped to the store, so another merchant's company id matches nothing and cannot be probed for existence.
## Path parameters
- `companyId` (string, required)
## Headers
- `Idempotency-Key` (string, required) — A unique key per logical write. Replaying a request with the same key returns the first response byte for byte instead of applying the write twice.
## Request body
Type: object
## Responses
- `204` — Success. The response has no body.
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks a required scope. `code` is `insufficient_scope`. This route is gated TWICE, on write_companies and then on write_companies:delete, and the message names whichever gate refused. A key holding neither is refused naming write_companies, because that gate runs first: seeing the parent named does NOT mean the qualifier would have been enough. Ask the merchant for both. The qualifier cannot be granted on its own in any case, since it narrows the parent rather than replacing it.
- `404` — The resource this url addresses does not exist, or never did on this store.
`resource` names the kind of thing that was missing and is the half to branch
on: the code is `not_found` on newer routes and a per-entity spelling on
routes that shipped before that rule, and the two mean the same thing.
A 404 is ALWAYS about the url. An id inside the request body that resolves to
nothing is 422 `unprocessable_reference` instead, so the two cases stay
distinguishable. An id that belongs to a different merchant reads exactly like
one that never existed.
- `409` — The request is well formed and the store's current state refuses it.
EVERY WRITE CAN ANSWER TWO OF THESE, whatever it does:
`idempotency_key_reused`, this Idempotency-Key already served a different
method, path or body. The key namespace is per store and not per endpoint, so a
key built from a business id collides across routes; use a fresh key per
logical write.
`idempotency_key_in_progress`, an identical request is still running. Retry
after a short delay; exactly one of the racing calls will have applied.
`not_configured` means the merchant has not set something up yet, with
`resource` naming what. The remaining codes are the per-route state rules named
on the operation.
- `413` — The request body exceeded the cap named in the message. `code` is
`payload_too_large`. Nothing was read and nothing was recorded, so the same
Idempotency-Key may be reused once the body is smaller.
- `415` — The body was not declared as `application/json`. `code` is
`unsupported_media_type`.
This API reads ONE media type. The `+json` structured suffixes are refused
too, because they name semantics (merge-patch in particular) this API does
not implement, and reading such a body as plain JSON would be a silent
misreading. A write that carries NO body needs no Content-Type at all.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request DELETE \
--url 'https://api.mercemur.com/api/v1/companies/{companyId}' \
--header 'Authorization: Bearer '
```
# Delete a company location
`DELETE /api/v1/companies/{companyId}/locations/{companyLocationId}`
## Path parameters
- `companyId` (string, required)
- `companyLocationId` (string, required)
## Headers
- `Idempotency-Key` (string, required) — A unique key per logical write. Replaying a request with the same key returns the first response byte for byte instead of applying the write twice.
## Request body
Type: object
## Responses
- `204` — Success. The response has no body.
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks a required scope. `code` is `insufficient_scope`. This route is gated TWICE, on write_companies and then on write_companies:delete, and the message names whichever gate refused. A key holding neither is refused naming write_companies, because that gate runs first: seeing the parent named does NOT mean the qualifier would have been enough. Ask the merchant for both. The qualifier cannot be granted on its own in any case, since it narrows the parent rather than replacing it.
- `404` — The resource this url addresses does not exist, or never did on this store.
`resource` names the kind of thing that was missing and is the half to branch
on: the code is `not_found` on newer routes and a per-entity spelling on
routes that shipped before that rule, and the two mean the same thing.
A 404 is ALWAYS about the url. An id inside the request body that resolves to
nothing is 422 `unprocessable_reference` instead, so the two cases stay
distinguishable. An id that belongs to a different merchant reads exactly like
one that never existed.
- `409` — The request is well formed and the store's current state refuses it.
EVERY WRITE CAN ANSWER TWO OF THESE, whatever it does:
`idempotency_key_reused`, this Idempotency-Key already served a different
method, path or body. The key namespace is per store and not per endpoint, so a
key built from a business id collides across routes; use a fresh key per
logical write.
`idempotency_key_in_progress`, an identical request is still running. Retry
after a short delay; exactly one of the racing calls will have applied.
`not_configured` means the merchant has not set something up yet, with
`resource` naming what. The remaining codes are the per-route state rules named
on the operation.
- `413` — The request body exceeded the cap named in the message. `code` is
`payload_too_large`. Nothing was read and nothing was recorded, so the same
Idempotency-Key may be reused once the body is smaller.
- `415` — The body was not declared as `application/json`. `code` is
`unsupported_media_type`.
This API reads ONE media type. The `+json` structured suffixes are refused
too, because they name semantics (merge-patch in particular) this API does
not implement, and reading such a body as plain JSON would be a silent
misreading. A write that carries NO body needs no Content-Type at all.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request DELETE \
--url 'https://api.mercemur.com/api/v1/companies/{companyId}/locations/{companyLocationId}' \
--header 'Authorization: Bearer '
```
# List a company's contacts
`GET /api/v1/companies/{companyId}/contacts`
## Path parameters
- `companyId` (string, required)
## Query parameters
- `limit` (integer) — Rows per page. Out of range is a 400 rather than a silent clamp, so a client asking for more than 100 learns it did not get it.
- `after` (string) — The next_cursor from the previous page. Opaque: decode nothing from it and construct nothing by hand, since its encoding is not part of this contract. Omit it to read the first page.
## Responses
- `200` — Success
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the read_companies scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `404` — The resource this url addresses does not exist, or never did on this store.
`resource` names the kind of thing that was missing and is the half to branch
on: the code is `not_found` on newer routes and a per-entity spelling on
routes that shipped before that rule, and the two mean the same thing.
A 404 is ALWAYS about the url. An id inside the request body that resolves to
nothing is 422 `unprocessable_reference` instead, so the two cases stay
distinguishable. An id that belongs to a different merchant reads exactly like
one that never existed.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request GET \
--url 'https://api.mercemur.com/api/v1/companies/{companyId}/contacts' \
--header 'Authorization: Bearer '
```
# List a company's locations
`GET /api/v1/companies/{companyId}/locations`
## Path parameters
- `companyId` (string, required)
## Query parameters
- `limit` (integer) — Rows per page. Out of range is a 400 rather than a silent clamp, so a client asking for more than 100 learns it did not get it.
- `after` (string) — The next_cursor from the previous page. Opaque: decode nothing from it and construct nothing by hand, since its encoding is not part of this contract. Omit it to read the first page.
## Responses
- `200` — Success
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the read_companies scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `404` — The resource this url addresses does not exist, or never did on this store.
`resource` names the kind of thing that was missing and is the half to branch
on: the code is `not_found` on newer routes and a per-entity spelling on
routes that shipped before that rule, and the two mean the same thing.
A 404 is ALWAYS about the url. An id inside the request body that resolves to
nothing is 422 `unprocessable_reference` instead, so the two cases stay
distinguishable. An id that belongs to a different merchant reads exactly like
one that never existed.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request GET \
--url 'https://api.mercemur.com/api/v1/companies/{companyId}/locations' \
--header 'Authorization: Bearer '
```
# List companies
`GET /api/v1/companies`
## Query parameters
- `status` (active | inactive) — The vocabulary is CLOSED and an unknown value is a 400, not an empty page: a client sending ?status=enabled and quietly receiving nothing would read it as "this merchant has no accounts".
- `external_id` (string) — The company carrying one identifier from your own system.
- `updated_after` (string (date-time)) — Companies touched at or after this RFC3339 instant. STATUS gates whether a company's buyers can order at all, and credit terms and contacts are edited throughout the relationship, while created_at is written once at onboarding. Supplying it CHANGES THE ORDER of this endpoint: the default walk descends created_at, and this one climbs updated_at, which is the only ordering in which a keyset walk over a mutable column cannot skip a row. A row edited mid-walk moves forward past your position and is returned again, so the walk is AT LEAST ONCE. The bound is INCLUSIVE, so resuming from the newest updated_at you hold re-delivers the rows sharing that instant. A cursor belongs to ONE ordering and is refused by the other.
- `limit` (integer) — Rows per page. Out of range is a 400 rather than a silent clamp, so a client asking for more than 100 learns it did not get it.
- `after` (string) — The next_cursor from the previous page. Opaque: decode nothing from it and construct nothing by hand, since its encoding is not part of this contract. Omit it to read the first page.
## Responses
- `200` — Success
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the read_companies scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request GET \
--url 'https://api.mercemur.com/api/v1/companies' \
--header 'Authorization: Bearer '
```
# Retrieve a company
`GET /api/v1/companies/{companyId}`
## Path parameters
- `companyId` (string, required)
## Responses
- `200` — Success
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the read_companies scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `404` — The resource this url addresses does not exist, or never did on this store.
`resource` names the kind of thing that was missing and is the half to branch
on: the code is `not_found` on newer routes and a per-entity spelling on
routes that shipped before that rule, and the two mean the same thing.
A 404 is ALWAYS about the url. An id inside the request body that resolves to
nothing is 422 `unprocessable_reference` instead, so the two cases stay
distinguishable. An id that belongs to a different merchant reads exactly like
one that never existed.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request GET \
--url 'https://api.mercemur.com/api/v1/companies/{companyId}' \
--header 'Authorization: Bearer '
```
# Retrieve a company contact
`GET /api/v1/companies/{companyId}/contacts/{companyContactId}`
## Path parameters
- `companyId` (string, required)
- `companyContactId` (string, required)
## Responses
- `200` — Success
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the read_companies scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `404` — The resource this url addresses does not exist, or never did on this store.
`resource` names the kind of thing that was missing and is the half to branch
on: the code is `not_found` on newer routes and a per-entity spelling on
routes that shipped before that rule, and the two mean the same thing.
A 404 is ALWAYS about the url. An id inside the request body that resolves to
nothing is 422 `unprocessable_reference` instead, so the two cases stay
distinguishable. An id that belongs to a different merchant reads exactly like
one that never existed.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request GET \
--url 'https://api.mercemur.com/api/v1/companies/{companyId}/contacts/{companyContactId}' \
--header 'Authorization: Bearer '
```
# Retrieve a company location
`GET /api/v1/companies/{companyId}/locations/{companyLocationId}`
## Path parameters
- `companyId` (string, required)
- `companyLocationId` (string, required)
## Responses
- `200` — Success
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the read_companies scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `404` — The resource this url addresses does not exist, or never did on this store.
`resource` names the kind of thing that was missing and is the half to branch
on: the code is `not_found` on newer routes and a per-entity spelling on
routes that shipped before that rule, and the two mean the same thing.
A 404 is ALWAYS about the url. An id inside the request body that resolves to
nothing is 422 `unprocessable_reference` instead, so the two cases stay
distinguishable. An id that belongs to a different merchant reads exactly like
one that never existed.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request GET \
--url 'https://api.mercemur.com/api/v1/companies/{companyId}/locations/{companyLocationId}' \
--header 'Authorization: Bearer '
```
# Revoke a contact's authority to buy on a company account
`DELETE /api/v1/companies/{companyId}/contacts/{companyContactId}`
## Path parameters
- `companyId` (string, required)
- `companyContactId` (string, required)
## Headers
- `Idempotency-Key` (string, required) — A unique key per logical write. Replaying a request with the same key returns the first response byte for byte instead of applying the write twice.
## Request body
Type: object
## Responses
- `204` — Success. The response has no body.
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks a required scope. `code` is `insufficient_scope`. This route is gated TWICE, on write_companies and then on write_companies:delete, and the message names whichever gate refused. A key holding neither is refused naming write_companies, because that gate runs first: seeing the parent named does NOT mean the qualifier would have been enough. Ask the merchant for both. The qualifier cannot be granted on its own in any case, since it narrows the parent rather than replacing it.
- `404` — The resource this url addresses does not exist, or never did on this store.
`resource` names the kind of thing that was missing and is the half to branch
on: the code is `not_found` on newer routes and a per-entity spelling on
routes that shipped before that rule, and the two mean the same thing.
A 404 is ALWAYS about the url. An id inside the request body that resolves to
nothing is 422 `unprocessable_reference` instead, so the two cases stay
distinguishable. An id that belongs to a different merchant reads exactly like
one that never existed.
- `409` — The request is well formed and the store's current state refuses it.
EVERY WRITE CAN ANSWER TWO OF THESE, whatever it does:
`idempotency_key_reused`, this Idempotency-Key already served a different
method, path or body. The key namespace is per store and not per endpoint, so a
key built from a business id collides across routes; use a fresh key per
logical write.
`idempotency_key_in_progress`, an identical request is still running. Retry
after a short delay; exactly one of the racing calls will have applied.
`not_configured` means the merchant has not set something up yet, with
`resource` naming what. The remaining codes are the per-route state rules named
on the operation.
- `413` — The request body exceeded the cap named in the message. `code` is
`payload_too_large`. Nothing was read and nothing was recorded, so the same
Idempotency-Key may be reused once the body is smaller.
- `415` — The body was not declared as `application/json`. `code` is
`unsupported_media_type`.
This API reads ONE media type. The `+json` structured suffixes are refused
too, because they name semantics (merge-patch in particular) this API does
not implement, and reading such a body as plain JSON would be a silent
misreading. A write that carries NO body needs no Content-Type at all.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request DELETE \
--url 'https://api.mercemur.com/api/v1/companies/{companyId}/contacts/{companyContactId}' \
--header 'Authorization: Bearer '
```
# Update a B2B company account
`PATCH /api/v1/companies/{companyId}`
## Path parameters
- `companyId` (string, required)
## Headers
- `Idempotency-Key` (string, required) — A unique key per logical write. Replaying a request with the same key returns the first response byte for byte instead of applying the write twice.
## Request body
Required.
- `name` (string) — Must not be blank. Omit the key to leave it unchanged.
- `external_id` (string | null) — Send null to clear it, which is the real operation when an account moves out of the system that owned it. Omit the key to leave it alone.
- `status` (active | inactive) — The reversible withdrawal. Undone by patching it back to active.
- `metadata` (object) — Replaces the stored bag wholesale. Send {} to empty it.
## Responses
- `200` — Success
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the write_companies scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `404` — The resource this url addresses does not exist, or never did on this store.
`resource` names the kind of thing that was missing and is the half to branch
on: the code is `not_found` on newer routes and a per-entity spelling on
routes that shipped before that rule, and the two mean the same thing.
A 404 is ALWAYS about the url. An id inside the request body that resolves to
nothing is 422 `unprocessable_reference` instead, so the two cases stay
distinguishable. An id that belongs to a different merchant reads exactly like
one that never existed.
- `409` — The request is well formed and the store's current state refuses it.
EVERY WRITE CAN ANSWER TWO OF THESE, whatever it does:
`idempotency_key_reused`, this Idempotency-Key already served a different
method, path or body. The key namespace is per store and not per endpoint, so a
key built from a business id collides across routes; use a fresh key per
logical write.
`idempotency_key_in_progress`, an identical request is still running. Retry
after a short delay; exactly one of the racing calls will have applied.
`not_configured` means the merchant has not set something up yet, with
`resource` naming what. The remaining codes are the per-route state rules named
on the operation.
- `413` — The request body exceeded the cap named in the message. `code` is
`payload_too_large`. Nothing was read and nothing was recorded, so the same
Idempotency-Key may be reused once the body is smaller.
- `415` — The body was not declared as `application/json`. `code` is
`unsupported_media_type`.
This API reads ONE media type. The `+json` structured suffixes are refused
too, because they name semantics (merge-patch in particular) this API does
not implement, and reading such a body as plain JSON would be a silent
misreading. A write that carries NO body needs no Content-Type at all.
- `422` — An id INSIDE the request resolves to nothing on this store. `code` is
`unprocessable_reference`, `resource` names the kind of thing that did not
resolve and `field` names where it arrived, so the fix is mechanical.
Distinct from 404, which is about the url, and from 400, which is about the
bytes. The message stays generic about WHY the id did not resolve: an id owned
by another merchant must read identically to one that never existed.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request PATCH \
--url 'https://api.mercemur.com/api/v1/companies/{companyId}' \
--header 'Authorization: Bearer '
```
# Update a company location
`PATCH /api/v1/companies/{companyId}/locations/{companyLocationId}`
## Path parameters
- `companyId` (string, required)
- `companyLocationId` (string, required)
## Headers
- `Idempotency-Key` (string, required) — A unique key per logical write. Replaying a request with the same key returns the first response byte for byte instead of applying the write twice.
## Request body
Required.
- `name` (string) — Must not be blank. Omit the key to leave it unchanged.
- `customer_group_id` (string | null) — Requires write_pricing in addition to write_companies, whether it is being set or cleared. Must name a customer group in this store.
- `address_line_1` (string | null) — Send null to clear it.
- `address_line_2` (string | null) — Send null to clear it.
- `city` (string | null) — Send null to clear it.
- `region` (string | null) — Send null to clear it.
- `postal_code` (string | null) — Send null to clear it.
- `country_code` (string | null) — Send null to clear it.
- `phone` (string | null) — Send null to clear it.
- `tax_registration_id` (string | null) — Send null to clear it.
- `payment_terms_days` (integer | null) — Send null to record that no terms are agreed and 0 to record due on receipt. The two are different commercial facts.
- `is_default` (boolean) — Setting it true demotes whichever location currently holds the flag, in the same transaction.
## Responses
- `200` — Success
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the write_companies scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `404` — The resource this url addresses does not exist, or never did on this store.
`resource` names the kind of thing that was missing and is the half to branch
on: the code is `not_found` on newer routes and a per-entity spelling on
routes that shipped before that rule, and the two mean the same thing.
A 404 is ALWAYS about the url. An id inside the request body that resolves to
nothing is 422 `unprocessable_reference` instead, so the two cases stay
distinguishable. An id that belongs to a different merchant reads exactly like
one that never existed.
- `409` — The request is well formed and the store's current state refuses it.
EVERY WRITE CAN ANSWER TWO OF THESE, whatever it does:
`idempotency_key_reused`, this Idempotency-Key already served a different
method, path or body. The key namespace is per store and not per endpoint, so a
key built from a business id collides across routes; use a fresh key per
logical write.
`idempotency_key_in_progress`, an identical request is still running. Retry
after a short delay; exactly one of the racing calls will have applied.
`not_configured` means the merchant has not set something up yet, with
`resource` naming what. The remaining codes are the per-route state rules named
on the operation.
- `413` — The request body exceeded the cap named in the message. `code` is
`payload_too_large`. Nothing was read and nothing was recorded, so the same
Idempotency-Key may be reused once the body is smaller.
- `415` — The body was not declared as `application/json`. `code` is
`unsupported_media_type`.
This API reads ONE media type. The `+json` structured suffixes are refused
too, because they name semantics (merge-patch in particular) this API does
not implement, and reading such a body as plain JSON would be a silent
misreading. A write that carries NO body needs no Content-Type at all.
- `422` — An id INSIDE the request resolves to nothing on this store. `code` is
`unprocessable_reference`, `resource` names the kind of thing that did not
resolve and `field` names where it arrived, so the fix is mechanical.
Distinct from 404, which is about the url, and from 400, which is about the
bytes. The message stays generic about WHY the id did not resolve: an id owned
by another merchant must read identically to one that never existed.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request PATCH \
--url 'https://api.mercemur.com/api/v1/companies/{companyId}/locations/{companyLocationId}' \
--header 'Authorization: Bearer '
```
# List currencies
`GET /api/v1/currencies`
## Query parameters
- `limit` (integer) — Rows per page. Out of range is a 400 rather than a silent clamp, so a client asking for more than 100 learns it did not get it.
- `after` (string) — The next_cursor from the previous page. Opaque: decode nothing from it and construct nothing by hand, since its encoding is not part of this contract. Omit it to read the first page.
## Responses
- `200` — Success
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the read_currencies scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request GET \
--url 'https://api.mercemur.com/api/v1/currencies' \
--header 'Authorization: Bearer '
```
# Retrieve a currency
`GET /api/v1/currencies/{currencyCode}`
## Path parameters
- `currencyCode` (string, required)
## Responses
- `200` — Success
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the read_currencies scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `404` — The resource this url addresses does not exist, or never did on this store.
`resource` names the kind of thing that was missing and is the half to branch
on: the code is `not_found` on newer routes and a per-entity spelling on
routes that shipped before that rule, and the two mean the same thing.
A 404 is ALWAYS about the url. An id inside the request body that resolves to
nothing is 422 `unprocessable_reference` instead, so the two cases stay
distinguishable. An id that belongs to a different merchant reads exactly like
one that never existed.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request GET \
--url 'https://api.mercemur.com/api/v1/currencies/{currencyCode}' \
--header 'Authorization: Bearer '
```
# Create a customer group
`POST /api/v1/customer-groups`
## Headers
- `Idempotency-Key` (string, required) — A unique key per logical write. Replaying a request with the same key returns the first response byte for byte instead of applying the write twice.
## Request body
Required.
- `name` (string, required) — The group's display name. Merchant-chosen, not unique, and not the id used to add or remove members.
- `metadata` (object | null) — Free-form key/value data. Published unchanged on the read: this write and the dashboard's own create call the same service method, so nothing new touches the column.
## Responses
- `201` — Created
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the write_customers scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `409` — The request is well formed and the store's current state refuses it.
EVERY WRITE CAN ANSWER TWO OF THESE, whatever it does:
`idempotency_key_reused`, this Idempotency-Key already served a different
method, path or body. The key namespace is per store and not per endpoint, so a
key built from a business id collides across routes; use a fresh key per
logical write.
`idempotency_key_in_progress`, an identical request is still running. Retry
after a short delay; exactly one of the racing calls will have applied.
`not_configured` means the merchant has not set something up yet, with
`resource` naming what. The remaining codes are the per-route state rules named
on the operation.
- `413` — The request body exceeded the cap named in the message. `code` is
`payload_too_large`. Nothing was read and nothing was recorded, so the same
Idempotency-Key may be reused once the body is smaller.
- `415` — The body was not declared as `application/json`. `code` is
`unsupported_media_type`.
This API reads ONE media type. The `+json` structured suffixes are refused
too, because they name semantics (merge-patch in particular) this API does
not implement, and reading such a body as plain JSON would be a silent
misreading. A write that carries NO body needs no Content-Type at all.
- `422` — An id INSIDE the request resolves to nothing on this store. `code` is
`unprocessable_reference`, `resource` names the kind of thing that did not
resolve and `field` names where it arrived, so the fix is mechanical.
Distinct from 404, which is about the url, and from 400, which is about the
bytes. The message stays generic about WHY the id did not resolve: an id owned
by another merchant must read identically to one that never existed.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request POST \
--url 'https://api.mercemur.com/api/v1/customer-groups' \
--header 'Authorization: Bearer '
```
# List a customer group's customers
`GET /api/v1/customer-groups/{customerGroupId}/customers`
The customers in one group, paged. This is where membership lives, and the group resource deliberately carries no members array: a group with 50,000 buyers would otherwise serialise 50,000 ids into one row of a list response, on a resource whose page cap says nothing about how many people it names. THE OTHER HALF OF THE B2B SYNC PATH is GET /price-lists/{priceListId}/customer- groups. Together they are price list to groups to customers, which is how a wholesale integration learns which buyers get which negotiated prices. Neither leg is useful without the other. THE ROWS ARE THE SAME CUSTOMER RESOURCE /customers serves, with the same fields and the same nullability. One customer has one shape whichever route found them, so a client can hand a row here to the same parser it uses there. CURSOR ONLY, no offset and no total. A merchant tagging customers inserts rows into this membership continuously, and an offset walk drops or repeats one on every page turn; here a dropped row is a buyer who silently stops receiving wholesale prices. AN EMPTY GROUP IS A 200 WITH AN EMPTY PAGE. A group id that does not exist, or belongs to another store, is a 404. The two are distinguished deliberately: a 200 for a mistyped id would record "this tier has no buyers" and apply retail prices to everyone in it. MEMBERSHIP IS READ-ONLY HERE. Nothing on this API adds or removes a member, for the reason the group family publishes no writes at all: a group's price-list targeting rows cascade with it, and a price list left untargeted applies to EVERY customer.
## Path parameters
- `customerGroupId` (string, required)
## Query parameters
- `limit` (integer) — Rows per page. Out of range is a 400 rather than a silent clamp, so a client asking for more than 100 learns it did not get it.
- `after` (string) — The next_cursor from the previous page. Opaque: decode nothing from it and construct nothing by hand, since its encoding is not part of this contract. Omit it to read the first page.
## Responses
- `200` — Success
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the read_customers scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `404` — The resource this url addresses does not exist, or never did on this store.
`resource` names the kind of thing that was missing and is the half to branch
on: the code is `not_found` on newer routes and a per-entity spelling on
routes that shipped before that rule, and the two mean the same thing.
A 404 is ALWAYS about the url. An id inside the request body that resolves to
nothing is 422 `unprocessable_reference` instead, so the two cases stay
distinguishable. An id that belongs to a different merchant reads exactly like
one that never existed.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request GET \
--url 'https://api.mercemur.com/api/v1/customer-groups/{customerGroupId}/customers' \
--header 'Authorization: Bearer '
```
# List customer groups
`GET /api/v1/customer-groups`
## Query parameters
- `updated_after` (string (date-time)) — Groups touched at or after this RFC3339 instant, for reconciling incrementally instead of re-reading the whole list. Supplying it CHANGES THE ORDER of this endpoint: the default walk descends created_at, and this one climbs updated_at, which is the only ordering in which a keyset walk over a mutable column cannot skip a row. A row edited mid-walk moves forward past your position and is returned again, so the walk is AT LEAST ONCE: apply the state of each row you receive and a repeat costs nothing. The bound is INCLUSIVE, so resuming from the newest updated_at you hold re-delivers the rows sharing that instant rather than dropping the ones your last page did not reach. A cursor belongs to ONE ordering and is refused by the other. THE ONE CAVEAT: membership lives in a join table that carries no timestamp, so ADDING OR REMOVING A CUSTOMER does not move the group in this walk. Only editing the group itself does; reconcile membership from the members sub-list.
- `limit` (integer) — Rows per page. Out of range is a 400 rather than a silent clamp, so a client asking for more than 100 learns it did not get it.
- `after` (string) — The next_cursor from the previous page. Opaque: decode nothing from it and construct nothing by hand, since its encoding is not part of this contract. Omit it to read the first page.
## Responses
- `200` — Success
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the read_customers scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request GET \
--url 'https://api.mercemur.com/api/v1/customer-groups' \
--header 'Authorization: Bearer '
```
# Rename a customer group or update its metadata
`PATCH /api/v1/customer-groups/{customerGroupId}`
## Path parameters
- `customerGroupId` (string, required)
## Headers
- `Idempotency-Key` (string, required) — A unique key per logical write. Replaying a request with the same key returns the first response byte for byte instead of applying the write twice.
## Request body
Required.
- `name` (string)
- `metadata` (object | null) — THREE STATES, all distinct: omit the key to leave the stored bag untouched, send null or {} to clear it, send an object to replace it wholesale. There is no per-key merge.
## Responses
- `200` — Success
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the write_customers scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `404` — The resource this url addresses does not exist, or never did on this store.
`resource` names the kind of thing that was missing and is the half to branch
on: the code is `not_found` on newer routes and a per-entity spelling on
routes that shipped before that rule, and the two mean the same thing.
A 404 is ALWAYS about the url. An id inside the request body that resolves to
nothing is 422 `unprocessable_reference` instead, so the two cases stay
distinguishable. An id that belongs to a different merchant reads exactly like
one that never existed.
- `409` — The request is well formed and the store's current state refuses it.
EVERY WRITE CAN ANSWER TWO OF THESE, whatever it does:
`idempotency_key_reused`, this Idempotency-Key already served a different
method, path or body. The key namespace is per store and not per endpoint, so a
key built from a business id collides across routes; use a fresh key per
logical write.
`idempotency_key_in_progress`, an identical request is still running. Retry
after a short delay; exactly one of the racing calls will have applied.
`not_configured` means the merchant has not set something up yet, with
`resource` naming what. The remaining codes are the per-route state rules named
on the operation.
- `413` — The request body exceeded the cap named in the message. `code` is
`payload_too_large`. Nothing was read and nothing was recorded, so the same
Idempotency-Key may be reused once the body is smaller.
- `415` — The body was not declared as `application/json`. `code` is
`unsupported_media_type`.
This API reads ONE media type. The `+json` structured suffixes are refused
too, because they name semantics (merge-patch in particular) this API does
not implement, and reading such a body as plain JSON would be a silent
misreading. A write that carries NO body needs no Content-Type at all.
- `422` — An id INSIDE the request resolves to nothing on this store. `code` is
`unprocessable_reference`, `resource` names the kind of thing that did not
resolve and `field` names where it arrived, so the fix is mechanical.
Distinct from 404, which is about the url, and from 400, which is about the
bytes. The message stays generic about WHY the id did not resolve: an id owned
by another merchant must read identically to one that never existed.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request PATCH \
--url 'https://api.mercemur.com/api/v1/customer-groups/{customerGroupId}' \
--header 'Authorization: Bearer '
```
# Retrieve a customer group
`GET /api/v1/customer-groups/{customerGroupId}`
## Path parameters
- `customerGroupId` (string, required)
## Responses
- `200` — Success
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the read_customers scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `404` — The resource this url addresses does not exist, or never did on this store.
`resource` names the kind of thing that was missing and is the half to branch
on: the code is `not_found` on newer routes and a per-entity spelling on
routes that shipped before that rule, and the two mean the same thing.
A 404 is ALWAYS about the url. An id inside the request body that resolves to
nothing is 422 `unprocessable_reference` instead, so the two cases stay
distinguishable. An id that belongs to a different merchant reads exactly like
one that never existed.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request GET \
--url 'https://api.mercemur.com/api/v1/customer-groups/{customerGroupId}' \
--header 'Authorization: Bearer '
```
# Correct a customer's name or phone number
`PATCH /api/v1/customers/{customerId}`
## Path parameters
- `customerId` (string, required)
## Headers
- `Idempotency-Key` (string, required) — A unique key per logical write. Replaying a request with the same key returns the first response byte for byte instead of applying the write twice.
## Request body
Required.
- `first_name` (string | null)
- `last_name` (string | null)
- `phone` (string | null)
## Responses
- `200` — Success
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the write_customers scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `404` — The resource this url addresses does not exist, or never did on this store.
`resource` names the kind of thing that was missing and is the half to branch
on: the code is `not_found` on newer routes and a per-entity spelling on
routes that shipped before that rule, and the two mean the same thing.
A 404 is ALWAYS about the url. An id inside the request body that resolves to
nothing is 422 `unprocessable_reference` instead, so the two cases stay
distinguishable. An id that belongs to a different merchant reads exactly like
one that never existed.
- `409` — The request is well formed and the store's current state refuses it.
EVERY WRITE CAN ANSWER TWO OF THESE, whatever it does:
`idempotency_key_reused`, this Idempotency-Key already served a different
method, path or body. The key namespace is per store and not per endpoint, so a
key built from a business id collides across routes; use a fresh key per
logical write.
`idempotency_key_in_progress`, an identical request is still running. Retry
after a short delay; exactly one of the racing calls will have applied.
`not_configured` means the merchant has not set something up yet, with
`resource` naming what. The remaining codes are the per-route state rules named
on the operation.
- `413` — The request body exceeded the cap named in the message. `code` is
`payload_too_large`. Nothing was read and nothing was recorded, so the same
Idempotency-Key may be reused once the body is smaller.
- `415` — The body was not declared as `application/json`. `code` is
`unsupported_media_type`.
This API reads ONE media type. The `+json` structured suffixes are refused
too, because they name semantics (merge-patch in particular) this API does
not implement, and reading such a body as plain JSON would be a silent
misreading. A write that carries NO body needs no Content-Type at all.
- `422` — An id INSIDE the request resolves to nothing on this store. `code` is
`unprocessable_reference`, `resource` names the kind of thing that did not
resolve and `field` names where it arrived, so the fix is mechanical.
Distinct from 404, which is about the url, and from 400, which is about the
bytes. The message stays generic about WHY the id did not resolve: an id owned
by another merchant must read identically to one that never existed.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request PATCH \
--url 'https://api.mercemur.com/api/v1/customers/{customerId}' \
--header 'Authorization: Bearer '
```
# Create a customer
`POST /api/v1/customers`
## Headers
- `Idempotency-Key` (string, required) — A unique key per logical write. Replaying a request with the same key returns the first response byte for byte instead of applying the write twice.
## Request body
Required.
- `email` (string, required)
- `first_name` (string | null)
- `last_name` (string | null)
- `phone` (string | null)
## Responses
- `201` — Created
- `400` — The request was refused before any state changed. `code` is one of:
`invalid_body`, a write body this route will not take. `reason` partitions it
and `field` names the key when one key is at fault.
`invalid_query`, a query parameter, including limit and after.
`invalid_text`, a NUL byte or bytes that are not valid UTF-8 anywhere in the
path, the query or the body. Strip control characters before sending.
`idempotency_key_required`, a write sent without the Idempotency-Key header.
`invalid_request`, an Idempotency-Key longer than 255 bytes.
Routes add their own codes for rules only they know. Switch with a default arm.
- `401` — No credential, or one this API does not accept. `code` is always
`unauthorized`.
THE BODY IS DELIBERATELY UNINFORMATIVE. An expired key, a revoked key, a
publishable key, a key belonging to another merchant and a key that never
existed are all refused with the same bytes, so this response cannot be used to
probe which keys exist. Check the key's state in the dashboard rather than
inferring it here.
Send the key as `Authorization: Bearer ` or as `X-API-Key: `. It is
never accepted in a query string.
- `403` — The key lacks the write_customers scope. `code` is `insufficient_scope` and the message names the scope to ask the merchant for.
- `409` — The request is well formed and the store's current state refuses it.
EVERY WRITE CAN ANSWER TWO OF THESE, whatever it does:
`idempotency_key_reused`, this Idempotency-Key already served a different
method, path or body. The key namespace is per store and not per endpoint, so a
key built from a business id collides across routes; use a fresh key per
logical write.
`idempotency_key_in_progress`, an identical request is still running. Retry
after a short delay; exactly one of the racing calls will have applied.
`not_configured` means the merchant has not set something up yet, with
`resource` naming what. The remaining codes are the per-route state rules named
on the operation.
- `413` — The request body exceeded the cap named in the message. `code` is
`payload_too_large`. Nothing was read and nothing was recorded, so the same
Idempotency-Key may be reused once the body is smaller.
- `415` — The body was not declared as `application/json`. `code` is
`unsupported_media_type`.
This API reads ONE media type. The `+json` structured suffixes are refused
too, because they name semantics (merge-patch in particular) this API does
not implement, and reading such a body as plain JSON would be a silent
misreading. A write that carries NO body needs no Content-Type at all.
- `422` — An id INSIDE the request resolves to nothing on this store. `code` is
`unprocessable_reference`, `resource` names the kind of thing that did not
resolve and `field` names where it arrived, so the fix is mechanical.
Distinct from 404, which is about the url, and from 400, which is about the
bytes. The message stays generic about WHY the id did not resolve: an id owned
by another merchant must read identically to one that never existed.
- `429` — Too many requests. `code` is `rate_limited`.
Two limits apply independently: one on the credential and the route family,
one on the client address. The headers describe whichever has less left, so
honouring Retry-After always clears the window that bound.
- `default` — Any status this operation does not list, in the same envelope.
A 5xx means the request may or may not have applied. Retry it with the SAME
Idempotency-Key: that is the only way to find out without risking a duplicate,
and it is what the key is for.
A few 4xx conditions arrive here rather than as a listed status because they
depend on the merchant's plan or on a module being wired: 402 when a quota or a
plan limit is reached, and 503 when a capability the route needs is not
configured on this deployment. Both carry a `code` naming which.
## Example
```bash
curl --request POST \
--url 'https://api.mercemur.com/api/v1/customers' \
--header 'Authorization: Bearer