Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 286 Next »

The purpose of this API is to register a parcel shipment. Given the data in the request, this API will perform the booking and return the corresponding transport information

Contents

Setup

Make sure you have the following information at hand before proceeding. Your carrier provider will generate/provide these values for you

Example

Description

Username (see Authentication section)

wsfoobar

A valid username.

Password (see Authentication section)

a-very-very-long-password

A password matching given username.

shopId

12345

All bookings are made with respect to a given shop. 

transportSolutionId

55

An identifier for a valid transport solution. The transport solution determines how the booked package will be distributed.

  • The user is a web service user

  • The user has access to the web service for booking

  • The user has access to the shop where registering the parcel

  • The shop has access to the specified transport solution

Environments / endpoints

Please use the TEST-endpoint while developing your system. By doing this you ensure that your test-data will not pollute any potential external systems or production.

TEST

POST

https://staging-ws.di.no/ws/json/parcel/booking/v-1/book

PRODUCTION

POST

https://ws.di.no/ws/json/parcel/booking/v-1/book

Authentication

This endpoint requires the user to be authenticated. Refer to the documentation here for more information on how to obtain a valid token to use in your request. 

Making a request

Notes

  • The booking endpoint is called once per order. 

  • Clients using this API should not fail if new optional fields are added to the API. If a new field is added to the request or response on a later stage, existing clients should handle this in a way such as they just ignore the field.

  • Some carriers may have more specific validation or input requirement than the general API, this is documented at the end of this section. Marked (warning) in request section 

Request-Headers

key

value example

comment

Authorization

Bearer "SECRET_WS_TOKEN"

See authentication on how to obtain a token

Content-Type

application/json

Idempotency-Key

"defined by client"

Optional, up to 40 characters. This header can be set by the client in order to make sure that no booking happens twice. The length of the text part of the header can be up to 40 characters. A request set with a unique client specified Idempotency-Key is only saved once on success, i.e. the risk of sending a duplicate order can be handled by the client by specifying a client side unique identifier for the order. The API will return the same response every time after a successful request with the same Idempotency-Key header set. 

For active pick-up parcels (C2X) in DI Last mile distribution duplicate bookings will have the field "trackingReference" populated with actual tracking reference, not return code as default in first booking response.

Request body

Name

Type

Example

Mandatory

Max Length

Description

shopId

whole number

95123

(tick)

n/a

The shop this booking is made for.

shopDisplayName

string

My Company Ltd


30

A user presentable name of the shopId. This will typically be used if another name than the normal name of the shop should be used in communication with the customer. Maximum 30 characters.

transportSolutionId

whole number

1

(tick)

n/a

A transport solution is a construct that contains multiple freight products. Its purpose is to group what freight products a customer has access to. See further explanation in transport solutions section.

shipmentId

string

(401)70712190172720651


35

ShipmentId is identificator for the entire order.

If not specified as a part of the request this will be generated and returned in the response with gs1 format as default. This should be a globally unique identifier.
Typically named MessageNumber, DocumentNumber or ConsignorsReference in EDI.

If you wish to define your own shipmenId use the GS1 international standard GINC (official documentation). If you are using other identification numbers contact your sales company to make sure the series is supported/configured correctly.

desiredDeliveryDate

string

20160120

(warning)

8

Date format yyyyMMdd. This date should be defined as distribution date. For deliveries (B2C) it is date of delivery, for pick up (C2B/C2C) this field will be used as date of pick up by carrier.

Optional field that can be specified if the parcel should be delivered/picked up on a specific date. If the specified date is not supported, then the freight product is not be supported. This means that the field is mandatory for for example labelless pick-up freight products.

desiredDeliveryTimePeriod

string

1930-2130

(warning) 

9

Time format HHmm-HHmm (desiredDeliveryTimeStart - desiredDeliveryTimeEnd)
Default value '2000-2200' will be used as delivery time interval if it is not given.

parties

list of Parcel Booking API#party objects

(tick)

n/a

List of parties involved in this shipment.

items

list of item objects

(tick)

n/a

List of all the items in this shipment. At least one item is required.

messageToCarrier

string

350

Typically delivery instructions. This information can be placed on some shipping labels in the information field.

messageToConsignee

string

350

This information can be placed on some shipping labels in the information field.

additionalServices

list of additionalService objects




Additional services that should be applied to the shipment.

(warning) Must be configured for the shop before use.

proofOfDelivery

string

SIMPLE_CONFIRMATION

Planned Proof Of Delivery (POD) set for the parcel, applied to all items in the shipment. Possible values:

NO_CONFIRMATION, SIMPLE_CONFIRMATION, SCAN, SCAN_AND_PICTURE, PICTURE

Transport Solutions

