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

# Read working memory

> The state of one scope and agent: version 0 and an empty body before the first write. A writer reads its own version or a newer one.



## OpenAPI

````yaml openapi/en/cell.json POST /v1/agent-state/read
openapi: 3.1.0
info:
  title: Niadra data API
  version: '1'
  description: >-
    Writing, context, history, objects, identity, privacy and governance of one
    space. Every space has a stable address, with the space and the region in
    its name.
servers:
  - url: https://{space}.{region}.api.niadra.com
    variables:
      space:
        default: acme-prod
        description: The space, which comes in the source key.
      region:
        default: us-east-2
        description: The region of the space, which also comes in the key.
security: []
paths:
  /v1/agent-state/read:
    post:
      tags:
        - state
      summary: Read working memory
      description: >-
        The working state of one scope and agent: version 0 and an empty body
        when it was never written.


        **Authentication.** Source key: `Authorization: Bearer nia_sk_...`.
        Required scope: `agent_state`. It answers only in a space with the
        `agent_state` feature on (the `features` document); in a space without
        it, 404.
      operationId: read_agent_state_v1_agent_state_read_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AgentStateReadRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentState'
          description: Successful Response
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
          description: The request does not match the contract.
      security:
        - sourceKey: []
      x-codeSamples:
        - lang: python
          label: Python
          source: >-
            state = conversation.agent_state.get()  # version 0 and an empty
            body before the first write

            step = state.body.get("step")
        - lang: typescript
          label: TypeScript
          source: >-
            const state = await convo.agentState.get(); // version 0 and an
            empty body before the first write

            const step = state.body.step;
components:
  schemas:
    AgentStateReadRequest:
      additionalProperties: false
      properties:
        agent:
          maxLength: 256
          minLength: 1
          title: Agent
          type: string
        scope:
          $ref: '#/components/schemas/AgentStateScope'
      required:
        - scope
        - agent
      title: AgentStateReadRequest
      type: object
    AgentState:
      additionalProperties: false
      properties:
        body:
          additionalProperties: true
          title: Body
          type: object
        updated_at:
          anyOf:
            - format: date-time
              type: string
            - type: 'null'
          title: Updated At
        version:
          title: Version
          type: integer
      required:
        - version
      title: AgentState
      type: object
    Problem:
      additionalProperties: false
      description: RFC 9457 problem details; `code` comes from the versioned error catalog.
      properties:
        code:
          title: Code
          type: string
        detail:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          title: Detail
        request_id:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          title: Request Id
        status:
          title: Status
          type: integer
        title:
          title: Title
          type: string
        type:
          default: about:blank
          title: Type
          type: string
      required:
        - title
        - status
        - code
      title: Problem
      type: object
    AgentStateScope:
      additionalProperties: false
      description: >-
        What one working state belongs to. The id travels in the body, never in
        a URL: a conversation id may

        look like a phone number.
      properties:
        id:
          maxLength: 512
          minLength: 1
          title: Id
          type: string
        kind:
          enum:
            - conversation
            - task
            - object
            - subject
          title: Kind
          type: string
      required:
        - kind
        - id
      title: AgentStateScope
      type: object
  securitySchemes:
    sourceKey:
      type: http
      scheme: bearer
      description: nia_sk_...

````