Skip to main content
Glama

get_subscription_invoices

Retrieve paginated invoices for a subscription with optional line-item, transaction, billrun, or external invoice details.

Instructions

List invoices for a subscription. GET /subscriptions/{subscriptionId}/invoices. Returns paginated invoices. Use include for line-item detail and transactions (e.g. include=detail,transactions).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
subscriptionIdYesSubscription ID (required)
includeNoComma-separated: detail, transactions, billruns, externalInvoices
pageNoNoPage number (default: 1)
itemPerPageNoItems per page (default: 25)

Implementation Reference

  • The handler function that validates input via Zod schema, then calls subscriptionService.getSubscriptionInvoices to fetch paginated invoices for a subscription.
    async function handler(client: Client, args: Record<string, unknown> | undefined) {
      const parsed = schema.safeParse(args);
      if (!parsed.success) {
        return errorResult(parsed.error.errors.map((e) => e.message).join("; "));
      }
      const { subscriptionId, include, pageNo, itemPerPage } = parsed.data;
      return handleToolCall(() =>
        subscriptionService.getSubscriptionInvoices(client, subscriptionId, {
          include,
          pageNo,
          itemPerPage,
        })
      );
    }
  • Zod schema defining input validation: subscriptionId (required string), include (optional string), pageNo (optional int >=1), itemPerPage (optional int >=1).
    const schema = z.object({
      subscriptionId: z.string().min(1, "subscriptionId is required"),
      include: z.string().optional(),
      pageNo: z.number().int().min(1).optional(),
      itemPerPage: z.number().int().min(1).optional(),
    });
  • Exports the Tool object (definition + handler) registered as 'get_subscription_invoices'.
    export const getSubscriptionInvoicesTool: Tool = {
      definition,
      handler,
    };
  • Registers getSubscriptionInvoicesTool in the array returned by registerSubscriptionTools(), making it available alongside other subscription tools.
    export function registerSubscriptionTools(): Tool[] {
      return [
        listSubscriptionsTool,
        getSubscriptionTool,
        createSubscriptionTool,
        updateSubscriptionTool,
        deleteSubscriptionTool,
        updateSubscriptionStatusTool,
        getSubscriptionUpcomingChargesTool,
        getSubscriptionInvoicesTool,
        getSubscriptionLogsTool,
        getSubscriptionExternalInvoicesTool,
        listSubscriptionRatePlansTool,
        getSubscriptionRatePlanTool,
        addSubscriptionRatePlanTool,
        updateSubscriptionRatePlanTool,
        removeSubscriptionRatePlanTool,
        getSubscriptionRatePlanChargeTool,
        addSubscriptionRatePlanChargeTool,
        updateSubscriptionRatePlanChargeTool,
        removeSubscriptionRatePlanChargeTool,
      ];
    }
  • The service function that builds query params and performs the GET /subscriptions/{subscriptionId}/invoices API call, returning a paginated response.
    export async function getSubscriptionInvoices(
      client: Client,
      subscriptionId: string,
      params?: SubscriptionInvoicesParams
    ): Promise<PaginatedResponse<unknown>> {
      const search = new URLSearchParams();
      if (params?.include) search.append("include", params.include);
      if (params?.pageNo != null) search.append("pageNo", String(params.pageNo));
      if (params?.itemPerPage != null) search.append("itemPerPage", String(params.itemPerPage));
      const q = search.toString();
      return client.get<PaginatedResponse<unknown>>(
        `/subscriptions/${subscriptionId}/invoices${q ? `?${q}` : ""}`
      );
    }
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries full burden. It reveals paginated behavior and the 'include' parameter for detail/transactions. However, it does not disclose other behaviors like authentication requirements, rate limits, or response structure, leaving gaps in transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise with three sentences. The first sentence states purpose, the third explains 'include'. The second sentence with the HTTP method is slightly redundant but not overly verbose. Efficient overall.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

No output schema exists. The description covers pagination and key parameter usage but does not detail the return format (e.g., invoice object fields). For a list tool, this is acceptable but could be improved by mentioning typical response structure.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so baseline is 3. The description adds value by providing an example for the 'include' parameter (e.g., include=detail,transactions), which clarifies usage beyond the schema description. No additional context for other parameters.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool lists invoices for a subscription, specifying the verb and resource. It distinguishes from siblings like 'get_customer_invoices' through the name and phrasing, but no explicit differentiation is made.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives such as 'get_customer_invoices' or 'list_invoices'. The description only hints at the 'include' parameter usage, lacking context on when not to use the tool.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/rhinosaas/rebillia-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server