A transport solution is composed of one or more freight products. A freight product describes a way of delivery, and is defined by a delivery method and the coverage of the method. The freight products included in a transport solution are ordered by priority (defined by the carrier company). 

An example to illustrate the relation between a transport solution and its freight products: There is the transport solution "CarrierCompany home delivery w/ServicePoint fallback" (e.g. transportSolutionId = 1). The transport solution consist of the following freight products:

  1. "CarrierCompany express home delivery" (freightProductId = 1)

  2. "CarrierCompany standard home delivery" (freightProductId = 2)

  3. "CarrierCompany ServicePoint" (freightProductId = 3)

When a booking request is made with transportSolutionId = 1, the booking API first checks if the request address and item measures is covered by the "CarrierCompany express home delivery", followed by "CarrierCompany standard home delivery" and finally "CarrierCompany ServicePoint". The highest priority freight product that is available for the specifications in the booking request determines the freight product (delivery method). The freightProductId will be present in the Booking API response. If no freight product covers the specifications in the booking request, the API will return an error response.

Remark that access to transport solutions are given per shop. Contact you carrier provider to determine which shopID(s) and transport solution ID(s) to use. It is not possible to registrer a booking directly to a freight product ID, but your carrier can provide a transportsolution with only the desired freight product as available response.

Party

Name

Type

Example

Mandatory

Max Value

Description

type

string

recipient

(tick)

n/a

consignee and consignor are required as part of the request.

The type of party involved. Following alternatives are legal:

  • consignee (Party to which the shipment are delivered to, normally the buyer of the goods)

  • consignor (Party sending/delivering the shipment. For B2C, this is typically a store or a warehouse)

  • returnAddress (Used if other than consignor party)

  • servicePoint (Can be specified in the request if the client wants to suggest a service point for a freight product. If specified in the request, the same service point is returned in the response if the resulting freight product has a servicePoint. If no service point was specified in the request and the resulting freight product deliver through servicePoint the closest ServicePoint is returned as part of the response)

  • pickupAddress (Can be specified in the request if the client wants to suggest a second service point for a freight product. Only relevant for a limited number of freight products. If specified in the request, the same service point is returned in the response if the resulting freight product has a pickupAddress. If no service point was specified in the request and the resulting freight product pick up through service point the closest service point is returned as part of the response)

id

string

0123456789

(warning)

17

Identifier that can be used to identify the same party between different shipments.
(warning) Must not be used if you have duplicate IDs for different customers or know if the shipment actually is for the same consumer. Then all shipments will be linked to the same consumer

name

string

Ola Nordmann

(warning)

105 

Name of party.
Mandatory for consignee and consignor.

countryCode

string

NO

(warning)

3

Country code, according to ISO 3166-1.
Mandatory for consignee and consignor.

postalName

string

OSLO

(warning)

35

Also known as city.

zipCode

string

0155

(warning)

9

Also known as postal code.
Mandatory for consignee and consignor.

address

string

Storgaten 11A H0202


105 

Combined address information with the following format:

  • Street name

  • Street number (with leading space)

  • Entrance

  • Floor type (only relevant for countryCode=NO)

    • H (main floor)

    • U (basement)

    • L (attic)

    • K (cellar)

  • Floor number

  • Flat number

coaddress

string

Kari Nordmann

255

Care of address

phone1

string

+47 402 10 000

(warning)

100

This is used for delivery confirmation and other automated SMS notification.

phone2

string

+47 402 20 000

100

This can be used for other automated SMS notification. 

email

string

ola@nordmann.no

(warning)

100

This can be used for automated email notification.

reference

string

012345

35

This can be an orderId or some other reference. consignee and consignor reference can be placed on some shipping labels.

contact

string

Customer service contact name

35

Contact information for the party. Consignee contact can be printed on some shipping labels.

Item

An item represents a physical parcel, with trackingReference as identifier. Structure your request with the same number of items as you want to have labels/physical parcels in your order.

Name

Type

Example

Mandatory

Max Length

Description

itemNumber

whole number

1

(tick)

n/a

Item/package number of the shipment. If there are 3 items in a shipment these items should have itemNumber 1,2 and 3.

Each item/package will result in one unique trackingReference and label.

trackingReference

string

(00)370724760010119754

(warning) 

35

If not specified as a part of the request this will be generated and returned in the response.

If you wish to define your own trackingReference use the gs1 international standard SCC (official documentation). If you are using other identification numbers contact your sales company to make sure the series is supported.

Typically named TransporterInstructionMark in EDI.

returnCode

string

XX-12345

10

Must be between 8 and 10 characters.

If the code is to be used in any other DI APIs, there are some additional requirements:

  • Start with one or more letters

  • Then a dash -

  • End with up to 8 letters or numbers, totalling maximally 10 characters

weight

whole number

600

n/a

Measuring unit is gram.

volume

decimal number

4

n/a

