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

# Start self-billing checkout

> Saves the billing details and opens the checkout that ends the caller tenant's trial.



## OpenAPI

````yaml https://swagger.flexprice.io post /portal/billing/checkout
openapi: 3.0.1
info:
  title: Flexprice API
  description: Flexprice API Service
  contact:
    name: API Support
  license:
    name: AGPL-3.0
    url: https://www.gnu.org/licenses/agpl-3.0.html
  version: '1.0'
servers:
  - url: https://us.api.flexprice.io/v1
    description: US Region
  - url: https://api.cloud.flexprice.io/v1
    description: India Region
security: []
paths:
  /portal/billing/checkout:
    post:
      tags:
        - SelfBilling
      summary: Start self-billing checkout
      description: >-
        Saves the billing details and opens the checkout that ends the caller
        tenant's trial.
      operationId: startSelfBillingCheckout
      requestBody:
        description: Billing details
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SelfBillingCheckoutRequest'
        required: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SelfBillingCheckoutResponse'
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/errors.ErrorResponse'
        '404':
          description: Self-billing disabled or subscription not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/errors.ErrorResponse'
        '409':
          description: A checkout is already in progress
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/errors.ErrorResponse'
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/errors.ErrorResponse'
      security:
        - ApiKeyAuth: []
      x-codeSamples:
        - lang: go
          label: Go
          source: "package main\n\nimport(\n\t\"context\"\n\tflexprice \"github.com/flexprice/go-sdk/v2\"\n\t\"github.com/flexprice/go-sdk/v2/models/types\"\n\t\"log\"\n)\n\nfunc main() {\n    ctx := context.Background()\n\n    s := flexprice.New(\n        flexprice.WithSecurity(\"<YOUR_API_KEY_HERE>\"),\n    )\n\n    res, err := s.SelfBilling.StartSelfBillingCheckout(ctx, types.SelfBillingCheckoutRequest{\n        AddressCity: \"<value>\",\n        AddressCountry: \"<value>\",\n        AddressLine1: \"856 Hammes Creek\",\n        AddressPostalCode: \"<value>\",\n        Email: \"Pamela.Rogahn3@gmail.com\",\n        Name: \"<value>\",\n    })\n    if err != nil {\n        log.Fatal(err)\n    }\n    if res.SelfBillingCheckoutResponse != nil {\n        // handle response\n    }\n}"
        - lang: python
          label: Python
          source: |-
            from flexprice import Flexprice


            with Flexprice(
                api_key_auth="<YOUR_API_KEY_HERE>",
            ) as f_client:

                res = f_client.self_billing.start_self_billing_checkout(address_city="<value>", address_country="<value>", address_line1="856 Hammes Creek", address_postal_code="<value>", email="Pamela.Rogahn3@gmail.com", name="<value>")

                # Handle response
                print(res)
        - lang: typescript
          label: TypeScript
          source: |-
            import { Flexprice } from "@flexprice/sdk";

            const flexprice = new Flexprice({
              apiKeyAuth: "<YOUR_API_KEY_HERE>",
            });

            async function run() {
              const result = await flexprice.selfBilling.startSelfBillingCheckout({
                addressCity: "<value>",
                addressCountry: "<value>",
                addressLine1: "856 Hammes Creek",
                addressPostalCode: "<value>",
                email: "Pamela.Rogahn3@gmail.com",
                name: "<value>",
              });

              console.log(result);
            }

            run();
components:
  schemas:
    SelfBillingCheckoutRequest:
      required:
        - address_city
        - address_country
        - address_line1
        - address_postal_code
        - email
        - name
      type: object
      properties:
        address_city:
          type: string
        address_country:
          type: string
        address_line1:
          type: string
        address_line2:
          type: string
        address_postal_code:
          type: string
        address_state:
          type: string
        email:
          type: string
        name:
          type: string
        tax_id:
          type: string
    SelfBillingCheckoutResponse:
      type: object
      properties:
        checkout_id:
          type: string
        status:
          $ref: '#/components/schemas/types.CheckoutStatus'
        tenant_status:
          $ref: '#/components/schemas/types.TenantInternalStatus'
        terminal:
          type: boolean
        url:
          type: string
    errors.ErrorResponse:
      type: object
      properties:
        code:
          $ref: '#/components/schemas/errors.ErrorCode'
        http_status_code:
          type: integer
        message:
          type: string
      x-speakeasy-name-override: ErrorResponse
    types.CheckoutStatus:
      type: string
      enum:
        - initiated
        - pending
        - completed
        - failed
        - expired
      x-enum-varnames:
        - CheckoutStatusInitiated
        - CheckoutStatusPending
        - CheckoutStatusCompleted
        - CheckoutStatusFailed
        - CheckoutStatusExpired
      x-speakeasy-name-override: CheckoutStatus
    types.TenantInternalStatus:
      type: string
      enum:
        - trialing
        - active
        - suspended
      x-enum-varnames:
        - TenantInternalStatusTrialing
        - TenantInternalStatusActive
        - TenantInternalStatusSuspended
      x-speakeasy-name-override: TenantInternalStatus
    errors.ErrorCode:
      type: string
      enum:
        - http_client_error
        - system_error
        - internal_error
        - not_found
        - already_exists
        - version_conflict
        - validation_error
        - invalid_operation
        - permission_denied
        - database_error
        - service_unavailable
        - too_many_requests
        - not_implemented
      x-enum-varnames:
        - ErrCodeHTTPClient
        - ErrCodeSystemError
        - ErrCodeInternalError
        - ErrCodeNotFound
        - ErrCodeAlreadyExists
        - ErrCodeVersionConflict
        - ErrCodeValidation
        - ErrCodeInvalidOperation
        - ErrCodePermissionDenied
        - ErrCodeDatabase
        - ErrCodeServiceUnavailable
        - ErrCodeTooManyRequests
        - ErrCodeNotImplemented
      x-speakeasy-name-override: ErrorCode
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      description: Enter your API key in the format *x-api-key &lt;api-key&gt;**
      name: x-api-key
      in: header

````

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