API introduction

Requests

On this page

This page describes what your software sends. The fields of each call are on its reference page.

Methods#

MethodUsed for
GETReading: lists and single items.
POSTCreating something, or an action (adjust stock, add shipment details, add a note).
PATCHChanging only the fields you send.
DELETEArchiving a product. It is the only DELETE call, and it never deletes.

A method that does not exist on an address answers 405 (method_not_allowed) with an Allow header listing the methods that do.

Addresses#

Calls go to /api/v1/... on your store. Ids in an address are whole numbers, for example /api/v1/products/7. Orders are found by their order number instead, for example /api/v1/orders/GK-261008-7WNM. The first letters are your store's order prefix (GK- by default); use the number exactly as your store shows it.

Order numbers#

An order number is text, for example GK-261008-7WNM: the store's order prefix, the date as yymmdd, a dash and four letters or digits. The prefix is a store setting of 2 to 6 letters or digits and a dash (default GK-). A new prefix applies to new orders only; existing orders keep their numbers and are still found by them. Always handle the number as text, and never assume a fixed prefix. More on the Orders reference page.

Headers#

HeaderWhenMeaning
Authorization or X-Api-KeyEvery requestYour API key. See Authentication.
Content-Type: application/jsonPOST and PATCH with a bodyThe body is JSON (UTF-8).
Idempotency-KeyOptional on POST and PATCHMakes a retry safe. See below.
Accept: application/jsonOptionalAnswers are always JSON.

The JSON body#

  • Send a JSON object. Every field of every call is listed on its reference page with its type, whether it is required and its limits (maximum length, minimum and maximum).
  • A field the call does not accept is refused, not ignored: you get 422 with the reason. For example, stock can never be sent when creating or updating a product:
{
    "error": {
        "code": "validation_failed",
        "message": "The request could not be accepted. See \"fields\" for what to fix.",
        "fields": {
            "stock": [
                "Stock cannot be set here. Use POST /api/v1/inventory/adjustments, which records a reason in the stock history."
            ]
        }
    }
}

Idempotency-Key#

Networks fail, and a retry must not create a second product or add stock twice. Send an Idempotency-Key header on POST and PATCH requests. Use 1 to 100 letters, digits or the characters . _ : -. A random UUID is ideal, one for each thing you want to do.

  • The first request with a key is carried out and its answer is stored for 24 hours.
  • The same key with the same request returns the stored answer again, with the header Idempotent-Replayed: true, and does nothing a second time. JSON bodies are compared by meaning, so the order of fields does not matter.
  • The same key with a different request returns 409 (idempotency_key_reuse). While the first request is still running, a second one returns 409 (idempotency_in_progress): retry in a moment.
  • A server error (500) is not stored, so you can retry it with the same key. After 24 hours a key can be used again.
  • Keys belong to the API key that sent them: another API key can use the same value without any clash.