> ## 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.

# Agent memory block

> The agent's working notes as one block for the prompt, after the instructions and before the customer's context, with an ETag.



## OpenAPI

````yaml openapi/en/cell.json GET /v1/agent-memory/block
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-memory/block:
    get:
      tags:
        - agent-memory
      summary: Agent memory block
      description: >-
        The notes this agent may read, as text for its prompt: after its
        instructions, before the customer's

        context. A key gets its own; a person previews an agent's with
        `source_id`.


        **Authentication.** Source key with the `agent_memory` or `context`
        scope, or a Console person token with the `integration` role (or admin).
      operationId: block_v1_agent_memory_block_get
      parameters:
        - in: query
          name: max_tokens
          required: false
          schema:
            default: 300
            maximum: 2000
            minimum: 50
            title: Max Tokens
            type: integer
          description: Token budget of the block, 50 to 2,000; 300 by default.
        - in: query
          name: tags
          required: false
          schema:
            anyOf:
              - items:
                  pattern: ^[a-z0-9][a-z0-9_.:-]{0,63}$
                  type: string
                maxItems: 8
                type: array
              - type: 'null'
            title: Tags
          description: Notes with these tags come first. Up to 8.
        - in: query
          name: view
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: View
          description: >-
            The view or task the agent works in, so notes tagged for it come
            first.
        - in: query
          name: source_id
          required: false
          schema:
            anyOf:
              - format: uuid
                type: string
              - type: 'null'
            title: Source Id
          description: 'People only: the agent whose block to preview.'
        - in: header
          name: if-none-match
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: If-None-Match
          description: The `etag` you already hold. Unchanged, the answer is 304.
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentMemoryBlock'
          description: The block, with the `ETag` in the header.
        '304':
          description: The block behind `If-None-Match` is still current.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
          description: The request does not match the contract.
      security:
        - sourceKey: []
        - personToken: []
      x-codeSamples:
        - lang: python
          label: Python
          source: >-
            # After your instructions, before the customer's context; cached and
            revalidated by ETag

            notes = niadra.agent_memory(max_tokens=300, tags=["scheduling"])

            system_prompt = "\n\n".join(part for part in (AGENT_INSTRUCTIONS,
            notes.text, ctx.system_block) if part)
        - lang: typescript
          label: TypeScript
          source: >-
            // After your instructions, before the customer's context; cached
            and revalidated by ETag

            const notes = await niadra.agentMemory({ max_tokens: 300, tags:
            ["scheduling"] });

            const system = [AGENT_INSTRUCTIONS, notes.text,
            ctx.text].filter(Boolean).join("\n\n");
components:
  schemas:
    AgentMemoryBlock:
      additionalProperties: false
      description: >-
        The block that goes into the prompt after the agent's instructions and
        before the customer's

        context: stable between customers, so it stays in the cacheable prefix.
      properties:
        enabled:
          default: true
          description: False when the space has agent memory turned off.
          title: Enabled
          type: boolean
        etag:
          title: Etag
          type: string
        notes:
          description: The notes the text carries, in order.
          items:
            format: uuid
            type: string
          title: Notes
          type: array
        text:
          description: Empty when there is nothing to show or agent memory is off.
          title: Text
          type: string
        tokens:
          default: 0
          title: Tokens
          type: integer
      required:
        - text
        - etag
      title: AgentMemoryBlock
      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
  securitySchemes:
    sourceKey:
      type: http
      scheme: bearer
      description: nia_sk_...
    personToken:
      type: http
      scheme: bearer
      bearerFormat: JWT

````