Measuring unit is cubic decimeter.

length

decimal number

120

n/a

Measuring unit is centimeter.

height

decimal number

5

n/a

Measuring unit is centimeter.

width

decimal number

12

n/a

Measuring unit is centimeter.

externalSupplierId

String

5415

n/a

ExternalSupplierId is the id of the supplier to the shop. It can be used for access control or filtering.

(warning) Must be configured for the shop before use. If service supplier specified in file is not configured (or does not exist) booking will be accepted and only linked to shop

⚠ Service supplier is connected to shop, no validation for coverage or other attributes

contentValue

decimal number

580

n/a

Currency is according to the location of the shopId.

contents

string

Brown shirt

100

Description of the contents. This can be placed on some shipping labels.

properties

map of item properties


n/a

Map with additional properties. Various information (properties) are specified only for certain transport products.

articles

list of Parcel Booking API#article objects



List of articles included in the item. 

Item properties

Name

Type

Example

Description

shortItemIdentifier

string

...0255

This can be placed on some shipping labels.

productType

string

Bread

Optional additional description of item.

Article

An article describes the content of your item/parcel. Mainly relevant if used for integrations with warehouse management systems.

Name

Type

Example

Mandatory

Description

articleNumber

string

"ART-1"

(tick)

An identifier for the article.

quantity

whole number

1

(tick)

The quantity of the article.

articleName

string

Brown shirt

(tick)

Name/description for the article.

Additional Services

Name

Type

Example

Mandatory

Description

key

string

ASA

(tick)

The key for the service. Note that the service must be configured for the shop before use.

value

string

null

Some services require an additional value to be included in the request. The value is ignored if the value is not required for the service.

Available Additional Services

 Available Additional Services

Key

Example value

Description

ASA

null

A service for sending labels by mail to consumers. A use case is when a consumer is to send a package that requires a label, and does not have access to a printer. 

ASB

"MYWMS"

A service for integration with an external packaging system, WMS.
Additional service value is required, and the service must be preconfigured for the shop. 

A1

"199:NOK:9876543210"

Specifies that the recipient is to pay for the parcel on delivery (Cash on Delivery). 
Format: "<amount>:<currency>:<sellers reference>".
Colon is used as separator. Both amount and currency is required, while sellers reference (KID number) is optional. 

RNL

true

A service to specify if the end-user is requires to show identification in order to pick up parcel

ASC

"https://di.no|Description"

A service where the party registrering the order can specify a custom URL and description for each order. This is only used to add specific information to labels fetched from the Parcel Label API, and the specific labels have to pre-designed with a layout for this input/QR code

Pipe symbol | is used as separator. Only qrCodeUrl is required, while qrCodeDescription is optional.

ASD

"41412756|Hei dette er en gave!"

A service to specify that this booking is a gift. The service shows the gift senders phone number and the message from the gift sender to the gift receiver.

ASE

null

Orders marked with this are registered as label-less, and have an additional id/code to identify the parcel instead of the regular label. The parcel still has a shipmentId and tracking reference, but the shorter (more consumer friendly ID) is an additional identification. This is frequently used for C2C and C2B parcels

Carrier specific requirements

Carrier

Requirements

Helthjem B2B

consignee.id is required

Helthjem C2B and C2C

consignor.phone1 or consignor.email is required 
consignee.phone1 or consignee.email is required 

shipment.desiredDeliveryDate
If specified this day represents the date where the carrier should pickup the package and should be earliest tomorrow. The consignor / sender will be instructed to lay out the package the day before pickup. Use of the field will result in an active pick-up order

shipment.item - Only one item allowed for return solutions.

item.trackingReference - This field should never be set by the callee. Tracking reference for pick-up packages is generated by the system and returned in the response. Callee should support all types and formats as identifier/code for pick-up parcels. 

Helthjem B2C

Do not use consignee.id 

Early Bird

Do not use consignee.id 

Postnord C2C Norway
(via helthjem)

consignee.name and consignor.name only allow 50 characters

Consignee.address and consignor.address only allow 50 characters

consignee.postalName and consignor.postalName is required

Weight is required

Consignee.email and consignor.email is validated by standard e-mail verification, including

  • does not contain invalid symbols (letters, numbers and symbol: @ , . allowed)

  • has a valid structure (xx@xx.xx)

  • use a valid domain

Consignee.phone1 and consignor.phone1 are validated, including

  • Deliveries in Norway: + or 00 [country code starting with 3 or 4]. Norwegian local number starting with 4 or 9.

  • Deliveries in Sweden: + or 00 [country code starting with 3 or 4]. Swedish local number starting with 07.

  • Deliveries in Finland: + or 00 [country code starting with 3 or 4]. Finnish local number starting with 04 or 050.

  • Deliveries in Denmark: + or 00[country code starting with 45] Danish local number starting with 5.

