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

# Create Session

> Create a new agent session associated with an entity.



## OpenAPI

````yaml https://platform.tracecat.com/api/openapi.json post /workspaces/{workspace_id}/agent/sessions
openapi: 3.1.0
info:
  title: Tracecat API
  summary: Tracecat API
  description: The open source AI automation platform for security teams and agents.
  termsOfService: >-
    https://docs.google.com/document/d/e/2PACX-1vQvDe3SoVAPoQc51MgfGCP71IqFYX_rMVEde8zC4qmBCec5f8PLKQRdxa6tsUABT8gWAR9J-EVs2CrQ/pub
  contact:
    name: Tracecat Founders
    email: founders@tracecat.com
  license:
    name: AGPL-3.0
    url: https://www.gnu.org/licenses/agpl-3.0.html
  version: '1'
servers:
  - url: /api
security: []
tags:
  - name: public
    description: Public facing endpoints
  - name: workflows
    description: Workflow management
  - name: actions
    description: Action management
  - name: triggers
    description: Workflow triggers
  - name: secrets
    description: Secret management
  - name: variables
    description: Workspace variable management
paths:
  /workspaces/{workspace_id}/agent/sessions:
    post:
      tags:
        - agent-sessions
      summary: Create Session
      description: Create a new agent session associated with an entity.
      operationId: agent-sessions-create_session
      parameters:
        - name: workspace_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
            title: Workspace Id
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AgentSessionCreate'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentSessionRead'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - APIKeyCookie: []
        - ServiceAccountApiKeyBearer: []
