Outbound Webhooks

This page will help you get started with our outbound webhooks. You'll be up and running in a jiffy!

Two Boxes offers a number of webhooks that can be subscribed to for staying up to date on the status of a return and it's line items. By leveraging these webhooks to integrate with Two Boxes data, you can access industry leading inspection and disposition outcome details about your returns.

Events

Active

Event TypeDescriptionEvent_Data Schema
return-initiatedEmitted when Two Boxes receives an upstream webhook from the RMA Provider that a return has been createdReturn Details
return-line-item-package-scannedEmitted when a package is scanned into the building using the XRay appReturn Line Item Scanned
return-line-item-package-scanned-not-foundEmitted when a package is scanned into the building using the XRay app but no return with the tracking number is foundReturn Line Item Scanned Not Found
return-line-item-gradedEmitted when a line in a return has completed gradingReturn Line Item Details
return-completeEmitted when all of the lines in a return have completed grading and the return has been closedReturn Details
return-line-item-ship-backEmitted when a return line item will be shipped backReturn Line Item Ship Back
return-ignoredEmitted when a return is ignoredReturn Details
return-archivedEmitted when a work capture return is archivedReturn Details
return-line-item-archivedEmitted when a return line item on a work capture return is archivedReturn Line Item Details
return-line-item-addedEmitted when a new line is added to a work capture returnReturn Line Item Details
bulk-return-initatedEmitted when a bulk return created, either on the fly at the warehouse or through an integration to Two BoxesBulk Return Details
bulk-return-updatedEmitted when a bulk return is updated, either through adding/removing products in it or changing the detailsBulk Return Details

Deprecated

Event TypeDescriptionEvent_Data Schema
return-archived-work-captureEmitted when a work capture return is archivedReturn Details
return-line-item-archived-work-captureEmitted when a return line item on a work capture return is archivedReturn Line Item Details
return-line-item-added-work-captureEmitted when a new line is added to a work capture returnReturn Line Item Details

Specifications

URL: { defined by customer as HTTPS URL }

Method: POST

Headers

NameValue
content-typeapplication/json
x-two-boxes-authorizationDefined by Two Boxes as a shared token
x-twoboxes-signatureThis is an HMAC signature that is hashed using SHA-256 with the webhook request body and a secret key set up for your webhook

Payload

There are 3 first level fields that define the information in the webhook. Within the event_data field is all the detailed data specific to the event.

PropertyTypeNullableVersionDescription
idstringv1Unique message ID that can be used to track idempotency
event_typestringv1One of the event types listed in the "Events" table above
event_dataJSON Objectv1Content defined based on the Event_Data schema for the event_type in the "Events" table above

Responses

ConditionStatsOutput Payload
Event Consumed2xxIgnored by Two Boxes
Event Previously Consumed2xxIgnored by Two Boxes
Post body not parsable JSON400Logged; Not retried
Caller not authenticated by API token401Logged; Retried
Unexpected system error500Logged; Not retried

Implementation

Configuration

To subscribe to Two Boxes webhooks, 2 pieces of information need to be shared and configured:

  • Provide Two Boxes with the url which to send the webhooks to
  • Two Boxes provides the shared token to be used in x-two-boxes-authorization header
  • Two Boxes provides the HMAC secret key that will be sent in the x-twoboxes-signature

Moreover, Two Boxes will:

  • Retry a failed webhook up to 15 times with an 2x exponential backoff delay. If system failures on the downstream webhook last longer than that, you will need to contact support to replay these events.
  • Cap request response times at 15s

For these reasons, Two Boxes recommends that webhook event messages are accepted and stored on the webhook host, then processed asynchronously where additional validation and any expensive processing can take place.

System Requirements

To receive data, your system must: 

  • Be publicly accessible from the internet,
  • Accept POST requests, 
  • Use SSL/TLS encryption
  • Check the verification token of every request to ensure that the request is a legitimate one from Two Boxes

HMAC Hashing

If you opt to enable the hmac signature for authentication in the webhook, please note the following about Two Boxes procedure for calculating the hmac value:

  • The HMAC signature value is hashed using sha256 with the webhook request body and a secret key setup for your webhook
  • The json payload we use to encode is not formatted with whitespace. It has to be exactly as we send it (no tabs, spaces, pretty json formatting)
  • The HMAC signature value and the request body are then base64 encoded before we send it to you. So they will need to be base64 decoded on your side.