---
title: List operations
description: List operations
url: /api/v0.2b/operations/listOperations
---

# List operations

`GET /operations`

````yaml
openapi: 3.1.0
info:
  title: Spoke API
  version: v0.2b
servers:
  - url: https://api.spoke.com/public/v0.2b
security:
  - BasicAuth: []
paths:
  /operations:
    get:
      operationId: listOperations
      summary: List operations
      tags:
        - Operations
      parameters:
        - schema:
            type: string
            minLength: 1
            maxLength: 255
          in: query
          name: pageToken
          required: false
          description: The page token to continue from.
        - schema:
            default: 20
            type: number
            minimum: 1
            maximum: 20
          in: query
          name: maxPageSize
          required: false
          description: The maximum number of operations to return per page.
        - schema:
            type: object
            properties:
              done:
                description: Filter by whether the operation is done.
                anyOf:
                  - type: string
                    enum:
                      - "true"
                  - type: string
                    enum:
                      - "false"
              type:
                description: The type of the operation. Use this to filter which operations to get when listing operations. If not specified, all operations are returned. If specified, only operations of the specified type are returned.
                type: string
                enum:
                  - plan_optimization
          in: query
          name: filter
          required: false
          description: The filter to apply to the list of operations.
      responses:
        "200":
          description: Success
          content:
            application/json:
              schema:
                type: object
                properties:
                  operations:
                    type: array
                    items:
                      $ref: "#/components/schemas/operationSchema"
                    description: The operations.
                  nextPageToken:
                    description: The next page token.
                    type:
                      - "null"
                      - string
                required:
                  - operations
                  - nextPageToken
                definitions:
                  operationSchema:
                    type: object
                    properties:
                      id:
                        type: string
                        pattern: ^operations\/[a-zA-Z0-9---_]{1,50}$
                        description: The id of the operation, in the format `operations/<id>`.
                      type:
                        type: string
                        enum:
                          - plan_optimization
                      done:
                        type: boolean
                        description: Whether the operation is done.
                      metadata:
                        type: object
                        properties:
                          canceled:
                            type: boolean
                            description: Whether the operation was canceled.
                          startedAt:
                            type: number
                            description: The time the operation started at, in seconds since epoch.
                          finishedAt:
                            description: The time the operation finished at, in seconds since epoch.
                            type:
                              - "null"
                              - number
                          startedBy:
                            anyOf:
                              - type: string
                                enum:
                                  - dispatcher
                              - type: string
                                enum:
                                  - api
                              - type: string
                            description: The entity that started the operation.
                          targetPlanId:
                            type: string
                            pattern: ^plans\/[a-zA-Z0-9---_]{1,50}$
                            description: The id of the plan, in the format `plans/<id>`.
                        required:
                          - canceled
                          - startedAt
                          - finishedAt
                          - startedBy
                          - targetPlanId
                        description: Metadata related to a plan optimization operation.
                      result:
                        anyOf:
                          - anyOf:
                              - type: object
                                properties:
                                  numOptimizedStops:
                                    type: number
                                    description: The number of stops that were considered for optimization.
                                  skippedStops:
                                    type: array
                                    items:
                                      type: object
                                      properties:
                                        id:
                                          type: string
                                          pattern: ^plans\/[a-zA-Z0-9---_]{1,50}\/stops\/[a-zA-Z0-9---_]{1,50}$
                                          description: The id of the stop, in the format `plans/<id>/stops/<id>`.
                                        reason:
                                          anyOf:
                                            - type: string
                                              enum:
                                                - impossible_time_window
                                            - type: string
                                              enum:
                                                - impossible_navigation
                                            - type: string
                                              enum:
                                                - impossible_number_of_stops
                                            - type: string
                                              enum:
                                                - impossible_order_of_stops
                                            - type: string
                                          description: The reason the stop was skipped.
                                      required:
                                        - id
                                        - reason
                                    description: The stops that were skipped, if any.
                                required:
                                  - numOptimizedStops
                                  - skippedStops
                              - type: object
                                properties:
                                  code:
                                    type: string
                                    description: A code that identifies the error
                                  message:
                                    type: string
                                    description: A human-readable message that describes the error. This message is not intended to be parsed by machines.
                                required:
                                  - code
                                  - message
                          - type: "null"
                        description: The result of the plan optimization operation, or an error.
                    required:
                      - id
                      - type
                      - done
                      - metadata
                      - result
                description: Success
        "400":
          description: Query parameters are invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: The error message.
                  code:
                    type: string
                    description: The error code.
                  param:
                    type: string
                    description: The parameter that caused the error.
                  url:
                    type: string
                    description: The URL with more information about the error.
                required:
                  - message
                description: Query parameters are invalid
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: The error message.
                  url:
                    type: string
                    description: The URL with more information about the error.
                required:
                  - message
                description: Unauthorized
        "500":
          description: An internal server error occurred
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: The error message.
                  code:
                    type: string
                    description: The error code.
                  param:
                    type: string
                    description: The parameter that caused the error.
                  url:
                    type: string
                    description: The URL with more information about the error.
                required:
                  - message
                description: An internal server error occurred
