# 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="/files/8CxTWPGuQCdaKrOD6Y10" 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="/files/XiIi5apatPfxcdTNRh5a" alt=""><figcaption></figcaption></figure>


---

# 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.received.ai/enterprise-contract-billing/the-enterprise-contract-billing-process/automate-invoicing.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.
