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

# Get Context by ID

> This endpoint retrieves all tasks and top-level messages associated with a specific context for the given agent.




## OpenAPI

````yaml /agentic/auto-generated-openapi.yml get /agents/{id}/v1/contexts/{contextId}
openapi: 3.1.1
info:
  title: Corti Agent API
  version: 0.1.0
  description: >
    The Corti Agent API allows users to interact with the Corti Agent, enabling
    the creation and management of threads, sending messages, and receiving
    responses.
servers: []
security: []
paths:
  /agents/{id}/v1/contexts/{contextId}:
    get:
      tags:
        - Agents
      summary: Get Context by ID
      description: >
        This endpoint retrieves all tasks and top-level messages associated with
        a specific context for the given agent.
      operationId: agents_get_context
      parameters:
        - $ref: '#/components/parameters/Tenant-Name'
        - $ref: '#/components/parameters/AgentID'
        - name: contextId
          in: path
          required: true
          description: The identifier of the context (thread) to retrieve tasks for.
          schema:
            type: string
        - name: limit
          in: query
          required: false
          description: >
            The maximum number of tasks and messages to return. If not specified
            all history is returned.
          schema:
            type: integer
            default: 100
        - name: offset
          in: query
          required: false
          description: >
            The number of tasks and messages to skip before starting to collect
            the result set. Default is 0.
          schema:
            type: integer
      responses:
        '200':
          description: Tasks retrieved successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentsContext'
        '400':
          description: >
            The request could not be processed, possibly due to missing required
            fields or invalid data.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentsErrorResponse'
        '401':
          description: |
            Authentication is required to access this endpoint.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentsErrorResponse'
        '404':
          description: Agent or context not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentsErrorResponse'
      x-codeSamples:
        - lang: csharp
          label: C# .NET SDK
          source: |
            using Corti;

            var client = new CortiClient(
                "TENANT_NAME",
                CortiClientEnvironment.Eu,
                new CortiClientAuth.ClientCredentials("client_id", "client_secret")
            );
            await client.Agents.GetContextAsync(
                "12345678-90ab-cdef-gh12-34567890abc",
                "contextId",
                new AgentsGetContextRequest()
            );
        - lang: javascript
          label: JavaScript SDK
          source: >
            import { CortiClient, CortiEnvironment } from "@corti/sdk";


            const client = new CortiClient({
                environment: CortiEnvironment.Eu,
                auth: {
                    clientId: "YOUR_CLIENT_ID",
                    clientSecret: "YOUR_CLIENT_SECRET"
                },
                tenantName: "YOUR_TENANT_NAME"
            });

            await
            client.agents.getContext("12345678-90ab-cdef-gh12-34567890abc",
            "contextId");
