Creates a new trip.
POST /api/trips { "state": "draft", "date": "2021-05-26", "user_id": 1, "company_id": 17, "mileage_vehicle_id": 9, "currency": "EUR", "original_currency": "EUR", "description": "Test trip", "cost_center_ids": [ 691 ], "entries_attributes": [ { "number_of_people": "John Smith", "distance": "300" }, { "number_of_people": "1", "distance": "200", "waypoints_attributtes": [ { "position": 0, "address": "Amsterdam", "latitude": 52.3675734, "longitude": 4.9041389 }, { "position": 1, "address": "The Hague", "latitude": 52.0704978, "longitude": 4.3006999 } ] } ] } 201 { "id": 115, "description": "Test trip", "_id": "trip-115", "user_name": "HackH", "state": "queue", "user_id": 1, "type": "trip", "updated_at": "2021-05-26T20:28:21.257Z", "cost_center_ids": [ 691 ], "date": "2021-05-26", "approvers": [], "approved_by": [], "approved_by_ids": [], "current_approvers_ids": [], "transaction_approvers": [], "created_at": "2021-05-26T20:28:21.257Z", "company_id": 17, "paid_at": null, "taxable": 135.0, "mileage_vehicle_id": 9, "cost_center_id": 0, "user": { "id": 1, "name": "HackH", "email": "buru@hack.com", "country": { "id": 3, "name": "Sweden", "currency": "SEK", "currency_symbol": "kr" } }, "cost_centers": [ { "id": 691, "name": "Ololo CC", "dimension_name": "Cost Center", "assignee_ids": [], "deactivated": false, "external_id": "”06”", "approvers": [] } ], "comments": [], "entries": [ { "id": 118, "trip_transaction_id": 115, "distance": 300.0, "number_of_people": "John Smith", "cost_cents": 13500, "cost_currency": "EUR", "original_amount_cents": 13500, "original_amount_currency": "EUR", "route": null } ], "vehicle": { "id": 9, "name": "Autolla (0.43 EUR/km)", "country": { "id": 1, "name": "Finland", "currency": "EUR", "created_at": "2017-09-06T11:51:21.283Z", "updated_at": "2021-01-15T18:09:35.537Z", "code": "FI" }, "years": [ { "id": 18, "year": 2019, "cost_cents": "43.0", "additional_passenger_cents": "0.0" }, { "id": 28, "year": 2020, "cost_cents": "43.0", "additional_passenger_cents": "0.0" }, { "id": 30, "year": 2021, "cost_cents": "45.0", "additional_passenger_cents": "1.0" } ] }, "documents": [] }
Param name | Description |
---|---|
draft
optional |
Whether created trip should be in draft state. If the value of this param is 1, trip will be saved as draft and will not be validated; otherwise, it will be either in reviewing or queue state (depending on whether its user has approvers or not). Validations:
|
trip
required |
Trip hash Validations:
|
trip[description]
required |
Trip description Validations:
|
trip[date]
required |
Trip date, e.g. “2021-05-26” Validations:
|
trip[mileage_vehicle_id]
required |
Mileage vehicle (from user/company mileage vehicle categories) Validations:
|
trip[expense_account_id]
optional , nil allowed |
Mileage account (from user/company settings). Will be set automatically if not passed Validations:
|
trip[cost_center_ids]
optional , nil allowed |
Cost center IDs. Should be up to 1 cost center ID per dimension. All optional Validations:
|
trip[original_currency]
required |
Mileage vehicle country currency, e.g. “EUR” Validations:
|
trip[entries_attributes]
required |
Trip entries. At least one should be present Validations:
|
trip[entries_attributes][number_of_people]
required |
Either a number, e.g. “2” or a comma-separated list of passengers, e.g. “Brian Kernigan,Dennis Ritchie,Ken Thompson” Validations:
|
trip[entries_attributes][distance]
required |
Trip distance in kilometers Validations:
|
trip[entries_attributes][route]
optional , nil allowed |
An optional route description. E.g. “Helsinki-Vantaa-Helsinki” Validations:
|
trip[entries_attributes][waypoints_attributes]
optional , nil allowed |
Entry Waypoints. At least 2 are required when present Validations:
|
trip[entries_attributes][waypoints_attributes][address]
optional , nil allowed |
Address: short place name, from Google Maps. Internal use only. Validations:
|
trip[entries_attributes][waypoints_attributes][latitude]
optional , nil allowed |
Geographic Latitude from Google Maps Validations:
|
trip[entries_attributes][waypoints_attributes][longitude]
optional , nil allowed |
Geographic Longitude from Google Maps Validations:
|
trip[entries_attributes][waypoints_attributes][position]
optional , nil allowed |
Waypoint position starting from 0. E.g. case with from-to waypoints: 0 for From waypoint, 1 for To waypoint Validations:
|
trip[conditional_values_attributes]
optional , nil allowed |
Values for expense account’s conditional fields (optional) Validations:
|
trip[conditional_values_attributes][field_id]
optional , nil allowed |
ID of expense account’s conditional field Validations:
|
trip[conditional_values_attributes][field_type]
optional , nil allowed |
Field type: Validations:
|
trip[conditional_values_attributes][value]
optional , nil allowed |
Conditional field’s value Validations:
|