Create flexible contract

Cre­at­ing a new flex­i­ble con­tract in select­ed route.

After suc­cess­ful­ly exe­cut­ing the method, you receive in response the con­tract details with the unique con­tract iden­ti­fi­ca­tion num­ber id assigned when cre­at­ing the new con­tract.

POST
/ext/contracts-api/v2/contracts/flexible

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/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
AttributeTypeExam­pleManda­to­ryDescrip­tion
car­ri­erObjectYesCar­ri­er invit­ed to the get con­tract
carrier.companyObjectYesCar­ri­er com­pa­ny details
carrier.company.idInt456745YesCar­ri­er com­pa­ny Id
carrier.contact_personsArray of ObjectsNoCar­ri­er per­sons invit­ed to get con­tract
carrier.contact_persons.employeeObjectNoCon­tact per­son details
carrier.contact_persons.employee.account_idInt123321NoCon­tact per­son inter­nal Id
con­figObjectYesCon­tract con­fig­u­ra­tion
config.send_to_carrierBooleanTrueYesCre­at­ed con­tract will be auto­mat­i­cal­ly send to car­ri­er.
True val­ue is required.
pric­ingObjectNoPric­ing for con­tract
pricing.negotiableBooleanTrueNo
pricing.priceObjectNoPrice options for nego­ti­a­tions
pricing.price.currencyString“eur”NoPrice cur­ren­cy for futher nego­ta­tions
routeObjectYesRoute for new con­tract
route.idString“3fa85f64-5717–4562-b3fc-2c963f66afa6”YesRoute 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 con­tains exact­ly the same list of fields as the Get con­tract details response and the fol­low­ing fields are filled auto­mat­i­cal­ly based on the request type:

AttributeTypeExam­pleDescrip­tion
pricing.typeString“no_rate”Pric­ing type. In the response always has val­ue “no_rate”
sta­tusString“waiting_for_acceptance”Con­tract sta­tus. In the response always has val­ue “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 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

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
}