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

# Start Stripe Checkout to buy credits (API key)

> Creates a Stripe Checkout session for the given package. Open `url` in a browser to pay, then call `POST /api/v1/credits/checkout/confirm` with `sessionId` (or wait for the Stripe webhook). Success/cancel redirect URLs are the same as Settings → Billing in the web app.



## OpenAPI

````yaml /openapi/programmatic.json post /api/v1/credits/checkout
openapi: 3.0.0
info:
  title: SnapIt Programmatic API
  description: >-
    Public API-key endpoints for invoice upload, extracted JSON, credit balance,
    and top-up. Authenticate with `Authorization: Bearer sk_live_…`. Full
    operator Swagger (including admin/JWT routes) remains at `/api/docs` on the
    API host.
  version: '1.0'
  contact: {}
servers:
  - url: https://api.trysnapit.com
    description: Production
  - url: http://localhost:3000
    description: Local development
security:
  - api-key: []
tags:
  - name: programmatic
    description: API-key authenticated upload, invoice JSON, balance, and credit top-up
paths:
  /api/v1/credits/checkout:
    post:
      tags:
        - programmatic
      summary: Start Stripe Checkout to buy credits (API key)
      description: >-
        Creates a Stripe Checkout session for the given package. Open `url` in a
        browser to pay, then call `POST /api/v1/credits/checkout/confirm` with
        `sessionId` (or wait for the Stripe webhook). Success/cancel redirect
        URLs are the same as Settings → Billing in the web app.
      operationId: checkout
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateCheckoutDto'
      responses:
        '200':
          description: Checkout session created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CheckoutSessionResponseDto'
        '400':
          description: Package unavailable or invalid packageId
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorResponseDto'
        '401':
          description: Invalid or missing API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorResponseDto'
        '404':
          description: Package or tenant not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorResponseDto'
        '503':
          description: >-
            Stripe is not configured. Add the secret key in Platform Admin →
            Settings → Integrations, or set STRIPE_SECRET_KEY.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorResponseDto'
      security:
        - api-key: []
components:
  schemas:
    CreateCheckoutDto:
      type: object
      properties:
        packageId:
          type: string
          description: Credit package UUID to purchase
      required:
        - packageId
    CheckoutSessionResponseDto:
      type: object
      properties:
        url:
          type: string
          example: https://checkout.stripe.com/c/pay/cs_test_…
          description: Open this URL in a browser to complete payment
        sessionId:
          type: string
          example: cs_test_a1b2c3
          description: Pass to POST /api/v1/credits/checkout/confirm after payment
      required:
        - url
        - sessionId
    ApiErrorResponseDto:
      type: object
      properties:
        statusCode:
          type: number
          example: 401
        message:
          oneOf:
            - type: string
            - type: array
              items:
                type: string
          example: Invalid or missing API key
        error:
          type: string
          example: Unauthorized
      required:
        - statusCode
        - message
  securitySchemes:
    api-key:
      type: apiKey
      in: header
      name: Authorization
      description: Bearer sk_live_… (include the Bearer prefix)
      x-default: Bearer sk_live_…

````

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