components:
  parameters:
    Tenant-Name:
      name: Tenant-Name
      in: header
      description: >-
        Identifies a distinct entity within Corti's multi-tenant system. Ensures
        correct routing and authentication of the request.
      required: true
      example: base
      schema:
        type: string
        description: >-
          Identifies a distinct entity within Corti's multi-tenant system.
          Ensures correct routing and authentication of the request.
        example: base
    AgentID:
      name: id
      in: path
      required: true
      description: The identifier of the agent associated with the context.
      schema:
        type: string
        description: The identifier of the agent associated with the context.
        example: 12345678-90ab-cdef-gh12-34567890abc
  schemas:
    AgentsContext:
      type: object
      properties:
        id:
          type: string
          description: The context ID.
        items:
          type: array
          items:
            oneOf:
              - $ref: '#/components/schemas/AgentsTask'
              - $ref: '#/components/schemas/AgentsMessage'
    AgentsErrorResponse:
      type: object
      required:
        - code
        - description
      properties:
        code:
          type: string
          description: |
            A machine-readable error code that identifies the type of error.
        description:
          type: string
          description: >
            A human-readable description of the error, providing more context
            about what went wrong.
        howToFix:
          type: string
          description: |
            A human-readable message describing how to fix the issue.
        details:
          type: object
          description: |
            An optional object containing additional details about the error.
          additionalProperties: true
        cause:
          type: object
          description: >
            An optional object containing the cause of the error, following the
            same structure as the parent error response.
          additionalProperties: true
    AgentsTask:
      type: object
      required:
        - id
        - status
        - contextId
        - kind
      properties:
        id:
          type: string
          description: Unique identifier for the task.
        contextId:
          type: string
          description: |
            Identifier for the context (thread) in which the task is created.
        status:
          $ref: '#/components/schemas/AgentsTaskStatus'
        history:
          type: array
          items:
            $ref: '#/components/schemas/AgentsMessage'
          description: The history of messages associated with the task.
        artifacts:
          type: array
          items:
            $ref: '#/components/schemas/AgentsArtifact'
          description: The artifacts associated with the task.
        metadata:
          type: object
          description: Additional metadata for the task.
        kind:
          type: string
          description: The kind of the object, always "task".
          enum:
            - task
    AgentsMessage:
      type: object
      required:
        - messageId
        - role
        - parts
        - kind
      properties:
        role:
          type: string
          description: The role of the message sender.
          enum:
            - user
            - agent
        parts:
          type: array
          items:
            $ref: '#/components/schemas/AgentsPart'
          description: The content of the message.
        metadata:
          type: object
          description: Additional metadata for the message.
        extensions:
          type: array
          items:
            type: string
          description: Extensions for the message.
        referenceTaskIds:
          type: array
          items:
            type: string
          description: Task IDs that this message references for additional context.
        messageId:
          type: string
          description: Unique identifier for the message.
        taskId:
          type: string
          description: Unique identifier for the task associated with the message.
        contextId:
          type: string
          description: Identifier for the context (thread) in which the message is sent.
        kind:
          type: string
          description: The kind of the object, always "message".
          enum:
            - message
    AgentsTaskStatus:
      type: object
      required:
        - state
      properties:
        state:
          type: string
          description: The current state of the task.
          enum:
            - submitted
            - working
            - input-required
            - completed
            - canceled
            - failed
            - rejected
            - auth-required
            - unknown
        message:
          $ref: '#/components/schemas/AgentsMessage'
          type: object
          description: Additional message or details about the task status.
        timestamp:
          type: string
          format: date-time
          description: The timestamp when this status was recorded.
    AgentsArtifact:
      type: object
      required:
        - artifactId
        - parts
      properties:
        artifactId:
          type: string
          description: Unique identifier for the artifact.
        name:
          type: string
          description: Name of the artifact.
        description:
          type: string
          description: Description of the artifact.
        parts:
          type: array
          items:
            $ref: '#/components/schemas/AgentsPart'
          description: The content of the artifact.
        metadata:
          type: object
          description: Additional metadata for the artifact.
        extensions:
          type: array
          items:
            type: string
          description: Extensions for the artifact.
    AgentsPart:
      type: object
      oneOf:
        - $ref: '#/components/schemas/AgentsTextPart'
        - $ref: '#/components/schemas/AgentsFilePart'
        - $ref: '#/components/schemas/AgentsDataPart'
    AgentsTextPart:
      type: object
      required:
        - kind
        - text
      properties:
        kind:
          type: string
          description: The kind of the part, always "text".
          enum:
            - text
        text:
          type: string
          description: The text content of the part.
        metadata:
          type: object
          description: Additional metadata for the text part.
    AgentsFilePart:
      type: object
      required:
        - kind
      properties:
        kind:
          type: string
          description: The kind of the part, always "file".
          enum:
            - file
        file:
          type: object
          oneOf:
            - $ref: '#/components/schemas/AgentsFileWithUri'
            - $ref: '#/components/schemas/AgentsFileWithBytes'
        metadata:
          type: object
          description: Additional metadata for the file part.
    AgentsDataPart:
      type: object
      required:
        - kind
        - data
      properties:
        kind:
          type: string
          description: The kind of the part, always "data".
          enum:
            - data
        data:
          type: object
          description: JSON data payload.
        metadata:
          type: object
          description: Additional metadata for the data part.
    AgentsFileWithUri:
      type: object
      required:
        - uri
      properties:
        uri:
          type: string
          format: uri
          description: The URI of the file.
        name:
          type: string
          description: The name of the file.
        mimeType:
          type: string
          description: The MIME type of the file.
    AgentsFileWithBytes:
      type: object
      required:
        - bytes
      properties:
        bytes:
          type: string
          format: byte
          description: The byte content of the file.
        name:
          type: string
          description: The name of the file.
        mimeType:
          type: string
          description: The MIME type of the file.

````