HTTP Marketplace#

HTTP Marketplace is Afosto's generic order connection. Afosto defines the API on this page; the selling platform implements it. Afosto then:

  • polls the platform for new and changed orders and imports them into Afosto;
  • picks up cancellations made on the platform from those same polls;
  • posts shipments (with track and trace) and cancellations made in Afosto back to the platform.

The direction is the reverse of the rest of these docs: here Afosto is the client and the platform hosts the endpoints.

Poll is dueGET /orders?channel=…&updated_since=…follow next_cursor to the last pageAll pages OK?noFailed pollwait (n − 1)² min, max 3 hupdated_since unchangedyesFor each order on the pagesImported before?noGET /orders/{order_id}import it once it is READYyesApply cancellationscancelled_quantity or CANCELLEDSuccessful pollnext poll within 3 min, failure count reset
Orders: Afosto polls the platform per channel
Shipped or cancelledin AfostoPOST /orders/{order_id}/…shipments or cancellations200, 201, 204done400, 401, 403, 422stops; message in the back office429, 5xx, timeoutretried later, same id
Updates: Afosto posts shipments and cancellations to the platform

Once your endpoints are up, check them against this specification with the tester.

·
Note:This specification is a draft and can still change.

Basics#

TopicAgreement
TransportHTTPS only. JSON request and response bodies, UTF-8, Content-Type: application/json.
Base URLChosen by the platform, e.g. https://api.example.com/afosto/v1. Every path below is relative to it.
AuthenticationAuthorization: Bearer <api_key> on every request. The platform issues the key; it is entered in the Afosto integration.
IP allowlistWhen the platform only admits known IP addresses, Afosto supplies the addresses it calls from.
TimestampsRFC 3339 with a time zone, e.g. 2026-12-02T14:05:00+01:00.
AmountsIntegers in the minor unit of the currency (cents), including VAT. 1995 is € 19,95.
CurrenciesISO 4217, e.g. EUR.
CountriesISO 3166-1 alpha-2, e.g. NL.
IdsStrings. An id never changes. Order ids are unique across all channels of the platform.
Response timeRespond within 30 seconds; Afosto treats a slower response as a failure and retries.

Status codes#

CodeMeaning for Afosto
200, 201, 204Success.
400, 401, 403, 422Permanent failure: Afosto stops and reports the error in its back office. Put a readable message in the body (see Error).
404The order does not exist.
429, 5xx, timeoutsTemporary failure: Afosto retries later.

Channels#

A platform can sell through several sales channels (its own shop, a marketplace, ...). Each channel is connected to Afosto once, as its own integration, and lands in its own Afosto sales channel.

Each channel has a code the platform chooses, e.g. webshop or marketplace-nl. Afosto lists the orders of one channel at a time, with the channel query parameter of GET /orders. The other order endpoints work on the order id alone.

When the merchant sets up a connection in Afosto, Afosto lists the platform's channels with GET /channels, and the merchant picks the one to connect. The same call checks that the base URL and API key work.

Endpoints#

The platform implements these five endpoints.

MethodPathPurpose
GET/channelsList the channels the API key gives access to
GET/ordersList the orders of a channel created or changed since a moment
GET/orders/{order_id}Get one order
POST/orders/{order_id}/shipmentsAfosto shipped (part of) an order
POST/orders/{order_id}/cancellationsAfosto cancelled (part of) an order

List channels#

GET /channels

Lists the channels the API key gives access to. Not paginated.

Response 200:

{
  "data": [{ "...": "Channel" }]
}
FieldTypeDescription
dataarray of ChannelEvery channel the API key gives access to.

List orders#

GET /orders

Lists the orders of one channel that were created or changed at or after updated_since, oldest change first. A change is anything that moves updated_at: a new order, a payment, a cancellation, a shipment.

Query parameters:

NameRequiredDescription
channelyesThe code of the Channel. Return only the orders placed in it.
updated_sinceyesRFC 3339 moment. Return orders whose updated_at is at or after it.
cursornoThe next_cursor of the previous page.
limitnoPage size, 1–100. Default 100.

