curl --request POST \
--url https://api.exowpee.com/v1/catalog/trips/{trip}/legs \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"from_stop_id": "<string>",
"from_stop_position": 2,
"to_stop_id": "<string>",
"to_stop_position": 2,
"distance_km": "<string>",
"rates": "<string>"
}
'import requests
url = "https://api.exowpee.com/v1/catalog/trips/{trip}/legs"
payload = {
"from_stop_id": "<string>",
"from_stop_position": 2,
"to_stop_id": "<string>",
"to_stop_position": 2,
"distance_km": "<string>",
"rates": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
from_stop_id: '<string>',
from_stop_position: 2,
to_stop_id: '<string>',
to_stop_position: 2,
distance_km: '<string>',
rates: '<string>'
})
};
fetch('https://api.exowpee.com/v1/catalog/trips/{trip}/legs', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.exowpee.com/v1/catalog/trips/{trip}/legs",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'from_stop_id' => '<string>',
'from_stop_position' => 2,
'to_stop_id' => '<string>',
'to_stop_position' => 2,
'distance_km' => '<string>',
'rates' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.exowpee.com/v1/catalog/trips/{trip}/legs"
payload := strings.NewReader("{\n \"from_stop_id\": \"<string>\",\n \"from_stop_position\": 2,\n \"to_stop_id\": \"<string>\",\n \"to_stop_position\": 2,\n \"distance_km\": \"<string>\",\n \"rates\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.exowpee.com/v1/catalog/trips/{trip}/legs")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"from_stop_id\": \"<string>\",\n \"from_stop_position\": 2,\n \"to_stop_id\": \"<string>\",\n \"to_stop_position\": 2,\n \"distance_km\": \"<string>\",\n \"rates\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.exowpee.com/v1/catalog/trips/{trip}/legs")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"from_stop_id\": \"<string>\",\n \"from_stop_position\": 2,\n \"to_stop_id\": \"<string>\",\n \"to_stop_position\": 2,\n \"distance_km\": \"<string>\",\n \"rates\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"trip_id": "<string>",
"from_stop_id": "<string>",
"to_stop_id": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"rates": [
{
"id": "<string>",
"trip_id": "<string>",
"trip_leg_id": "<string>",
"label": "<string>",
"amount": 123,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
}
]
}{
"message": "<string>",
"errors": {}
}Add a leg to a trip
Connects two existing stops of a trip with a leg, so goods can travel between them.
curl --request POST \
--url https://api.exowpee.com/v1/catalog/trips/{trip}/legs \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"from_stop_id": "<string>",
"from_stop_position": 2,
"to_stop_id": "<string>",
"to_stop_position": 2,
"distance_km": "<string>",
"rates": "<string>"
}
'import requests
url = "https://api.exowpee.com/v1/catalog/trips/{trip}/legs"
payload = {
"from_stop_id": "<string>",
"from_stop_position": 2,
"to_stop_id": "<string>",
"to_stop_position": 2,
"distance_km": "<string>",
"rates": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
from_stop_id: '<string>',
from_stop_position: 2,
to_stop_id: '<string>',
to_stop_position: 2,
distance_km: '<string>',
rates: '<string>'
})
};
fetch('https://api.exowpee.com/v1/catalog/trips/{trip}/legs', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.exowpee.com/v1/catalog/trips/{trip}/legs",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'from_stop_id' => '<string>',
'from_stop_position' => 2,
'to_stop_id' => '<string>',
'to_stop_position' => 2,
'distance_km' => '<string>',
'rates' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.exowpee.com/v1/catalog/trips/{trip}/legs"
payload := strings.NewReader("{\n \"from_stop_id\": \"<string>\",\n \"from_stop_position\": 2,\n \"to_stop_id\": \"<string>\",\n \"to_stop_position\": 2,\n \"distance_km\": \"<string>\",\n \"rates\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.exowpee.com/v1/catalog/trips/{trip}/legs")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"from_stop_id\": \"<string>\",\n \"from_stop_position\": 2,\n \"to_stop_id\": \"<string>\",\n \"to_stop_position\": 2,\n \"distance_km\": \"<string>\",\n \"rates\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.exowpee.com/v1/catalog/trips/{trip}/legs")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"from_stop_id\": \"<string>\",\n \"from_stop_position\": 2,\n \"to_stop_id\": \"<string>\",\n \"to_stop_position\": 2,\n \"distance_km\": \"<string>\",\n \"rates\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"trip_id": "<string>",
"from_stop_id": "<string>",
"to_stop_id": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"rates": [
{
"id": "<string>",
"trip_id": "<string>",
"trip_leg_id": "<string>",
"label": "<string>",
"amount": 123,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
}
]
}{
"message": "<string>",
"errors": {}
}trip_legs.create
Conditions
- Only the company that owns the trip can change it; a trip shared by another company can be read but not modified.
- Only a trip whose status is active can be modified; an archived trip is refused with a validation error.
- Each of from and to must be identified by stop id or by stop position inside the trip.
- The destination stop must come after the source stop by position.
- A leg between the same two stops cannot exist twice (409).
- distance_km and rates are refused.
- Creates the leg between the two stops; rates of the leg are added through the rates endpoint.
Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
Identifier of the trip (27-character KSUID). The trip must be visible to the calling company.
Body
Identifier of the stop where the leg starts. Alternative to from_stop_position; the id wins when both are sent. Must be a stop of this trip.
27Position of the stop where the leg starts, used when from_stop_id is not sent. Minimum 1.
x >= 1Identifier of the stop where the leg ends; it must come after the source on the route. Alternative to to_stop_position; the id wins when both are sent.
27Position of the stop where the leg ends, used when to_stop_id is not sent. Minimum 1.
x >= 1Not accepted: legs carry no distance; any value is refused.
Not accepted on this endpoint: add rates to a leg through the rates endpoint with trip_leg_id.
Response
TripLegResource
Identifier of the leg (27-character KSUID).
Identifier of the trip the leg belongs to.
Identifier of the stop where the leg starts.
Identifier of the stop where the leg ends.
Date and time the record was created (ISO 8601, UTC).
Date and time the record was last changed (ISO 8601, UTC).
Rates of this leg owned by the calling company; present only when the relation is loaded (trip responses, not leg create or update).
Show child attributes
Show child attributes