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

# List or export the credit ledger

> Requires workspace admin access. Reads customer-visible credits and debits across the workspace. JSON is paginated: reuse next_cursor while has_more is true, including when a filtered page is empty. CSV streams the matching history and ignores cursor and limit. Responses are private and uncached.

Authentication: workspace API key in `Authorization: Bearer <key>`.

## Errors

| Status | Meaning |
| - | - |
| 401 | Missing or invalid workspace authentication. |
| 403 | The authenticated identity lacks access to this resource or operation. |
| 500 | Server failure. Retry this read; it does not start new work. |


## OpenAPI

````yaml openapi.json GET /api/v2/billing/ledger
openapi: 3.1.1
info:
  title: Deepline API
  version: v2
  description: >-
    Discover typed GTM tools and callable Plays, then execute a tool or start
    and inspect a durable Deepline Play run. Use the MCP endpoint when your
    client supports Model Context Protocol.
  contact:
    name: Deepline support
    email: team@deepline.com
    url: https://deepline.com/contact
servers:
  - url: https://code.deepline.com
    description: Deepline production runtime API
security: []
tags:
  - name: Health
    description: Availability checks.
  - name: Billing
    description: Safe recovery of existing purchase intent.
  - name: Tools
    description: Discover and execute typed provider tools.
  - name: Plays
    description: Discover, start, and inspect durable Play runs.
externalDocs:
  description: API reference
  url: https://deepline.com/docs/api-reference
paths:
  /api/v2/billing/ledger:
    get:
      tags:
        - Billing
      summary: List or export the credit ledger
      description: >-
        Requires workspace admin access. Reads customer-visible credits and
        debits across the workspace. JSON is paginated: reuse next_cursor while
        has_more is true, including when a filtered page is empty. CSV streams
        the matching history and ignores cursor and limit. Responses are private
        and uncached.
      operationId: getBillingLedger
      parameters:
        - name: format
          in: query
          description: Omit for a JSON page; csv streams a CSV download.
          schema:
            type: string
            enum:
              - csv
        - name: limit
          in: query
          description: >-
            JSON page size; default 50, clamped to 5000. CSV export ignores the
            requested page limit.
          schema:
            type: integer
            minimum: 1
            maximum: 5000
            default: 50
        - name: since_at
          in: query
          description: Lower creation-time bound as Unix milliseconds.
          schema:
            type: integer
            minimum: 0
        - name: before_at
          in: query
          description: Upper creation-time bound as Unix milliseconds.
          schema:
            type: integer
            minimum: 0
        - name: cursor
          in: query
          description: >-
            Opaque next_cursor from the previous JSON page. Preserve all
            filters. Ignored for CSV.
          schema:
            type: string
        - name: run_id
          in: query
          description: Exact public run ID.
          schema:
            type: string
        - name: operation
          in: query
          description: Exact billed operation name.
          schema:
            type: string
      responses:
        '200':
          description: One JSON page, or a CSV download when format=csv.
          content:
            application/json:
              schema:
                type: object
                properties:
                  org_id:
                    type: string
                  scope:
                    type: object
                    properties:
                      kind:
                        const: org
                    required:
                      - kind
                  entries:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: string
                        delta:
                          type: number
                          description: Positive for a credit, negative for a debit.
                        reason:
                          type: string
                        provider:
                          type:
                            - string
                            - 'null'
                        operation:
                          type:
                            - string
                            - 'null'
                        request_id:
                          type:
                            - string
                            - 'null'
                        run_id:
                          type:
                            - string
                            - 'null'
                        billing_stage:
                          type:
                            - string
                            - 'null'
                        charge_state:
                          type:
                            - string
                            - 'null'
                        billing_mode:
                          type:
                            - string
                            - 'null'
                        pricing_model:
                          type:
                            - string
                            - 'null'
                        pricing_basis:
                          type:
                            - string
                            - 'null'
                        charge_credits:
                          type: number
                        outcome:
                          type:
                            - string
                            - 'null'
                        result_count:
                          type:
                            - number
                            - 'null'
                        deepline_rough_usd:
                          type:
                            - number
                            - 'null'
                        api_key_id:
                          type:
                            - string
                            - 'null'
                        metadata:
                          type:
                            - object
                            - 'null'
                          additionalProperties: true
                        billing_audit:
                          type: object
                          additionalProperties: true
                        stripe_session_id:
                          type:
                            - string
                            - 'null'
                        created_at:
                          type: string
                      required:
                        - id
                        - delta
                        - reason
                        - provider
                        - operation
                        - request_id
                        - run_id
                        - billing_stage
                        - charge_state
                        - billing_mode
                        - pricing_model
                        - pricing_basis
                        - charge_credits
                        - outcome
                        - result_count
                        - deepline_rough_usd
                        - api_key_id
                        - metadata
                        - billing_audit
                        - stripe_session_id
                        - created_at
                  has_more:
                    type: boolean
                  next_cursor:
                    type:
                      - string
                      - 'null'
                  next_before_at:
                    type: 'null'
                required:
                  - org_id
                  - scope
                  - entries
                  - has_more
                  - next_cursor
                  - next_before_at
              example:
                org_id: org_example
                scope:
                  kind: org
                entries: []
                has_more: false
                next_cursor: null
                next_before_at: null
            text/csv:
              schema:
                type: string
              example: >
                created_at,delta_credits,reason,provider,operation,request_id,run_id,billing_stage,charge_state,billing_mode,pricing_model,pricing_basis,charge_credits,outcome,result_count,deepline_rough_usd,api_key_id,stripe_session_id
        '401':
          description: Missing or invalid workspace authentication.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error: Unauthorized
        '403':
          description: >-
            The authenticated identity lacks access to this resource or
            operation.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Server failure. Retry this read; it does not start new work.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - bearerAuth: []
components:
  schemas:
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          oneOf:
            - type: string
              description: Route-specific error message.
            - type: object
              properties:
                code:
                  type: string
                message:
                  type: string
                resolution:
                  type: string
              additionalProperties: true
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: Deepline workspace API key
      description: >-
        Create a workspace API key in the Deepline dashboard before calling
        authenticated endpoints.

````

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