Create Trip
Creating a Rider/Operator Trip
This endpoint creates a new trip, associating it with a contract and setting the initial leg. The status of the leg in the request will be set to Assigned if it has been assigned a cargo trip and an operator trip.
📚 Full API Documentation: For all endpoints, see https://api.opteverything.com/docs
Prerequisites​
- You have created legs (see Creating Legs Guide)
- You have your authentication token
Step 1: Create a Trip​
Endpoint​
POST /trip/trips
Description​
Create a trip after all legs are planned. Only one of the following should be provided:
contract_id
(for a CargoTrip), orride_contract_id
andoperator_contract_id
(for an OperatorTrip).
Required Information​
Name | Type | Required | Description | Default |
---|---|---|---|---|
contract_id | string | No | The contract ID | — |
ride_contract_id | string | No | The ride contract ID | — |
operator_contract_id | string | No | The operator contract ID | — |
current_leg_id | integer | No | The current leg ID | — |
Example Request​
curl -X POST "https://api.opteverything.com/trip/trips" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <YOUR_TOKEN>" \
-d '{
"contract_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"ride_contract_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"operator_contract_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"current_leg_id": 0
}'
Responses​
Success (201 Created)​
Status Code: 201 Created
{
"trip_id": 0,
"owner_id": 0,
"contract_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"ride_contract_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"operator_contract_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"current_leg_id": 0
}
Field | Type | Description |
---|---|---|
trip_id | integer | Unique identifier for the newly created trip |
owner_id | integer | ID of the user who owns the trip |
contract_id | string | The contract ID |
ride_contract_id | string | The ride contract ID |
operator_contract_id | string | The operator contract ID |
current_leg_id | integer | The current leg ID |
Error (400 Bad Request)​
Status Code: 400 Bad Request
{
"success": false,
"error_code": "INVALID_LEG_IDS",
"message": "One or more leg IDs are invalid"
}
Field | Type | Description |
---|---|---|
success | boolean | Always false on error |
error_code | string | Machine-readable error identifier |
message | string | Human-readable error explanation |
Next Steps​
Continue to the next guide: User Event Creation
Or see the full API documentation.