API reference
Search
K
Links
Comment on page

Create a parcel

How to create a parcel via API
To create a new parcel, send a POST request to the /api/parcels endpoint, passing the resource arguments in the request body.

Request

POST https://yourdomain.commercelayer.io/api/parcels

Arguments

Body Parameter
Type
Required
type
string
Required
attributes.weight
float
Required
attributes.unit_of_weight
string
Required
attributes.eel_pfc
string
Optional
attributes.contents_type
string
Optional
attributes.contents_explanation
string
Optional
attributes.customs_certify
boolean
Optional
attributes.customs_signer
string
Optional
attributes.non_delivery_option
string
Optional
attributes.restriction_type
string
Optional
attributes.restriction_comments
string
Optional
attributes.customs_info_required
boolean
Optional, default 'false'
attributes.shipping_label_url
string
Optional
attributes.shipping_label_file_type
string
Optional
attributes.shipping_label_size
string
Optional
attributes.shipping_label_resolution
string
Optional
attributes.tracking_number
string
Optional
attributes.tracking_status
string
Optional
attributes.tracking_status_detail
string
Optional
attributes.tracking_status_updated_at
datetime
Optional
attributes.tracking_details
object
Optional
attributes.carrier_weight_oz
string
Optional
attributes.signed_by
string
Optional
attributes.incoterm
string
Optional
attributes.delivery_confirmation
string
Optional
attributes.reference
string
Optional
attributes.reference_origin
string
Optional
attributes.metadata
object
Optional
relationships.shipment
object
Required
relationships.package
object
Required

Example

Request
Response
The following request creates a new parcel:
curl -g -X POST \
'https://yourdomain.commercelayer.io/api/parcels' \
-H 'Accept: application/vnd.api+json' \
-H 'Authorization: Bearer your-access-token' \
-H 'Content-Type: application/vnd.api+json' \
-d '{
"data": {
"type": "parcels",
"attributes": {
"weight": 1000.0,
"unit_of_weight": "gr"
},
"relationships": {
"shipment": {
"data": {
"type": "shipments",
"id": "ABCRtyUpBa"
}
},
"package": {
"data": {
"type": "packages",
"id": "BCDRtyUpBa"
}
}
}
}
}'
On success, the API responds with a 201 Created status code, returning the created resource object:
{
"data": {
"id": "xYZkjABcde",
"type": "parcels",
"links": {
"self": "https://yourdomain.commercelayer.io/api/parcels/xYZkjABcde"
},
"attributes": {
"number": "#1234/S/001/P/001",
"weight": 1000.0,
"unit_of_weight": "gr",
"eel_pfc": "EEL",
"contents_type": "merchandise",
"contents_explanation": "",
"customs_certify": false,
"customs_signer": "John Doe",
"non_delivery_option": "return",
"restriction_type": "none",
"restriction_comments": "",
"customs_info_required": false,
"shipping_label_url": "https://bucket.s3-us-west-2.amazonaws.com/files/postage_label/20180101/123.pdf",
"shipping_label_file_type": "application/pdf",
"shipping_label_size": "4x7",
"shipping_label_resolution": "200",
"tracking_number": "1Z4V2A000000000000",
"tracking_status": "delivered",
"tracking_status_detail": "arrived_at_destination",
"tracking_status_updated_at": "2018-01-01T12:00:00.000Z",
"tracking_details": [
{
"object": "TrackingDetail",
"message": "Pre-Shipment information received",
"status": "pre_transit",
"datetime": "2018-02-27T16:02:17Z",
"source": "DHLExpress",
"tracking_location": {
"object": "TrackingLocation"
}
}
],
"carrier_weight_oz": "42.32",
"signed_by": "John Smith",
"incoterm": "EXW",
"delivery_confirmation": "SIGNATURE",
"created_at": "2018-01-01T12:00:00.000Z",
"updated_at": "2018-01-01T12:00:00.000Z",
"reference": "ANY-EXTERNAL-REFEFERNCE",
"reference_origin": "ANY-EXTERNAL-REFEFERNCE-ORIGIN",
"metadata": {
"foo": "bar"
}
},
"relationships": {
"shipment": {
"links": {
"self": "https://yourdomain.commercelayer.io/api/parcels/xYZkjABcde/relationships/shipment",
"related": "https://yourdomain.commercelayer.io/api/parcels/xYZkjABcde/shipment"
}
},
"package": {
"links": {
"self": "https://yourdomain.commercelayer.io/api/parcels/xYZkjABcde/relationships/package",
"related": "https://yourdomain.commercelayer.io/api/parcels/xYZkjABcde/package"
}
},
"parcel_line_items": {
"links": {
"self": "https://yourdomain.commercelayer.io/api/parcels/xYZkjABcde/relationships/parcel_line_items",
"related": "https://yourdomain.commercelayer.io/api/parcels/xYZkjABcde/parcel_line_items"
}
},
"attachments": {
"links": {
"self": "https://yourdomain.commercelayer.io/api/parcels/xYZkjABcde/relationships/attachments",
"related": "https://yourdomain.commercelayer.io/api/parcels/xYZkjABcde/attachments"
}
},
"events": {
"links": {
"self": "https://yourdomain.commercelayer.io/api/parcels/xYZkjABcde/relationships/events",
"related": "https://yourdomain.commercelayer.io/api/parcels/xYZkjABcde/events"
}
},
"versions": {
"links": {
"self": "https://yourdomain.commercelayer.io/api/parcels/xYZkjABcde/relationships/versions",
"related": "https://yourdomain.commercelayer.io/api/parcels/xYZkjABcde/versions"
}
}
},
"meta": {
"mode": "test"
}
}
}