Premo C2C

consignor.phone1 or consignor.email is required 
consignee.phone1 or consignee.email is required 

shipment.desiredDeliveryDate - If specified this day represents the date where the carrier should pickup the package and should be earliest tomorrow. The consignor / sender will be instructed to lay out the package the day before pickup.Use of the field will result in an active pick-up order

shipment.item - Only one item allowed for return solutions.

item.trackingReference - This field should never be set by the callee. Tracking reference for pick-up packages is generated by the system and returned in the response. Callee should support all types and formats as identifier/code for pick-up parcels. 

Postnord ServicePoint Sweden
(via Dooris)

consignee.phone1 is required 
consignor.address is required

consignee.name and consignor.name only allow 50 characters
consignee.address and consignor.address only allow 50 characters
consignee.coaddress and consignor.coaddress only allow 50 characters
consignee.postalName and consignor.postalName only allow 50 characters
consignee.email and consignor.email only allow 70 characters


Consignee.phone1 and consignor.phone1 are validated, including

  • Deliveries in Norway: + or 00 [country code starting with 3 or 4]. Norwegian local number starting with 4 or 9.

  • Deliveries in Sweden: + or 00 [country code starting with 3 or 4]. Swedish local number starting with 07.

  • Deliveries in Finland: + or 00 [country code starting with 3 or 4]. Finnish local number starting with 04 or 050.

  • Deliveries in Denmark: + or 00[country code starting with 45] Danish local number starting with 5

Postnord home delivery Sweden (via Dooris)

item.trackingReference must be in s10 format if specified
shipmentId can be included in booking, but is not used by Postnord and not searchable at Postnord sites.

consignee.name and consignor.name only allow 50 characters
consignee.address and consignor.address only allow 50 characters
consignee.coaddress and consignor.coaddress only allow 50 characters
consignee.postalName and consignor.postalName only allow 50 characters
consignee.email and consignor.email only allow 70 characters

ODA 
(via helthjem)

consignee.phone1, consignee.email, consignee.postalName, consignee.zipCode is required 

Extra phone validation added, only valid phone numbers allowed

Zoopit
(via helthjem)

shipment.desiredDeliveryTimePeriod is used to specify the delivery time interval

Morgenlevering (company)

item.externalSupplierId is required

Amedia B2C

item.trackingReference is required, and can be in format gs1, s10 or DPD
shipmentId is required, and can be in format gs1, s10 or DPD

If item.trackingReference or shipmentId is not specified general gs1 format will be used and returned in the response.

For DPD format the AI identifier % is required in order to extract the shipment number / tracking reference. Valid DPD strings:

  • (%)0004326136193011084461015786

  • %0004326136193011084461015786

Response 

Name

Type

Example

Mandatory

Description

shipmentId

string

(401)70712190172720651

(tick)

See description with the same name in the request.

freightProductId

whole number

2

(tick)

The selected freight product for this shipment. See example freight products ablow

parties

list of party objects


(tick)

Note that the API could make minor changes to the returned consignee address.

items

list of item objects


(tick)

See description with the same name in the request.

properties

map of properties



Map with additional properties. Various information (properties) are specified only for certain transport products.

additionalServices

list of additionalService objects



See description with the same name in the request.

Freight Products

The freight product describes a way of delivery, and is defined by a delivery method and the coverage of the given method. Contact you carrier provider to determine which freight product ID(s) you'll have access to and can expect in the response. 

Properties

Name

Type

Example

Description

productCode

string

72

This can be placed on some shipping labels.

productName

string

Home delivery express

This can be placed on some shipping labels.

routingCode

String

OSL

This can be placed on some shipping labels.

issuerNumber

String

1

This can be placed on some shipping labels.

customerNumber

String

1234567

This can be placed on some shipping labels.

missionCode

String

2341-75213437173(90)1300034123456772-GH

This can be placed on some shipping labels.

routing

String

1234-01/4321-02-dropp x4321x12345

This can be placed on some shipping labels.
The format depends on last mile carrier setup, and not all information points are required and the length of each information point may also vary.

The general definition is describes below
"XXXX-yyy/ZZZZ-www-DropCode xRRRRRxSSSSS"
where
XXXX = pre transport main car number (if exists)

ZZZZ = local transport main car number
yy and ww = drop number for specified car
DropCode = description of drop point
RRRR = last mile route
SSSSS = drop number on last mile route

routeName

String

56789

This can be placed on some shipping labels.

routeAddress

String

My address 12

This can be placed on some shipping labels.

routeDescription

String

This can be placed on some shipping labels.

routingDescription

String

This can ble placed on some shipping labels.

Examples

Example 1: Specifying a standard B2C order

Curl request standard B2C

 Curl request standard B2C
