If you're using Claude Code, Cursor, or a similar tool to build your integration, paste the block below as your opening prompt. It gives the assistant the API's ground rules up front so it doesn't have to infer them — and, just as importantly, tells it what the API doesn't do, so it doesn't invent endpoints that don't exist.
Fill in the last line with what you want built.
Don't paste your API token into the prompt — tell the assistant to read it from an environment variable and add it yourself.
You are building an integration against the CartGenie Public API.
REFERENCE
Docs: https://api.cartgenie.com/public-api-docs
OpenAPI spec: https://api.cartgenie.com/public-api-docs.openapi (YAML)
Postman: https://api.cartgenie.com/public-api-docs.postman
Fetch the spec before writing code. It is the single source of truth.
Do not invent endpoints, fields, or shapes — if something isn't in the
spec, say so instead of assuming it exists.
BASICS
Base URL: https://api.cartgenie.com, all endpoints under /public/v1/
Auth: every request needs `Authorization: Bearer <token>`.
Read the token from an environment variable. Never hardcode it and
never expose it to a browser or any client-side code.
Sanity check: GET /public/v1/store returns 200 when the token is valid
and the API is enabled for the store.
SURFACE AREA — CHECK THE SPEC, DON'T HARDCODE A LIST
The API grows over time; endpoints and fields get added. Build only
against the spec you fetched, not a remembered list. At a high level it
covers the store, products (variants, options, bundles, images,
inventory and other product settings), image uploads, orders
(fulfillment, tracking, payment status, refunds), customers,
categories, discounts and webhooks — treat that as orientation, not a
contract, and confirm every call against the spec.
Two things gate what you can actually call, on top of the spec:
- Token scopes are per area and split read vs write (e.g. read_orders
vs write_orders). A call your token isn't scoped for fails — usually
403, sometimes 404.
- Per-store availability: an endpoint can be in the spec but switched
off for a given store, or still rolling out. Those answer 404 with an
EMPTY message body. Treat an empty-message 404 as "not available for
this store," not as a bug or a missing route.
RULES THAT WILL BREAK NAIVE CODE
1. Strict validation. Any field an endpoint doesn't define returns 422
rather than being ignored. Never read an object, modify it, and POST
the whole thing back — build request bodies from scratch with only
the fields being changed. A PATCH/PUT with no fields is also 422.
2. Cursor pagination. Pass `limit` and send `meta.next_cursor` back as
`cursor`. Stop when `meta.has_more` is false. Cursors are opaque —
never construct or parse them.
3. Incremental sync. products, variants, orders and customers accept
`updated_since` (ISO-8601). Persist the timestamp of each successful
run and use it to start the next. The product feed also reports
removals — reconcile against a full listing on a schedule, since not
every change is guaranteed to reach the feed.
4. Money is in the smallest currency unit. 4900 is $49.00. Never do
float math on it. Weights and dimensions are in hundredths of the
store's configured unit, which the API does not expose — confirm the
unit out of band.
5. Inventory writes are absolute, not increments. PUT
/variants/{id}/inventory with `stock` sets the level; always send
`expected_stock` so the write is conditional — on 409 the response
carries `actual_stock`, so retry from that without re-reading.
Tracking must be on first: enable it with PATCH /variants/{id} and
`track_inventory: true` (you may set the initial `stock` in that same
PATCH). An unpublished variant still keeps its stock.
6. Images attach by `url` (CartGenie fetches it) OR by uploading a file
first: POST /public/v1/uploads returns a signed form, you POST the
file to storage, then reference the returned `upload_id` in
PUT /products/{id}/images or /variants/{id}/images. Don't POST file
bytes to the images endpoint itself.
7. Variants are created by adding an option set (POST
/products/{id}/options), not by a "create variant" call. New
combinations copy an existing variant's settings but NOT its SKU.
8. SKUs are not unique within a store. GET /variants?sku= always
returns an array. Never take [0] and assume it's correct.
9. Product deletions are polymorphic. Check `deleted_at` before
touching any other field. A permanently deleted product carries only
id, name, slug, status, deleted_at and updated_at — no price, stock,
variants, images or url. Archived products keep the full shape but
also carry `deleted_at`.
10. Order shapes are conditionally complete. `shipment` is an object on
shippable orders and an empty ARRAY on digital-only ones. Refunds
live at GET /orders/{name}/refunds. payment.method and
transaction_id are null until the gateway records them.
11. Orders are addressed by merchant-visible name, not database id.
URL-encode it.
12. Tracking routing. With zero fulfillments, tracking goes to the
order's shipment. With exactly one, omit fulfillment_id. With more
than one, or a partially fulfilled order, fulfillment_id is
required. Once any fulfillment exists, shipment.tracking_* reads
back null — read tracking from fulfillments[].
13. Cancel is a status change only. It does not refund, restock, remove
fulfillments, or cancel subscriptions. Refund / unfulfill / restock
are separate calls.
WEBHOOKS
Body arrives as {"type": "<event>", "payload": {...}} with a `Signature`
header holding an HMAC-SHA256 of the RAW body, keyed with the store's
webhook secret (Settings → Webhooks). Hash the raw bytes exactly as
received — re-serializing the JSON produces a different digest. A
delivery is attempted up to three times with exponential backoff and a
10-second timeout, so answer fast. The envelope carries no delivery id,
so make the handler idempotent on the payload itself. Endpoints must be
public HTTPS.
ERROR HANDLING
401 bad token, 403 missing scope, 409 state conflict, 422 validation,
429 rate limit (120 req/min, 4 req/sec per token — respect
X-RateLimit-Remaining and Retry-After). 404 is overloaded: a non-empty
message like "Resource not found." means the record doesn't exist; an
EMPTY message means the API or that capability isn't enabled for the
store. Handle each distinctly; don't collapse them into a generic retry.
HOW TO WORK
Ask before assuming anything not covered above or in the spec. State
your assumptions explicitly. Write the sync/state logic so a partial
failure can be resumed rather than restarted.
WHAT I WANT YOU TO BUILD
[describe your integration here]