The production API base is https://api.merchi.co/. Current SDK requests use protocol v6; the backend also registers v5. Standard resource URLs include the protocol and a trailing slash, for example /v6/products/ and /v6/products/123/.
This guide follows the API source at the audited revision. The API reference identifies implemented endpoints. Availability depends on the deployed server revision and the caller’s permissions.
A generic API key is not required for every endpoint. Some product reads allow public access; writes and private data require the applicable user, domain and model permissions. A publicly reachable route does not grant access to every record.
For user sessions, the backend accepts the session_token cookie, or a session_token query/form parameter. Prefer cookies where your application supports them. Do not supply different cookie and parameter tokens: the backend rejects mismatches and can invalidate the affected sessions. Keep tokens out of shared URLs, logs and client bundles.
client_token, invoice_token and cart_token are separate credentials used by their corresponding workflows. They are not interchangeable with an authenticated staff session. A generic Authorization: Bearer token is not a replacement for these REST credentials; MCP authentication has its own handling.
Browser requests also pass the server’s origin/domain checks. For cross-origin cookie requests, the browser must send credentials and the origin must be accepted by the server. as_domain can select domain context for eligible users; it does not grant permissions.
Sources: request authentication and context, product access declarations.
For a public storefront, send an unauthenticated request scoped to the store’s numeric domain ID. Set MERCHI_API to your environment’s HTTPS API origin and MERCHI_DOMAIN_ID to the store’s positive numeric ID from your integration configuration.
curl --fail-with-body --get "$MERCHI_API/v6/products/" \
--data-urlencode "in_domain=${MERCHI_DOMAIN_ID:?Set the store domain ID}" \
--data-urlencode 'public_only=true' \
--data-urlencode 'limit=10' \
--data-urlencode 'offset=0' \
--data-urlencode 'embed={"domain":{}}'
An unscoped public list can contain products from several stores. Public visibility is limited to published master products marked public in active domains. A signed-in caller can have additional access through staff roles or related jobs. For a customer-facing catalog, use an unauthenticated request so the list reflects what customers can browse.
Use in_domain for an explicitly scoped catalog. The alternative in_domain_name applies the filter when the hostname resolves to a domain in Merchi. If it matches no domain, the API can return the unscoped visible list. Supplying both parameters returns HTTP 400.
Product access policy · Domain filter parsing
For a single product, substitute a real product ID. An anonymous request for an existing private product returns HTTP 401. When using an authenticated read for a store page, check that the returned product belongs to the expected domain.
const url = new URL('https://api.merchi.co/v6/products/123/');
url.searchParams.set('embed', JSON.stringify({ domain: {} }));
const response = await fetch(url, { credentials: 'include' });
const data = await response.json();
if (!response.ok) throw new Error(data.message || `HTTP ${response.status}`);
console.log(data.product);
Standard single-entity responses wrap the entity under its singular JSON name (product in this example). The product list returns entries under products, each wrapping an entity under product. Read the pagination fields count, available, limit and offset at the top level. Custom actions can return different shapes.
Use the product ID from your storefront’s product list to fetch the
calculator inputs. Set MERCHI_PRODUCT_ID to that ID.
curl --fail-with-body --get "$MERCHI_API/v6/products/$MERCHI_PRODUCT_ID/pricing-rules/"
A supported product returns currency, taxPercent, product, fields
and groupFields at the top level. The product object supplies
unitPrice, minimumPrice, setup charges and an optional
discountGroup. When present, discountGroup.discounts contains entries
with lowerLimit and amount. Use fields for independent options and
groupFields for options that repeat by group.
For example, the SDK pricing fixture includes this excerpt.
{
"currency": "AUD",
"taxPercent": 10,
"product": {
"unitPrice": 30,
"minimumPrice": 0,
"discountGroup": {
"groupRestricted": false,
"discounts": [{"lowerLimit": 400, "amount": 10}]
}
}
}
Here taxPercent is 10 percent, and the quantity tier starts at 400 units
with a 10 percent unit-price discount. A positive minimumPrice is a
floor on the base product amount. When the discounted unit price multiplied
by quantity falls below that floor, the calculator divides the floor by the
quantity to get the effective unit price.
For inventory-limited products, needsInventory is true. An option’s
available flag is a snapshot. The inventoryUnits array describes
stock by option combination using optionIds and quantity. Check the
current quantity and selections at checkout.
SDK pricing fixture · SDK discount calculation
An unsupported product can return HTTP 200 with an unsupported reason
and currency, without the calculator inputs. A missing product returns
HTTP 404. For a staff quote with selected options and quantities, use the
server-side estimate.
Pricing rules route · Pricing bundle serializer
For standard product CRUD, the implemented verbs are:
| Operation | Method | Path |
|---|---|---|
| List | GET | /v6/products/ |
| Read | GET | /v6/products/<id>/ |
| Create | POST | /v6/products/ |
| Partial update | PATCH | /v6/products/<id>/ |
| Delete | DELETE | /v6/products/<id>/ |
The standard create/update helpers consume form parameters. Do not send JSON to these helpers and expect it to be parsed as form data. Custom endpoints may explicitly accept JSON; consult their implementation. Required fields and writable relationships are model-specific.
For example, this partial update changes a product name, using an existing authenticated browser session with edit permission:
const response = await fetch('https://api.merchi.co/v6/products/123/', {
method: 'PATCH',
credentials: 'include',
body: new URLSearchParams({ name: 'Updated product name' })
});
const data = await response.json();
if (!response.ok) throw new Error(data.message || `HTTP ${response.status}`);
console.log(data.product);
Use POST with a form body for creation and supply the fields required by the selected model. Creation normally returns HTTP 201; the standard partial-update helper returns 200. Check the status before parsing a response body: some actions return an empty response or a non-JSON payload. Deletion follows each model’s archival/deletion policy and may be rejected when related records prevent it.
Sources: CRUD helpers and response serialization, product routes.
limit and offset control standard lists; the default limit is 25. Limits can vary by endpoint.sort names the supported model field and order is asc or desc.count_only=true requests the standard list count without loading rows: the entity array is empty and available carries the matching total.embed is a JSON object whose relationship values are nested objects, such as {"domain":{"company":{}}}. A comma-separated string or array is not the embed format. The backend bounds its length and validates its structure.include_archived controls archived-data inclusion and is separate from embed; it does not bypass access policy.skip_rights=true suppresses rights information in serialization. It does not skip authorization.The shared filter helper accepts snake_case or camelCase for parameters it handles, but rejects supplying both forms of one parameter. This is not a guarantee that every custom endpoint accepts both spellings. See the filter reference for model-specific filters.
Keep the same filters and ordering on every request. For products, sort=id&order=asc gives a stable order for unchanged data. Set MERCHI_API to the HTTPS API origin and MERCHI_DOMAIN_ID to the store’s positive numeric ID.
curl --fail-with-body --get "$MERCHI_API/v6/products/" \
--data-urlencode "in_domain=${MERCHI_DOMAIN_ID:?Set the store domain ID}" \
--data-urlencode 'sort=id' \
--data-urlencode 'order=asc' \
--data-urlencode 'limit=2' \
--data-urlencode 'offset=0' \
--data-urlencode 'skip_count=true'
The response contains one product object per entry in products. These are the pagination fields for a first page with two results.
{"count":2,"available":null,"limit":2,"offset":0}
Set the next request’s offset to the returned offset + count. For a positive page size, stop on an empty page or when count < limit using the returned limit. With exactly a full page and no total, the next page may be empty. Offset pagination can skip or repeat records if matching products change while you page.
| List mode | Response |
|---|---|
| Default |
count is the number of rows on this page. available is the total matching the filters before pagination. |
skip_count=true |
Rows are returned with available: null. |
count_only=true |
The row array is empty, count is zero, and available is the total. This mode takes precedence if both flags are supplied. |
Use a positive limit to bound the response. On the standard list helper, limit=0 removes the SQL row limit.
Product sort keys · Pagination and count modes
Use the HTTP status as the primary success indicator. Standard API errors include message, statusCode and errorCode. Custom handlers and infrastructure may return other formats. Check the content type before parsing JSON, and handle an empty body separately. Handle invalid input, missing/inaccessible resources, expired credentials and permission failures explicitly. Do not automatically retry a failed write: reconcile whether the operation took effect before repeating it.
The backend enforces request limits and may progressively delay requests before rejecting excessive traffic. Avoid unbounded polling, request only needed embeds and paginate large collections. Apply bounded retries to safe transient reads.
Sources: error responses, routing, CORS and throttling.
File uploads, checkout, payments, drafts, shipment actions and external-provider callbacks have dedicated handlers. Do not extrapolate the product CRUD body or response shape to them. For multipart uploads, use FormData and let the HTTP client supply its boundary instead of manually setting Content-Type. Check the endpoint’s accepted fields, authentication and response before integrating it.
See the integration workflows for checkout, Stripe attempts and refunds, draft review, carrier shipping and signed webhook delivery.
The file guide covers multipart field names, scoped file access and public catalog downloads.