POST
Add a leg to a trip
Company space For: Stock keeper, Manager · Permission: 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.
What else happens
  • Creates the leg between the two stops; rates of the leg are added through the rates endpoint.
Part of Reusable trips and waypoints.

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

trip
string
required

Identifier of the trip (27-character KSUID). The trip must be visible to the calling company.

Body

application/json
from_stop_id
string | null

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.

Required string length: 27
from_stop_position
integer | null

Position of the stop where the leg starts, used when from_stop_id is not sent. Minimum 1.

Required range: x >= 1
to_stop_id
string | null

Identifier 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.

Required string length: 27
to_stop_position
integer | null

Position of the stop where the leg ends, used when to_stop_id is not sent. Minimum 1.

Required range: x >= 1
distance_km
string

Not accepted: legs carry no distance; any value is refused.

rates
string

Not accepted on this endpoint: add rates to a leg through the rates endpoint with trip_leg_id.

Response

TripLegResource

id
string
required

Identifier of the leg (27-character KSUID).

trip_id
string
required

Identifier of the trip the leg belongs to.

from_stop_id
string
required

Identifier of the stop where the leg starts.

to_stop_id
string
required

Identifier of the stop where the leg ends.

created_at
string<date-time>
required

Date and time the record was created (ISO 8601, UTC).

updated_at
string<date-time>
required

Date and time the record was last changed (ISO 8601, UTC).

rates
TripRateResource · object[]

Rates of this leg owned by the calling company; present only when the relation is loaded (trip responses, not leg create or update).