AppMage

ChargeableRpc

ChargeableRpc provides a single RPC endpoint for listing chargeable items associated with the current subscription. The endpoint accepts paging and optional filter/sort inputs, and it uses the subscription identifier from request context to scope the results.

Endpoints

POST /api/rpc (Method: ChargeableRpc.getData)

ChargeableRpc.getData lists chargeable items for the current subscription. The method requires a subscription-scoped request context and returns a paginated result set with the matching records and a total count.

  • Description: Lists chargeable items for a subscription.

  • Request Body:

    {
      "method": "ChargeableRpc.getData",
      "params": {
        "filter": {},
        "sort": {},
        "page": 1,
        "pageSize": 20
      }
    }
  • Parameters:

    Name Type Required Description
    filter Any No Optional filter object merged into the database query.
    sort Any No Optional sort specification. If omitted, results are sorted by createdAt descending.
    page Number Yes Positive integer page number, used to calculate the result offset.
    pageSize Number Yes Positive integer number of records to return per page.
  • Response:

    {
      "success": true,
      "data": {
        "data": [],
        "totalCount": 0
      }
    }

    The data field contains the list returned by the backing data source, and totalCount contains the number of records matching the same query.

  • Example (cURL):

    curl -X POST "${APP_BASE_URL}/api/rpc" \
      -H "Content-Type: application/json" \
      -d '{
        "method": "ChargeableRpc.getData",
        "params": {
          "page": 1,
          "pageSize": 20
        }
      }'

Behavior Notes

The method reads context.subscriptionId and throws an error if it is missing, so the endpoint requires subscription context to operate successfully. The request parameters are validated with a Zod schema that requires page and pageSize to be positive integers, while filter and sort are optional.

The method combines the provided filter with the subscription target identifier before querying the chargeables collection, then applies pagination and sorting.