> ## 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.

# session.createToken({ ttl })



## OpenAPI

````yaml /api-reference/openapi.json post /sessions/{id}/tokens
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:
  /sessions/{id}/tokens:
    post:
      summary: session.createToken({ ttl })
      operationId: createSessionToken
      parameters:
        - $ref: '#/components/parameters/SessionId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateTokenRequest'
      responses:
        '201':
          description: The token
          headers:
            Request-Id:
              $ref: '#/components/headers/RequestId'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SessionToken'
        default:
          $ref: '#/components/responses/Error'
components:
  parameters:
    SessionId:
      name: id
      in: path
      required: true
      description: The session's ID
      schema:
        type: string
        pattern: ^ses_[0-7][0-9a-hjkmnp-tv-z]{25}$
  schemas:
    CreateTokenRequest:
      type: object
      additionalProperties: false
      required:
        - ttlSeconds
      properties:
        ttlSeconds:
          type: integer
          minimum: 1
    SessionToken:
      type: object
      required:
        - token
        - expiresAt
      properties:
        token:
          type: string
        expiresAt:
          $ref: '#/components/schemas/Timestamp'
    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'
    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.