Skip to content

The api.declare_parcel function

Request description

The function takes the following three arguments :

  • username: given by IMX
  • password: given by IMX
  • data: a dictionary-like object containing your request data

Data object

data is described below.

Fields displayed as bold are mandatory, fields suffixed with a dot are dictionary members (example : options). Fields suffixed with [] are lists (example : parcel_content).

Name Description
version char(1)API Version
account char(40)Client account at IMX.In most cases, it’s the same as the username.
business_unit c(40)Your business unit
reference c(40)Your parcel reference.Each reference most match a unique parcel.
reference2 c(40)Your alternative parcel reference.
comment c(400)Your comment
sort_id c(6)Sort ID
options A dictionary object that contains additional information about the parcel.
.service c(1)Type of service (track and trace, express, etc.)See reference below.
.entry_mode c(40)Starting point of the parcel shipment. See reference below.Default value : delivery_to_imx.
.cod_value n(10,2)In case of a COD, its value. The decimal mark is the period, two decimals are allowed.Default value : 0.
.cod_currency c(3)ISO 4217.Default value : "EUR".
.insurance_value n(10,2)Desired insured value. Maximum value is 500 EUR. The decimal mark is the eriod, two decimals are allowed.Default value : 0.
.insurance_currency c(3)ISO 4217.Default value : 0.
.pod booleanSet to True if a proof of delivery is required. It requires service to be at least « 1 ».Default value : False.
.carrier c(20)If specified, will force the given carrier and bypass IMX rules of affectation. Some limitations may apply according to the addressee’s country.
.carrier_tracking_id booleanIf true, the function will return a carrier tracking id (if available at WS’s call time).>Default value : False.
.label booleanIf True, the function will return a PDF file (if available), or a file with asked format in options.label_formatDefault value : True
.label_format c(30)Label file format.pdf, zpl_203, zpl_300. Default value : pdf
.routing_option c(2)Option de routage.Option spécifique de routage, selon accord d'IMX
pickup Data relevant for pickup
.network c(40)Carrier responsible for the pickup
.address dictAddress where the pickup should be done. Contains the same fields as the other addresses : name, address1, address2, address3, postcode, town, country, phone, email. Setup may require an address_id as well.
parcelshop_delivery Data relevant for parcelshop delivery
.network c(30)Parcelshop networkMandatory if service is 4.
.parcelshop_id c(30)Parcelshop IDMandatory if service is 4
.choice n(1,0)If 1, IMX will get addresse's closest parcelshop. Ignored if parcelshop_delivery.parcelshop_id if filled. To be implemented.
.choice_notification_by_imx n(1,0)If 1, IMX sends a notification email to the addressee. To be implemented.
parcel_description A dictionary object that contains additional description about the parcel.
.weight n(10,3)Weight in kg.3 decimals allowed.
.length n(5,0)Length in cm.No decimal allowed.
.height n(5,0)Height in cm.No decimal allowed.
.width n(5,0)Width in cm.No decimal allowed.
.shipping_fees n(10,2)Transport fees.
.shipping_fees_currency n(10,2)ISO 4217 code.d>Default value : “EUR”.
.shipping_category c(1)Content category.Default value : '2' ("Goods"). See reference below.
.shipping_category_desc c(30)Content description, mandatory if shipping_category = '5' ("Others").
.invoice_number c(30)Invoice number.
.invoice base64Binary content of the invoice, as a PDF file. Size must be below 1Mo. Binary content must be base64-encoded.
.id_sender c(30)Sender's customs ID.
addressee A dictionary object that contains additional informations about the addressee.
.name c(80)addressee data
.company c(80)
.address1 c(80)
.address2 c(80)
.address3 c(80)
.postcode c(20)
.town c(80)
.province c(80)
.country c(2)Addressee’s country codeISO 3166-1 alpha2
.email c(80)Addressee’s email. Strongly advised.
.phone c(80)Addressee’s phone numberStrongly advised.
sender A dictionary object that contains additional informations about the sender.
.name c(80)Sender’s data. Same fields as addressee, See note below..
.company c(80)
.address1 c(80)
.address2 c(80)
.address3 c(80)
.postcode c(20)
.town c(80)
.province c(80)
.country c(2)
.email c(80)
.phone c(80)
parcel_content[] A dictionary object that contains additional informations about the parcel's content.
.description c(80)Parcel content description.
.classification c(20)UE classification code.See note below..
.origine c(20)c>Merchandise’s country of origin.ISO 3166-1 alpha2.
.value n(10,2)Merchandise’s value for customs declaration. The decimal mark is the period.Example: 10.02
.currency c(3)Monnaie de la déclaration de valeur.ISO 4217 code. Default value: "EUR"
.amount n(10)Amount of products.Default value: 1
.weight n(10,3)Unit product's weight, in kilos.
.prc_cov c(6)Percentage of volatile organic compounds.Example : '12.24'
.reference c(80)Client's reference for the product.