Response 200:

{
  "data": [{ "...": "Order" }],
  "next_cursor": "eyJvZmZzZXQiOjEwMH0"
}
FieldTypeDescription
dataarray of OrderThe orders on this page, sorted on updated_at ascending.
next_cursorstring or nullThe cursor of the next page; null on the last page.

Get an order#

GET /orders/{order_id}

Response 200: one Order. 404 when the order is unknown.

Afosto calls this right before it imports or updates an order, so it always works with the latest state.

Post a shipment#

POST /orders/{order_id}/shipments

Afosto handed (part of) the order to the carrier. Body: a Shipment.

Response 201 (or 200 when this shipment id was received before, see Idempotency). The body is ignored.

Afosto sends one shipment per parcel. An order can have several shipments.

Post a cancellation#

POST /orders/{order_id}/cancellations

Afosto cancelled (part of) the order, e.g. because an item is out of stock. Body: a Cancellation.

Response 201 (or 200 when this cancellation id was received before). The body is ignored. Respond 422 with a message when the lines cannot be cancelled any more.

Afosto can post a cancellation per piece: one cancellation with quantity 1 for each cancelled piece, so a line can get several cancellations. The reason can be empty.

Objects#

Fields marked required must be present and not empty. Optional fields may be left out or be null.

Channel#

FieldTypeRequiredDescription
codestringyesThe value of the channel query parameter of GET /orders.
namestringyesThe name the merchant recognises, e.g. Marketplace NL.
currencystringnoThe currency of the channel's orders.
country_codestringnoThe country the channel sells to, when it sells to one.

Order#

FieldTypeRequiredDescription
idstringyesThe order's id on the platform.
numberstringyesThe order number the customer sees. Used as the order number in Afosto.
statusstringyesPENDING, READY, CANCELLED or COMPLETED. See Order status.
created_attimestampyesWhen the customer placed the order.
updated_attimestampyesWhen the order last changed.
currencystringyesCurrency of every amount on the order.
customerCustomeryesWho placed the order.
billing_addressAddressyes
shipping_addressAddressyesWhere the order goes. For a pickup point order: the customer's own address.
pickup_pointPickupPointnoSet when the customer chose a pickup point.
shippingShippingnoThe shipping method the customer chose and what they paid for it.
linesarray of LineyesAt least one line.
customer_notestringnoNote of the customer, e.g. a delivery instruction.
referencestringnoThe customer's own reference, e.g. a purchase order number.
metadataobject of string → stringnoAny extra data the platform wants to keep on the order. Stored as is.

Order status#

StatusMeaningAfosto
PENDINGPlaced but not ready to fulfil, e.g. not paid yet.Waits; imports it once it is READY.
READYPaid and ready to be fulfilled.Imports it.
CANCELLEDCancelled as a whole.Not imported; cancelled in Afosto when it was imported before.
COMPLETEDFully shipped or closed.Nothing.

Partial cancellations are on the lines (cancelled_quantity), not on the order status.

Customer#

FieldTypeRequiredDescription
emailstringyes
phonestringnoPreferably in international format, +31612345678.
given_namestringyes
family_namestringyes
organisationOrganisationnoSet for a business customer.

Organisation#

FieldTypeRequiredDescription
namestringyes
vat_numberstringnoe.g. NL123456789B01.
coc_numberstringnoChamber of commerce number.

Address#

FieldTypeRequiredDescription
given_namestringyes
family_namestringyes
organisationstringno
streetstringyesStreet name, without the house number.
house_numberstringyese.g. 12.
house_number_suffixstringnoe.g. A or bis.
address_line_2stringnoAny extra address line.
postal_codestringyes
citystringyes
regionstringnoState or province, where the country uses one.
country_codestringyes

PickupPoint#

FieldTypeRequiredDescription
carrierstringyesPOSTNL, DHL, DPD, GLS or UPS.
idstringyesThe carrier's id of the pickup point.
country_codestringyes

