Parcel Single Address Check API
Content
Purpose and use of service
Single address check API is designed to provide information about delivery options for a specified address and consumer. Based on the address, contact information and delivery options(transportSolution) in the request the API will respond with the best possible delivery option and transport details for that option, considering the next 7 days ahead. The transport options can be used for sorting or to create a label for the shipment (or you may use Parcel Label API after a booking is registered)
The coverage check is based on the coverage available from the different carriers. We continuously receive updated information from each carrier, and therefore the delivery option result may vary with time
To determine coverage we also look at previous shipment to similar addresses and consumers, this help correct misspellings and find coverage.
Integration tips
We recommend to always include all information you have available, and use the same information in the Booking API to ensure the results are consistent
Do the coverage check as close as possible to booking (Parcel Booking API) to reduce the chance of changes in coverage
For delivery address where there are households and businesses it is necessary to specify household number, e.g. H0201, in order for the system to know which of the options you want
Only use
desiredDeliveryDate
if the delivery must be for a specific date. You may specify a holiday or none working day, which can result in a different delivery option than you hoped for. Without a date the next possible distribution date will be set as defaultOnly use
deliveryPointId
if you are sure the ID you use is correct. If this fields is set some of the steps this API usually do to determine coverage are skipped. Also this value is not possible to set in the Booking API, increasing the (very small) chance that the results from that API is not consistent with the result from this API
If you wish to coverage check a batch of addresses or constantly know which delivery options are available for a consumer database (or similar) please contact you parter carrier to discuss options.
We reserve the right to regulate users who misuse this service.
Setup
| 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
TEST POSt | https://staging-ws.di.no/ws/json/addressCheck/single/v-1/find |
---|---|
PRODUCTION POSt | https://ws.di.no/ws/json/addressCheck/single/v-1/find |
Making a request
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.
For a delivery address where there are households and businesses it is necessary to specify household number, e.g. H0201, to ensure the API identifies correct delivery place
Request header
Field | Value |
---|---|
Content-Type | application/json |
Authorization | $SECRET_WS_TOKEN - jwt token from authentication |
Request body
Field | Description | Example | Data type | Mandatory |
---|---|---|---|---|
shopId | The identifier of the shop that makes the request | 23 | Integer | |
transportSolutionId | The transport solution that we want transport information from | 12 | Integer | |
desiredDeliveryDate | The date that the delivery is planned to arrive on | 2019-04-10 | String | |
customerName | Name of the receiver of the package | Ola Norrman | String | |
countryCode | Two letter country code of the destination of the package | NO | String | |
postalName | City name of the destination | Oslo | String | |
zipCode | Zip code of the destination | 0155 | String | |
address | Street name of the destination | Akersgata 55A H0212 | String | Required for home delivery |
partyId | ID to specify consignee or consignor | 1234 | Integer | Required for B2B delivery |
deliveryPointId | Reference to the delivery point (address). This ID can be found from 🏘 DI Address Helper serviceor as a response from Parcel Booking API | 12345678 | Integer | |
co | Care of address of the destination | Kari Norrman | String | |
volume | The volume of the package, in cubic decimeters | 5.3 | Double | |
weight | The weight of the shipment |
|
|
|
Field | Value |
---|---|
Content-Type | application/json |
Authorization | $SECRET_WS_TOKEN - jwt token from authentication |
Curl request example
curl https://dev-ws.di.no/ws/json/addressCheck/single/v-1/find \
-H "Authorization: Bearer $SECRET_WS_TOKEN"\
-H "Content-Type:application/json" \
-d '{
"shopId": 33,
"transportSolutionId": 10,
"desiredDeliveryDate": "2017-04-27",
"customerName": "Cust Name",
"countryCode" : "NO",
"postalName" : "SEM",
"zipCode": "3171",
"address": "GAMLE RAMNESVEI 38",
"deliveryPointId": null,
"co" : "",
"weight": null,
"volume": null
}'
Response
The endpoint replies with a response object in JSON format, containing the following data
Field | Description | Example | Data type |
---|---|---|---|
productName | A static name of the freight product that the package is routed to | DOOR_DELIVERY | String |
routeName | name of the route that the carrier takes |
| String |
companyId | Id of the company that owns the route |
| Integer |
routing | Transport information that can be printed on a label | 1234-01/4321-02-smeplass x325117x598 | String |
routingCode | The name of the sorting station the package is delivered to | 1 | String |
routeAddress | delivery instructions |
| String |
routeDescription | delivery instructions |
| String |
routingDescription | delivery instructions |
| String |
handOverId | describes the location that the parcel is delivered from the previous handler to the distribution company |
| Integer |
handOverCity | describes the location that the parcel is delivered from the previous handler to the distribution company |
| String |
handOverZipCode | describes the location that the parcel is delivered from the previous handler to the distribution company |
| String |
handOverStreetName | describes the location that the parcel is delivered from the previous handler to the distribution company |
| String |
handOverStreetNumber | describes the location that the parcel is delivered from the previous handler to the distribution company |
| Integer |
handOverDescription | describes the location that the parcel is delivered from the previous handler to the distribution company |
| String |
plannedDeparture | describes the time of day the first transport car in a chain will depart. Formatted as HHMM | 0221 | String |
Example response
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. New error keys may occur, you should handle this according to the HTTP status code.
Sample error
Field | Description |
---|---|
statusCode | The HTTP code associated with this error. |
errorKey | A machine parseable error code, this may be empty and new errorKeys can be added at a later stage |
errorMap | Additional details pertaining to the error. |
Error Keys