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

# Create a session

> Create a session for an existing named agent.



## OpenAPI

````yaml /gateway-agent-harness-openapi.json post /v1/agents/sessions
openapi: 3.1.0
info:
  title: TrueFoundry Agent Harness
  description: Stateful agent execution API.
  version: 0.1.0
servers:
  - url: '{scheme}://{gatewayBaseURL}/{tenantName}'
    variables:
      scheme:
        default: https
        enum:
          - http
          - https
      gatewayBaseURL:
        default: gateway.truefoundry.ai
        description: Gateway host. Override for self-hosted deployments.
      tenantName:
        default: truefoundry
        description: Tenant identifier
    description: Gateway base URL (per-tenant)
security:
  - AuthorizationBearer: []
paths:
  /v1/agents/sessions:
    post:
      tags:
        - Agent Harness
      summary: Create a session
      description: Create a session for an existing named agent.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateSessionRequest'
      responses:
        '201':
          description: Session created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GetSessionResponse'
        '400':
          description: Unsupported caller subject type.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RequestErrorResponse'
        '401':
          description: Missing or invalid authentication token.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RequestErrorResponse'
        '403':
          description: Caller is not authorized to create sessions for this agent.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RequestErrorResponse'
        '404':
          description: Agent not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RequestErrorResponse'
        '409':
          description: Session id already exists.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RequestErrorResponse'
        '422':
          description: Invalid request body.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RequestErrorResponse'
components:
  schemas:
    CreateSessionRequest:
      type: object
      properties:
        agent_name:
          type: string
          minLength: 1
          maxLength: 255
          description: Name of an existing agent in the tenant.
      required:
        - agent_name
    GetSessionResponse:
      type: object
      properties:
        data:
          $ref: '#/components/schemas/Session'
      required:
        - data
    RequestErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
            type:
              type: string
            code:
              type:
                - string
                - 'null'
            param:
              type:
                - string
                - 'null'
          required:
            - message
      required:
        - error
    Session:
      type: object
      properties:
        id:
          type: string
        agent_name:
          type: string
        title:
          type:
            - string
            - 'null'
        created_by_subject:
          $ref: '#/components/schemas/Subject'
        created_at:
          type: string
        updated_at:
          type: string
      required:
        - id
        - agent_name
        - title
        - created_by_subject
        - created_at
        - updated_at
    Subject:
      type: object
      properties:
        subject_id:
          type: string
        subject_type:
          type: string
        subject_slug:
          type:
            - string
            - 'null'
      required:
        - subject_id
        - subject_type
  securitySchemes:
    AuthorizationBearer:
      type: http
      scheme: bearer
      bearerFormat: JWT

````