Afosto can only ship to the pickup point when the merchant has a pickup point shipping method of that carrier.

Shipping#

FieldTypeRequiredDescription
methodstringnoName of the shipping method, e.g. Standard or Evening delivery. Afosto matches it to an Afosto shipping method by name.
carrierstringnoPreferred carrier, same codes as PickupPoint.
priceintegeryesWhat the customer paid for shipping, in cents including VAT. 0 for free shipping.

Line#

One product on the order.

FieldTypeRequiredDescription
idstringyesThe line's id; unique within the order. Shipments and cancellations refer to it.
skustringyesThe SKU of the product, the same as in Afosto.
gtinstringnoEAN/GTIN of the product.
titlestringyesProduct name as sold.
quantityintegeryesNumber of pieces ordered, at least 1.
cancelled_quantityintegernoNumber of those pieces cancelled on the platform. Default 0.
shipped_quantityintegernoNumber of those pieces the platform shipped itself, for a PLATFORM line. Default 0.
unit_priceintegeryesPrice per piece the customer paid, in cents including VAT, after discount.
original_unit_priceintegernoPrice per piece before discount, when there was one.
vat_ratenumberyesVAT percentage, e.g. 21, 9 or 0.
image_urlstringno
fulfilmentstringnoWho ships the line: MERCHANT or PLATFORM. Default MERCHANT. See Fulfilment.

Fulfilment#

ValueMeaningAfosto
MERCHANTThe merchant ships the line from its own stock.Reserves stock, ships the line and posts a shipment for it.
PLATFORMThe platform ships the line from its own warehouse, e.g. a fulfilment service of the marketplace.Books the line on the order without reserving stock or shipping it, from the location set on the connection. Marks the pieces in shipped_quantity as shipped. Posts no shipments or cancellations for it.

An order can mix both: Afosto then ships and reports only the MERCHANT lines.

Raise shipped_quantity on a PLATFORM line when the platform ships its pieces, and move updated_at. Afosto picks it up from the next poll and reports those pieces as shipped in Afosto. shipped_quantity plus cancelled_quantity is at most quantity.

Shipment#

Sent by Afosto.

FieldTypeDescription
idstringAfosto's id of the shipment. The same shipment always has the same id.
shipped_attimestampWhen it was handed to the carrier.
carrierstringe.g. POSTNL, DHL, DPD.
tracking_numberstring
tracking_urlstring or nullTrack and trace link, when the carrier has one.
linesarrayThe pieces in this shipment: { "line_id": "...", "quantity": 1 }. Only lines with fulfilment MERCHANT.

Cancellation#

Sent by Afosto.

FieldTypeDescription
idstringAfosto's id of the cancellation. The same cancellation always has the same id.
cancelled_attimestamp
reasonstring or nullFree text, e.g. Out of stock.
linesarrayThe pieces cancelled: { "line_id": "...", "quantity": 1 }.

Error#

Body of any 4xx or 5xx response:

{ "message": "Line 7 is already shipped" }

Behaviour#

Polling#

  • Afosto polls the order list per channel. After a successful poll, the next one follows within 3 minutes.
  • updated_since is the start of Afosto's last successful poll, minus an overlap. When a poll fails (timeout, 5xx), the next poll asks from the same moment again, so no order is missed. The platform does not need to remember anything about Afosto.
  • The overlap means the same order can come back in several polls. Afosto recognises orders it imported before by id.
  • Make sure updated_at moves on every change that matters to Afosto: becoming READY, and any change of cancelled_quantity or shipped_quantity.
  • The first poll of a new connection asks from the start moment set on the connection, by default the moment the connection was switched on; orders that last changed before that are not imported.

Backoff after a failed poll#

A poll fails when a page of GET /orders fails: a timeout, a connection error, 429, 5xx or a 4xx. Afosto then backs off automatically: every failed poll in a row moves the next one further out.

Failed polls in a rowNext poll after
1At once
21 minute
34 minutes
49 minutes
516 minutes
n(n − 1)² minutes, at most 3 hours

