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

# Confirm a paid Checkout session (API key)

> After the customer pays at Stripe, call this with the Checkout `sessionId` to credit the workspace immediately. Idempotent — safe to retry. The Stripe webhook also fulfills the same purchase.



## OpenAPI

````yaml /openapi/programmatic.json post /api/v1/credits/checkout/confirm
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/confirm:
    post:
      tags:
        - programmatic
      summary: Confirm a paid Checkout session (API key)
      description: >-
        After the customer pays at Stripe, call this with the Checkout
        `sessionId` to credit the workspace immediately. Idempotent — safe to
        retry. The Stripe webhook also fulfills the same purchase.
      operationId: confirmCheckout
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ConfirmCheckoutDto'
      responses:
        '200':
          description: Payment confirmed and balance returned
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ConfirmCheckoutResponseDto'
        '400':
          description: Invalid session id or payment not completed yet
          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: Checkout session 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:
    ConfirmCheckoutDto:
      type: object
      properties:
        sessionId:
          type: string
          description: Stripe Checkout Session id from the success redirect
          example: cs_test_a1b2c3
      required:
        - sessionId
    ConfirmCheckoutResponseDto:
      type: object
      properties:
        applied:
          type: boolean
          description: >-
            True when credits were added by this confirm call; false if already
            applied
        credits:
          type: number
          example: 100
          description: Credits on the purchased package
        balance:
          type: number
          example: 142
          description: Workspace balance after confirm
        creditCostPerInvoice:
          type: number
          example: 1
      required:
        - applied
        - credits
        - balance
        - creditCostPerInvoice
    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.