> ## Documentation Index
> Fetch the complete documentation index at: https://agno-v2-studio-tools-doc.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`.



## 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: 2.5.6
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`.
      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: Learning created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LearningResponse'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnauthenticatedResponse'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ForbiddenResponse'
        '409':
          description: A learning already exists for this identity. Use PATCH to update it.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ConflictResponse'
        '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:
          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:
            - 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:
            - type: object
            - type: 'null'
          title: Content
          description: The learning content payload
        metadata:
          anyOf:
            - 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.
    UnauthenticatedResponse:
      properties:
        detail:
          type: string
          title: Detail
          description: Error detail message
        error_code:
          anyOf:
            - type: string
            - type: 'null'
          title: Error Code
          description: Error code for categorization
      type: object
      required:
        - detail
      title: UnauthenticatedResponse
      example:
        detail: Unauthenticated access
        error_code: UNAUTHENTICATED
    ForbiddenResponse:
      properties:
        detail:
          type: string
          title: Detail
          description: Error detail message
        error_code:
          anyOf:
            - type: string
            - type: 'null'
          title: Error Code
          description: Error code for categorization
      type: object
      required:
        - detail
      title: ForbiddenResponse
      example:
        detail: Cannot list learnings for another user
        error_code: FORBIDDEN
    ConflictResponse:
      properties:
        detail:
          type: string
          title: Detail
          description: Error detail message
        error_code:
          anyOf:
            - type: string
            - type: 'null'
          title: Error Code
          description: Error code for categorization
      type: object
      required:
        - detail
      title: ConflictResponse
      example:
        detail: >-
          A 'user_profile' learning already exists for this identity. Use PATCH
          to update it.
        error_code: CONFLICT
    ValidationErrorResponse:
      properties:
        detail:
          type: string
          title: Detail
          description: Error detail message
        error_code:
          anyOf:
            - type: string
            - type: 'null'
          title: Error Code
          description: Error code for categorization
      type: object
      required:
        - detail
      title: ValidationErrorResponse
      example:
        detail: Validation error
        error_code: VALIDATION_ERROR
    InternalServerErrorResponse:
      properties:
        detail:
          type: string
          title: Detail
          description: Error detail message
        error_code:
          anyOf:
            - type: string
            - type: 'null'
          title: Error Code
          description: Error code for categorization
      type: object
      required:
        - detail
      title: InternalServerErrorResponse
      example:
        detail: Internal server error
        error_code: INTERNAL_SERVER_ERROR
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````