Allocate with a specific carrier service
Assign shipments to a specific carrier service using the ‘allocate with carrier service’ endpoints, ideal for tighter control over shipment routing.
Get the carrier service reference
Want to specify the carrier service that should take your shipment? This guide explains how to allocate shipments to specific services.
In order to allocate a shipment to a specific carrier service, you’ll need to know that service’s {carrier_service_reference}
. The {carrier_service_reference}
is a unique identifier for each service available in the Shipments platform.
Allocate a shipment with a specific carrier service
The Allocate Shipment with Carrier Service endpoint enables you to allocate a shipment to a specific carrier service. To call Allocate Shipment with Carrier Service, send a PUT
request to https://api.sorted.com/pro/shipments/{reference}/allocate/service/{service_ref}
, where {reference}
refers to the shipment you want to allocate and {service_ref}
is the reference of the carrier service that you want to allocate to.
The Shipments platform then attempts to allocate the specified shipment to the specified carrier service and returns an Allocate Result.
All Shipments API endpoints that allocate consignments individually return an Allocate Result object. The Allocate Result contains details of:
- The shipment’s current
state
following the allocation request. For successful requests this would generally be Allocated. - The carrier and service that the shipment was allocated to.
- The
price
of the allocation. - Any relevant tracking references.
- The services that were unable to provide a quote.
- The
shipping_date
andexpected_delivery_date
for the shipment.
Allocate shipment with carrier service example
The example shows a successful request to allocate shipment sp_00794355402411366010308868571136 to a carrier service with the {carrier_service_reference}
FF_LINET-00001.
Allocate shipment with carrier service request
PUT https://api.sorted.com/pro/shipments/sp_00794355402411366010308868571136/allocate/service/FF_LINET-00001
Allocate shipment with carrier service response
{
"shipment_reference": "sp_00794355402411366010308868571136",
"state": "allocated",
"price": {
"net": 2.00,
"gross": 2.00,
"taxes": [
{
"rate": {
"reference": "FF_LINET-00001",
"country_iso_code": "GB",
"type": "Zero",
"value": 0.0000
},
"amount": 0.000000
}
],
"currency": "GBP"
},
"message": "Shipment sp_00794355402411366010308868571136 has been allocated successfully",
"carrier": {
"reference": "FF_LINET",
"name": "Lineten",
"service_reference": "FF_LINET-00001",
"service_name": "Lineten - Standard On Demand"
},
"tracking_details": {
"shipment": {
"reference": "sp_00794355402411366010308868571136",
"tracking_references": [
"8376568"
]
},
"contents": []
},
"_links": [
{
"href": "https://api-int.sorted.com/pro/shipments/sp_00794355402411366010308868571136",
"rel": "shipment",
"reference": "sp_00794355402411366010308868571136",
"type": "shipment"
},
{
"href": "https://api-int.sorted.com/pro/labels/sp_00794355402411366010308868571136/pdf",
"rel": "label",
"reference": "sp_00794355402411366010308868571136",
"type": "label"
},
{
"href": "https://api-int.sorted.com/pro/labels/sp_00794355402411366010308868571136/zpl",
"rel": "label",
"reference": "sp_00794355402411366010308868571136",
"type": "label"
}
],
"correlation_id": "e35a94cd-f3e5-401a-85b8-dcda0aa2d553.SAPI_496bfd60-08b5-4cd3-86a7-502601288357",
"details": [],
"excluded_services": []
}
For full reference information on the Allocate Shipment with Carrier Service endpoint, see the Shipments API reference.
Allocate multiple shipments with a specific carrier service
The Allocate With Carrier Service endpoint enables you to queue one or more shipments for allocation to a specific carrier service. To call Allocate With Carrier Service, send a PUT
request to https://api.sorted.com/pro/shipments/allocate/service
. The body of the request should contain a list of the {shipments}
that you want to allocate and the {carrier_service_reference}
of the carrier service you want to allocate to.
Optionally, you can also include a list of service capabilities
. Where capabilities are provided, then Shipments only allocates the shipment to a carrier service that meets those capabilities. Each capability should list the type
of service capability specified and the value
that that capability should have.
For information on available service capabilities and values, see the Shipments API reference.
202 - Accepted
response. Note that, as the Allocate with Carrier Service operation is asynchronous, this response only indicates that the specified shipments have been queued for allocation and does not guarantee that the shipments have been or will be successfully allocated. Allocate with Carrier Service does not override existing allocation rules. If the carrier service you selected does not meet your existing allocation rules, an error is returned.All Shipments API endpoints that queue multiple shipments for allocation return an Allocate Shipments result. The Allocate Shipments result includes a list of all shipments that were successfully queued and details of all shipments that were rejected for allocation, including the references of those shipments and the reason for rejection.
When you make a request to allocate multiple shipments simultaneously, Ship queues those shipments to be allocated at a later time rather than allocating them straight away. This helps to optimise performance. Ship then allocates queued shipments via an automated background process.
Allocate with carrier service example
The example shows a request to queue four shipments for allocation to a carrier service with the {carrier_service_reference}
FF_LINET-00001. Three shipments have been successfully queued, but one was rejected because its {reference}
could not be found.
Allocate with carrier service request
PUT https://api.sorted.com/pro/shipments/allocate/service
{
"shipments": [
"sp_00794372987452683804666199932928",
"sp_00794373204515521320006493798400",
"sp_00794373381493583963175932002304",
"sp_10014418709726822400876827879904"
],
"carrier_service_reference": "FF_LINET-00001"
}
Allocate with carrier service response
{
"message": "3 shipments queued for allocation successfully. 1 shipment rejected for allocation.",
"queued": [
"sp_00794372987452683804666199932928",
"sp_00794373204515521320006493798400",
"sp_00794373381493583963175932002304"
],
"rejected": [
{
"code": "shipment_not_found",
"message": "The shipment cannot be found.",
"references": [
"sp_10014418709726822400876827879904"
]
}
],
"_links": []
}
For full reference information on the Allocate With Carrier Service endpoint, see the Shipments API reference.
Allocation next steps
- Allocating to Default Rules - How to allocate shipments based on your pre-defined allocation rules.
- Allocating Within a Carrier Service Group - How to allocate shipments with a carrier service from a specific carrier service group.