Skip to content

Orders API (B2B)

Create and retrieve orders via the API.
This endpoint is idempotent and protected using Laravel Sanctum.


Authentication

All requests must be authenticated using a Bearer token.

Required headers

Authorization: Bearer <SANCTUM_TOKEN> Accept: application/json Content-Type: application/json

If authentication fails, the API returns 401 Unauthorized.


Create Order (Idempotent)

Create a new order (each giftcard is an unique order) or retrieve an existing one using a unique api_id.

POST /api/orders

Idempotency

  • If an order with the same api_id already exists for the same API user,
    the API will not create a new order and returns the existing order.
  • If the api_id exists but belongs to a different API user, the request fails with 422.
  • It is recommended to use a unique prefix per API user to avoid conflicts.

Request Body

Master fields

FieldTypeRequiredDescription
api_idstringYesUnique reference from the B2B client
product_idstringYesEAN of the product
amountintegerYesValue of the giftcard

Example Request

json
{
  "api_id": "B2B-GC-10001",
  "product_id": 2002,
  "email": "inkoop@bedrijf.nl",
  "amount": 50
}

Responses

201 Created (New Order)

json
{
  "giftcard": {
    "id": 12345,
    "store_id": 1,
    "product_id": 2002,
    "email": "inkoop@bedrijf.nl",
    "value": 50,
    "type": "digital",
    "status": "pending",
    "code": null,
    "pin": null,
    "created_at": "2026-02-03T12:00:00Z",
    "updated_at": "2026-02-03T12:00:00Z"
  }
}

200 OK (Order Already Exists)

When the same api_id is used by the same API user, we will return the same response as above with status code 200 OK.

Giftcard status fields

When an order contains giftcard products, the API returns giftcard-related status fields on both order level and item level.

Response fields (Giftcards)

FieldTypeDescription
statusstringGiftcard generation status. Possible values: success, pending, error
  • success → the giftcard has been generated
  • pending → the giftcard is still pending
  • error → the giftcard could not be retrieved

Item-level (giftcard products)

Each item in the items array contains giftcard-related fields.

FieldTypeDescription
statusstringStatus of the individual giftcard
codestring | nullGenerated giftcard code (if available)
pinstring | nullGiftcard PIN (if applicable)

Possible giftcard_status values

ValueMeaning
successGiftcard successfully generated
pendingGiftcard generation still in progress
errorAn error occurred while generating the giftcard

Error Responses

422 Validation Error

json
    {
    "message": "The given data was invalid.",
        "errors": {
        "product_id": [
          "Ongeldige product ID."
        ]
    }
}

401 Unauthorized

Returned when:

No token is provided

Token is invalid or expired

500 Server Error

json
{
"message": "Server error"
}

Orders are created directly in status:

  • Duplicate requests are safe due to idempotency