Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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

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

...

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. 

...

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

Authorization

Bearer "SECRET_WS_TOKEN"

See authentication on how to obtain a token

Content-Type

application/json

Request-Path-Parameters

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

Replace

Code Block
languagejson
[
  { "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

Code Block
languagejson
[
  { "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

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

Removes an object from the order. Supported paths:

Edit operations available
See Parcel Booking API documentation for more details about use and definition of each path and value

Path

Operation supported

Value description

Example operation

/shopId

"op": "replace"

Whole number,
The shop this booking is made for.

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

/shopDisplayName

"op": "replace"

String, A user presentable name of the shopId.

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

/transportSolutionId

"op": "replace"

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

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

/shipmentId

"op": "replace"

String. ShipmentId is identificator for the entire order.

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

/desiredDeliveryDate

"op": "replace"

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

Code Block
languagejson
{ "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.

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

/messageToCarrier

"op": "replace"

String, Typically delivery instructions.

Code Block
languagejson
{ "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.

Code Block
languagejson
{ "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

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

/campaignMark

"op": "replace"

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

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

/parties/{partyType}/type

"op": "replace"

String,
Type of party involved.

Code Block
languagejson
{ "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.

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

/parties/{partyType}/name

"op": "replace"

String,
Consignor/sender name

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

/parties/{partyType}/countryCode

"op": "replace"

String,
Country code, according to ISO 3166-1

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

/parties/{partyType}/postalName

"op": "replace"

String,
Consignor/sender city

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

/parties/{partyType}/zipCode

"op": "replace"

String,
Consignor/sender postal code

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

/parties/{partyType}/address

"op": "replace"

String,
Consignor/sender street address, number and household

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

/parties/{partyType}/coAddress

"op": "replace"

String,
Consignor/sender co address

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

/parties/{partyType}/phone1

"op": "replace"

String,
This can be used for automated SMS notification.

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

/parties/{partyType}/phone2

"op": "replace"

String,
This can be used for automated SMS notification.

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

/parties/{partyType}/email

"op": "replace"

String,
Consignor/sender email

Code Block
languagejson
{ "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.

Code Block
{"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.

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

/items/{itemNumber}/itemNumber

"op": "replace"

Whole Number, Item/package number of the shipment.

Code Block
{"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.

Code Block
{"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.

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

/items/{itemNumber}/weight

"op": "replace"

Whole Number, Measuring unit is gram.

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

/items/{itemNumber}/volume

"op": "replace"

Decimal Number, Measuring unit is cubic decimeter.

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

/items/{itemNumber}/length

"op": "replace"

Decimal Number, Measuring unit is centimeter.

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

/items/{itemNumber}/height

"op": "replace"

Decimal Number, Measuring unit is centimeter.

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

/items/{itemNumber}/width

"op": "replace"

Decimal Number, Measuring unit is centimeter.

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

/items/{itemNumber}/contentValue

"op": "replace"

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

Code Block
{"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.

Code Block
{"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.

Code Block
{"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.

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

/additionalServices

"op": "add"

Adds Additional services that should be applied to the shipment.

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

/additionalServices/{key}

"op": "remove"

Removes additional services that should be applied to the shipment.

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

Examples

Curl request replace consignee details

...

Expand
titleCurl request edit distribution date
Code Block
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

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

...

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.

...

Code Block
{
    "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

Expand
titleList of error keys

Error key

Status code

Action

no.access.api

403

Your user does not have access to this API. Notify your carrier contact person to update your access

no.access.shop.id

403

Your user does not have access to the shop registered to the order you try to edit. Notify your carrier contact person to update your access

cannot.find.order

404

We can not recognise the shipmentID specified, please check that it is a valid and correct ID

unable.to.edit.exporter.order

400

For some carriers and freight products we do not have the possibility to edit and order after they have registered the order, therefor these orders can not be edited. See flow chart under “use of service” for details.

order.cancelled

400

It is not possible to edit cancelled ordres

no.changes.in.patch

400

The edit order request you are trying to perform does not have any changes from what information is already registered on the order.

invalid.format.desiredDeliveryDate

400

Please check your date format

order.changes.freightproduct

400

The edit order request you have will result in a different delivery method (freight product), and is not possible to perform. This can be for several reasons, maybe the date or address changes are not supported for the existing freight product

failed.to.parse.request

400

Please check your path value, we are not able to recognise the key. Remember this path value is case sensitive

JsonPatch.format.invalid

400

Please check you request format, see valid format in examples above.

failed.to.map.JsonPatch

400

distributionDate.must.be.in.future

400

Change distribution date.

error.parcel.final.status

400

Parcel has reach a final destination and can not be edited.

order.exported

400

For some carriers and freight products we do not have the possibility to edit and order after they have registered the order, therefor these orders can not be edited. See flow chart under “use of service” for details.

party.name.required

400

Required information and validation for each value is equal to the booking API, see details in Parcel Booking API documentation

party.name.too.long

400

Required information and validation for each value is equal to the booking API, see details in Parcel Booking API documentation

address.required

400

Required information and validation for each value is equal to the booking API, see details in Parcel Booking API documentation

address.too.long

400

Required information and validation for each value is equal to the booking API, see details in Parcel Booking API documentation

zipCode.required

400

Required information and validation for each value is equal to the booking API, see details in Parcel Booking API documentation

email.too.long

400

Required information and validation for each value is equal to the booking API, see details in Parcel Booking API documentation

phone.too.long

400

Required information and validation for each value is equal to the booking API, see details in Parcel Booking API documentation

co.address.too.long

400

Required information and validation for each value is equal to the booking API, see details in Parcel Booking API documentation

zipCode.too.long

400

Required information and validation for each value is equal to the booking API, see details in Parcel Booking API documentation

postalName.too.long

400

Required information and validation for each value is equal to the booking API, see details in Parcel Booking API documentation

countryCode.too.long

400

Required information and validation for each value is equal to the booking API, see details in Parcel Booking API documentation

error.parcel.under.distribution

409

Please see https://jira-di.atlassian.net/wiki/spaces/DIPUB/pages/2177597504/Parcel+Edit+Order+API#Use-of-Service for when parcels can be edited.

internal.error

500

If you receive this error please notify your carrier contact person, and provide the request(s) you try to perform

...