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

# Update context

> Update an existing context. Re-indexes in vector store if content changes.



## OpenAPI

````yaml /openapi-docs.yaml put /contexts/{context_id}
openapi: 3.1.0
info:
  title: Nia AI API
  version: 1.1.0
  description: >-
    Nia AI API provides a single, consistent `sources` resource for all indexed
    content.


    ## Core Resources


    **Sources** (`/sources`)

    - `repository`

    - `documentation`

    - `research_paper`

    - `huggingface_dataset`

    - `local_folder`


    **Search** (`/search`)

    - `mode`: query | web | deep | universal


    Legacy endpoints are deprecated and will be removed in a future version.
    Prefer `/sources` and `/search` for new integrations.
servers:
  - url: https://apigcp.trynia.ai/v2
    description: Production API
  - url: http://localhost:8000/v2
    description: Local development
security:
  - ApiKeyAuth: []
tags:
  - name: Auth
    description: API-first signup, login, and API key bootstrapping
  - name: Sources
    description: >-
      Unified source management (repositories, documentation, papers, datasets,
      local folders)
  - name: Search
    description: Unified search endpoint with mode discriminator
  - name: Context Sharing
    description: Cross-agent context management and retrieval
  - name: Categories
    description: Category management for organizing indexed sources
  - name: GitHub Search
    description: Live GitHub search and repository exploration
  - name: Advisor
    description: Context-aware code advisor against indexed documentation
  - name: Dependencies
    description: Dependency analysis and documentation subscription
  - name: Usage
    description: Usage tracking and bulk operations