curl --request POST --url https://staging-ws.di.no/ws/json/parcel/booking/v-1/book \
     --header "Authorization: Bearer $SECRET_WS_TOKEN" \
     --header 'Content-Type: application/json' \
     --data "{ \
               \"shopId\": 100, \
               \"transportSolutionId\": 1, \ 
               \"parties\": [{\"type\": \"consignee\", \"name\": \"Ola Norman\", \"countryCode\": \"NO\", \"postalName\": \"OSLO\", \"zipCode\": \"1234\", \
                              \"address\": \"MyAddress 182\", \"phone1\": \"95990099\", \"email\": \"ola.norrman@example.com\"}, \
                             {\"type\": \"consignor\", \"name\": \"shopName\", \"countryCode\": \"NO\", \"zipCode\": \"1234\"} ], \
               \"items\": [{\"itemNumber\": 1, \"weight\": 400, \"contents\": \"Shoes\", \"properties\": {\"ProductType\": \"Shoes\"}}] \
             }"

Response example Json standard B2C

 Response example Json standard B2C
{  
   "shipmentId":"(401)70720060080003600",
   "freightProductId":1,
   "parties":[  
      {  
         "type":"consignee",
         "id":null,
         "name":"Ola Norrman",
         "countryCode":"NO",
         "postalName":"OSLO",
         "zipCode":"1234",
         "address":"MyAdress 182",
         "phone1":"95990099",
         "phone2":null,
         "email":"ola.norrman@example.com",
         "reference":null,
         "contact":null
      },
      {  
         "type":"consignor",
         "id":null,
         "name":"MyShop",
         "countryCode":"NO",
         "postalName":null,
         "zipCode":"1234",
         "address":null,
         "phone1":null,
         "phone2":null,
         "email":null,
         "reference":null,
         "contact":null
      }
   ],
   "items":[  
      {  
         "itemNumber":1,
         "trackingReference":"(00)370724760080003567",
         "weight":400,
         "volume":null,
         "length":null,
         "height":null,
         "width":null,
         "contentValue":null,
         "contents":"Koiebrød",
         "properties":{  
            "ProductType":"Bread",
            "shortItemIdentifier":"...3567"
         },
		 "articles": []
      }
   ],
   "properties":{  
      "productName":"Home delivery express",
      "routeAddress":"RouteStartAddress 32",
      "routeDescription":"",
      "routeName":"23465",
      "routing":"1-26514/CAR-164-111-50",
      "routingCode":"1"
   }
}

Example 2: Specifying a standard B2C with servicePoint

Comment: Notice that servicePoint is added to the response. Servicepoint can also be specified in the request.

Curl request standard B2C with servicePoint
 Curl request standard B2C with servicePoint
curl --request POST  --url https://staging-ws.di.no/ws/json/parcel/booking/v-1/book  \
     --header "Authorization: Bearer $SECRET_WS_TOKEN"  \
     --header 'Content-Type: application/json' \
     --data "{\
              \"shopId\": 100, \
              \"transportSolutionId\": 1, \
              \"parties\": [{\"type\": \"consignee\", \"name\": \"Ola Norrman\", \"countryCode\": \"NO\", \"postalName\": \"OSLO\", \
                             \"zipCode\": \"1234\", \"address\": \"MyAddress 182\", \"phone1\": \"95990099\", \"email\": \"ola.norrman@example.com\"}, \
                            {\"type\": \"consignor\", \"name\": \"morgenlevering.no\", \"countryCode\": \"NO\", \"zipCode\": \"4321\"} ], \
              \"items\": [{\"itemNumber\": 1, \"weight\": 400, \"contents\": \"Shoes\", \"properties\": {\"ProductType\": \"Shoes\"}}] \
             }"
Response example Json standard B2C with servicePoint
 Response example Json standard B2C with servicePoint
{  
   "shipmentId":"(401)70724760080003888",
   "freightProductId":1,
   "parties":[  
      {  
         "type":"consignee",
         "id":null,
         "name":"Ola Norrman",
         "countryCode":"NO",
         "postalName":"OSLO",
         "zipCode":"1234",
         "address":"MyAddress 182",
         "phone1":"95990099",
         "phone2":null,
         "email":"ola.norrman@example.com",
         "reference":null,
         "contact":null
      },
      {  
         "type":"consignor",
         "id":null,
         "name":"MyShop",
         "countryCode":"NO",
         "postalName":null,
         "zipCode":"4321",
         "address":null,
         "phone1":null,
         "phone2":null,
         "email":null,
         "reference":null,
         "contact":null
      },
      {  
         "type":"servicePoint",
         "id":"36990033",
         "name":"STORE NAME KIOSK",
         "countryCode":"NO",
         "postalName":"OSLO",
         "zipCode":"1234",
         "address":"StorAddress 211",
         "phone1":null,
         "phone2":null,
         "email":null,
         "reference":null,
         "contact":null
      }
   ],
   "items":[  
      {  
         "itemNumber":1,
         "trackingReference":"(00)370724760080003888",
         "weight":400,
         "volume":null,
         "length":null,
         "height":null,
         "width":null,
         "contentValue":null,
         "contents":"Koiebrød",
         "properties":{  
            "ProductType":"Bread"
         },
		 "articles": []
      }
   ],
   "properties":{  
      "customerNumber":"1234567",
      "issuerNumber":"15",
      "missionCode":"421(578)1405\u001D90qwrw0001719",
      "productCode":"11",
      "productName":"Pick-upParcel",
      "routingCode":"OSL"
   }
}

