Parcel Replace Order API

Parcel Replace Order API

This API enables replacing an order registered in DI

Content

Purpose and use of Service

Replace Order API is used to replace details for an existing order. Replacing will create a new order, cancel an old one and applies to all items in that order.

Setup

Make sure you have the following information at hand before proceeding.

 

Example

Description

 

Example

Description

Username (see Authentication section)

wsfoobar

A valid username.

Password (see Authentication section)

a-very-very-long-password

A password matching given username.

  • The user is a web service user

  • The user has access to the web service for editing orders

  • The user has access to the shop registered on the order

Environments / Endpoints

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

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

  • 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.

  • Changes will be updated for all parcels/kolli for the shipment/order specified

  • You may have several patch operations in one request

  • If request contains remove operation it should be the last operation in the request

  • If one of the operations in a request is invalid the whole request will be interrupted

  • It is not possible to undo a replace request, but you can do several replace requests on the same shipment which will cause creating new order every time

Notes

It is neccessary to remove the servicePoint party to if it should be automatically re-assigned. This could be relevant if consignee address has been changed, and servicePoint should be re-evaluated and re-assigned.

Request-Headers

key

value example

comment

key

value example

comment

Authorization

Bearer "SECRET_WS_TOKEN"

See authentication on how to obtain a token

Content-Type

application/json

 

Request-Path-Parameters

Name

Example

Description

Name

Example

Description

shipmentId

70724761617883184

The message number of the order that will be replaced

Request-Body

JSON file containing an array of patch operations.. The current patch operations supported by JSON Patch are:

Name

Example

Description

Name

Example

Description

Replace

[   { "op": "replace", "path": "/transportSolutionId", "value": 1 } ]

Replace the existing value with new value for specified path.
The old value is not stored, and can not be retrieved after replaced.

Description of each key:
“op“ → operation used
”path” → JSON Pointer used to specify which part of the model needs to be changed
”value” → The value that will be changed

Add

[   { "op": "add", "path": "/parties", "value":  { "type": "servicePoint", "id": 1 } } ]

Add new value with the specified properties. Value object’s structure is dependant on the type of the object. Supported paths:

Remove

[   { "op": "remove", "path": "/parties/servicePoint" } ]

Removes an object from the order. Supported paths:

Edit operations available
See https://jira-di.atlassian.net/wiki/spaces/DIPUB/pages/68026370 documentation for more details about use and definition of each path and value

Path

Operation supported

Value description

Example operation

Path

Operation supported

Value description

Example operation

/shopId

"op": "replace"

Whole number,
The shop this booking is made for.

{ "op":"replace", "path": "/shopId", "value": 95123 }

/shopDisplayName

"op": "replace"

String, A user presentable name of the shopId.

{ "op":"replace", "path": "/shopDisplayName", "value": "My Company Ltd" }

/transportSolutionId

"op": "replace"

Whole number,
A transport solution is a construct that contains multiple freight products

{ "op":"replace", "path": "/transportSolutionId", "value": 123 }

/shipmentId

"op": "replace"

String. ShipmentId is identificator for the entire order.

{ "op":"replace", "path": "/shipmentId", "value": "(401)70712190172720651" }

/desiredDeliveryDate

"op": "replace"

String, Date format yyyyMMdd. This date should be defined as distribution date.

{ "op":"replace", "path": "/desiredDeliveryDate", "value": "20250101" }

/desiredDeliveryTimePeriod

"op": "replace"

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

{ "op":"replace", "path": "/desiredDeliveryTimePeriod", "value": "1930-2130" }

/messageToCarrier

"op": "replace"

String, Typically delivery instructions.

{ "op":"replace", "path": "/messageToCarrier", "value": "Some Instruction Here" }

/messageToConsignee

"op": "replace"

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

{ "op":"replace", "path": "/messageToConsignee", "value": "Some Information Here" }

/proofOfDelivery

"op": "replace"

String, proof of delivery options. Possible values: NO_CONFIRMATION, SIMPLE_CONFIRMATION, SCAN, SCAN_AND_PICTURE, PICTURE

{ "op":"replace", "path": "/proofOfDelivery", "value": "NO_CONFIRMATION" }

/campaignMark

"op": "replace"

Boolean, When set to true, an asterix (*) will be visible on some labels.

{ "op":"replace", "path": "/campaignMark", "value": true }

/parties/{partyType}/type

"op": "replace"

String,
Type of party involved.

{ "op":"replace", "path": "/parties/consignor/type", "value": "consignee" }

/parties/{partyType}/id

"op": "replace"

String,
Identifier that can be used to identify the same party between different shipments.

{ "op":"replace", "path": "/parties/servicePoint/id", "value": "1234" }

/parties/{partyType}/name

"op": "replace"

String,
Consignor/sender name

{ "op":"replace", "path": "/parties/consignor/name", "value": "MyStore" }

/parties/{partyType}/countryCode

"op": "replace"

String,
Country code, according to ISO 3166-1

{ "op":"replace", "path": "/parties/consignor/countryCode", "value": "NO" }

/parties/{partyType}/postalName

"op": "replace"

String,
Consignor/sender city

{"op":"replace","path":"/parties/consignor/postalName","value":"Oslo"}, 

/parties/{partyType}/zipCode

"op": "replace"

String,
Consignor/sender postal code

{"op":"replace","path":"/parties/consignor/zipCode","value":"0577"}

/parties/{partyType}/address

 

"op": "replace"

String,
Consignor/sender street address, number and household

{ "op":"replace","path":"/parties/consignor/address","value":"Storgata 4B H0201"},

/parties/{partyType}/coAddress

 

