> ## Documentation Index
> Fetch the complete documentation index at: https://stage-docs.getswitch.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Assign Drivers to Route

> Assign one or more drivers to a route. Each must be an active user of your company or its child companies; if one fails, none is assigned.

**Failure Modes:**
- **401**: Token is missing or invalid
- **403**: Insufficient permissions, you cannot manage the route's company, or a driver is outside your company tree
- **404**: No route with this ID, or a driver does not exist
- **409**: A driver is already assigned to this route
- **422**: Invalid request body

**Required Auth Scopes:**
- `routing-operations:manage`



## OpenAPI

````yaml /api-reference/openapi.json post /operations/routes/{route_id}/drivers
openapi: 3.1.0
info:
  title: SWITCH API
  version: '1.0'
  description: >-
    The SWITCH API gives mobility and logistics teams programmatic access to
    SWITCH forecasts, fleet operations, routing and analytics. Every request is
    authenticated with an API key sent as a bearer token.
servers:
  - url: https://stage-api.getswitch.io
    description: Stage
security: []
tags:
  - name: Forecast
    description: Demand forecasts per zone and time window.
  - name: Operations
    description: Fleet imbalance, rebalancing suggestions and generated tasks.
  - name: Routing
    description: Route optimisation for single and multiple fleets.
  - name: Routing Sessions
    description: Saved routing sessions, their routes and drivers.
  - name: Routing Operations
    description: Complete, undo and re-route the stops of a route.
  - name: Fleet Management
    description: Your depots, stations, drivers and cargo vehicles.
  - name: Integrations
    description: Vehicles, statuses and commands on your fleet platform.
  - name: Station Based Analytics
    description: Analytics for station-based (docked) services.
  - name: Zone Based Analytics
    description: Analytics for free-floating services, by zone.
  - name: Free Float Analytics
    description: Trip history for free-floating services.
  - name: Transit Analytics
    description: Punctuality and service delivery for public transit.
  - name: Live
    description: Real-time fleet, delivery and transit status.
  - name: Grids
    description: Spatial grids used by forecasts and analytics.
  - name: API Keys
    description: Create and manage the API keys you call this API with.
paths:
  /operations/routes/{route_id}/drivers:
    post:
      tags:
        - Routing Sessions
      summary: Assign Drivers to Route
      description: >-
        Assign one or more drivers to a route. Each must be an active user of
        your company or its child companies; if one fails, none is assigned.


        **Failure Modes:**

        - **401**: Token is missing or invalid

        - **403**: Insufficient permissions, you cannot manage the route's
        company, or a driver is outside your company tree

        - **404**: No route with this ID, or a driver does not exist

        - **409**: A driver is already assigned to this route

        - **422**: Invalid request body


        **Required Auth Scopes:**

        - `routing-operations:manage`
      operationId: assign_route_drivers
      parameters:
        - name: route_id
          in: path
          required: true
          schema:
            type: integer
            description: Route ID, from the session detail or the route list.
            title: Route Id
          description: Route ID, from the session detail or the route list.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DriverAssignRequest'
      responses:
        '201':
          description: Drivers assigned. Returns the assignment records.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/DriverAssignmentPublic'
                title: Response Assign Route Drivers
              example:
                - id: 880
                  route_id: 412
                  driver_id: 57
                  created_at: '2026-11-30T07:58:11Z'
                - id: 881
                  route_id: 412
                  driver_id: 63
                  created_at: '2026-11-30T07:58:11Z'
        '401':
          description: Unauthorized. Token is missing or invalid.
        '403':
          description: Forbidden. Insufficient permissions.
        '404':
          description: Not Found. Route or driver not found.
        '409':
          description: Conflict. Driver already assigned.
        '422':
          description: Unprocessable Entity. Validation failed.
        '500':
          description: Internal Server Error.
      security:
        - HTTPBearer: []
        - HTTPBearer: []
components:
  schemas:
    DriverAssignRequest:
      properties:
        driver_ids:
          items:
            type: integer
          type: array
          minItems: 1
          title: Driver Ids
          description: User IDs of the drivers to assign (`user_id` of a driver).
      type: object
      required:
        - driver_ids
      title: DriverAssignRequest
      description: Request body to assign one or more drivers to a route.
      examples:
        - driver_ids:
            - 57
            - 63
    DriverAssignmentPublic:
      properties:
        id:
          type: integer
          title: Id
          description: ID of the assignment.
        route_id:
          type: integer
          title: Route Id
          description: Route ID.
        driver_id:
          type: integer
          title: Driver Id
          description: User ID of the driver.
        created_at:
          type: string
          format: date-time
          title: Created At
          description: When the driver was assigned.
      type: object
      required:
        - id
        - route_id
        - driver_id
        - created_at
      title: DriverAssignmentPublic
      description: Response for a driver assignment operation.
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer
      description: >-
        An API key, sent as `Authorization: Bearer <key>`. Create one in the
        SWITCH Copilot under **Settings → API keys** (needs the API keys
        permission in your company), or with `POST /auth/api-keys`. The key is
        shown once, at creation.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.