Balancing contracts in the route

Set­ting bal­anc­ing type for route.

The route-id iden­ti­fi­ca­tion num­ber in request can be obtained when cre­at­ing the route or by down­load­ing the routes list.

POST
/ext/contracts-api/v2/routes/{route-id}/balance
Request Authorization

Every request MUST include a valid access token obtained dur­ing the user autho­riza­tion process, pro­vid­ed using the Bear­er token scheme in the Autho­riza­tion head­er.

Successful Response
Request Header
POST  /ext/contracts-api/v2/routes/{route-id}/balance HTTP/1.1 
Host: api.platform.trans.eu 
Content-Type: application/json
Accept: application/json
Authorization: Bearer {access_token) 
Api-key: {unique_app_api-key}
Request Parameters
AttributeTypeExam­pleManda­to­ryDescrip­tion
balancing_typeString“MANUAL”YesBal­anc­ing type select­ed for route. Avail­able val­ues: MANUAL, CONTRACT_CONDITION, PERCENTAGE_SHARE, PRICE_ASCENDING, FREIGHT_LIMIT
con­tractsArray of ObjectsYes for PERCENTAGE_SHAREPer­cent­age of orders among car­ri­ers
contracts.contract_idString“0dfc855d-ae8d-4d08-a8d4-a3375f8b78f9”NoCar­ri­er con­tract id
contracts.percentage_shareFloat81NoPer­cent­age share for car­ri­er con­tract.
All per­cent­ages must add up to 100.
freight_limitObjectYes for FREIGHT_LIMITTrans­port lim­its for FREIGHT_LIMIT type of bal­anc­ing.
freight_limit.maxInt30YesMax lim­it in %
freight_limit.minInt70yesMin lim­it in %
Example Request Body
{
  "type": "in_order"
  "data": {
    "publication_time": {
      "value": 32000,
      "unit_code": "s",
      "user_unit_code": "min"
    },
    "order": "next_recipient"
  }
}
Response Fields
AttributeTypeExam­pleDescrip­tion
balancing_typeString“MANUAL”Bal­anc­ing type choosen in request
contracted_route_idString“3a378345-1939–48c1-bc71-639e0add8048”Route Id choosen in request
freight_limitObjectTrans­port lim­its for FREIGHT_LIMIT type of bal­anc­ing.
freight_limit.maxInt30Max lim­it in %
freight_limit.minInt70Min lim­it in %
load_idString“3090941d-a16f-475f-9f8b-26d­b0c­c­c4a5d”
nameString“Route no 1”Con­tract­ed route name
Response Body
{
    "contracted_route_id": "3a378345-1939-48c1-bc71-639e0add8048",
    "load_id": "3090941d-a16f-475f-9f8b-26db0ccc4a5d",
    "balancing_type": "FREIGHT_LIMIT",
    "name": "trasa2 API",
    "freight_limit": {
        "min": 30,
        "max": 70
    }
}

Clients errors (code 400)

HTTP 4xx sta­tus codes indi­cate client errors, mean­ing that the request could not be processed due to an issue on the client side. Below is a list of request-spe­cif­ic errors.

Example error 1

Not valid route id

{
    "type": "http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html",
    "title": "Bad Request",
    "status": 400,
    "detail": "Route with ID: 2f13c8bd-2160-4ea6-a7e5-6929b5eb2692 not found!",
    "service_code": 5404
}
Example error 2

No required ‘balancing_type’ field

{
    "message": [
        "balancing_type must be one of the following values: MANUAL, CONTRACT_CONDITION, PERCENTAGE_SHARE, PRICE_ASCENDING, FREIGHT_LIMIT"
    ],
    "error": "Bad Request",
    "statusCode": 400,
    "service_code": 5404
}
Example error 3

Not allowed bal­anc­ing type

{
    "type": "http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html",
    "title": "BalancingTypeException",
    "status": 420,
    "detail": "Chosen balancing type is not allowed for this contracted-route."
}
Example error 4

Wrong con­tract ids for the route

{
    "type": "http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html",
    "title": "Conflict",
    "status": 409,
    "detail": "Contracts are not compatible"
}
Example error 5

For PERCENTAGE_SHARE bal­anc­ing type sum­ma­ry share must be 100

{
    "type": "http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html",
    "title": "Unprocessable Entity",
    "status": 422,
    "detail": "Failed Validation",
    "validation_messages": {
        "contracts": {
            "contractsPercentageShare": "Contracts summary percentage share must be equal 100 and contains only unique contract ids"
        }
    }
}