> ## Documentation Index
> Fetch the complete documentation index at: https://agno-v2.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Learning

> Create a new learning record. For the identity-keyed learning types (`user_profile`, `user_memory`, `session_context`, `entity_memory`) the record id is derived deterministically from the identity fields so it reconciles with what the agent reads/writes — provide those fields (else 422), and if a record already exists the request is rejected with 409 (use PATCH to update it). Other types get a generated id. For a scoped (non-admin) caller, the body's `user_id` must be omitted/null or match the caller (mismatch → 403); admins and unscoped callers may set any `user_id`. An `entity_memory` record whose body omits `namespace` is stored under the `global` default; the endpoint cannot see how a given store is configured, so a caller writing for a store running with `namespace="user"` or a custom namespace must pass `namespace` explicitly or the record will not be visible to it.



## OpenAPI

````yaml post /learnings
openapi: 3.1.0
info:
  title: Agno API Reference
  description: The all-in-one, private, secure agent platform that runs in your cloud.
  version: 3.0.4
servers: []
security: []
paths:
  /learnings:
    post:
      tags:
        - Learnings
      summary: Create Learning
      description: >-
        Create a new learning record. For the identity-keyed learning types
        (`user_profile`, `user_memory`, `session_context`, `entity_memory`) the
        record id is derived deterministically from the identity fields so it
        reconciles with what the agent reads/writes — provide those fields (else
        422), and if a record already exists the request is rejected with 409
        (use PATCH to update it). Other types get a generated id. For a scoped
        (non-admin) caller, the body's `user_id` must be omitted/null or match
        the caller (mismatch → 403); admins and unscoped callers may set any
        `user_id`. An `entity_memory` record whose body omits `namespace` is
        stored under the `global` default; the endpoint cannot see how a given
        store is configured, so a caller writing for a store running with
        `namespace="user"` or a custom namespace must pass `namespace`
        explicitly or the record will not be visible to it.
      operationId: create_learning
      parameters:
        - name: db_id
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: Database ID to use
            title: Db Id
          description: Database ID to use
        - name: table
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: The database table to use (requires db_id)
            title: Table
          description: The database table to use (requires db_id)
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LearningCreate'
      responses:
        '201':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LearningResponse'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BadRequestResponse'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnauthenticatedResponse'
        '403':
          description: 'Insufficient permissions. Required scope(s): learnings:write'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NotFoundResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationErrorResponse'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InternalServerErrorResponse'
      security:
        - {}
        - HTTPBearer: []
