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

# Buy credits

> Creates a Stripe checkout URL. Open url to complete payment. Credits are added after payment confirmation, not when this endpoint returns. Read GET /api/v1/credits to confirm the balance. Default purchase range: 10–100,000 credits.



## OpenAPI

````yaml POST /api/v1/credits/checkout
openapi: 3.1.0
info:
  title: YCpedia API
  version: 1.0.0
  description: >-
    Read, generate, and update profile articles by LinkedIn ID. Obtain your API
    key and API base URL from the YCpedia team.
servers:
  - url: https://api.thealmanac.ai
    description: Production API
security:
  - CustomerApiKey: []
paths:
  /api/v1/credits/checkout:
    post:
      summary: Buy credits
      description: >-
        Creates a Stripe checkout URL. Open url to complete payment. Credits are
        added after payment confirmation, not when this endpoint returns. Read
        GET /api/v1/credits to confirm the balance. Default purchase range:
        10–100,000 credits.
      operationId: buy_credits
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ApiCheckoutRequest'
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CheckoutSessionResponse'
        '400':
          description: Credit purchase outside the allowed range.
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    oneOf:
                      - type: string
                      - type: array
                        items:
                          additionalProperties: true
                          type: object
                required:
                  - detail
        '401':
          description: Missing or invalid API key.
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    oneOf:
                      - type: string
                      - type: array
                        items:
                          additionalProperties: true
                          type: object
                required:
                  - detail
        '422':
          description: Invalid request or missing Idempotency-Key.
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    oneOf:
                      - type: string
                      - type: array
                        items:
                          additionalProperties: true
                          type: object
                required:
                  - detail
        '429':
          description: Rate limit exceeded. Wait for the Retry-After duration.
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    oneOf:
                      - type: string
                      - type: array
                        items:
                          additionalProperties: true
                          type: object
                required:
                  - detail
          headers:
            Retry-After:
              description: Seconds to wait before retrying.
              schema:
                type: integer
                example: 60
        '502':
          description: Checkout unavailable.
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    oneOf:
                      - type: string
                      - type: array
                        items:
                          additionalProperties: true
                          type: object
                required:
                  - detail
        '503':
          description: Payments are not configured.
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    oneOf:
                      - type: string
                      - type: array
                        items:
                          additionalProperties: true
                          type: object
                required:
                  - detail
      security:
        - CustomerApiKey: []
components:
  schemas:
    ApiCheckoutRequest:
      properties:
        credits:
          exclusiveMinimum: 0
          title: Credits
          type: integer
          examples:
            - 100
      required:
        - credits
      title: ApiCheckoutRequest
      type: object
    CheckoutSessionResponse:
      properties:
        session_id:
          title: Session Id
          type: string
        url:
          title: Url
          type: string
      required:
        - session_id
        - url
      title: CheckoutSessionResponse
      type: object
  securitySchemes:
    CustomerApiKey:
      type: http
      scheme: bearer
      description: Your customer API key (alm_…). Keep it on your server.

````