# MSP Billing

### Description

The MSP Billing endpoint provides programmatic access to billing data, usage metrics, and account management capabilities for Keeper Managed Service Providers (MSPs) and Distributors. This endpoint enables partners to retrieve current and historical usage data, manage trial and paid accounts, and integrate billing information with PSA (Professional Services Automation) and financial systems.

The MSP Billing API exposes billing and account lifecycle data through a RESTful interface, supporting consumption-based billing reconciliation, automated account provisioning, and financial reporting integration.

### Overview

The Admin REST API MSP Billing endpoint delivers comprehensive billing and account management capabilities for the Keeper MSP ecosystem. This functionality supports critical partner operations:

**Billing Reconciliation**\
Retrieve current and monthly usage data for all Managed Companies. Integrate with PSA platforms like ConnectWise, Datto, or Gradient MSP for automated billing reconciliation and invoice generation.

**Account Lifecycle Management**\
Programmatically create trial accounts, convert trials to paid subscriptions, activate expired accounts, and cancel paid accounts. Automate the full customer lifecycle without manual intervention in the Admin Console.

**Usage Analytics**\
Track license consumption across all Managed Companies. Monitor product utilization, Secure Add-On adoption, and storage consumption for capacity planning and upsell identification.

**Financial Reporting**\
Export billing data for integration with accounting systems. Generate reports on revenue by customer, product mix analysis, and monthly recurring revenue (MRR) tracking.

#### Prerequisites

* Active Keeper MSP or Distributor account
* [Advanced Reporting and Alerts Module (ARAM)](/enterprise-guide/event-reporting.md) add-on enabled
* API key provided by Keeper (contact your support representative)
* Pre-shared secret for JWT generation
* Vendor name assigned by Keeper

### Configuration

### Generate an API token

For Billing APIs please use `BILLING` read role when generating an API token.

Example:

```bash
# 30‑day BILLING key (Read)
public-api-key generate --name "Billing Integration" --roles "BILLING:1" --expires 30d
```

### MSP Billing Usage API

#### **Endpoint**

```
GET bi_api/rest/public/msp/billing-usage
```

**Purpose**\
Retrieve monthly billing usage details for the authenticated MSP and its linked Managed Companies (MCs), including unit pricing, base licenses and add-ons consumption, quantities, and associated costs for a specified month and year.

**Authentication**\
Send your API token in the `x-api-token` header:\
`x-api-token: Bearer <API_TOKEN>`

#### Query parameters

<table><thead><tr><th width="198.1015625">Name</th><th width="106.35546875">Type</th><th width="171.8125">Required</th><th>Description</th></tr></thead><tbody><tr><td><code>month</code></td><td>Integer</td><td>Yes</td><td>Single digit from <strong>1 to 12</strong>, without a leading zero (e.g. <code>1</code> or <code>11</code>).</td></tr><tr><td><code>year</code></td><td>Integer</td><td>Yes</td><td>Four-digit year (e.g. <code>2025</code> or <code>2023</code>).</td></tr></tbody></table>

#### Headers

<table><thead><tr><th width="237.5390625">Header</th><th>Example</th></tr></thead><tbody><tr><td>x-api-token</td><td>Bearer &#x3C;API_TOKEN></td></tr></tbody></table>

#### Example of requests

**Request with no pagination**

```bash
curl --location '<https://keepersecurity.com/bi_api/rest/public/msp/billing-usage?month=8&year=2025>' \
--header 'x-api-token: Bearer g0mNDtMW6zkJl0Jcxv-4kJH9beIrIsLqVvvDOhp0'
```

#### Example success response (200)

```json
{
    "total": 3.91,
    "tax": 0.51,
    "currency": "USD",
    "mcItems": [
        {
            "total": 3.4,
            "companyName": "free mc",
            "products": [
                {
                    "unitPrice": 3.4,
                    "unit": "user",
                    "quantity": 1,
                    "productId": 10010,
                    "productName": "Keeper Enterprise Bundle",
                    "avgMonthlyCost": 3.4
                }
            ]
        }
    ],
    "subTotal": 3.4,
    "mspItem": {
        "total": 3.4,
        "companyName": "free msp",
        "products": [
            {
                "unitPrice": 3.4,
                "unit": "user",
                "quantity": 1,
                "productId": 720,
                "productName": "MSP Base License",
                "avgMonthlyCost": 3.4
            }
        ]
    }
}
```

#### Error codes

| Code | Message               | Cause                      |
| ---- | --------------------- | -------------------------- |
| 400  | Missing/Invalid month | Month is invalid.          |
| 400  | Missing/Invalid year  | Year is invalid.           |
| 403  | Forbidden             | MC trying to access api.   |
| 401  | Unauthorized          | Invalid or missing token.  |
| 500  | Internal Server Error | Unexpected error occurred. |

***

#### Security Notes

* Treat API tokens like passwords; rotate them on a schedule.
* Restrict permissions to the minimum required roles and actions.
* Prefer short expirations; use `never` only for special automation cases.
* Store tokens in a secure location (e.g., Keeper Vault).

### MSP Current Usage API

**Endpoint**

```
GET bi_api/rest/public/msp/current-usage
```

**Purpose**\
Retrieve snapshot of current usage (base licenses and add-ons) for the authenticated MSP and linked Managed Companies (MCs).

**Authentication**\
Send your API token in the `x-api-token` header:\
`x-api-token: Bearer <API_TOKEN>`

#### Headers

<table><thead><tr><th width="237.5390625">Header</th><th>Example</th></tr></thead><tbody><tr><td>x-api-token</td><td>Bearer &#x3C;API_TOKEN></td></tr></tbody></table>

#### Example of requests

**Request with no pagination**

```bash
curl --location '<https://keepersecurity.com/bi_api/rest/public/msp/current-usage>' \
--header 'x-api-token: Bearer g0mNDtMW6zkJl0Jcxv-4kJH9beIrIsLqVvvDOhp0'
```

#### Example success response (200)

```json
{
    "mcItems": [
        {
            "maximumAllowedUsers": 2147483647,
            "companyName": "free mc",
            "plan": "Keeper Enterprise Bundle",
            "invitedUsers": 0,
            "products": [
                {
                    "unit": "user",
                    "quantity": 1,
                    "productId": 10010,
                    "productName": "Keeper Enterprise Bundle"                    
                }
            ]
        }
    ],
    "mspItem": {
        "companyName": "free msp",
        "invitedUsers": 2,
        "products": [
            {
                "unit": "user",
                "quantity": 1,
                "productId": 720,
                "productName": "MSP Base License"
            }
        ]
    }
}
```

#### Error codes

| Code | Message               | Cause                      |
| ---- | --------------------- | -------------------------- |
| 403  | Forbidden             | MC trying to access api.   |
| 401  | Unauthorized          | Invalid or missing token.  |
| 500  | Internal Server Error | Unexpected error occurred. |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.keeper.io/keeperpam/commander-cli/admin-rest-api/msp-billing.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
