Skip to main content

Webhooks

To avoid the need for polling, which is inefficient and non-robust, RPI Print API supports sending webhooks (HTTP notifications) out on certain order events. These can be activated by setting webhookUrl property when creating new order.

Notifications are sent in a reliable manner (several retries with backoff), so can be used to keep track of an order's progress.

The content of notifications is always JSON, describing the order, much like if you performed a GET request on it.

Notifications are configured in the create order request by using the webhookUrl property:

{
"webhookUrl": "https://endpoint.com/callbacks/741231"
}

webhookUrl can be set to a different URL for each created order and may include query parameters, for example ?orderid=1234. During development you might want to use one of the webhook testing services, such as https://webhook.site or https://ngrok.com/.

An improperly formatted webhookUrl will result in order creation failure. The URL must satisfy the following requirements:

  • The webhookUrl must be a valid URL.
  • webhookUrl must start with the https:// prefix. Any other protocol will not be accepted.
  • webhookUrl must be publicly accessible via the internet.
  • You must have control over the URL.
  • The URL should not point to "localhost" or use any private IP addresses such as those in the 192.168.x.x or 10.x.x.x ranges. These are typically reserved for private networks and are not accessible over the public internet.

Webhook request

The webhook request that is sent to your endpoint has a JSON body with this structure:

property nametypedescription
sourcestringThe "source" of an event that triggered the sending of this webhook
timestringTimestamp of webhook event, in UTC, ISO-8601 format
dataobjectThis is almost always an OrderFullResponse as described in the API Reference.

The only exception for the data property is when an error happens before the order is accepted by Print API. Generally, such an error means the order could not be created, so Print API doesn't have the necessary data to populate a OrderFullResponse.

In this case the source will be OrderStoring, and the contents will be a JSON payload with these properties:

propertytypedescription
fullOrderIdstringThe "full" order id is a combination of your 'Customer Name' and the customerOrderId, joined with the / character: {customerPublicId}/{customerOrderId}}
customerOrderIdstringUnique identifier for an order
messagestringA message describing why the order could not be created / was not accepted by Print API

List of webhook sources

sourceevent that causes this webhook
OrderAcceptedByPrinterOrder has been accepted by the printer, this marks the start of printing process. Cancellation requests might fail from this point forward.
OrderAssetsAllProcessedAll print assets that order contains have been successfully processed
OrderCancellationRequestSentToPrinterOrder is already in printing state and order cancellation has been sent to the printer. Waiting for confirmation or rejecton for cancellation.
OrderCancelledBeforeSubmissionToPrinterOrder has been cancelled before it has been sent to printing.
OrderCancelledOrder has been successfully cancelled.
OrderCreatedOrder has passed initial validation and has been queued for further processing.
OrderEnteredHoldingBinOrder has entered holding bin. Order will stay in holding bin for approximately 3 hours. During this time window cancellation will always succeed.
OrderErrorAtPrinterThere was an issue printing the order, please check order details for more information or contact CS
OrderExceedsLimitQueueOrder has exceeded the daily limit and over-the-limit queue and has been rejected. Order will not be processed.
OrderExitedHoldingBinOrder has exited holding bin after 3 hours or after manual approval by CS support and has been scheduled to be send to the pinter.
OrderExitedLimitQueueOrder that has been over the daily order limit has been released to normal workflow.
OrderFailedOrder print asset processing has failed, usually that means there is an issue with submitted print assets. Check order validation responses for more details.
OrderFinishedPricingOrder has pricing & taxes applied and those fields are now available.
OrderInExceptionStateOrder has entered EXCEPTION state. This state usually requires CS support to resolve.
OrderOverLimitQueuedThis order has been placed in limit queue as more than maximum amount of orders have been submitted the last 24 hours.
OrderReceivedOrder has been received by the system and is queued for initial validation.
OrderReprintRequestedReprint of this order has been created.
OrderShippedOrder has been shipped. Orders can be shipped in single or multiple shipments. When last shippment is sent this marks the end of the order workflow.
OrderShippingEstimatesRefreshedShipping estimates have been updated for this order before sending to printer. Shippment date might have changed due to time order spent in limited queue or in holding bin.
OrderSubmittedToPrinterOrder has been sent to the printer and is waiting for confirmation by the printer.
OrderValidationFailedOrder validation failed. Check validation responses on the order for more details.
OrderVoidedByPrinterOrder that has already entered printing state has been successfuly cancelled.
PaymentFailurePayment has failed. Scheduled payments will be retried the next day. Verify your payment information.
PaymentSuccessfulPayment has been successful, orders waiting for payment will move to holding bin

Webhook response

Webhook endpoint should respond with HTTP Status between 200 and 299 (2XX) and should ideally take less than 10 seconds to respond. In case any of these conditions are not met, webhook sending will be retried at a later time. In case of continuous failures webhook sending will be retried a number of times, after which the specific webhook event will be marked as failed.

All sent webhooks for an order are listed on the Order Details page (Callbacks section) in the RPI Dashboard. (Failed attempts are also listed in the Dashboard along with the reason for the failure, e.g., "404 Not Found" if your endpoint responded with this HTTP status.)

Webhook signature

The webhook request body is signed with an hmac-sha256 signature to prevent tampering and to make sure webhook was sent by RPI Print API. The Signature is sent as a Base64 encoded hash value in the webhook HTTP request header x-rpi-printapi-hmac-sha256.

Webhook Secret can be obtained from the RPI Dashboard, API Credentials section.

Example: Calculate hmac-sha256 in nodejs

import { createHmac } from "crypto" 
...
const hmacSignature = createHmac('sha256', webHookSecret).update(webhookReceivedBodyAsString, 'utf8').digest('base64');

List of