---
title: Retrieve an operation
description: Retrieve an operation
url: /api/v0.2b/operations/getOperation
---

# Retrieve an operation

`GET /operations/{operationId}`

````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/{operationId}:
    get:
      operationId: getOperation
      summary: Retrieve an operation
      tags:
        - Operations
      parameters:
        - schema:
            type: string
            pattern: ^[a-zA-Z0-9---_]{1,50}$
          in: path
          name: operationId
          required: true
          description: The ID of the operation to cancel.
      responses:
        "200":
          description: The requested operation
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/operationSchema"
                description: The requested operation
        "400":
          description: ID format is 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: ID format is invalid
                title: The request is 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
        "404":
          description: Not Found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    enum:
                      - The operation was not found.
                  code:
                    type: string
                    enum:
                      - operation_not_found
                required:
                  - message
                  - code
                description: Not Found
        "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.
````