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

# Get credits

> Read the organization's remaining credit balance.

Returns `{ available, plan_credits, topup_credits, period }` for the key's
organization — the total spendable balance plus its split into subscription (plan)
and top-up credits, and the current billing `period`. Requires the `usage.read`
scope. For pricing detail, see [Pricing](/guides/pricing).


## OpenAPI

````yaml api-reference/openapi.json GET /credits
openapi: 3.1.0
info:
  title: Samsa API
  description: >-
    The Samsa public REST API. Authenticate with an organization API key as a
    bearer token (`Authorization: Bearer samsa_sk_...`). Errors follow a single
    envelope shape; every response carries an `X-Request-ID`.
  version: 1.0.0
servers:
  - url: https://api.samsa.ai/public/v1
security:
  - BearerAuth: []
paths:
  /credits:
    get:
      tags:
        - Usage
      summary: Read the organization's remaining credit balance
      description: >-
        Return ``{available, plan_credits, topup_credits, period}`` for the
        key's org.
      operationId: read_credits_credits_get
      parameters:
        - name: authorization
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Authorization
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicCreditsResponse'
        '401':
          description: Missing, invalid, expired, or revoked API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
        '402':
          description: Insufficient credits or inactive subscription.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
        '403':
          description: The API key lacks the required scope.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
        '404':
          description: Resource not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
        '422':
          description: Request validation failed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
        '429':
          description: Rate limit exceeded.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
        '500':
          description: Internal server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
components:
  schemas:
    PublicCreditsResponse:
      properties:
        available:
          type: integer
          title: Available
          description: >-
            Total credits spendable right now — the sum of `plan_credits` and
            `topup_credits`.
          examples:
            - 1450
        plan_credits:
          type: integer
          title: Plan Credits
          description: >-
            Remaining monthly subscription-pool credits. 0 when the plan pool is
            exhausted or the subscription is canceled and past its period end
            (top-up credits stay spendable).
          examples:
            - 1200
        topup_credits:
          type: integer
          title: Topup Credits
          description: Remaining credits from valid (non-expired) top-up purchases.
          examples:
            - 250
        period:
          $ref: '#/components/schemas/BillingPeriod'
      type: object
      required:
        - available
        - plan_credits
        - topup_credits
        - period
      title: PublicCreditsResponse
      description: |-
        ``GET /credits`` body — the org's REMAINING credit balances (ADR §10).

        All three amounts are balances (not allocations), so
        ``available == plan_credits + topup_credits`` always holds.
    ErrorEnvelope:
      properties:
        error:
          $ref: '#/components/schemas/ErrorDetail'
      type: object
      required:
        - error
      title: ErrorEnvelope
      description: The complete public error body — an ``error`` object wrapper (ADR §5).
    BillingPeriod:
      properties:
        start:
          type: string
          format: date-time
          title: Start
          examples:
            - '2026-07-01T00:00:00+00:00'
        end:
          type: string
          format: date-time
          title: End
          examples:
            - '2026-08-01T00:00:00+00:00'
      type: object
      required:
        - start
        - end
      title: BillingPeriod
      description: The org subscription's current billing-period bounds (ISO-8601).
    ErrorDetail:
      properties:
        type:
          type: string
          title: Type
          examples:
            - authentication_error
        code:
          type: string
          title: Code
          examples:
            - invalid_api_key
        message:
          type: string
          title: Message
          examples:
            - The provided API key is invalid, expired, or revoked.
        request_id:
          type: string
          title: Request Id
          examples:
            - 8f14e45fceea167a5a36dedd4bea2543
        param:
          anyOf:
            - type: string
            - type: 'null'
          title: Param
          description: Present on validation errors — names the offending field.
          examples:
            - aspect_ratio
      type: object
      required:
        - type
        - code
        - message
        - request_id
      title: ErrorDetail
      description: The ``error`` object of the public envelope (ADR §5).
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: >-
        Organization API key as a bearer token: `Authorization: Bearer
        samsa_sk_...`.

````