Example 3: Specifying a standard B2B order  

Special attributes:

  • Request must specify "id" for the consignee (must be pre-registered)

  • Response includes "retailerId" that should be placed on the label.

Curl request B2B
 Curl request B2B
curl --request POST  --url https://staging-ws.di.no/ws/json/parcel/booking/v-1/book  \
     --header "Authorization: Bearer $SECRET_WS_TOKEN"  \
     --header 'Content-Type: application/json' \
     --data "{\
              \"shopId\": 100, \
              \"transportSolutionId\": 1, \
              \"parties\": [{\"type\": \"consignee\", \"id\": \"12345\", \"name\": \"Verksted A\", \"countryCode\": \"NO\", \"postalName\": \"OSLO\", \
                             \"zipCode\": \"1234\", \"address\": \"Verkstedgaten 101\", \"phone1\": \"23232323\", \"email\": \"verksted@example.com\"}, \
                            {\"type\": \"consignor\", \"name\": \"Leverandør A\", \"countryCode\": \"NO\", \"postalName\": \"OSLO\", \
                             \"zipCode\": \"0180\", \"address\": \"Stavangergata 37\", \"phone1\": \"22222222\", \"email\": \"post@leverandora.no\"} ], \
              \"items\": [{\"itemNumber\": 1, \"weight\": 400, \"contents\": \"tool A\"}, \
                          {\"itemNumber\": 2, \"weight\": 1230, \"contents\": \"tool B\"} ] \
             }"
Response example Json B2B
 Response example Json B2B
{
  "shipmentId": "(401)70724760120001111",
  "freightProductId": 1,
  "parties": [
    {
      "type": "consignor",
      "id": null,
      "name": "Leverandør A",
      "countryCode": "NO",
      "postalName": "OSLO",
      "zipCode": "0180",
      "address": "Address 37",
      "phone1": "22222222",
      "phone2": null,
      "email": "post@leverandora.no",
      "reference": null,
      "contact": null,
      "coaddress": null
    },
    {
      "type": "consignee",
      "id": "78534",
      "name": "Verksted A",
      "countryCode": "NO",
      "postalName": "Oslo",
      "zipCode": "0467",
      "address": "Verkstedgaten 101",
      "phone1": "23232323",
      "phone2": "",
      "email": "butikka@example.com",
      "reference": null,
      "contact": null,
      "coaddress": null
    }
  ],
  "items": [
    {
      "itemNumber": 1,
      "trackingReference": "(00)370724760120004123",
      "weight": 1000,
      "volume": null,
      "length": null,
      "height": null,
      "width": null,
      "contentValue": null,
      "contents": "Tool A",
      "properties": {
        "shortItemIdentifier": "...1123"
      },
	  "articles": [],
      "externalOrderId": null
    },
    {
      "itemNumber": 2,
      "trackingReference": "(00)370724760120001432",
      "weight": 1000,
      "volume": null,
      "length": null,
      "height": null,
      "width": null,
      "contentValue": null,
      "contents": "Tool B",
      "properties": {
        "shortItemIdentifier": "...1130"
      },
	  "articles": [],
      "externalOrderId": null
    }
  ],
  "properties": {
    "productName": "B"B,
    "retailerId": "483441",
    "routeAddress": "DeliverAddress 89",
    "routeDescription": null,
    "routeName": "",
    "routing": "80-0-place-T",
    "routingCode": "",
    "routingDescription": ""
  }
}

Example 4: Specifying a standard C2C order

Comment: notice that the format of the trackingReference in the response is different for return solutions. 

Curl request C2C
 Curl request C2C
