> ## Documentation Index
> Fetch the complete documentation index at: https://developers.kardinal.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Fetch the latest state of a plan



## OpenAPI

````yaml /openapi.yaml get /agencies/{agencyId}/plans/{planId}/state
openapi: 3.0.3
info:
  title: Kardinal ARO API
  version: 2.55.0
  description: This document specifies the REST API of Kardinal ARO v2.
  contact:
    url: https://kardinal.ai/
    email: contact@kardinal.ai
servers:
  - url: /api/v2
security:
  - access_token: []
tags:
  - name: Authenticate
    description: How to authenticate, and manage the access and refresh tokens.
  - name: Plan
    description: How to create, retrieve, update and delete plans.
  - name: Resource
    description: How to create, retrieve, update and delete resources in a plan.
  - name: Order
    description: How to create, retrieve, update and delete orders in a plan.
  - name: SimplePlan
    description: How to create a plan through the use of a simple plan.
paths:
  /agencies/{agencyId}/plans/{planId}/state:
    parameters:
      - $ref: '#/components/parameters/agencyId'
      - $ref: '#/components/parameters/planId'
    get:
      tags:
        - Management
        - Plan
      summary: Fetch the latest state of a plan
      operationId: fetchLastPlanState
      responses:
        '200':
          description: Latest plan state.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EnvelopedTimedPlanState'
        '401':
          $ref: '#/components/responses/NotAuthenticated'
        '403':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
        '500':
          $ref: '#/components/responses/InternalServerError'
components:
  parameters:
    agencyId:
      name: agencyId
      description: The agency id.
      in: path
      required: true
      schema:
        $ref: '#/components/schemas/AgencyId'
    planId:
      name: planId
      description: The plan id.
      in: path
      required: true
      schema:
        $ref: '#/components/schemas/RegexIdValidation'
  schemas:
    EnvelopedTimedPlanState:
      type: object
      properties:
        item:
          $ref: '#/components/schemas/TimedPlanState'
        agencyId:
          $ref: '#/components/schemas/AgencyId'
        planId:
          $ref: '#/components/schemas/PlanId'
      description: '[TO_VALIDATE] Description pending review by a Kardinal engineer.'
    AgencyId:
      description: The agency id.
      readOnly: true
      example: LND_Agency-42
      allOf:
        - $ref: '#/components/schemas/RegexPrefixedIdValidation'
    RegexIdValidation:
      type: string
      description: >-
        At least one character among those allowed: unaccented alpha-numeric
        characters, "-", ".", "_", "~", ":", "@", "!", "$", ",".
      pattern: ^[a-zA-Z0-9-._~:@!$,]+$
    TimedPlanState:
      type: object
      readOnly: true
      properties:
        planVersion:
          description: The corresponding plan's version.
          type: number
          example: 2
        timestamp:
          $ref: '#/components/schemas/DateTime'
        state:
          $ref: '#/components/schemas/PlanState'
      description: '[TO_VALIDATE] Description pending review by a Kardinal engineer.'
    PlanId:
      description: The plan id.
      readOnly: true
      example: plan-AB
      allOf:
        - $ref: '#/components/schemas/RegexIdValidation'
    EnvelopedErrors:
      type: object
      properties:
        errors:
          type: array
          items:
            $ref: '#/components/schemas/Error'
      description: '[TO_VALIDATE] Description pending review by a Kardinal engineer.'
    RegexPrefixedIdValidation:
      type: string
      description: An id beginning with a prefix and an underscore.
      pattern: ^[A-Z]{3,6}_[a-zA-Z0-9-._~:@!$,]+$
    DateTime:
      type: string
      description: >-
        A full calendar date time, expressed in the ISO8601 **date** format:
        YYYY-MM-DDThh:mm:ssZ.
      example: '2019-11-15T12:34:56Z'
    PlanState:
      type: string
      readOnly: true
      description: |
        The corresponding plan's state.
          - waiting: The plan was received and is awaiting processing.
          - processing: The plan is being processed.
          - preOptimizing: The plan is being optimized while awaiting traffic or other information.
          - preOptimized: While still awaiting traffic or other information, one of the following events has occurred:
              no better solution can be produced, or the optimization period has reached its limit.
              Note that 'preOptimized' should be followed by 'optimizing' and 'optimized'.
          - optimizing: The plan is being optimized with all required information.
          - optimized: This state can be triggered by one of the following events:
              no better solution can be produced, or the optimization period has reached its limit.
          - stopped: The plan's awaiting optimizations were canceled.
          - deleted: The plan was deleted and awaiting optimizations were canceled.
          - interrupted: The plan was either updated, stopped or deleted during its optimization.
      enum:
        - waiting
        - processing
        - preOptimizing
        - preOptimized
        - optimizing
        - optimized
        - stopped
        - deleted
        - interrupted
    Error:
      type: object
      readOnly: true
      properties:
        code:
          type: string
          description: '[TO_VALIDATE] Description pending review by a Kardinal engineer.'
        message:
          type: string
          description: '[TO_VALIDATE] Description pending review by a Kardinal engineer.'
        properties:
          $ref: '#/components/schemas/ErrorProperties'
      required:
        - message
        - code
      description: '[TO_VALIDATE] Description pending review by a Kardinal engineer.'
    ErrorProperties:
      type: object
      additionalProperties:
        type: string
      description: '[TO_VALIDATE] Description pending review by a Kardinal engineer.'
  responses:
    NotAuthenticated:
      description: The caller is not authenticated.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/EnvelopedErrors'
    Unauthorized:
      description: The caller is not authorized to perform this action.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/EnvelopedErrors'
    NotFound:
      description: The specified resource was not found.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/EnvelopedErrors'
    InternalServerError:
      description: An internal server error has occurred.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/EnvelopedErrors'
  securitySchemes:
    access_token:
      type: http
      scheme: bearer
      bearerFormat: JWT

````