REST API
Documentation
- Nederlands
- English
Statuses
Print API distinguishes four order statuses. If you use our payment screen, there is also a separate payment status. Both the order status as the payment status can be requested from the API. Print API also has webhooks to automatically notify your server of status changes.
Example
To obtain the latest order or payment status from the API, you need the ID of the associated order.
Simply send an HTTP get to the URL of the order: v2/orders/{id}
.
Replace {id}
by the ID of the order.
GET v2/orders/{orderId} HTTP/1.1
Authorization: Bearer TOKEN
Accept: application/json
Aside from the status, the API response also contains all other order data. This data has been omitted from
the example below for brevity. Note that the field checkout
is only present if you use our
payment screen.
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Content-Length: 746
{
"id": "83432183",
"status": "Created",
"dateTime": "2015-10-21T12:53:06.9931422",
...
"checkout": {
"status": "Open",
"amount": 22.49,
"paymentUrl": "https://test.printapi.nl/v2/payments/0WIqo9FoUv2xwMI6Bzuo/start",
"setupUrl": "https://test.printapi.nl/v2/checkout/5L2zKMnOqp6A15GoP909Z",
}
...
}
Print API distinguishes the following order statuses:
Created | Order created but is awaiting files and/or payment. |
Processing | Order is being processed. |
Shipped | Order has been shipped to the recipient. |
Cancelled | Order has been cancelled. |
In addition, Print API distinguishes the following payment statuses:
Open | Payment incomplete. The paymentUrl remains available for up to 24 hours. |
Successful | Payment successfully completed. |
Cancelled |
The paymentUrl has expired and the order has been cancelled.
|
Webhooks
You can use our webhooks to let Print API automatically notify your server when the status of an order or payment changes. It's essentially a push notification over HTTP. You can configure the URLs of your application's webhooks in your settings. We never send sensitive data to your webhook URLs, so HTTPS is optional.
Webhook call:POST /your-webhook-url HTTP/1.1
Content-Type: application/x-www-form-urlencoded
orderId=59802395
The request body only contains an order ID. You can use this order ID to request the latest status from the API, as explained previously. This intermediate step may seem a little cumbersome, but it prevents random people from calling your webhook with false information.
Your webhook only has to return the HTTP status code 200 OK
. This lets Print API know the call
was processed successfully. If your webhook returns another status code, like 503 Service Unavailable
,
Print API will try again up to 9 times:
- First failure: new attempt after ± 2 minutes
- Second failure: new attempt after ± 5 minutes
- Subsequently: new attempt after ± 60 minutes, up to 7 times
You will automatically be notified per e-mail when a call to your webhook fails for the first time. You'll be notified again if the request failed ten times in succession and won't be attempted again.