components:
  schemas:
    AgentSessionCreate:
      properties:
        id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: Id
          description: Session ID. If not provided, service generates one.
        title:
          type: string
          maxLength: 200
          minLength: 1
          title: Title
          description: Human-readable title for the session
          default: New Chat
        created_by:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: Created By
          description: User who created this session
        entity_type:
          $ref: '#/components/schemas/AgentSessionEntity'
          description: Type of entity this session is associated with
        entity_id:
          type: string
          format: uuid
          title: Entity Id
          description: ID of the associated entity
        tools:
          anyOf:
            - items:
                type: string
              type: array
              maxItems: 50
            - type: 'null'
          title: Tools
          description: Extra tools added to this session alongside entity defaults
        mcp_integrations:
          anyOf:
            - items:
                type: string
              type: array
              maxItems: 50
            - type: 'null'
          title: Mcp Integrations
          description: MCP integration IDs attached to this session
        agent_preset_id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: Agent Preset Id
          description: Agent preset used for this session (if any)
        agent_preset_version_id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: Agent Preset Version Id
          description: >-
            Pinned preset version used for this session. If null, the session
            follows the preset's current version.
        harness_type:
          $ref: '#/components/schemas/HarnessType'
          description: Agent harness type
          default: claude_code
      type: object
      required:
        - entity_type
        - entity_id
      title: AgentSessionCreate
      description: Request schema for creating an agent session.
    AgentSessionRead:
      properties:
        id:
          type: string
          format: uuid
          title: Id
        workspace_id:
          type: string
          format: uuid
          title: Workspace Id
        title:
          type: string
          title: Title
        created_by:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: Created By
        entity_type:
          $ref: '#/components/schemas/AgentSessionEntity'
        entity_id:
          type: string
          format: uuid
          title: Entity Id
        channel_context:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Channel Context
        tools:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Tools
        mcp_integrations:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Mcp Integrations
        agent_preset_id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: Agent Preset Id
        agent_preset_version_id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: Agent Preset Version Id
        agents_binding:
          anyOf:
            - $ref: '#/components/schemas/ResolvedAgentsConfig'
            - type: 'null'
        harness_type:
          anyOf:
            - type: string
            - type: 'null'
          title: Harness Type
        last_error:
          anyOf:
            - type: string
            - type: 'null'
          title: Last Error
        last_stream_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Last Stream Id
        artifacts:
          items:
            $ref: '#/components/schemas/Artifact'
          type: array
          title: Artifacts
        parent_session_id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: Parent Session Id
        created_at:
          type: string
          format: date-time
          title: Created At
        updated_at:
          type: string
          format: date-time
          title: Updated At
      type: object
      required:
        - id
        - workspace_id
        - title
        - created_by
        - entity_type
        - entity_id
        - channel_context
        - tools
        - mcp_integrations
        - agent_preset_id
        - agent_preset_version_id
        - harness_type
        - created_at
        - updated_at
      title: AgentSessionRead
      description: Response schema for agent session.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    AgentSessionEntity:
      type: string
      enum:
        - case
        - agent_preset
        - agent_preset_builder
        - copilot
        - workflow
        - approval
        - external_channel
      title: AgentSessionEntity
      description: |-
        The type of entity associated with an agent session.

        Determines the context and behavior of the session:
        - CASE: Chat attached to a Case entity for investigation
        - AGENT_PRESET: Live chat testing a preset configuration
        - AGENT_PRESET_BUILDER: Builder chat for editing/configuring a preset
        - WORKSPACE_CHAT: Workspace-level chat assistant (wire value: copilot)
        - WORKFLOW: Workflow-initiated agent run (from action)
        - APPROVAL: Inbox approval continuation (hidden from main chat list)
        - EXTERNAL_CHANNEL: External channel session (e.g. Slack thread)
    HarnessType:
      type: string
      enum:
        - pydantic-ai
        - claude_code
      title: HarnessType
      description: Supported agent harnesses.
    ResolvedAgentsConfig:
      properties:
        enabled:
          type: boolean
          title: Enabled
          default: false
        subagents:
          items:
            $ref: '#/components/schemas/ResolvedAttachedSubagentRef'
          type: array
          title: Subagents
      additionalProperties: false
      type: object
      title: ResolvedAgentsConfig
      description: Persisted agents toggle with immutable resolved child refs.
    Artifact:
      oneOf:
        - $ref: '#/components/schemas/CaseArtifact'
        - $ref: '#/components/schemas/WorkflowArtifact'
        - $ref: '#/components/schemas/RunArtifact'
        - $ref: '#/components/schemas/TableArtifact'
        - $ref: '#/components/schemas/AgentArtifact'
        - $ref: '#/components/schemas/AlertArtifact'
        - $ref: '#/components/schemas/IntegrationArtifact'
        - $ref: '#/components/schemas/SecretArtifact'
        - $ref: '#/components/schemas/GenericArtifact'
      discriminator:
        propertyName: type
        mapping:
          agent:
            $ref: '#/components/schemas/AgentArtifact'
          alert:
            $ref: '#/components/schemas/AlertArtifact'
          case:
            $ref: '#/components/schemas/CaseArtifact'
          generic:
            $ref: '#/components/schemas/GenericArtifact'
          integration:
            $ref: '#/components/schemas/IntegrationArtifact'
          run:
            $ref: '#/components/schemas/RunArtifact'
          secret:
            $ref: '#/components/schemas/SecretArtifact'
          table:
            $ref: '#/components/schemas/TableArtifact'
          workflow:
            $ref: '#/components/schemas/WorkflowArtifact'
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    ResolvedAttachedSubagentRef:
      properties:
        preset:
          type: string
          maxLength: 160
          minLength: 1
          title: Preset
        preset_version:
          anyOf:
            - type: integer
              minimum: 1
            - type: 'null'
          title: Preset Version
        name:
          anyOf:
            - type: string
              maxLength: 80
              minLength: 1
              pattern: ^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$
            - type: 'null'
          title: Name
        description:
          anyOf:
            - type: string
              maxLength: 1000
            - type: 'null'
          title: Description
        max_turns:
          anyOf:
            - type: integer
              minimum: 1
            - type: 'null'
          title: Max Turns
        preset_id:
          type: string
          format: uuid
          title: Preset Id
        preset_version_id:
          type: string
          format: uuid
          title: Preset Version Id
      additionalProperties: false
      type: object
      required:
        - preset
        - preset_id
        - preset_version_id
      title: ResolvedAttachedSubagentRef
      description: Persisted subagent ref with immutable preset/version identifiers.
    CaseArtifact:
      properties:
        id:
          type: string
          title: Id
        title:
          type: string
          title: Title
        scope:
          anyOf:
            - $ref: '#/components/schemas/ArtifactScope'
            - type: 'null'
        type:
          type: string
          const: case
          title: Type
          default: case
        severity:
          $ref: '#/components/schemas/CaseSeverity'
        status:
          $ref: '#/components/schemas/CaseStatus'
      additionalProperties: false
      type: object
      required:
        - id
        - title
        - severity
        - status
      title: CaseArtifact
      description: Case artifact shown in artifact-capable chat surfaces.
    WorkflowArtifact:
      properties:
        id:
          type: string
          title: Id
        title:
          type: string
          title: Title
        scope:
          anyOf:
            - $ref: '#/components/schemas/ArtifactScope'
            - type: 'null'
        type:
          type: string
          const: workflow
          title: Type
          default: workflow
        color:
          type: string
          title: Color
        isPublished:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Ispublished
      additionalProperties: false
      type: object
      required:
        - id
        - title
        - color
      title: WorkflowArtifact
      description: Workflow artifact shown in artifact-capable chat surfaces.
    RunArtifact:
      properties:
        id:
          type: string
          title: Id
        title:
          type: string
          title: Title
        scope:
          anyOf:
            - $ref: '#/components/schemas/ArtifactScope'
            - type: 'null'
        type:
          type: string
          const: run
          title: Type
          default: run
        workflowId:
          type: string
          title: Workflowid
        status:
          type: string
          enum:
            - running
            - success
            - failed
            - cancelled
          title: Status
        startedAt:
          type: string
          format: date-time
          title: Startedat
      additionalProperties: false
      type: object
      required:
        - id
        - title
        - workflowId
        - status
        - startedAt
      title: RunArtifact
      description: Workflow run artifact shown in artifact-capable chat surfaces.
    TableArtifact:
      properties:
        id:
          type: string
          title: Id
        title:
          type: string
          title: Title
        scope:
          anyOf:
            - $ref: '#/components/schemas/ArtifactScope'
            - type: 'null'
        type:
          type: string
          const: table
          title: Type
          default: table
        rowCount:
          anyOf:
            - type: integer
            - type: 'null'
          title: Rowcount
      additionalProperties: false
      type: object
      required:
        - id
        - title
      title: TableArtifact
      description: Table artifact shown in artifact-capable chat surfaces.
    AgentArtifact:
      properties:
        id:
          type: string
          title: Id
        title:
          type: string
          title: Title
        scope:
          anyOf:
            - $ref: '#/components/schemas/ArtifactScope'
            - type: 'null'
        type:
          type: string
          const: agent
          title: Type
          default: agent
      additionalProperties: false
      type: object
      required:
        - id
        - title
      title: AgentArtifact
      description: Agent preset artifact shown in artifact-capable chat surfaces.
    AlertArtifact:
      properties:
        id:
          type: string
          title: Id
        title:
          type: string
          title: Title
        scope:
          anyOf:
            - $ref: '#/components/schemas/ArtifactScope'
            - type: 'null'
        type:
          type: string
          const: alert
          title: Type
          default: alert
      additionalProperties: false
      type: object
      required:
        - id
        - title
      title: AlertArtifact
      description: Alert artifact stub. Extend when alert surfaces are wired.
    IntegrationArtifact:
      properties:
        id:
          type: string
          title: Id
        title:
          type: string
          title: Title
        scope:
          anyOf:
            - $ref: '#/components/schemas/ArtifactScope'
            - type: 'null'
        type:
          type: string
          const: integration
          title: Type
          default: integration
      additionalProperties: false
      type: object
      required:
        - id
        - title
      title: IntegrationArtifact
      description: Integration artifact stub. Extend when integration surfaces are wired.
    SecretArtifact:
      properties:
        id:
          type: string
          title: Id
        title:
          type: string
          title: Title
        scope:
          anyOf:
            - $ref: '#/components/schemas/ArtifactScope'
            - type: 'null'
        type:
          type: string
          const: secret
          title: Type
          default: secret
      additionalProperties: false
      type: object
      required:
        - id
        - title
      title: SecretArtifact
      description: Secret artifact stub. Extend when secret surfaces are wired.
    GenericArtifact:
      properties:
        id:
          type: string
          title: Id
        title:
          type: string
          title: Title
        scope:
          anyOf:
            - $ref: '#/components/schemas/ArtifactScope'
            - type: 'null'
        type:
          type: string
          const: generic
          title: Type
          default: generic
        data:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Data
      additionalProperties: false
      type: object
      required:
        - id
        - title
      title: GenericArtifact
      description: Escape hatch for surfaced objects without a dedicated panel view.
    ArtifactScope:
      properties:
        agentId:
          anyOf:
            - type: string
            - type: 'null'
          title: Agentid
        agentType:
          anyOf:
            - type: string
            - type: 'null'
          title: Agenttype
        parentToolCallId:
          anyOf:
            - type: string
            - type: 'null'
          title: Parenttoolcallid
      additionalProperties: false
      type: object
      title: ArtifactScope
      description: Attribution scope for artifact data parts.
    CaseSeverity:
      type: string
      enum:
        - unknown
        - informational
        - low
        - medium
        - high
        - critical
        - fatal
        - other
      title: CaseSeverity
      description: |-
        Case severity values aligned with OCSF severity values.

        Values:
            UNKNOWN (0): The event/finding severity is unknown
            INFORMATIONAL (1): Informational message. No action required
            LOW (2): The user decides if action is needed
            MEDIUM (3): Action is required but the situation is not serious at this time
            HIGH (4): Action is required immediately
            CRITICAL (5): Action is required immediately and the scope is broad
            FATAL (6): An error occurred but it is too late to take remedial action
            OTHER (99): The event/finding severity is not mapped
    CaseStatus:
      type: string
      enum:
        - unknown
        - new
        - in_progress
        - on_hold
        - resolved
        - closed
        - other
      title: CaseStatus
      description: Case status values aligned with OCSF Incident Finding status.
  securitySchemes:
    APIKeyCookie:
      type: apiKey
      in: cookie
      name: fastapiusersauth
    ServiceAccountApiKeyBearer:
      type: http
      description: Tracecat service account API key.
      scheme: bearer

````