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

# Add context items

> Add or update datasources, artifacts, and/or attachments on a session. Upserts by (type, resource_uri). Returns the full updated context. 403 if not owned, 404 if not found.



## OpenAPI

````yaml /openapi/em-talk2data-v2.yaml post /talk2data/chat/sessions/{session_id}/context
openapi: 3.1.0
info:
  title: Talk to Data Service
  version: 3.2.0-dev1
servers: []
security: []
paths:
  /talk2data/chat/sessions/{session_id}/context:
    post:
      tags:
        - chat-sessions
      summary: Add context items
      description: >-
        Add or update datasources, artifacts, and/or attachments on a session.
        Upserts by (type, resource_uri). Returns the full updated context. 403
        if not owned, 404 if not found.
      operationId: add_session_context_talk2data_chat_sessions__session_id__context_post
      parameters:
        - name: session_id
          in: path
          required: true
          schema:
            type: string
            description: Session ID
            title: Session Id
          description: Session ID
        - name: x-project-id
          in: header
          required: true
          schema:
            type: string
            description: Project identifier
            title: X-Project-Id
          description: Project identifier
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AddSessionContextRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SessionContextResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    AddSessionContextRequest:
      properties:
        datasources:
          items:
            $ref: '#/components/schemas/DatasourceContext-Input'
          type: array
          maxItems: 20
          title: Datasources
        artifacts:
          items:
            $ref: '#/components/schemas/ArtifactContext'
          type: array
          maxItems: 50
          title: Artifacts
        attachments:
          items:
            $ref: '#/components/schemas/AttachmentContext'
          type: array
          maxItems: 20
          title: Attachments
      type: object
      title: AddSessionContextRequest
      description: Add one or more context items to a session (POST .../context).
    SessionContextResponse:
      properties:
        datasources:
          items:
            $ref: '#/components/schemas/DatasourceContext-Output'
          type: array
          title: Datasources
        artifacts:
          items:
            $ref: '#/components/schemas/ArtifactContext'
          type: array
          title: Artifacts
        attachments:
          items:
            $ref: '#/components/schemas/AttachmentContext'
          type: array
          title: Attachments
      type: object
      title: SessionContextResponse
      description: Current session context (GET/POST/DELETE .../context).
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    DatasourceContext-Input:
      properties:
        type:
          type: string
          const: datasource
          title: Type
          default: datasource
        resource_uri:
          type: string
          maxLength: 512
          title: Resource Uri
        datasource_type:
          type: string
          title: Datasource Type
          default: database
        datasource_name:
          type: string
          maxLength: 255
          title: Datasource Name
        datasource_description:
          anyOf:
            - type: string
              maxLength: 1000
            - type: 'null'
          title: Datasource Description
        created_at:
          anyOf:
            - type: string
            - type: 'null'
          title: Created At
        selected_schemas:
          anyOf:
            - items:
                $ref: '#/components/schemas/DatasourceSelectedSchema'
              type: array
            - type: 'null'
          title: Selected Schemas
      type: object
      required:
        - resource_uri
        - datasource_name
      title: DatasourceContext
      description: Selected datasource for the message context.
    ArtifactContext:
      properties:
        resource_uri:
          type: string
          maxLength: 255
          title: Resource Uri
        artifact_type:
          type: string
          title: Artifact Type
        artifact_title:
          anyOf:
            - type: string
            - type: 'null'
          title: Artifact Title
        created_at:
          anyOf:
            - type: string
            - type: 'null'
          title: Created At
      type: object
      required:
        - resource_uri
        - artifact_type
      title: ArtifactContext
      description: Referenced artifact for follow-up questions.
    AttachmentContext:
      properties:
        resource_uri:
          type: string
          maxLength: 255
          title: Resource Uri
        filename:
          type: string
          title: Filename
        content_type:
          type: string
          title: Content Type
      type: object
      required:
        - resource_uri
        - filename
        - content_type
      title: AttachmentContext
      description: Uploaded file reference from assets registry.
    DatasourceContext-Output:
      properties:
        type:
          type: string
          const: datasource
          title: Type
          default: datasource
        resource_uri:
          type: string
          maxLength: 512
          title: Resource Uri
        datasource_type:
          type: string
          title: Datasource Type
          default: database
        datasource_name:
          type: string
          maxLength: 255
          title: Datasource Name
        datasource_description:
          anyOf:
            - type: string
              maxLength: 1000
            - type: 'null'
          title: Datasource Description
        created_at:
          anyOf:
            - type: string
            - type: 'null'
          title: Created At
        selected_schemas:
          anyOf:
            - items:
                $ref: '#/components/schemas/DatasourceSelectedSchema'
              type: array
            - type: 'null'
          title: Selected Schemas
      type: object
      required:
        - resource_uri
        - datasource_name
      title: DatasourceContext
      description: Selected datasource for the message context.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    DatasourceSelectedSchema:
      properties:
        schema_name:
          type: string
          title: Schema Name
        schema_fqn:
          anyOf:
            - type: string
            - type: 'null'
          title: Schema Fqn
        selected_tables:
          anyOf:
            - items:
                $ref: '#/components/schemas/DatasourceSelectedTable'
              type: array
            - type: 'null'
          title: Selected Tables
      type: object
      required:
        - schema_name
      title: DatasourceSelectedSchema
      description: A schema the user scoped, with optional table list.
    DatasourceSelectedTable:
      properties:
        table_name:
          type: string
          title: Table Name
        table_fqn:
          anyOf:
            - type: string
            - type: 'null'
          title: Table Fqn
      type: object
      required:
        - table_name
      title: DatasourceSelectedTable
      description: A table the user scoped within a schema.
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````