---
title: "Usage margin"
description: "Over meter usage lines of finalized invoices (not voided) dated in the range: revenue = line amount − its discount − its credit notes, before tax; margin = revenue − cost."
canonical_url: "https://twominutebilling.com/help/developers/api-reference/analytics/usage-margin"
---
# Usage margin

> Over meter usage lines of finalized invoices (not voided) dated in the range: revenue = line amount − its discount − its credit notes, before tax; margin = revenue − cost.

<api-operation method="GET" path="/v1/businesses/{biz}/reports/usage_margin">
<template v-slot:docs="">

A line with no full cost is counted in `lines_without_cost` and left out of revenue and cost. One row per group and currency; currencies are never added together. Needs `usage_margin:view`.

## Path parameters

<table>
<thead>
  <tr>
    <th>
      Parameter
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Required
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        biz
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        yes
      </strong>
    </td>
    
    <td>
      The business's id (biz_…).
    </td>
  </tr>
</tbody>
</table>

## Query parameters

<table>
<thead>
  <tr>
    <th>
      Parameter
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Required
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        from
      </code>
    </td>
    
    <td>
      <code>
        string · ISO-8601
      </code>
    </td>
    
    <td>
      <strong>
        yes
      </strong>
    </td>
    
    <td>
      Start, inclusive (RFC 3339).
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        to
      </code>
    </td>
    
    <td>
      <code>
        string · ISO-8601
      </code>
    </td>
    
    <td>
      <strong>
        yes
      </strong>
    </td>
    
    <td>
      End, exclusive (RFC 3339). At most 366 days after <code>
        from
      </code>
      
      .
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        group_by
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      no
    </td>
    
    <td>
      Default <code>
        customer
      </code>
      
      .
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        currency
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      no
    </td>
    
    <td>
      One currency only.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        customer
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      no
    </td>
    
    <td>
      One customer's id (cus_…).
    </td>
  </tr>
</tbody>
</table>

## Response

<table>
<thead>
  <tr>
    <th>
      Field
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        object
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      The object type; always <code>
        usage_margin
      </code>
      
      . One of <code>
        usage_margin
      </code>
      
      .
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        group_by
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      The usage margin's group by. One of <code>
        customer
      </code>
      
      , <code>
        model
      </code>
      
      , <code>
        meter
      </code>
      
      .
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        from
      </code>
    </td>
    
    <td>
      <code>
        string · ISO-8601
      </code>
    </td>
    
    <td>
      The usage margin's from.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        to
      </code>
    </td>
    
    <td>
      <code>
        string · ISO-8601
      </code>
    </td>
    
    <td>
      The usage margin's to.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        data
      </code>
    </td>
    
    <td>
      <code>
        array of object
      </code>
    </td>
    
    <td>
      The rows on this page.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        data.customer
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      The customer's id (cus_…).
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        data.customer_name
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      With <code>
        group_by=customer
      </code>
      
      : the customer's name, else its email.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        data.model
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      The pricing model.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        data.meter
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      The usage margin's meter.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        data.currency
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      The usage margin's currency (ISO-4217 code).
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        data.revenue_minor
      </code>
    </td>
    
    <td>
      <code>
        integer
      </code>
    </td>
    
    <td>
      After discounts and credit notes, before tax.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        data.cost_minor
      </code>
    </td>
    
    <td>
      <code>
        integer
      </code>
    </td>
    
    <td>
      The cost in minor units (integer), e.g. 2900 = $29.00.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        data.margin_minor
      </code>
    </td>
    
    <td>
      <code>
        integer
      </code>
    </td>
    
    <td>
      The margin in minor units (integer), e.g. 2900 = $29.00.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        data.margin_percent
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      The usage margin's margin percent.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        data.lines
      </code>
    </td>
    
    <td>
      <code>
        integer
      </code>
    </td>
    
    <td>
      The usage margin's lines.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        data.lines_without_cost
      </code>
    </td>
    
    <td>
      <code>
        integer
      </code>
    </td>
    
    <td>
      The usage margin's lines without cost.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        totals
      </code>
    </td>
    
    <td>
      <code>
        array of object
      </code>
    </td>
    
    <td>
      The usage margin's totals.
    </td>
  </tr>
</tbody>
</table>

## Status codes

<table>
<thead>
  <tr>
    <th>
      Status
    </th>
    
    <th>
      Meaning
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        200
      </code>
    </td>
    
    <td>
      The margin per group and the totals per currency.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        400
      </code>
    </td>
    
    <td>
      The range is not correct.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        404
      </code>
    </td>
    
    <td>
      No such customer.
    </td>
  </tr>
</tbody>
</table>
</template>

<template v-slot:request="">

```bash [Request]
curl "$TMBILLING_URL/v1/businesses/biz_XXXXXXXXXXXX01/reports/usage_margin?from=2026-03-14T09%3A30%3A00Z&to=2026-04-14T09%3A30%3A00Z" \
  -H "Authorization: Bearer $TMBILLING_API_KEY"
```

</template>

<template v-slot:response="">
<code-group>

```json [200 OK]
{
  "object": "usage_margin",
  "group_by": "customer",
  "from": "2026-03-14T09:30:00Z",
  "to": "2026-04-14T09:30:00Z",
  "data": [
    {
      "customer": "cus_XXXXXXXXXXXX01",
      "customer_name": "Maya Castillo",
      "model": "flat",
      "meter": "Meter",
      "currency": "USD",
      "revenue_minor": 2900
    }
  ],
  "totals": [
    {
      "currency": "USD",
      "revenue_minor": 2900,
      "cost_minor": 2900,
      "margin_minor": 2900,
      "margin_percent": "35.96",
      "lines": 1
    }
  ]
}
```

```json [400 Bad Request]
{
  "error": {
    "type": "invalid_request_error",
    "message": "The range is not correct."
  }
}
```

```json [404 Not Found]
{
  "error": {
    "type": "invalid_request_error",
    "message": "No such customer."
  }
}
```

</code-group>
</template>
</api-operation>


## Sitemap

See the full [sitemap](https://twominutebilling.com/sitemap.md) for all pages.