curl --request POST  --url https://staging-ws.di.no/ws/json/parcel/booking/v-1/book  \
     --header "Authorization: Bearer $SECRET_WS_TOKEN"  \
     --header 'Content-Type: application/json' \
     --data "{\
              \"shopId\": 1, \
              \"transportSolutionId\": 23, \
              \"parties\": [{\"type\": \"consignee\", \"name\": \"Ola Normann\", \"countryCode\": \"NO\", \"postalName\": \"LANGHUS\", \
                             \"zipCode\": \"1405\", \"address\": \"Sloratoppen 82\", \"phone1\": \"23232323\", \"email\": \"ola@normann.com\"}, \
                            {\"type\": \"consignor\", \"name\": \"Kari Normann\", \"countryCode\": \"NO\", \"postalName\": \"OSLO\", \
                             \"zipCode\": \"0680\", \"address\": \"ENEBAKKVEIEN 2B\", \"phone1\": \"22222222\", \"email\": \"kari@normann.no\"} ], \
              \"items\": [{\"itemNumber\": 1, \"weight\": 400 } ] \
             }"
Response example Json C2C
 Response example Json C2C
{
  "shipmentId": "(401)70724760120001115",
  "freightProductId": 26,
  "parties": [
    {
      "type": "consignor",
      "id": null,
      "name": "Kari Normann",
      "countryCode": "NO",
      "postalName": "OSLO",
      "zipCode": "0680",
      "address": "ENEBAKKVEIEN 2B",
      "phone1": "22222222",
      "phone2": null,
      "email": "kari@normann.no",
      "reference": null,
      "contact": null,
      "coaddress": null
    },
    {
      "type": "consignee",
      "id": null,
      "name": "Ola Normann",
      "countryCode": "NO",
      "postalName": "LANGHUS",
      "zipCode": "1405",
      "address": "Sloratoppen 1",
      "phone1": "23232323",
      "phone2": "",
      "email": "ola@normann.com",
      "reference": null,
      "contact": null,
      "coaddress": null
    }
  ],
   "items": [
        {
            "itemNumber": 1,
            "trackingReference": "R-ECPAV",
            "weight": 400,
            "volume": null,
            "length": null,
            "height": null,
            "width": null,
            "contentValue": null,
            "contents": null,
            "properties": {
                "shortItemIdentifier": "...ECPV"
            },
			"articles": [],
            "externalOrderId": null
        }
    ],
    "properties": {
        "productName": "Meg til deg",
        "routeAddress": "RYENSTUBBEN 7",
        "routeDescription": "BUDSENTRAL RYEN 1",
        "routeName": "23331",
        "routing": "1-23331/AFT-133-100-10",
        "routingDescription": "BUDSENTRAL RYEN"
    }
}

Example 5: Specifying Additional Service ASB with Item Articles

Note that the additional service must be activated for the shop, and that the value of the additionalService object must be preconfigured. The additional service, ASB, requires at least one article per item. 

Curl request Additional Service with Item Articles
 Curl request Additional Service with Item Articles
curl --request POST --url https://staging-ws.di.no/ws/json/parcel/booking/v-1/book \
     --header "Authorization: Bearer $SECRET_WS_TOKEN" \
     --header 'Content-Type: application/json' \
     --data "{
               \"shopId\": 1, 
               \"transportSolutionId\": 1, 
			   \"additionalServices\": [{\"key\": \"ASB\", \"value\": \"AS_KEY\" }], 
               \"parties\": [{\"type\": \"consignee\", \"name\": \"Ola Norrman\", \"countryCode\": \"NO\", \"postalName\": \"LANGHUS\", \"zipCode\": \"1405\",
                              \"address\": \"Sloratoppen 12\", \"phone1\": \"99550099\", \"email\": \"ola.norrman@example.com\"},
                             {\"type\": \"consignor\", \"name\": \"shop.no\", \"countryCode\": \"NO\", \"zipCode\": \"0155\"} ],
               \"items\": [{\"itemNumber\": 1, \"weight\": 400, \"contents\": \"Shoes\", \"properties\": {\"ProductType\": \"Shoes\"},
			   \"articles\": [{\"articleNumber\": \"ART_0001\", \"articleName\": \"Shoes\", \"quantity\": 1}]}]
             }"
Response example Additional Service with Item Articles
 Response example Additional Service with Item Articles
{
    "shipmentId": "(401)70724760120010124",
    "freightProductId": 1,
    "parties": [
        {
            "type": "consignee",
            "id": null,
            "name": "Ola Norrman",
            "countryCode": "NO",
            "postalName": "LANGHUS",
            "zipCode": "1405",
            "address": "Sloratoppen 12",
            "phone1": "99550099",
            "phone2": null,
            "email": "ola.norrman@example.com",
            "reference": null,
            "contact": null,
            "coaddress": null
        },
        {
            "type": "consignor",
            "id": null,
            "name": "shop.no",
            "countryCode": "NO",
            "postalName": null,
            "zipCode": "0155",
            "address": null,
            "phone1": null,
            "phone2": null,
            "email": null,
            "reference": null,
            "contact": null,
            "coaddress": null
        }
    ],
    "items": [
        {
            "itemNumber": 1,
            "trackingReference": "(00)370724760120010132",
            "weight": 400,
            "volume": null,
            "length": null,
            "height": null,
            "width": null,
            "contentValue": null,
            "contents": "Koiebrød",
            "properties": {
                "ProductType": "shoes",
                "shortItemIdentifier": "...0132"
            },
            "articles": [
                {
                    "articleNumber": "ART_0001",
                    "quantity": 1,
                    "articleName": "shoes"
                }
            ],
            "externalOrderId": null
        }
    ],
    "properties": {
        "productName": "home delivery standard",
        "routeAddress": "SØNSTERUDVEIEN 32",
        "routeDescription": "",
        "routeName": "26507",
        "routeSeq": "43",
        "routing": "1-31/1644-53-x236507x4",
        "routingCode": "1",
        "routingDescription": "DROPP 1"
    }
}

