# Automate Invoicing

## Step 1: Track Usage (for usage-based products)

In the event that a contract includes a **usage-based product**, Received's **usage API** automatically **tracks and calculates usage rates** for each customer per billing cycle.

This API is provided by Received, and **embedded into your software**, enabling automatic usage tracking.\
\
Our embeddable API looks like this:

```
usage_event = {
  "timestamp": "2024-02-05T08:55:32.160Z",
  "customer_ref": "4096966d-5c1c-4e18-8b47-6a365e3c16ea",
  "customer_name": "ACME",
  "usage_product_ref": "bb50da07-c686-4688-8550-66305e17aab0",
  "usage_product_name": "Units",
  "quantity": 10,
  "additional_report_data": {
    "note": "User-specific note"
  },
  "validations": {
    "currency": "USD",
    "entity_ref": "55899733-32a0-4912-9d2e-a5b0f04dcdb6"
  }
}

event_report_resp = requests.post('https://api.received.ai/api/usage/event', headers=headers, data=json.dumps(usage_event))
```

Once this API is embedded, usage is tracked and collected by Received. When it's time to invoice customers, Received's **internal API collects the relevant data** and calculates the total due for each specific product in the contract.

Our API looks like this:

```
// POST/api/usage/event
```

#### Request Body

Example Value

```
{
  "timestamp": "2024-02-05T09:02:27.279Z",
  "customer_ref": "b4fe1e43-321f-479c-aee7-c11d73616ff2",
  "customer_name": "ACME",
  "usage_product_ref": "9db3fbc3-5e77-43c8-828f-bc2b69cbc9f3",
  "usage_product_name": "Units",
  "quantity": 10,
  "additional_report_data": {
    "note": "User-specific note"
  },
  "validations": {
    "currency": "USD",
    "entity_ref": "d78bf43b-e76a-4a70-8f56-d3dfcea0dffe"
  }
}
```

#### Responses

Example Value

```
{
  "timestamp": "2024-02-05T09:02:27.279Z",
  "customer_ref": "b4fe1e43-321f-479c-aee7-c11d73616ff2",
  "customer_name": "ACME",
  "usage_product_ref": "9db3fbc3-5e77-43c8-828f-bc2b69cbc9f3",
  "usage_product_name": "Units",
  "quantity": 10,
  "additional_report_data": {
    "note": "User-specific note"
  },
  "validations": {
    "currency": "USD",
    "entity_ref": "d78bf43b-e76a-4a70-8f56-d3dfcea0dffe"
  }
}
```

## Step 2: Automatic Invoicing&#x20;

When the issue date is reached, Received's system **calculates the total amount due** for each product in the contract and **sends out invoices** to customers. Depending on each contract's settings, invoices can be sent **separately for each product**, or as one **collective invoice** for the entire contract.

<figure><img src="https://353618749-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5hOxCDd4OuyqtVEtphDN%2Fuploads%2FZvQbmeCRopdCk8N2E6ox%2F64eb00a16ff3fda1ff670ca6_B2B%20Billing%20Automation-p-800%20(1).png?alt=media&#x26;token=85534ae8-ede7-40e4-a6ed-fb3162ec1dee" alt=""><figcaption></figcaption></figure>

## Step 3: Payment Collection

Customers can pay their invoices by credit card (via Stripe), wire transfer, or crypto wallet.&#x20;

Upon payment, Received's system automatically matches incoming payments with outstanding invoices for **seamless reconciliation** and automatically **recognizes revenue** according to **ASC-606 and IFRS-15** compliance.<br>

<figure><img src="https://353618749-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5hOxCDd4OuyqtVEtphDN%2Fuploads%2FMbc5cIKoGD5N8h1ZYay4%2Fddd.png?alt=media&#x26;token=c55e8828-4210-40c7-bf0f-35d1ebea629c" alt=""><figcaption></figcaption></figure>