Notices

  • IMX allows address data to be fairly long, but some carriers are much more restrictive. Please specify address fields as short as possible.

  • IMX requires only name and town for addresses, but most carriers need much more. Postcodes and at least one address line are mandatory in most countries.

  • The sender object is not mandatory.

  • The parcel_content object is a list. You may fill up with all differents items that are a parcel. Within European Union, the parcel_content object is not mandatory.

References for request object fields

options.service

Value Description
0 Pack Prio
10 Pack Standard
1 Pack Sign
3 Pack Premium
4 Pack Parcelshop
5 Pack Easy
11 Traced Return
13 Premium Return
14 Parcelshop Return

options.entry_mode

Value Description
delivery_to_imx Parcels will be carried to IMX's hub or collected by IMX
parcelshop_dropoff Parcels will be left in a parcelshop
pickup Parcels will be collected by a carrier at some of your warehouses or shops. This option requires some setup and must be discussed with your sales representative

options.carrier

In most cases, this field must be left blank.

options.cod_currency, options.insurance_currency, parcel_content[].currency

ISO 4216 codes listing is available at https://fr.wikipedia.org/wiki/ISO_4217

parcel_description.shipping_category

Valeur Description
0 Gift
1 Sample
2 Goods sales
3 Document
4 Goods return
5 Others

addressee.country and sender.country

ISO-3166-1 alpha2 codes listing is available at http://www.iso.org/iso/fr/french_country_names_and_code_elements The value “SP” is also allowed for delivery towards French military addresses.

parcel_content[].classification

The customs classification codes are available at http://ec.europa.eu/taxation_customs/customs/procedural_aspects/general/community_code/index_en.htm We currently don’t do any validation on this field.

Response description

Field Description
success booleanIndicates whether the request was successful
label binaryBase64-encoded PDF data for the requested label.
infos[] c(400)Various messages.
label_source c(20)Indicates the label source (“imx” or carrier).
errors List of error data. Contains the following fields :
.field c(40)Name of the field generating error.We use the dot notation Exemples : country, options.networks, addressee.postcode, etc.
.message c(400)Error description.
.code c(20)Not specified.
Warnings List of warning data. Contains the following fields :
.field c(40)Name of the field generating the warning.
.message c(400)Warning description.
.code c(20)Not specified.
tracking_data List of tracking data. Contains the following fields :
.imx_tracking_id n(20)IMX unique reference number for the parcel.
.imx_tracking_url c(100)IMX tracking URL.
.carrier_tracking_id c(80) Carrier’s tracking number (if requested and available).
.scan_id c(100)Carrier’s scan id.
.carrier_tracking_url c(200)Carrier’s tracking URL (if requested and available).
.carrier_tracking_website c(100)Carrier’s tracking website, in case the carrier’s tracking url is not available.
.carrier_name c(100)Carrier’s name.

Notices

  • Success is True if and only if errors is an empty list, but there may be some warnings.

  • If requested (options.label=True), the field label contains binary content of the PDF file. Pages dimension is 10cmx15cm. The file can contain multiple pages according to destination country and carrier. We provide a CN23 label for countries outside UE. The file content is base64-encoded and has to be decoded before to be saved on disk or printed.

  • Errors and warnings fields are lists of objects.

  • Infos is a string.

Error messages

In case or errors, the errors field is a non-empty list of objects with the following properties :

· code: type of error. See values below ;

· message : message attempting to give an explicit description of the problem. Most of the time, it’s a message transmitted by the final carrier.

· field: field causing the error. In case the error is caused by a combination of fields, this data may not be available.

· value : value causing the error.

code field options

In live condition, most errors come from addresses not matching the final carrier’s specifications. To make debugging easier, we summarize those errors in five categories.

Value Description
INVALID Invalid value. It may be caused by invalid data type (for instance, non-numerical value for weight field) or invalid data itself (postcode too long or too short).
MANDATORY Blank value whereas the field is mandatory.
ROUTING_ERROR Transmitted by final carrier. For instance, can be a postcode which is temporary not deserved because of snow falls.
TOO_LONG Too long value. In most cases, the limitation comes from the final carrier.
UNKNOWN Error to be classified.

Address fields length

WS allows fields as long as 80 characters. However, most carriers have lower limits. It is safer to limit address fields to 32 characters.

Examples

Python

Basic example

Example with an error

International call example

PHP

Basic example