Book draft shipments API specification

Wuunder has multiple APIs to connect with:

1. A book shipments API

where you can book a shipment at a specific carrier and using a specific service. We return the shipping label, track & trace url and the carrier name. If there's a problem with the address or when the service is not possible for the shipment you want to book we return an error. On this page you can find all the details. 

2. A book draft shipments API

where you can send draft shipments to Wuunder. Sending the specific carrier and service is optional. These draft shipments you can book at once using the bulk booking feature in MyWuunder. 

This technical manual contains all the information required to work with the Wuunder book draft shipments API. If you do have any questions, please, contact us.

General

The Wuunder API is a RESTful API, served over HTTPS. All data is sent and received as JSON and encoded in UTF-8.

visit Wuunder's API Docs for more information. 

Wuunder provides isolated staging and production environments:

API

ENVIRONMENT

BASE URL

Authentication

API calls are authenticated using API tokens.
Clients that wish to integrate with the Wuunder API will be assigned a per-client token. If you do not have an API key you can request one here.

API tokens must be included in the Authorization headers.

 

     Authorization: Bearer TOKEN-HERE

 

Content type

Customers must specify the type of content they are sending through the Content-Type header. At this time, only application/json supported:

 

     Content-Type: application / json

 

Versioning

Customers must specify the API version they wish to consume. Specifying the API version is done via the Accept headers:

     Accept: application / json

Errors

Errors use the appropriate HTTP status code where possible. Missing parameters for example will respond with a 422 Unprocessable Entity response.

 
     HTTP / 1.1 422 Unprocessable Entity

     {
       Errors: [
         {"Field": "weight", "messages": ["can't be blank"]}
       ]
     }
 

Providing an invalid authentication token will result in a 401 Unauthorized:

 
     HTTP / 1.1 401 Unauthorized

     {
        “Error”: “unauthorized”
     }
 

HTTP Verbs

Where possible, the Wuunder API strives to use appropriate HTTP verbs for each action.

Resources

All String fields must obey a maximum of 255 characters unless otherwise noted in the description. You can always observe this behavior in the “redirect page”. MyWuunder.

NAME

REQUIRED

TYPE

DESCRIPTION

country

Y

String

ISO-2 country code, for example "NL" or "BE".

family_name

Y

String

Maximum length: 30.

given_name

Y

String

Maximum length: 30.

house_number

Y

String

Number including any additions. Maximum length: 8.

location

Y

String

Maximum length: 30.

zip_code

Y

String

Maximum length: 9.

street_name

Y

String

Street part of the addresses. Maximum length: 35.

business

N

String

When included this addresses will be considered a business address, otherwise a private address

email_address

N

String

Email address associated with this address. Maximum length: 40.

phone_number

N

String

Phone number associated with this address. E.123 format, for example +31683243251

chamber_of_commerce_number

N

String

REQUIRED

Please use your own e-mail address for testing purposes because Wuunder will send a booking confirmation to the booker (optional), Shipping confirmation with the label to the sender (optional) and track & trace e-mail to the receiver (optional).

Create draft shipments

This API allows to create draft shipments in the Wuunder system.

Conceptually this flow is initiated by a third-party system that creates drafts. The Wuunder system will store the shipment drafts and respond with a url that should be used to redirect a user to the Wuunder system so the shipment can be booked. More information about booking drafts you can find here.

