---
title: "Report usage from your app"
---

Send metered usage to SaaSify so the cloud marketplace bills the buyer for pay-as-you-go consumption.

:::note
Base URLs: `https://api.saasify.ai` (production). Test against
`https://api-demo.saasify.ai` (demo). See [Environments](/developers/environments).
:::

:::note[Before you start]
**You need:** an authenticated [service user](/developers/authentication) with a role that can post usage, an active subscription, and the meter (dimension) names configured for its plan.
:::

## How metering works

For usage-based pricing, the marketplace doesn't know how much a buyer consumed — your application does. You measure consumption against the plan's meters (dimensions) and report it to SaaSify, which forwards it to the right cloud so it appears on the buyer's bill. For the concept and how each cloud meters, see [Metering and usage](/concepts/metering-and-usage).

The usual loop is:

1. Look up the meters for the subscription's plan.
2. Measure usage in your app over a billing window.
3. Post the usage for each meter.
4. Confirm it posted (or handle a failure).

## Find the meters for a subscription

Before posting, get the meter names you can report against:

- `GET /api/subscriptions/{subscriptionID}/meters` — meters configured for a subscription.
- `GET /api/subscriptions/metersbyplan` — meters available on a plan.

## Post usage

Post a usage quantity for a subscription and meter. The canonical single-record endpoint is:

```
POST /api/subscriptions/{subscriptionID}/usage
```

A usage record identifies the meter (dimension), the quantity consumed, and the time it applies to.

:::code-group
```bash title="cURL"
curl -X POST https://api-demo.saasify.ai/api/subscriptions/SUBSCRIPTION_ID/usage \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
        "DimensionName": "api_calls",
        "Quantity": 1500,
        "UsageTime": "2026-12-04T00:00:00Z"
      }'
```
```python title="Python"
import requests

r = requests.post(
    f"{BASE}/api/subscriptions/{sub_id}/usage",
    headers={"Authorization": f"Bearer {token}"},
    json={"DimensionName": "api_calls", "Quantity": 1500,
          "UsageTime": "2026-12-04T00:00:00Z"},
)
payload = r.json()
if payload["Status"] != "SUCCESS":
    raise RuntimeError(payload.get("ErrorMessage"))
```
```javascript title="Node"
const r = await fetch(`${BASE}/api/subscriptions/${subId}/usage`, {
  method: "POST",
  headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json" },
  body: JSON.stringify({
    DimensionName: "api_calls",
    Quantity: 1500,
    UsageTime: "2026-12-04T00:00:00Z",
  }),
});
const payload = await r.json();
if (payload.Status !== "SUCCESS") throw new Error(payload.ErrorMessage);
```
```csharp title="C#"
var body = new StringContent(
    "{\"DimensionName\":\"api_calls\",\"Quantity\":1500,\"UsageTime\":\"2026-12-04T00:00:00Z\"}",
    System.Text.Encoding.UTF8, "application/json");
var resp = await client.PostAsync($"/api/subscriptions/{subId}/usage", body);
```
:::


Posting from a CRM or external billing source has a parallel V2 endpoint that takes an `origin` (such as the system you post from):

```
POST /api/v2/subscriptions/{origin}/usagepost
GET  /api/v2/subscriptions/{origin}/usagepost/{subscriptionId}   # read what was posted
```

See the [API reference](/developers/api-reference) for the exact V1 vs V2 shapes and choose one for your integration.

## Post usage in bulk

To upload many records at once rather than one call per record, use the batch endpoints:

- `POST /api/batchusage/bulkupload` — submit a batch; this creates a job.
- `GET /api/batchusage/joblog` — list batch jobs and their status.
- `GET /api/batchusage/{jobLogID}/usagehistory` — see the per-record result of one job.

Batch upload is asynchronous: submit, then poll the job log (gently — see [Rate limits](/developers/rate-limits)) until the job completes, and read the usage history to find any rejected rows.

## Confirm it posted

Read back what SaaSify recorded:

- `GET /api/subscriptions/subscriptionmeteredusage/{subscriptionId}` — metered usage recorded for a subscription.

A usage post can succeed into SaaSify but still be rejected later by the cloud. SaaSify raises a `UsagePostingFailed` event you can subscribe to — see [Webhooks](/developers/webhooks).

## Per-cloud notes

::::tabs
:::tab[AWS Marketplace]
Usage is forwarded to AWS Marketplace metering. AWS has a dedicated meter-post path (`api/aws/postmeterusage`) in addition to the subscription usage endpoint. AWS meters by dimension; report against the dimension names configured on the plan.
:::
:::tab[Microsoft Marketplace]
Usage is forwarded to the Microsoft commercial marketplace metered-billing API. Report against the plan's dimensions. Microsoft rejects usage posted outside the allowed reporting window, so post promptly for each hour/period.
:::
:::tab[Google Cloud Marketplace]
Usage is forwarded to Google Cloud Marketplace usage reporting. You can read posting transactions with `GET /api/subscriptions/transactions/gcp/{subscriptionId}`.
:::
::::


## Related

::::cards
:::card[Metering and usage]{href="/concepts/metering-and-usage"}
The concept, per cloud.
:::
:::card[Webhooks]{href="/developers/webhooks"}
Get notified when a usage post fails.
:::
:::card[API reference]{href="/developers/api-reference"}
Exact usage-posting schemas.
:::
::::