The first successful poll resets the count; polling is back to every few minutes. Because updated_since stays at the last successful poll, that poll picks up every order that changed while the platform was unreachable. Failed polls are shown on the connection in the Afosto back office.

Cancellations on the platform#

When the customer or the platform cancels pieces after Afosto imported the order, raise cancelled_quantity on the line (or set the order status to CANCELLED) and move updated_at. Afosto picks it up from the next poll and cancels the pieces that were not shipped yet. Pieces already handed to the carrier stay as they are.

Idempotency#

Afosto may post the same shipment or cancellation again, e.g. after a timeout. A POST with an id the platform received before must succeed (200) without doing anything twice.

Retries#

Afosto retries a failed call later, with growing intervals. Errors that keep coming back are shown in the Afosto back office, with the message of the response.

Example#

GET /channels

{
  "data": [
    { "code": "webshop", "name": "Webshop", "currency": "EUR", "country_code": "NL" },
    { "code": "marketplace-nl", "name": "Marketplace NL", "currency": "EUR", "country_code": "NL" }
  ]
}

GET /orders?channel=marketplace-nl&updated_since=2026-12-02T14:00:00%2B01:00

{
  "data": [
    {
      "id": "100482",
      "number": "SO-100482",
      "status": "READY",
      "created_at": "2026-12-02T14:01:12+01:00",
      "updated_at": "2026-12-02T14:03:40+01:00",
      "currency": "EUR",
      "customer": {
        "email": "j.jansen@example.com",
        "phone": "+31612345678",
        "given_name": "Jan",
        "family_name": "Jansen"
      },
      "billing_address": {
        "given_name": "Jan",
        "family_name": "Jansen",
        "street": "Hoofdstraat",
        "house_number": "12",
        "house_number_suffix": "A",
        "postal_code": "1234 AB",
        "city": "Amsterdam",
        "country_code": "NL"
      },
      "shipping_address": {
        "given_name": "Jan",
        "family_name": "Jansen",
        "street": "Hoofdstraat",
        "house_number": "12",
        "house_number_suffix": "A",
        "postal_code": "1234 AB",
        "city": "Amsterdam",
        "country_code": "NL"
      },
      "shipping": { "method": "Standard", "carrier": "POSTNL", "price": 495 },
      "lines": [
        {
          "id": "1",
          "sku": "TSHIRT-BLK-M",
          "gtin": "8712345678906",
          "title": "Organic cotton T-shirt, black, M",
          "quantity": 1,
          "cancelled_quantity": 0,
          "shipped_quantity": 0,
          "unit_price": 2995,
          "vat_rate": 21,
          "fulfilment": "MERCHANT"
        },
        {
          "id": "2",
          "sku": "TOTE-CANVAS",
          "title": "Canvas tote bag",
          "quantity": 2,
          "cancelled_quantity": 0,
          "shipped_quantity": 0,
          "unit_price": 1495,
          "original_unit_price": 1995,
          "vat_rate": 21,
          "fulfilment": "MERCHANT"
        }
      ]
    }
  ],
  "next_cursor": null
}

POST /orders/100482/shipments

{
  "id": "6f1c2a0e-3b7d-4d55-9a54-2f0b8c1d7e21",
  "shipped_at": "2026-12-03T10:15:00+01:00",
  "carrier": "POSTNL",
  "tracking_number": "3SABCD1234567",
  "tracking_url": "https://jouw.postnl.nl/track-and-trace/3SABCD1234567-NL-1234AB",
  "lines": [
    { "line_id": "1", "quantity": 1 },
    { "line_id": "2", "quantity": 2 }
  ]
}

POST /orders/100482/cancellations

{
  "id": "b8e4f9d2-1c6a-4f0e-8d3b-7a2e5c9f0b14",
  "cancelled_at": "2026-12-02T16:20:00+01:00",
  "reason": "Out of stock",
  "lines": [{ "line_id": "2", "quantity": 1 }]
}