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

# Get paginated credit ledger history

> Returns paginated credit/debit transactions from the council's
ledger table. Supports filtering by `credit_type` and pagination
via `page`/`per_page` (or `per_page=-1` for all records).

Council ID is auto-detected from session context or user meta.
Non-admin users can only query their own council. The `admin_notes`
field is only populated for users with `administrator`,
`ss_admin_all`, or `ss_power_user` roles.

Registered as `wp_ajax_sagescreen_get_credit_ledger` — **login required**.




## OpenAPI

````yaml /openapi/private/specs/wp/wp-ajax-misc.yml post /wp-admin/admin-ajax.php?action=sagescreen_get_credit_ledger
openapi: 3.1.0
info:
  title: SageScreen — Misc AJAX Modules (User · Council · Billing · Splash · Demo)
  version: 1.0.0
servers:
  - url: https://{domain}/wp-json/sagescreen/v1
    description: WordPress REST API
    variables:
      domain:
        default: api.sagescreen.app
security: []
tags:
  - name: User – REST
    description: Zapier-facing REST endpoints
  - name: User – AJAX
    description: Council user management AJAX endpoints
  - name: User – Profile
    description: Self-service profile updates
  - name: Council – REST
    description: Zapier-facing REST endpoints for council data sync
  - name: Council – AJAX
    description: Council user and sage management AJAX endpoints
  - name: Billing – Stripe
    description: Stripe webhook and subscription endpoints
  - name: Billing – Broadcast
    description: Postmark broadcast unsubscribe endpoint
  - name: Billing – Pipedrive
    description: Pipedrive CRM ID set-* webhook endpoints (called by Zapier)
  - name: Billing – AJAX
    description: Credit ledger, reactivation, and portal AJAX endpoints
  - name: Splash
    description: Splash banner AJAX endpoints
  - name: Demo
    description: Demo signup and management AJAX endpoints
  - name: CSV Upload
    description: Bulk candidate CSV upload
paths:
  /wp-admin/admin-ajax.php?action=sagescreen_get_credit_ledger:
    post:
      tags:
        - Billing – AJAX
      summary: Get paginated credit ledger history
      description: >
        Returns paginated credit/debit transactions from the council's

        ledger table. Supports filtering by `credit_type` and pagination

        via `page`/`per_page` (or `per_page=-1` for all records).


        Council ID is auto-detected from session context or user meta.

        Non-admin users can only query their own council. The `admin_notes`

        field is only populated for users with `administrator`,

        `ss_admin_all`, or `ss_power_user` roles.


        Registered as `wp_ajax_sagescreen_get_credit_ledger` — **login
        required**.
      operationId: ajaxGetCreditLedger
      requestBody:
        required: true
        content:
          application/x-www-form-urlencoded:
            schema:
              $ref: '#/components/schemas/GetCreditLedgerRequest'
      responses:
        '200':
          description: Ledger result (check `success` field)
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: '#/components/schemas/GetCreditLedgerSuccess'
                  - $ref: '#/components/schemas/BillingInternalAjaxErrorResponse'
              examples:
                success:
                  summary: Paginated ledger page
                  value:
                    success: true
                    data:
                      - id: 142
                        date: Feb 15, 2026 9:00 AM
                        date_raw: '2026-02-15 09:00:00'
                        type: Credit
                        type_raw: credit
                        credit_type: Credits
                        credit_type_raw: credits
                        amount: '+100'
                        amount_raw: 100
                        running_balance: 250
                        expires_at: Feb 15, 2027
                        expires_at_raw: '2027-02-15 09:00:00'
                        reference_type: order
                        reference_id: '4821'
                        reference_label: 'Order #4821'
                        reference_link: /wp-admin/post.php?post=4821&action=edit
                        notes: Annual renewal
                        action: Renew (Auto)
                        action_raw: renew_auto
                        reason: ''
                        reason_raw: null
                        admin_notes: ''
                    total: 47
                    page: 1
                    per_page: 25
                    message: Credit ledger retrieved successfully
                noCouncil:
                  summary: No council context found
                  value:
                    success: false
                    data: []
      security:
        - wpAjaxNonce: []