components:
  schemas:
    LearningCreate:
      properties:
        learning_type:
          type: string
          title: Learning Type
          description: Type of learning (e.g. 'user_profile', 'entity_memory')
        content:
          additionalProperties: true
          type: object
          title: Content
          description: The learning content payload
        namespace:
          anyOf:
            - type: string
            - type: 'null'
          title: Namespace
          description: Namespace for scoping ('user', 'global', or custom)
        user_id:
          anyOf:
            - type: string
            - type: 'null'
          title: User Id
          description: >-
            Associated user ID. When the request is authenticated, must match
            the JWT subject or be omitted/null (which creates a global /
            non-user-scoped record).
        agent_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Agent Id
          description: Associated agent ID
        team_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Team Id
          description: Associated team ID
        session_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Session Id
          description: Associated session ID
        entity_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Entity Id
          description: Associated entity ID
        entity_type:
          anyOf:
            - type: string
            - type: 'null'
          title: Entity Type
          description: Entity type
        metadata:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Metadata
          description: Optional metadata
      type: object
      required:
        - learning_type
        - content
      title: LearningCreate
      description: Request body for creating a learning record.
    LearningResponse:
      properties:
        learning_id:
          type: string
          title: Learning Id
          description: Unique identifier for the learning record
        learning_type:
          type: string
          title: Learning Type
          description: Type of learning (e.g. 'user_profile', 'entity_memory')
        namespace:
          anyOf:
            - type: string
            - type: 'null'
          title: Namespace
          description: Namespace for scoping ('user', 'global', or custom)
        user_id:
          anyOf:
            - type: string
            - type: 'null'
          title: User Id
          description: Associated user ID
        agent_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Agent Id
          description: Associated agent ID
        team_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Team Id
          description: Associated team ID
        session_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Session Id
          description: Associated session ID
        entity_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Entity Id
          description: Associated entity ID (for entity-specific learnings)
        entity_type:
          anyOf:
            - type: string
            - type: 'null'
          title: Entity Type
          description: Entity type (e.g. 'person', 'company')
        content:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Content
          description: The learning content payload
        metadata:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Metadata
          description: Optional metadata
        created_at:
          anyOf:
            - type: integer
            - type: 'null'
          title: Created At
          description: Creation timestamp (Unix epoch seconds)
        updated_at:
          anyOf:
            - type: integer
            - type: 'null'
          title: Updated At
          description: Last update timestamp (Unix epoch seconds)
      type: object
      required:
        - learning_id
        - learning_type
      title: LearningResponse
      description: A single learning record as returned by the API.
    BadRequestResponse:
      properties:
        detail:
          type: string
          title: Detail
          description: Human-readable error message
        error_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Error Id
          description: >-
            Stable identifier for the specific error, present only when the
            error carries one
        error_type:
          anyOf:
            - type: string
            - type: 'null'
          title: Error Type
          description: Category of the error, present only when the error carries one
      type: object
      required:
        - detail
      title: BadRequestResponse
      example:
        detail: Bad request
    UnauthenticatedResponse:
      properties:
        detail:
          type: string
          title: Detail
          description: Human-readable error message
        error_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Error Id
          description: >-
            Stable identifier for the specific error, present only when the
            error carries one
        error_type:
          anyOf:
            - type: string
            - type: 'null'
          title: Error Type
          description: Category of the error, present only when the error carries one
      type: object
      required:
        - detail
      title: UnauthenticatedResponse
      example:
        detail: Unauthenticated access
    NotFoundResponse:
      properties:
        detail:
          type: string
          title: Detail
          description: Human-readable error message
        error_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Error Id
          description: >-
            Stable identifier for the specific error, present only when the
            error carries one
        error_type:
          anyOf:
            - type: string
            - type: 'null'
          title: Error Type
          description: Category of the error, present only when the error carries one
      type: object
      required:
        - detail
      title: NotFoundResponse
      example:
        detail: Not found
    ValidationErrorResponse:
      properties:
        detail:
          anyOf:
            - type: string
            - items:
                $ref: '#/components/schemas/ValidationErrorDetail'
              type: array
          title: Detail
          description: >-
            A single message for an explicitly raised 422, or a list of
            field-level errors for a request-validation failure
      type: object
      required:
        - detail
      title: ValidationErrorResponse
      description: >-
        422 body. Two runtime shapes share this status code, and the same
        endpoint can

        return either, so ``detail`` is typed as their union:


        - FastAPI's request-validation handler emits a **list** of field-level
        errors (built-in
          coercion errors and custom-validator ``ValueError``s alike).
        - A route that raises ``HTTPException(status_code=422, detail="...")``
        for a semantic
          check (e.g. an invalid cron expression) emits a **string** through the HTTPException
          handler.
      example:
        detail:
          - loc:
              - body
              - endpoint
            msg: Value error, Endpoint must be a path, not a full URL
            type: value_error
    InternalServerErrorResponse:
      properties:
        detail:
          type: string
          title: Detail
          description: Human-readable error message
        error_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Error Id
          description: >-
            Stable identifier for the specific error, present only when the
            error carries one
        error_type:
          anyOf:
            - type: string
            - type: 'null'
          title: Error Type
          description: Category of the error, present only when the error carries one
      type: object
      required:
        - detail
      title: InternalServerErrorResponse
      example:
        detail: Internal server error
    ValidationErrorDetail:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Loc
          description: Path to the offending field, e.g. ['body', 'endpoint']
        msg:
          type: string
          title: Msg
          description: Human-readable error message
        type:
          type: string
          title: Type
          description: Error type identifier, e.g. 'value_error' or 'missing'
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationErrorDetail
      description: >-
        One field-level error inside a 422 body, matching FastAPI's default
        shape.
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.