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

# Create payment gateway session

> Create a payment gateway session for client-side card tokenization.

Returns short-lived credentials scoped to the authenticated developer.
Use the credentials with the corresponding gateway's client-side SDK to
tokenize a card. Tokens created this way are locked to the developer's
container and cannot be used by other developers.



## OpenAPI

````yaml https://app.stainless.com/api/spec/documented/checkout-intents/openapi.documented.yml post /api/v1/payment-gateways/{gateway}/session
openapi: 3.0.0
info:
  title: Universal Checkout API
  version: 1.0.5
  description: >-
    Turn any product URL into a completed checkout. Instantly retrieve price,
    tax, and shipping for any product, and let users buy without ever leaving
    your native AI experience.


    View the [Rye API docs](https://docs.rye.com).
  termsOfService: https://rye.com/terms-of-service
  license:
    name: UNLICENSED
  contact:
    name: Rye
    email: dev@rye.com
    url: https://docs.rye.com
servers:
  - url: https://staging.api.rye.com
security: []
paths:
  /api/v1/payment-gateways/{gateway}/session:
    post:
      tags:
        - Payment Gateways
      summary: Create payment gateway session
      description: |-
        Create a payment gateway session for client-side card tokenization.

        Returns short-lived credentials scoped to the authenticated developer.
        Use the credentials with the corresponding gateway's client-side SDK to
        tokenize a card. Tokens created this way are locked to the developer's
        container and cannot be used by other developers.
      operationId: CreateSession
      parameters:
        - description: The payment gateway to create a session for
          in: path
          name: gateway
          required: true
          schema:
            $ref: '#/components/schemas/PaymentGateway'
      responses:
        '200':
          description: Gateway-specific session credentials
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaymentGatewaySession'
        '401':
          description: Authentication Failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AuthenticationError'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RuntimeError'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RuntimeError'
      security:
        - bearerAuth:
            - checkout_intents:write
      x-codeSamples:
        - lang: JavaScript
          source: >-
            import CheckoutIntents from 'checkout-intents';


            const client = new CheckoutIntents({
              apiKey: process.env['CHECKOUT_INTENTS_API_KEY'], // This is the default and can be omitted
            });


            const paymentGatewaySession = await
            client.paymentGateways.createSession('basis-theory');


            console.log(paymentGatewaySession.container);
        - lang: Python
          source: |-
            import os
            from checkout_intents import CheckoutIntents

            client = CheckoutIntents(
                api_key=os.environ.get("CHECKOUT_INTENTS_API_KEY"),  # This is the default and can be omitted
            )
            payment_gateway_session = client.payment_gateways.create_session(
                "basis-theory",
            )
            print(payment_gateway_session.container)
        - lang: Java
          source: >-
            package com.rye.example;


            import com.rye.client.CheckoutIntentsClient;

            import com.rye.client.okhttp.CheckoutIntentsOkHttpClient;

            import com.rye.models.paymentgateways.PaymentGateway;

            import
            com.rye.models.paymentgateways.PaymentGatewayCreateSessionParams;

            import com.rye.models.paymentgateways.PaymentGatewaySession;


            public final class Main {
                private Main() {}

                public static void main(String[] args) {
                    CheckoutIntentsClient client = CheckoutIntentsOkHttpClient.fromEnv();

                    PaymentGatewaySession paymentGatewaySession = client.paymentGateways().createSession(PaymentGateway.BASIS_THEORY);
                }
            }
        - lang: cURL
          source: >-
            curl
            https://staging.api.rye.com/api/v1/payment-gateways/$GATEWAY/session
            \
                -X POST \
                -H "Authorization: Bearer $CHECKOUT_INTENTS_API_KEY"
components:
  schemas:
    PaymentGateway:
      type: string
      enum:
        - basis-theory
      nullable: false
    PaymentGatewaySession:
      properties:
        container:
          type: string
        sessionKey:
          type: string
        gateway:
          type: string
          enum:
            - basis_theory
          nullable: false
      required:
        - container
        - sessionKey
        - gateway
      type: object
    AuthenticationError:
      properties:
        name:
          type: string
        message:
          type: string
        stack:
          type: string
      required:
        - name
        - message
      type: object
      additionalProperties: false
    RuntimeError:
      properties:
        name:
          type: string
        message:
          type: string
        stack:
          type: string
      required:
        - name
        - message
      type: object
      additionalProperties: false
  securitySchemes:
    bearerAuth:
      type: apiKey
      in: header
      name: Authorization
      description: Rye API key

````