paths:
  /contexts/{context_id}:
    put:
      tags:
        - Context Sharing
      summary: Update context
      description: >-
        Update an existing context. Re-indexes in vector store if content
        changes.
      operationId: update_context_v2_v2_contexts__context_id__put
      parameters:
        - name: context_id
          in: path
          required: true
          schema:
            type: string
            title: Context Id
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ContextShareUpdateRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContextShareResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    ContextShareUpdateRequest:
      properties:
        title:
          anyOf:
            - type: string
              maxLength: 200
              minLength: 1
            - type: 'null'
          title: Title
        summary:
          anyOf:
            - type: string
              maxLength: 1000
              minLength: 10
            - type: 'null'
          title: Summary
        content:
          anyOf:
            - type: string
              minLength: 50
            - type: 'null'
          title: Content
        tags:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Tags
        metadata:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Metadata
        nia_references:
          anyOf:
            - $ref: '#/components/schemas/routes__v2__contexts__NiaReferences-Input'
            - type: 'null'
        edited_files:
          anyOf:
            - items:
                $ref: '#/components/schemas/routes__v2__contexts__EditedFile'
              type: array
            - type: 'null'
          title: Edited Files
        organization_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Organization Id
        memory_type:
          anyOf:
            - type: string
              enum:
                - scratchpad
                - episodic
                - fact
                - procedural
            - type: 'null'
          title: Memory Type
          description: Memory type
        ttl_seconds:
          anyOf:
            - type: integer
              minimum: 0
            - type: 'null'
          title: Ttl Seconds
          description: Custom TTL in seconds
        lineage:
          anyOf:
            - $ref: '#/components/schemas/LineageInput'
            - type: 'null'
          description: Provenance tracking
      type: object
      title: ContextShareUpdateRequest
      description: Request model for updating a shared context.
    ContextShareResponse:
      properties:
        id:
          type: string
          title: Id
        user_id:
          type: string
          title: User Id
        organization_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Organization Id
        title:
          type: string
          title: Title
        summary:
          type: string
          title: Summary
        content:
          type: string
          title: Content
        tags:
          items:
            type: string
          type: array
          title: Tags
        agent_source:
          type: string
          title: Agent Source
        created_at:
          type: string
          format: date-time
          title: Created At
        updated_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Updated At
        metadata:
          additionalProperties: true
          type: object
          title: Metadata
        nia_references:
          anyOf:
            - $ref: '#/components/schemas/NiaReferences-Output'
            - type: 'null'
        edited_files:
          items:
            $ref: '#/components/schemas/EditedFile-Output'
          type: array
          title: Edited Files
        memory_type:
          type: string
          enum:
            - scratchpad
            - episodic
            - fact
            - procedural
          title: Memory Type
          default: episodic
        expires_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Expires At
        lineage:
          anyOf:
            - $ref: '#/components/schemas/LineageMetadata'
            - type: 'null'
        category_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Category Id
      type: object
      required:
        - id
        - user_id
        - title
        - summary
        - content
        - tags
        - agent_source
        - created_at
        - metadata
      title: ContextShareResponse
      description: Response model for context operations.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    routes__v2__contexts__NiaReferences-Input:
      properties:
        indexed_resources:
          items:
            $ref: '#/components/schemas/routes__v2__contexts__IndexedResource'
          type: array
          title: Indexed Resources
        search_queries:
          items:
            $ref: '#/components/schemas/routes__v2__contexts__SearchQuery'
          type: array
          title: Search Queries
        session_summary:
          anyOf:
            - type: string
            - type: 'null'
          title: Session Summary
      type: object
      title: NiaReferences
      description: Structured tracking of NIA resources used during conversation.
    routes__v2__contexts__EditedFile:
      properties:
        file_path:
          type: string
          title: File Path
          description: Path to the file
        operation:
          type: string
          title: Operation
          description: 'Type: ''created'', ''modified'', ''deleted'''
        changes_description:
          type: string
          title: Changes Description
          description: Brief description of changes
        key_changes:
          items:
            type: string
          type: array
          title: Key Changes
        language:
          anyOf:
            - type: string
            - type: 'null'
          title: Language
          description: Programming language of the file
      type: object
      required:
        - file_path
        - operation
        - changes_description
      title: EditedFile
      description: Represents a file that was modified during the conversation.
    LineageInput:
      properties:
        source_ids:
          items:
            type: string
          type: array
          title: Source Ids
          description: Source identifiers (e.g., 'repo:owner/repo', 'doc:name')
        confidence:
          anyOf:
            - type: number
              maximum: 1
              minimum: 0
            - type: 'null'
          title: Confidence
          description: Confidence score 0-1
        derived_from:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Derived From
          description: Parent context IDs if derived
        tool_calls:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Tool Calls
          description: Tools used to create this artifact
        model_version:
          anyOf:
            - type: string
            - type: 'null'
          title: Model Version
          description: Model version that created this
      type: object
      title: LineageInput
      description: Input model for lineage tracking.
    NiaReferences-Output:
      properties:
        indexed_resources:
          items:
            $ref: '#/components/schemas/IndexedResource-Output'
          type: array
          title: Indexed Resources
        search_queries:
          items:
            $ref: '#/components/schemas/SearchQuery-Output'
          type: array
          title: Search Queries
        session_summary:
          anyOf:
            - type: string
            - type: 'null'
          title: Session Summary
      type: object
      title: NiaReferences
      description: Structured tracking of NIA resources used during conversation.
    EditedFile-Output:
      properties:
        file_path:
          type: string
          title: File Path
          description: Path to the file
        operation:
          type: string
          title: Operation
          description: 'Type: ''created'', ''modified'', ''deleted'''
        changes_description:
          type: string
          title: Changes Description
          description: Brief description of changes
        key_changes:
          items:
            type: string
          type: array
          title: Key Changes
        language:
          anyOf:
            - type: string
            - type: 'null'
          title: Language
          description: Programming language of the file
      type: object
      required:
        - file_path
        - operation
        - changes_description
      title: EditedFile
      description: Represents a file that was modified during the conversation.
    LineageMetadata:
      properties:
        created_at:
          type: string
          format: date-time
          title: Created At
          description: When this artifact was created
        source_ids:
          items:
            type: string
          type: array
          title: Source Ids
          description: Source identifiers (e.g., 'repo:owner/repo', 'doc:name')
        confidence:
          anyOf:
            - type: number
            - type: 'null'
          title: Confidence
          description: Confidence score 0-1
        derived_from:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Derived From
          description: Parent context IDs if derived
        tool_calls:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Tool Calls
          description: Tools used to create this artifact
        model_version:
          anyOf:
            - type: string
            - type: 'null'
          title: Model Version
          description: Model version that created this
      type: object
      required:
        - created_at
      title: LineageMetadata
      description: Provenance tracking for content artifacts.
    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
    routes__v2__contexts__IndexedResource:
      properties:
        identifier:
          type: string
          title: Identifier
          description: Repository (owner/repo) or documentation URL/ID
        resource_type:
          type: string
          title: Resource Type
          description: 'Type: ''repository'' or ''documentation'''
        purpose:
          type: string
          title: Purpose
          description: Why this resource was used/referenced
        indexed_at:
          anyOf:
            - type: string
            - type: 'null'
          title: Indexed At
          description: When it was indexed
      type: object
      required:
        - identifier
        - resource_type
        - purpose
      title: IndexedResource
      description: Represents a NIA resource (repository or documentation) with context.
    routes__v2__contexts__SearchQuery:
      properties:
        query:
          type: string
          title: Query
          description: The search query that was performed
        query_type:
          type: string
          title: Query Type
          description: 'Type: ''codebase'', ''documentation'', etc.'
        resources_searched:
          items:
            type: string
          type: array
          title: Resources Searched
        key_findings:
          type: string
          title: Key Findings
          description: Brief summary of what was found
        useful_results_count:
          type: integer
          title: Useful Results Count
          default: 0
      type: object
      required:
        - query
        - query_type
        - key_findings
      title: SearchQuery
      description: Represents a search query performed during the conversation.
    IndexedResource-Output:
      properties:
        identifier:
          type: string
          title: Identifier
          description: Repository (owner/repo) or documentation URL/ID
        resource_type:
          type: string
          title: Resource Type
          description: 'Type: ''repository'' or ''documentation'''
        purpose:
          type: string
          title: Purpose
          description: Why this resource was used/referenced
        indexed_at:
          anyOf:
            - type: string
            - type: 'null'
          title: Indexed At
          description: When it was indexed
      type: object
      required:
        - identifier
        - resource_type
        - purpose
      title: IndexedResource
      description: Represents a NIA resource (repository or documentation) with context.
    SearchQuery-Output:
      properties:
        query:
          type: string
          title: Query
          description: The search query that was performed
        query_type:
          type: string
          title: Query Type
          description: 'Type: ''codebase'', ''documentation'', etc.'
        resources_searched:
          items:
            type: string
          type: array
          title: Resources Searched
        key_findings:
          type: string
          title: Key Findings
          description: Brief summary of what was found
        useful_results_count:
          type: integer
          title: Useful Results Count
          default: 0
      type: object
      required:
        - query
        - query_type
        - key_findings
      title: SearchQuery
      description: Represents a search query performed during the conversation.
  securitySchemes:
    ApiKeyAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: API key must be provided in the Authorization header

````