"op": "replace"

String,
Consignor/sender co address

{ "op":"replace", "path": "/parties/consignor/coAddress", "value": "MyStores Corporate Group" }

/parties/{partyType}/phone1

 

"op": "replace"

String,
This can be used for automated SMS notification.

{ "op":"replace", "path": "/parties/consignor/phone1", "value": "12345678" }

/parties/{partyType}/phone2

 

"op": "replace"

String,
This can be used for automated SMS notification.

{ "op":"replace", "path": "/parties/consignor/phone2", "value": "12345678" }

/parties/{partyType}/email

 

"op": "replace"

String,
Consignor/sender email

{ "op":"replace", "path": "/parties/consignor/email", "value": "info@email.com" }

/parties/{partyType}/reference

"op": "replace"

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

{"op":"replace","path":"/parties/consignor/reference","value":"senderReference"}, 

/parties/{partyType}/contact

"op": "replace"

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

{"op":"replace","path":"/parties/consignor/contact","value":"Customer service contact name"}

/items/{itemNumber}/itemNumber

"op": "replace"

Whole Number, Item/package number of the shipment.

{"op":"replace","path":"/items/1/itemNumber","value": 2}

/items/{itemNumber}/trackingReference

"op": "replace"

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

{"op":"replace","path":"/items/1/trackingReference","value": "(00)370724760010119754" }

/items/{itemNumber}/returnCode

"op": "replace"

String, If specified this will be used for custom return functionality.

{"op":"replace","path":"/items/1/returnCode","value": "R-1234567" }

/items/{itemNumber}/weight

"op": "replace"

Whole Number, Measuring unit is gram.

{"op":"replace","path":"/items/1/weight","value": 600 }

/items/{itemNumber}/volume

"op": "replace"

Decimal Number, Measuring unit is cubic decimeter.

{"op":"replace","path":"/items/1/volume","value": 4 }

/items/{itemNumber}/length

"op": "replace"

Decimal Number, Measuring unit is centimeter.

{"op":"replace","path":"/items/1/length","value": 120 }

/items/{itemNumber}/height

"op": "replace"

Decimal Number, Measuring unit is centimeter.

{"op":"replace","path":"/items/1/height","value": 5 }

/items/{itemNumber}/width

"op": "replace"

Decimal Number, Measuring unit is centimeter.

{"op":"replace","path":"/items/1/width","value": 12 }

/items/{itemNumber}/contentValue

"op": "replace"

Decimal Number, Currency is according to the location of the shopId.

{"op":"replace","path":"/items/1/contentValue","value": 580 }

/items/{itemNumber}/externalSupplierId

"op": "replace"

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

{"op":"replace","path":"/items/1/externalSupplierId","value": 5415 }

/items/{itemNumber}/contents

"op": "replace"

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

{"op":"replace","path":"/items/1/contents","value": "Brown shirt" }

/items/{itemNumber}/properties

"op": "replace"

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

{"op":"replace","path":"/items/1/properties","value": {"productType": "Bread"} }

/additionalServices

"op": "add"

Adds Additional services that should be applied to the shipment.

{"op":"add","path":"/additionalServices", "value": {"key" : "KEY", "value": "VALUE"} }

/additionalServices/{key}

"op": "remove"

Removes additional services that should be applied to the shipment.

{"op":"remove","path":"/additionalServices/ASA" }

Examples

Curl request replace consignee details

curl --location --request PUT 'https://staging-ws.di.no/ws/json/parcel/booking/v-1/orders/70724762044206508' \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer $SECRET_WS_TOKEN' \ --data-raw '[ { "op", "replace", "path", "/parties/consignee/name", "value", "new consignee" }, { "op", "replace", "path", "/parties/consignee/phone1", "value", "1234567" }, { "op", "replace", "path", "/parties/consignee/email", "value", "new.consignee@email.com" }, { "op", "replace", "path", "/parties/consignee/countryCode", "value", "NO" }, { "op", "replace", "path", "/parties/consignee/postalName", "value", "FREDRIKSTAD" }, { "op", "replace", "path", "/parties/consignee/zipCode", "value", "1620" }, { "op", "replace", "path", "/parties/consignee/address", "value", "OSLOGATA 20A" }, { "op", "replace", "path", "/parties/consignee/coaddress", "value", "new C/O ADDRESS" } ]'

 

Curl request replace transport solution ID

curl --location --request PUT 'https://staging-ws.di.no/ws/json/parcel/booking/v-1/orders/70724762044206508' \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer $SECRET_WS_TOKEN' \ --data-raw '[ { "op": "replace", "path": "/transportSolutionId", "value": 22 } ]'

 

Curl request remove party

curl --location --request PUT 'https://staging-ws.di.no/ws/json/parcel/booking/v-1/orders/70724762044206508' \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer $SECRET_WS_TOKEN' \ --data-raw '[ { "op": "remove", "path": "/parties/servicePoint" } ]'

 

Curl request add party

curl --location --request PUT 'https://staging-ws.di.no/ws/json/parcel/booking/v-1/orders/70724762044206508' \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer $SECRET_WS_TOKEN' \ --data-raw '[ { "op": "add", "path": "/parties", "value": { "type": "servicePoint", "id": 123 } } ]'

 

Response 

Name

Type

Example

Mandatory

Description

Name

Type

Example

Mandatory

Description

shipmentId

string

(401)70712190172720651

See description with the same name in the request.

freightProductId

whole number

2

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

parties

list of party objects

 

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

items

list of item objects

 

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 additionalServices objects

 

 

See description with the same name in the request.

The response is the same as for Parcel booking API, see example and more details in that documentation.

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

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.