components:
  schemas:
    GetCreditLedgerRequest:
      type: object
      required:
        - action
        - nonce
      properties:
        action:
          type: string
          const: sagescreen_get_credit_ledger
        nonce:
          type: string
          description: WP nonce for `sagescreen_frontend_nonce`
        council_id:
          type: string
          format: uuid
          description: Council UUID (optional, auto-detected from session/user meta)
          examples:
            - c9d8e7f6-5a4b-3c2d-1e0f-a1b2c3d4e5f6
        page:
          type: integer
          description: Page number (1-indexed)
          default: 1
          examples:
            - 1
        per_page:
          type: integer
          description: Results per page (max 100, or -1 for all)
          default: 25
          examples:
            - 25
        credit_type:
          $ref: '#/components/schemas/CreditType'
    GetCreditLedgerSuccess:
      type: object
      properties:
        success:
          type: boolean
          const: true
          examples:
            - true
        data:
          type: array
          items:
            $ref: '#/components/schemas/CreditLedgerEntry'
        total:
          type: integer
          description: Total number of matching ledger rows
          examples:
            - 47
        page:
          type: integer
          description: Current page number
          examples:
            - 1
        per_page:
          type: integer
          description: Rows per page (or -1 when all rows returned)
          examples:
            - 25
        message:
          type: string
          examples:
            - Credit ledger retrieved successfully
    BillingInternalAjaxErrorResponse:
      type: object
      description: |
        Standard AJAX error. The `data` field is either a plain string
        or an object with a `message` key and optional context fields.
      properties:
        success:
          type: boolean
          const: false
          examples:
            - false
        data:
          oneOf:
            - type: string
              examples:
                - Security check failed
            - type: object
              properties:
                success:
                  type: boolean
                  description: Inner success flag (present on reactivation errors)
                  examples:
                    - false
                message:
                  type: string
                  examples:
                    - You must be logged in
    CreditType:
      type: string
      description: Type of credit in the ledger
      enum:
        - credits
        - sage_credits
      examples:
        - credits
    CreditLedgerEntry:
      type: object
      description: A single row from the credit ledger, formatted for display
      properties:
        id:
          type: integer
          description: Ledger row primary key
          examples:
            - 142
        date:
          type: string
          description: Formatted date/time in council timezone
          examples:
            - Feb 15, 2026 9:00 AM
        date_raw:
          type: string
          description: Raw MySQL datetime
          examples:
            - '2026-02-15 09:00:00'
        type:
          type: string
          description: >-
            Human-readable transaction type (e.g. "Credit", "Debit",
            "Adjustment")
          examples:
            - Credit
        type_raw:
          $ref: '#/components/schemas/LedgerTransactionType'
        credit_type:
          type: string
          description: Human-readable credit type (e.g. "Credits", "Sage Credits")
          examples:
            - Credits
        credit_type_raw:
          $ref: '#/components/schemas/CreditType'
        amount:
          type: string
          description: Signed amount string (e.g. "+100", "-5")
          examples:
            - '+100'
        amount_raw:
          type: integer
          description: Numeric amount (positive for credits, negative for debits)
          examples:
            - 100
        running_balance:
          type: integer
          description: Council balance after this transaction
          examples:
            - 250
        expires_at:
          type: string
          description: Formatted expiry date or empty string
          examples:
            - Feb 15, 2027
        expires_at_raw:
          type:
            - string
            - 'null'
          description: Raw MySQL datetime or null
          examples:
            - '2027-02-15 09:00:00'
        reference_type:
          type: string
          description: >-
            Type of referenced entity (order, screen, council_sage, user) or
            empty
          examples:
            - order
        reference_id:
          type: string
          description: ID of referenced entity or empty
          examples:
            - '4821'
        reference_label:
          type: string
          description: Human-readable reference label
          examples:
            - 'Order #4821'
        reference_link:
          type: string
          description: URL to referenced entity or empty
          examples:
            - /wp-admin/post.php?post=4821&action=edit
        notes:
          type: string
          description: Free-text notes
          examples:
            - Annual renewal
        action:
          type: string
          description: Human-readable action label
          examples:
            - Renew (Auto)
        action_raw:
          type:
            - string
            - 'null'
          description: Machine-readable action key
          examples:
            - renew_auto
        reason:
          type: string
          description: Human-readable reason label (adjustments only)
          examples:
            - Customer Goodwill
        reason_raw:
          type:
            - string
            - 'null'
          description: Machine-readable reason key
          examples:
            - customer_goodwill
        admin_notes:
          type: string
          description: Admin-only notes (empty for non-global-admin users)
          examples:
            - 'Approved by support ticket #1234'
    LedgerTransactionType:
      type: string
      description: Transaction type recorded in the ledger
      enum:
        - credit
        - debit
        - adjustment
      examples:
        - credit
  securitySchemes:
    wpAjaxNonce:
      type: apiKey
      in: query
      name: nonce
      description: WordPress AJAX nonce (passed as form field, verified per-action)

````