If the user completes the booking in the Wuunder system the provided webhook_url will be called with information about the booking, see [Booking webhook] (# booking-webhook) for details. Additionally, the user will be redirected back to the url specified in redirect_url.

 
     POST / drafts
 

Requestbody

NAME

REQUIRED

TYPE

DESCRIPTION

id

Y

String

A (unique) ID referring to the shipment in the bulk request. Note that is only intended to be used by the client to correlate the request and the response items. This ID is not used by the Wuunder system.

family_name

Y

DraftShipment

You can find more info about #DraftShipments  here.

example

 

     [
       {
         “Id”: “1”,
         “Draft”: {
          "Delivery_address": {
            “Business”: “Janssen BV”,
            "Chamber_of_commerce_number": null,
            “Country”: “NL”,
            “Email_address”: null,
            “Family_name”: “Janssen”,
            “Given_name”: “Jan”,
            "House_number": "12",
            “Locality”: “Eindhoven”,
            “Phone_number”: “+31612345678”,
            “Street_name”: “Delivery address”,
            “Zip_code”: “1234AB”
          },
          “Customer_reference”: “12345678”,
          “Description”: “test”,
          “Height”: “50”,
          “Kind”: “package”,
          "Length": "10",
          "Personal_message": "test",
          "Pickup_address": {
            “Business”: “Sample shop”,
            "Chamber_of_commerce_number": "21",
            “Country”: “NL”,

            “Eori_number”: “132321321”,
            “Barrel”: “132321321”,

           “email_address”: “[email protected]",

            “Family_name”: “SurnameContact person”,

            “Given_name”: “First nameContact person”,
            "House_number": "1",
            “Locality”: “Place”,
            “Phone_number”: “+31612345678”,
            “Street_name”: “Company address”,
            "Zip_code": "1111AA"
         },
         “Picture”: null,
         “Value”: “6900”,
         “Weight”: “5000”,
         "Width": "20",
         “Number_of_items”: 1,
        "Preferred_service_level": "dpd: cheapest",

          “Number_of_items”: 1,
          "Order_lines": [
          {

           "Hs_code": "58342450",
            “Country_of_orgin”: “NL”,
           “Quantity”: 1,
           “Description”: “Gifts”,
           Value: 18.95,
           Weight: 1,
           “Sku”: “12345”,
           “Ean”: “987654321”        

           “Source”: {
           “Product”: “magento”,
           "Plugin": {
             “Build”: “1.9”,
             “Versions”: “1.0”
          }
         },
         "Webhook_url": "https://my.backend.com/webhooks",
         "Redirect_url": "https://my.backend.com/admin"
       }
      },
     … // multiple drafts can be sent in one request
     ]

 

Successful response

 

      Status: 200 OK

      [
         {
           Errors: [
             {
             “Field”: “child”,
             “Messages”: [
               "Is not valid"
             ]
          }
        ],
        “Id”: “1”
      },
      {
        Errors: [],
        “Id”: “2”,
        “url”: “https://api.wearewuunder.com/account/drafts/ff8a3d08-e5ff-4cc2-8a7c-9eb2e4e030d6/edit”
      }
     ]

 

Error responses

HTTPS STATUS CODE

ERROR DESCRIPTION

200

This API will generally always return an HTTP 200 response, even if the drafts in the request have validation errors. This is because this API is a bulk API, where some resources can be valid while others are not.

Booking Webhook

When the user successfully completes a booking the webhook specified when creating the booking will be called with the following payload:

 

     {
       "Action": "shipment_booked",
       “Shipment”: {
         “id”: “7db6bba2-9b85-4624-a22f-ab4c7ac57611”,
         “Description”: “Printer”,
         “Personal_message”: “Here are the ordered printers, have fun!”,
         Value: 189,
         “Kind”: “package”,
         Length: 100,
         Width: 100,
         “Height”: 100,
         Weight: 2000,
         “Status”: “pending_label”,
         “Is_return”: false,
         “Customer_reference”: “12345678”,
         “Customer_reference”: “reference”,
         "Drop_off": false,
         “parcelshop_id”: “7db6bba2-9b85-4624-a22f-ab4c7ac57611”,

         "Pickup_address": {
           “Business”: “Mycompany BV”,
           "Chamber_of_commerce_number": "21",
           “email_address”: “[email protected]",
           "Family_name": "SurnameContact person",
           “Given_name”: “First nameContact person”,
           “Locality”: “Place”,
           “Phone_number”: “+31612345678”,
           “Street_name”: “Company address”,
           "House_number": "1",
           "Zip_code": "1111AA",
           “Country”: “NL”
         },

         "Delivery_address": {
           “Business”: “Janssen BV”,
           "Chamber_of_commerce_number": null,
           “email_address”: “[email protected]",
           “Family_name”: “Janssen”,
           “Given_name”: “Jan”,
           “Locality”: “Eindhoven”,
           “Phone_number”: “+31612345678”,
           “Street_name”: “Company address”,
           "House_number": "12",
           “Zip_code”: “1234AB”,
           “Country”: “NL”
         },

         “Label_url”: “https://api.wearewuunder.com/shipments/123/label”,
         "Track_and_trace_url": "https://api.wearewuunder.com/shipments/123/track_and_trace",
         "Picture_url": "https://s3.amazonaws.com/some-bucket/printer.jpg"
       },
       "Rate": {
         "Carrier_name": "DPD",
         “Currency”: “EUR”,
         “id”: “e3a06e99-d1a2-4aa8-b6fe-2be7fa25cdde”,
         “Info”: “info”,
         “Modality”: “road”,
         “Pickup_date”: “2018-04-13”,
         “Price”: 695,
         "Rate_modifier": 1,
         “Service_level”: “DPD Home”,
         "Service_time": {
           “After”: “15:00:00”,
           “Before”: “17:00:00”
         },
         “Barrel”: 146
       },
       “Authentication_token”: “token” // JWT token
     }

 

 

Track and Trace Web Hook

 

     {
       "Action": "track_and_trace_updated",
       “Track_and_trace_code”: “S3123”,
       "Carrier_code": "TNT",
       "Carrier_name": "TNT Express",
       “Authentication_token”: “token” // JWT token
     }

 

It is expected that the system receiving the webhook responds with a 2xx status response. Any other response will be considered as a failure, in which case the Wuunder system will start retrying the webhook using exponential back off.

Authentication token from the webhook response

Sample dates:

Token

     

     “eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJib29raW5
      nX2lkIjoiNzhkZTZjNDYtMWE2Ni00YmQxLTg0MmQtZTkzNmIw
      ZDg4MjRiIiwiZXhwIjoxNTAzNTc3MTExNjA2Ljk0OX0.Q4ED7N
      q2JUa5uZaxcaAG3m6oGI0oeFjcb_5Mz0HQOPw” 

 

Consist of:

HEADER: ALGORITHM & TOKEN TYPE

   

     json
     {
       “Alga”: “HS256”,
       “Type”: “JWT”
     }

 

PAYLOAD: DATES

     

     json
     {
       “booking_id: “78de6c46-1a66-4bd1-e936b0d8824b”
       "Exp": 1503577111606.949
     }

 

Where booking_id is the identifier of processed booking and exp
expiration time. Wuunder expects the webshop to validate that the expiry time
has not passed yet.

Webshops can verify the validity of the token by calculating the signature, using
their webshop token as the shared secret.

     

     exp = booking_inserted_at (unix time) + default_expiration_time (24 * 60 * 60)