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.
Once your endpoints are up, check them against this specification with the tester.
Basics#
| Topic | Agreement |
|---|---|
| Transport | HTTPS only. JSON request and response bodies, UTF-8, Content-Type: application/json. |
| Base URL | Chosen by the platform, e.g. https://api.example.com/afosto/v1. Every path below is relative to it. |
| Authentication | Authorization: Bearer <api_key> on every request. The platform issues the key; it is entered in the Afosto integration. |
| IP allowlist | When the platform only admits known IP addresses, Afosto supplies the addresses it calls from. |
| Timestamps | RFC 3339 with a time zone, e.g. 2026-12-02T14:05:00+01:00. |
| Amounts | Integers in the minor unit of the currency (cents), including VAT. 1995 is € 19,95. |
| Currencies | ISO 4217, e.g. EUR. |
| Countries | ISO 3166-1 alpha-2, e.g. NL. |
| Ids | Strings. An id never changes. Order ids are unique across all channels of the platform. |
| Response time | Respond within 30 seconds; Afosto treats a slower response as a failure and retries. |
Status codes#
| Code | Meaning for Afosto |
|---|---|
200, 201, 204 | Success. |
400, 401, 403, 422 | Permanent failure: Afosto stops and reports the error in its back office. Put a readable message in the body (see Error). |
404 | The order does not exist. |
429, 5xx, timeouts | Temporary 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.
| Method | Path | Purpose |
|---|---|---|
GET | /channels | List the channels the API key gives access to |
GET | /orders | List the orders of a channel created or changed since a moment |
GET | /orders/{order_id} | Get one order |
POST | /orders/{order_id}/shipments | Afosto shipped (part of) an order |
POST | /orders/{order_id}/cancellations | Afosto cancelled (part of) an order |
List channels#
GET /channels
Lists the channels the API key gives access to. Not paginated.
Response 200:
| Field | Type | Description |
|---|---|---|
data | array of Channel | Every 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:
| Name | Required | Description |
|---|---|---|
channel | yes | The code of the Channel. Return only the orders placed in it. |
updated_since | yes | RFC 3339 moment. Return orders whose updated_at is at or after it. |
cursor | no | The next_cursor of the previous page. |
limit | no | Page size, 1–100. Default 100. |
Response 200:
| Field | Type | Description |
|---|---|---|
data | array of Order | The orders on this page, sorted on updated_at ascending. |
next_cursor | string or null | The 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#
| Field | Type | Required | Description |
|---|---|---|---|
code | string | yes | The value of the channel query parameter of GET /orders. |
name | string | yes | The name the merchant recognises, e.g. Marketplace NL. |
currency | string | no | The currency of the channel's orders. |
country_code | string | no | The country the channel sells to, when it sells to one. |
Order#
| Field | Type | Required | Description |
|---|---|---|---|
id | string | yes | The order's id on the platform. |
number | string | yes | The order number the customer sees. Used as the order number in Afosto. |
status | string | yes | PENDING, READY, CANCELLED or COMPLETED. See Order status. |
created_at | timestamp | yes | When the customer placed the order. |
updated_at | timestamp | yes | When the order last changed. |
currency | string | yes | Currency of every amount on the order. |
customer | Customer | yes | Who placed the order. |
billing_address | Address | yes | |
shipping_address | Address | yes | Where the order goes. For a pickup point order: the customer's own address. |
pickup_point | PickupPoint | no | Set when the customer chose a pickup point. |
shipping | Shipping | no | The shipping method the customer chose and what they paid for it. |
lines | array of Line | yes | At least one line. |
customer_note | string | no | Note of the customer, e.g. a delivery instruction. |
reference | string | no | The customer's own reference, e.g. a purchase order number. |
metadata | object of string → string | no | Any extra data the platform wants to keep on the order. Stored as is. |
Order status#
| Status | Meaning | Afosto |
|---|---|---|
PENDING | Placed but not ready to fulfil, e.g. not paid yet. | Waits; imports it once it is READY. |
READY | Paid and ready to be fulfilled. | Imports it. |
CANCELLED | Cancelled as a whole. | Not imported; cancelled in Afosto when it was imported before. |
COMPLETED | Fully shipped or closed. | Nothing. |
Partial cancellations are on the lines (cancelled_quantity), not on the order status.
Customer#
| Field | Type | Required | Description |
|---|---|---|---|
email | string | yes | |
phone | string | no | Preferably in international format, +31612345678. |
given_name | string | yes | |
family_name | string | yes | |
organisation | Organisation | no | Set for a business customer. |
Organisation#
| Field | Type | Required | Description |
|---|---|---|---|
name | string | yes | |
vat_number | string | no | e.g. NL123456789B01. |
coc_number | string | no | Chamber of commerce number. |
Address#
| Field | Type | Required | Description |
|---|---|---|---|
given_name | string | yes | |
family_name | string | yes | |
organisation | string | no | |
street | string | yes | Street name, without the house number. |
house_number | string | yes | e.g. 12. |
house_number_suffix | string | no | e.g. A or bis. |
address_line_2 | string | no | Any extra address line. |
postal_code | string | yes | |
city | string | yes | |
region | string | no | State or province, where the country uses one. |
country_code | string | yes |
PickupPoint#
| Field | Type | Required | Description |
|---|---|---|---|
carrier | string | yes | POSTNL, DHL, DPD, GLS or UPS. |
id | string | yes | The carrier's id of the pickup point. |
country_code | string | yes |
Afosto can only ship to the pickup point when the merchant has a pickup point shipping method of that carrier.
Shipping#
| Field | Type | Required | Description |
|---|---|---|---|
method | string | no | Name of the shipping method, e.g. Standard or Evening delivery. Afosto matches it to an Afosto shipping method by name. |
carrier | string | no | Preferred carrier, same codes as PickupPoint. |
price | integer | yes | What the customer paid for shipping, in cents including VAT. 0 for free shipping. |
Line#
One product on the order.
| Field | Type | Required | Description |
|---|---|---|---|
id | string | yes | The line's id; unique within the order. Shipments and cancellations refer to it. |
sku | string | yes | The SKU of the product, the same as in Afosto. |
gtin | string | no | EAN/GTIN of the product. |
title | string | yes | Product name as sold. |
quantity | integer | yes | Number of pieces ordered, at least 1. |
cancelled_quantity | integer | no | Number of those pieces cancelled on the platform. Default 0. |
shipped_quantity | integer | no | Number of those pieces the platform shipped itself, for a PLATFORM line. Default 0. |
unit_price | integer | yes | Price per piece the customer paid, in cents including VAT, after discount. |
original_unit_price | integer | no | Price per piece before discount, when there was one. |
vat_rate | number | yes | VAT percentage, e.g. 21, 9 or 0. |
image_url | string | no | |
fulfilment | string | no | Who ships the line: MERCHANT or PLATFORM. Default MERCHANT. See Fulfilment. |
Fulfilment#
| Value | Meaning | Afosto |
|---|---|---|
MERCHANT | The merchant ships the line from its own stock. | Reserves stock, ships the line and posts a shipment for it. |
PLATFORM | The 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.
| Field | Type | Description |
|---|---|---|
id | string | Afosto's id of the shipment. The same shipment always has the same id. |
shipped_at | timestamp | When it was handed to the carrier. |
carrier | string | e.g. POSTNL, DHL, DPD. |
tracking_number | string | |
tracking_url | string or null | Track and trace link, when the carrier has one. |
lines | array | The pieces in this shipment: { "line_id": "...", "quantity": 1 }. Only lines with fulfilment MERCHANT. |
Cancellation#
Sent by Afosto.
| Field | Type | Description |
|---|---|---|
id | string | Afosto's id of the cancellation. The same cancellation always has the same id. |
cancelled_at | timestamp | |
reason | string or null | Free text, e.g. Out of stock. |
lines | array | The pieces cancelled: { "line_id": "...", "quantity": 1 }. |
Error#
Body of any 4xx or 5xx response:
Behaviour#
Polling#
- Afosto polls the order list per channel. After a successful poll, the next one follows within 3 minutes.
updated_sinceis 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_atmoves on every change that matters to Afosto: becomingREADY, and any change ofcancelled_quantityorshipped_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 row | Next poll after |
|---|---|
| 1 | At once |
| 2 | 1 minute |
| 3 | 4 minutes |
| 4 | 9 minutes |
| 5 | 16 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
GET /orders?channel=marketplace-nl&updated_since=2026-12-02T14:00:00%2B01:00
POST /orders/100482/shipments
POST /orders/100482/cancellations