components:
  schemas:
    operationIdSchema:
      type: string
      pattern: ^operations\/[a-zA-Z0-9---_]{1,50}$
    operationSchema:
      type: object
      properties:
        id:
          allOf:
            - $ref: "#/components/schemas/operationIdSchema"
          description: The id of the operation, in the format `operations/<id>`.
        type:
          type: string
          enum:
            - plan_optimization
        done:
          type: boolean
          description: Whether the operation is done.
        metadata:
          type: object
          properties:
            canceled:
              type: boolean
              description: Whether the operation was canceled.
            startedAt:
              type: number
              description: The time the operation started at, in seconds since epoch.
            finishedAt:
              description: The time the operation finished at, in seconds since epoch.
              type:
                - "null"
                - number
            startedBy:
              anyOf:
                - type: string
                  enum:
                    - dispatcher
                - type: string
                  enum:
                    - api
                - type: string
              description: The entity that started the operation.
            targetPlanId:
              allOf:
                - $ref: "#/components/schemas/planIdSchema"
              description: The id of the plan, in the format `plans/<id>`.
          required:
            - canceled
            - startedAt
            - finishedAt
            - startedBy
            - targetPlanId
          description: Metadata related to a plan optimization operation.
        result:
          anyOf:
            - anyOf:
                - type: object
                  properties:
                    numOptimizedStops:
                      type: number
                      description: The number of stops that were considered for optimization.
                    skippedStops:
                      type: array
                      items:
                        type: object
                        properties:
                          id:
                            allOf:
                              - $ref: "#/components/schemas/stopIdSchema"
                            description: The id of the stop, in the format `plans/<id>/stops/<id>`.
                          reason:
                            anyOf:
                              - type: string
                                enum:
                                  - impossible_time_window
                              - type: string
                                enum:
                                  - impossible_navigation
                              - type: string
                                enum:
                                  - impossible_number_of_stops
                              - type: string
                                enum:
                                  - impossible_order_of_stops
                              - type: string
                            description: The reason the stop was skipped.
                        required:
                          - id
                          - reason
                      description: The stops that were skipped, if any.
                  required:
                    - numOptimizedStops
                    - skippedStops
                - type: object
                  properties:
                    code:
                      type: string
                      description: A code that identifies the error
                    message:
                      type: string
                      description: A human-readable message that describes the error. This message is not intended to be parsed by machines.
                  required:
                    - code
                    - message
            - type: "null"
          description: The result of the plan optimization operation, or an error.
      required:
        - id
        - type
        - done
        - metadata
        - result
    planIdSchema:
      type: string
      pattern: ^plans\/[a-zA-Z0-9---_]{1,50}$
    stopIdSchema:
      type: string
      pattern: ^plans\/[a-zA-Z0-9---_]{1,50}\/stops\/[a-zA-Z0-9---_]{1,50}$
  securitySchemes:
    BasicAuth:
      type: http
      scheme: basic
      description: Use the API key as the username and leave the password empty.
````