---
title: "[beta] Create a route template for a specific hub"
method: POST
path: "/hub/route-templates"
tags: ["Beta APIs"]
---

# \[beta\] Create a route template for a specific hub

`POST /hub/route-templates`

## Request

- Base URL: `https://api.samsara.com`
- URL: `https://api.samsara.com/hub/route-templates`
- Auth: HTTP bearer

Create a new route template for a hub.

 <b>Rate limit:</b> 5 requests/sec (learn more about rate limits <a href="https://developers.samsara.com/docs/rate-limits" target="_blank">here</a>).

To use this endpoint, select **Write Routes** under the Driver Workflow category when creating or editing an API token. <a href="https://developers.samsara.com/docs/authentication#scopes-for-api-tokens" target="_blank">Learn More.</a>
 

 **Submit Feedback**: Likes, dislikes, and API feature requests should be filed as feedback in our <a href="https://forms.gle/zkD4NCH7HjKb7mm69" target="_blank">API feedback form</a>. If you encountered an issue or noticed inaccuracies in the API documentation, please <a href="https://www.samsara.com/help" target="_blank">submit a case</a> to our support team.

## Request body

- HubRouteTemplatesCreateHubRouteTemplateRequestBody: Request body for creating a hub route template.
  - `defaultDepotEnd` CreateHubRouteTemplateDepotEndInputRequestBody: The default end depot for routes created from this template.
    - `externalId` string: External ID of the depot location.
  - `defaultDepotStart` CreateHubRouteTemplateDepotStartInputRequestBody: The default start depot for routes created from this template.
    - `externalId` string: External ID of the depot location.
  - `defaultStartTimeOfDay` string: Default start time in HH:MM format in the hub's local timezone (e.g. '08:00').
  - `hubId` string, required: The ID of the hub.
  - `locationExternalIds` string[]: Stop locations referenced by external ID, in the order they should be visited.
  - `name` string, required: The name of the route template.

## Response `200`

OK response.

- HubRouteTemplatesCreateHubRouteTemplateResponseBody
  - `data` HubRouteTemplateObjectResponseBody, required: A route template for a hub.
    - `createdAtTime` string, date-time, required: The timestamp when the route template was created, in RFC 3339 format.
    - `defaultDepotEnd` HubRouteTemplateDepotObjectResponseBody: A depot location for a route template.
      - `externalId` string: The customer-provided external identifier for the depot location.
      - `formattedAddress` string, required: The formatted address of the depot location.
      - `id` string, required: The unique identifier for the depot location.
      - `latitude` number, double, required: Latitude coordinate of the depot location.
      - `longitude` number, double, required: Longitude coordinate of the depot location.
      - `name` string, required: The name of the depot location.
    - `defaultDepotStart` HubRouteTemplateDepotObjectResponseBody: A depot location for a route template.
      - `externalId` string: The customer-provided external identifier for the depot location.
      - `formattedAddress` string, required: The formatted address of the depot location.
      - `id` string, required: The unique identifier for the depot location.
      - `latitude` number, double, required: Latitude coordinate of the depot location.
      - `longitude` number, double, required: Longitude coordinate of the depot location.
      - `name` string, required: The name of the depot location.
    - `defaultStartTimeOfDay` string: Default start time of day for the route template, in HH:MM format in the hub's local timezone (e.g. '08:00').
    - `distanceMeters` integer, required: Total distance of the route in meters.
    - `durationSeconds` integer, required: Total duration of the route in seconds.
    - `hubId` string, required: The hub identifier this route template belongs to.
    - `hubTimezone` string, required: The IANA timezone of the hub (e.g. 'America/Los_Angeles').
    - `id` string, required: The unique identifier for the route template.
    - `locations` HubRouteTemplateLocationObjectResponseBody[], required: Ordered list of stop locations in the route template.
      - `externalId` string: The customer-provided identifier for the location.
      - `formattedAddress` string, required: The formatted address of the location.
      - `latitude` number, double, required: Latitude coordinate of the location.
      - `longitude` number, double, required: Longitude coordinate of the location.
      - `name` string, required: The name of the location.
      - `position` integer, required: The 1-based position of this stop in the route template.
    - `name` string, required: The name of the route template.
    - `updatedAtTime` string, date-time, required: The timestamp when the route template was last updated, in RFC 3339 format.

## Other responses

- `401`: Unauthorized response.
- `404`: Not Found response.
- `405`: Method Not Allowed response.
- `413`: Content Too Large response.
- `429`: Too Many Requests response.
- `500`: Internal Server Error response.
- `501`: Not Implemented response.
- `502`: Bad Gateway response.
- `503`: Service Unavailable response.
- `504`: Gateway Timeout response.
- `default`: Bad Request response.

---

[API](https://skmtc.dev/samsara/apis/samsara-api.md) - [All operations](https://skmtc.dev/samsara/apis/samsara-api/llms.txt) - [OpenAPI document](https://skmtc.dev/samsara/apis/samsara-api/revisions/a9e35d4999be?raw)
