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

# Create Session

> Initiate a new payment session



## OpenAPI

````yaml POST /v1/sessions
openapi: 3.1.0
info:
  title: ToffeePay API
  description: Public API for game partners
  version: 0.1.1
servers:
  - url: https://api.toffeepay.com
    description: Production
  - url: https://api.sandbox.toffeepay.com
    description: Sandbox
security:
  - BearerAuth: []
paths:
  /v1/sessions:
    post:
      summary: CreateSession
      description: Initiate a new payment session
      operationId: PaymentService_CreateSession
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/pay.v1.CreateSessionRequest'
        required: true
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/pay.v1.Session'
                title: session
components:
  schemas:
    pay.v1.CreateSessionRequest:
      type: object
      properties:
        game_id:
          type: string
          title: game_id
        user_id:
          type: string
          title: user_id
        item:
          $ref: '#/components/schemas/pay.v1.Item'
          title: item
        return_url:
          type: string
          title: return_url
          format: uri
        wallet_enabled:
          type:
            - boolean
            - 'null'
          title: wallet_enabled
      title: CreateSessionRequest
      required:
        - game_id
        - user_id
        - item
      additionalProperties: false
      description: Session requests/responses
    pay.v1.Session:
      type: object
      properties:
        id:
          type: string
          title: id
        url:
          type: string
          title: url
        status:
          type: string
          title: status
          enum:
            - pending
            - paid
            - failed
            - cancelled
            - expired
        payment_id:
          type: string
          title: payment_id
          deprecated: true
        user_id:
          type: string
          title: user_id
        game_id:
          type: string
          title: game_id
        item:
          $ref: '#/components/schemas/pay.v1.Item'
          title: item
        created_at:
          $ref: '#/components/schemas/google.protobuf.Timestamp'
          title: created_at
        paid_at:
          oneOf:
            - $ref: '#/components/schemas/google.protobuf.Timestamp'
            - type: 'null'
          title: paid_at
        failed_at:
          oneOf:
            - $ref: '#/components/schemas/google.protobuf.Timestamp'
            - type: 'null'
          title: failed_at
        cancelled_at:
          oneOf:
            - $ref: '#/components/schemas/google.protobuf.Timestamp'
            - type: 'null'
          title: cancelled_at
        expired_at:
          oneOf:
            - $ref: '#/components/schemas/google.protobuf.Timestamp'
            - type: 'null'
          title: expired_at
        tax:
          oneOf:
            - $ref: '#/components/schemas/pay.v1.Tax'
            - type: 'null'
          title: tax
          description: sales tax for the session
        metadata:
          oneOf:
            - $ref: '#/components/schemas/pay.v1.SessionMetadata'
            - type: 'null'
          title: metadata
      title: Session
      required:
        - id
        - url
        - status
        - user_id
        - game_id
        - item
        - created_at
      additionalProperties: false
    pay.v1.Item:
      type: object
      properties:
        title:
          type: string
          title: title
        price:
          exclusiveMinimum: 0
          type: integer
          title: price
          format: int32
        currency:
          type: string
          title: currency
          enum:
            - USD
            - GBP
            - EUR
        image:
          type:
            - string
            - 'null'
          title: image
          pattern: ^(https?://|data:)
        country:
          type:
            - string
            - 'null'
          title: country
          maxLength: 2
          minLength: 2
          pattern: ^[A-Z]{2}$
          description: 'ISO 3166-1 alpha-2: "US", "GB", "DE"'
      title: Item
      required:
        - title
        - price
        - currency
      additionalProperties: false
    google.protobuf.Timestamp:
      type: string
      format: date-time
    pay.v1.Tax:
      type: object
      properties:
        amount:
          type: integer
          title: amount
          minimum: 0
          format: int32
      title: Tax
      additionalProperties: false
    pay.v1.SessionMetadata:
      type: object
      properties:
        offer_id:
          type:
            - string
            - 'null'
          title: offer_id
      title: SessionMetadata
      additionalProperties: false
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````