Error handling

API requests that result in errors will return an appropriate HTTP status code to help you identify the type of error. You can use the table below to understand what each code means, og search online with the HTTP status code. The HTTP error keys used are based on the standard, and therefore available online (Tips to search “HTTP code XXX”)

In addition to HTTP status there may be more details in the errorKey field. Error Keys can be added at a later stage, clients should handle this as well as an empty value for errorKey.

HTTP Status code

Text

Description

400

Client or Validation Error

The request body/query string is not in the correct format.

401

Authentication Failure

Indicates that the Authorization header is either missing or incorrect. You can learn more about the Authorization header here.

403

Access denied

This indicates that the agent whose credentials were used in making this request was not authorized to perform this API call. It could be that you do not have access to the shop or transportsolution you provided in your request. If you believe this is a mistake, please reach out to your contact so it can be rectified.

405

Method not allowed

This API request used the wrong HTTP verb/method. For example a PUT request will result in this error.

4xx

Client error

Generally receiving an error code that starts with 4 indicates that the client needs to change something.

500

Unexpected Server Error

Oops! This may indicates an error on our side. Please try again, if the error continues notify your contact person

Error response

In addition to the HTTP status code, most errors will also return a response body that contains more information to help you debug the error. A sample error response is shown below. The format of the error response body is explained after the example.

Sample error
{
    "statusCode": 401,
    "errorKey": "authentication.missing",
    "errorMap": {}
}

Field

Description

statusCode

The HTTP code associated with this error.

errorKey

A machine parseable error code.

errorMap

Additional details pertaining to the error.

Error Keys

 List of error keys

errorKey

status code

description

additional.service.not.activated.for.shop

400

article.number.required

400

desiredDeliveryDate.must.be.in.future

400

invalid.additional.service.specified

400

invalid.article.quantity

400

invalid.format.desiredDeliveryDate

400

invalid.party.type

400

invalid.transport.solution

400

invalid.format.additional.service

400

invalid.value.for.additional.service

400

item.article.required.for.additional.service

400

item.required

400

no.carrier.support

400

Not possible to deliver to this address. more information can be found here
Notify your contact person if you don´t have access.

no.carrier.support.admittance.deviation

400

Missing key for delivery address. Notify your contact person.

no.carrier.support.order.too.many.parcel.items

400

Max value for this parameter is exceeded, requirements can be set for shop or freightproduct. Notify your contact person.

no.carrier.support.package.too.big

400

Max value for this parameter is exceeded, requirements can be set for shop or freightproduct. Notify your contact person.

no.carrier.support.package.too.expensive

400

Max value for this parameter is exceeded, requirements can be set for shop or freightproduct. Notify your contact person.

no.carrier.support.package.too.heavy

400

Max value for this parameter is exceeded, requirements can be set for shop or freightproduct. Notify your contact person.

over.max.length.of.idempotency.key

400

Max value for this parameter is exceeded, requirements can be set for shop or freightproduct. Notify your contact person.

party.name.required

400

party.countryCode.required

400

party.zipCode.required

400

party.type.consignee.required

400

party.type.consignor.required

400

required.shop.id

400

no.retailer.found

400

The ServicePoint ID used is not valide. Please use a valid service point ID of registrere the booking without a specific servicePoint. Use Get all servicePoint API to see all valid servicePoints.

sellers.reference.length.25

400

shipment.id.already.exists

400

tracking.reference.already.exists

400

transportSolutionId.required

400

value.required.for.additional.service

400

validation.error.duplicate.order.information

400

wrong.itemNumber

400

wrong.shop.id

400

desiredDeliveryDate.not.supported

400

invalid.product.customersystem

400

Mismatch in setup for shop/customersystem/transportsolution/freightproduct. Please contact your carrier and ask them to update. If the setup is newly configured, wait some time and then try again (caching).

no.access.api

403

no.access.shop.id

403

internal.error

500



Other notes

DI receive Norwegian postal numbers and coordinates from GEODATA (🔗 LINK) - based on this our algorithm calculates closest ServicePoint


  • No labels