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

# agent.sessions.create({ cwd?, systemPrompt?, metadata? })



## OpenAPI

````yaml /api-reference/openapi.json post /agents/{id}/sessions
openapi: 3.1.0
info:
  title: paddock API
  version: 1.0.0
  description: >-
    The paddock API. Send an API key, or a session token on its own session, as
    a bearer token.
servers:
  - url: https://api.paddock.build/v1
security:
  - bearer: []
paths:
  /agents/{id}/sessions:
    post:
      summary: agent.sessions.create({ cwd?, systemPrompt?, metadata? })
      operationId: createSession
      parameters:
        - $ref: '#/components/parameters/AgentId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateSessionRequest'
      responses:
        '201':
          description: Created
          headers:
            Request-Id:
              $ref: '#/components/headers/RequestId'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Session'
        default:
          $ref: '#/components/responses/Error'
components:
  parameters:
    AgentId:
      name: id
      in: path
      required: true
      description: The agent's ID
      schema:
        type: string
        pattern: ^agt_[0-7][0-9a-hjkmnp-tv-z]{25}$
  schemas:
    CreateSessionRequest:
      type: object
      additionalProperties: false
      properties:
        cwd:
          type: string
        systemPrompt:
          type: string
        metadata:
          $ref: '#/components/schemas/Metadata'
    Session:
      description: The session's projection of its events; status is computed when served.
      type: object
      required:
        - id
        - agentId
        - cwd
        - systemPrompt
        - status
        - lastSeq
        - lastUserSeq
        - processedSeq
        - heldSeq
        - lastError
        - retryAt
        - lastEventAt
        - observedGeneration
        - metadata
        - createdAt
      properties:
        id:
          type: string
          pattern: ^ses_[0-7][0-9a-hjkmnp-tv-z]{25}$
        agentId:
          type: string
          pattern: ^agt_[0-7][0-9a-hjkmnp-tv-z]{25}$
        cwd:
          type: string
        systemPrompt:
          description: >-
            Composed at creation from the agent's system prompt and the one
            given; fixed for the session's life.
          type:
            - string
            - 'null'
        status:
          $ref: '#/components/schemas/SessionStatus'
        lastSeq:
          $ref: '#/components/schemas/Seq'
        lastUserSeq:
          $ref: '#/components/schemas/Seq'
        processedSeq:
          $ref: '#/components/schemas/Seq'
        heldSeq:
          $ref: '#/components/schemas/Seq'
        lastError:
          oneOf:
            - $ref: '#/components/schemas/TurnError'
            - type: 'null'
        retryAt:
          oneOf:
            - $ref: '#/components/schemas/Timestamp'
            - type: 'null'
        lastEventAt:
          description: The createdAt of the event at lastSeq; null if none.
          oneOf:
            - $ref: '#/components/schemas/Timestamp'
            - type: 'null'
        observedGeneration:
          description: >-
            The agent generation the session's harness runs in full; 0 before
            the first.
          type: integer
          minimum: 0
        metadata:
          $ref: '#/components/schemas/Metadata'
        createdAt:
          $ref: '#/components/schemas/Timestamp'
    Metadata:
      description: The customer's own string keys and values; never case-converted.
      type: object
      additionalProperties:
        type: string
    SessionStatus:
      type: string
      enum:
        - idle
        - running
        - retrying
        - failed
        - blocked
    Seq:
      description: A position in an agent's event log.
      type: integer
      minimum: 0
      maximum: 9007199254740991
    TurnError:
      type: object
      required:
        - code
        - message
      properties:
        code:
          $ref: '#/components/schemas/TurnErrorCode'
        message:
          type: string
    Timestamp:
      description: RFC 3339 in UTC with milliseconds.
      type: string
      format: date-time
      pattern: ^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{3}Z$
      x-go-type: wire.Timestamp
      x-go-type-import:
        path: github.com/wenfengwang/paddock/internal/wire
    ErrorBody:
      description: The body of every non-2xx response.
      type: object
      required:
        - error
      properties:
        error:
          $ref: '#/components/schemas/ErrorObject'
    TurnErrorCode:
      type: string
      enum:
        - harness_error
        - watchdog_timeout
        - model_unavailable
        - model_auth
        - context_too_long
        - conversation_lost
        - sandbox_unavailable
        - internal
    ErrorObject:
      type: object
      required:
        - code
        - message
      properties:
        code:
          $ref: '#/components/schemas/ErrorCode'
        message:
          type: string
        details:
          type: object
    ErrorCode:
      type: string
      enum:
        - invalid_request
        - unauthorized
        - forbidden
        - not_found
        - conflict
        - payload_too_large
        - unsupported
        - unavailable
        - internal
  headers:
    RequestId:
      description: The request's ID, for support and logs
      schema:
        type: string
  responses:
    Error:
      description: Every non-2xx response
      headers:
        Request-Id:
          $ref: '#/components/headers/RequestId'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorBody'
  securitySchemes:
    bearer:
      type: http
      scheme: bearer
      description: An API key, or a session token on its own session

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.