Creating a new flexible contract in selected route.
After successfully executing the method, you receive in response the contract details with the unique contract identification number id assigned when creating the new contract.
POST
/ext/contracts-api/v2/contracts/flexible
Request Authorization
Every request MUST include a valid access token obtained during the user authorization process, provided using the Bearer token scheme in the Authorization header.
Successful Response
Error Response
Request Header
POST /ext/contracts-api/v2/contracts/flexible 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 for create flexible contract
| Attribute | Type | Example | Mandatory | Description |
| carrier | Object | Yes | Carrier invited to the get contract | |
| carrier.company | Object | Yes | Carrier company details | |
| carrier.company.id | Int | 456745 | Yes | Carrier company Id |
| carrier.contact_persons | Array of Objects | No | Carrier persons invited to get contract | |
| carrier.contact_persons.employee | Object | No | Contact person details | |
| carrier.contact_persons.employee.account_id | Int | 123321 | No | Contact person internal Id |
| config | Object | Yes | Contract configuration | |
| config.send_to_carrier | Boolean | True | Yes | Created contract will be automatically send to carrier.True value is required. |
| pricing | Object | No | Pricing for contract | |
| pricing.negotiable | Boolean | True | No | |
| pricing.price | Object | No | Price options for negotiations | |
| pricing.price.currency | String | “eur” | No | Price currency for futher negotations |
| route | Object | Yes | Route for new contract | |
| route.id | String | “3fa85f64-5717–4562-b3fc-2c963f66afa6” | Yes | Route Id |
Example Request Body for create flexible contract
{
"route": {
"id": "3a378345-1939-48c1-bc71-639e0add8048"
},
"pricing": {
"price": {
"currency": "pln"
},
"negotiable": false
},
"carrier": {
"company": {
"id": 1013865
},
"contact_persons": [
{
"employee": {
"account_id": 771476
}
}
]
},
"config": {
"send_to_carrier": true
}
}Response Fields for created flexible contract
The response contains exactly the same list of fields as the Get contract details response and the following fields are filled automatically based on the request type:
| Attribute | Type | Example | Description |
| pricing.type | String | “no_rate” | Pricing type. In the response always has value “no_rate” |
| status | String | “waiting_for_acceptance” | Contract status. In the response always has value “waiting_for_acceptance” |
Response Body for create flexible contract
{
"id": "0bd41dab-f606-4b38-ab7a-24e868a729a8",
"base_contract_id": "0bd41dab-f606-4b38-ab7a-24e868a729a8",
"type": "flexible",
"position": null,
"percentage_share": 0,
"route": {
"id": "3a378345-1939-48c1-bc71-639e0add8048",
"unique_key": "456788",
"name": "trasa2 API",
"publication_scenario": {
"type": "in_order",
"data": {
"publication_time": {
"value": 300,
"unit_code": "s",
"user_unit_code": "min"
},
"order": "next_recipient"
}
},
"spots": [
{
"id": "287b8962-bb35-4012-938c-3eed57d52596",
"name": "Początek PL 50-002 2021-08-11 13:51:15",
"type": "loading",
"place": {
"address": {
"locality": "Wrocław",
"postal_code": "50-002",
"country": "pl",
"street": "Nowa",
"number": "2",
"location_id": 2513724,
"detailed_location_id": null,
"foreign_id": null,
"radius": null
},
"coordinates": {
"latitude": 51.1,
"longitude": 17.03333
}
}
},
{
"id": "078e89c1-dcca-417f-9973-569cb87279c2",
"name": "Początek trasy",
"type": "unloading",
"place": {
"address": {
"locality": "Wrocław",
"postal_code": "53-146",
"country": "pl",
"street": "Racławicka",
"number": "2-4",
"location_id": 1185465,
"detailed_location_id": 58279582,
"foreign_id": null,
"radius": null
},
"coordinates": {
"latitude": 51.0825872,
"longitude": 17.0038841
}
}
}
],
"distance": {
"declared": null,
"calculated": {
"value": 4,
"unit_code": "km"
}
},
"suggested_calculated_route_id": "fa4c5378-0ccc-4737-90d2-efec0a1dd1a8",
"distance_match": {
"min": null,
"max": null
},
"is_roundtrip": false,
"requirements": {
"required_truck_bodies": [],
"required_adr_classes": [],
"required_ways_of_loading": [],
"additional_requirements": [],
"shipping_remarks": null,
"freight_type": null,
"vehicle_size": null,
"width": null,
"height": null,
"length": null,
"volume": null,
"capacity": {
"min": null,
"max": null
},
"exemption_from_adr": false
},
"loads": [
{
"name": null,
"type_of_load": null,
"amount": null,
"width": null,
"height": null,
"length": null,
"volume": null,
"weight": {
"min": null,
"max": null
},
"pallets": {
"is_stackable": false,
"is_exchangeable": false
}
}
],
"balancing": {
"type": "freight_limit",
"allowed_types": [
"manual",
"freight_limit",
"percentage_share"
],
"data": {
"freight_limit": {
"min": null,
"max": null
}
}
},
"status": "active",
"shipments_summary": {
"amount": 1,
"weight": {
"value": 22,
"unit_code": "t"
},
"distance": {
"value": 342,
"unit_code": "km"
},
"price": [
{
"amount": 56,
"currency": "1_eur"
}
]
},
"position": 231,
"_stats": {
"contracts": {
"fixed": 1,
"flexible": 1
},
"transports": {
"realized": {
"average_price": null,
"count": 0
},
"awaiting": {
"median_price": null,
"count": null
},
"cheapest_carrier_offer": null
}
}
},
"period": {
"from": null,
"to": null
},
"pricing": {
"type": "no_rate",
"price": {
"currency": "eur"
}
},
"status": "waiting_for_acceptance",
"carrier": {
"company": {
"id": 1013865,
"name": "Carrier IIT 2"
},
"contact_persons": [
{
"id": "011a9d31-7b53-4365-999d-e27d64df7046",
"employee": {
"id": 999446,
"account_id": 771476,
"given_name": "Jan",
"family_name": "Nowak",
"trans_id": "1013865-3",
"email": "jnowak@mail.eu",
"telephone": "(0048) 12345678"
},
"channels": [
"email",
"push",
"web-push",
"messenger"
],
"reported_by": {
"company": {
"id": 1007374
}
}
}
],
"cooperation_status": "active"
},
"shipper": {
"company": {
"id": 1007374,
"name": "Forwarder IIT"
},
"contact_persons": [
{
"id": "2a7936e1-3f6a-4654-9c72-93857bf6941d",
"employee": {
"id": 993848,
"account_id": 765361,
"given_name": "Krzysztof",
"family_name": "Kowalski",
"trans_id": "1007374-5",
"email": "kkowalski@mail.eu",
"telephone": null
},
"channels": [
"email",
"push",
"web-push",
"messenger"
],
"reported_by": {
"company": {
"id": 1007374
}
}
}
],
"cooperation_status": "active"
},
"deactivations": [],
"_stats": {
"transports": {
"realized": null,
"average_per_month": null,
"awaiting": null
},
"offers": {
"accepted": null,
"total": null,
"acceptance_rate": null
},
"base_contract": {
"registered": 0,
"waiting_for_acceptance": 1,
"waiting_for_initial_carrier_offer": 0,
"waiting_for_shipper_offer": 0,
"waiting_for_carrier_offer": 0,
"refused": 0,
"accepted": 0,
"active": 0,
"finished": 0
}
},
"_meta": {
"has_been_sent_to_carrier": true
}
}Clients errors (code 400)
HTTP 4xx status codes indicate client errors, meaning that the request could not be processed due to an issue on the client side. Below is a list of request-specific errors.
Example error 1
Invalid route id
{
"type": "http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html",
"title": "Bad Request",
"status": 400,
"detail": "Contracted route with ID: 3fa85f64-5717-4562-b3fc-2c963f66afa6 not found!",
"service_code": 5404
}Example error 2
Send_to_carrier field must be set True
{
"type": "http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html",
"title": "Unprocessable Entity",
"status": 422,
"detail": "Failed Validation",
"validation_messages": {
"config": {
"send_to_carrier": {
"equals": "send_to_carrier must be equal to true"
}
}
},
"service_code": 5404
}