> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dolfinai.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Quick Start - AR

> Send your first invoice in four API calls

This guide walks through the end-to-end flow of sending an invoice via the Dolfin API. You'll create a customer, create a product, create an invoice, and send it.

## Prerequisites

* A Dolfin **API key**
* An **organisation** already provisioned (see [Client Integration](/guides/client-integration))
* A valid **session token** or API key for authentication

<Note>
  All requests below require the `x-dolfin-api-key` and `x-dolfin-organisation-id` headers. See [Authentication](/guides/authentication) for details.
</Note>

## Overview

<Steps>
  <Step title="Create a customer">
    Add the customer who will receive the invoice.
  </Step>

  <Step title="Create a product">
    Define the product or service you're billing for.
  </Step>

  <Step title="Create an invoice">
    Build a draft invoice with line items referencing the customer and product.
  </Step>

  <Step title="Send the invoice">
    Mark the invoice as sent and deliver it to the customer.
  </Step>
</Steps>

***

## Step 1: Create a Customer

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.dolfinai.co/customers \
    -H "x-dolfin-api-key: dol_live_abc123" \
    -H "x-dolfin-organisation-id: 9a658587-fe02-402e-b1ac-bfaf53274ef8" \
    -H "Content-Type: application/json" \
    -d '{
      "name": "Riverside Construction Ltd",
      "email": "accounts@riverside.co.uk",
      "addressLine1": "45 Thames Street",
      "city": "London",
      "postalCode": "SE1 2AQ",
      "country": "GB"
    }'
  ```

  ```javascript Node.js theme={null}
  const customer = await fetch('https://api.dolfinai.co/customers', {
    method: 'POST',
    headers: {
      'x-dolfin-api-key': 'dol_live_abc123',
      'x-dolfin-organisation-id': '9a658587-fe02-402e-b1ac-bfaf53274ef8',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      name: 'Riverside Construction Ltd',
      email: 'accounts@riverside.co.uk',
      addressLine1: '45 Thames Street',
      city: 'London',
      postalCode: 'SE1 2AQ',
      country: 'GB',
    }),
  }).then(r => r.json());
  ```
</CodeGroup>

**Response:**

```json theme={null}
{
  "id": "c3456789-abcd-ef01-2345-6789abcdef01",
  "organisationId": "9a658587-fe02-402e-b1ac-bfaf53274ef8",
  "name": "Riverside Construction Ltd",
  "email": "accounts@riverside.co.uk",
  "addressLine1": "45 Thames Street",
  "city": "London",
  "postalCode": "SE1 2AQ",
  "country": "GB",
  "createdAt": "2025-01-20T09:00:00Z",
  "updatedAt": "2025-01-20T09:00:00Z"
}
```

<Note>
  Save the customer `id` - you'll need it when creating the invoice.
</Note>

***

## Step 2: Create a Product

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.dolfinai.co/products \
    -H "x-dolfin-api-key: dol_live_abc123" \
    -H "x-dolfin-organisation-id: 9a658587-fe02-402e-b1ac-bfaf53274ef8" \
    -H "Content-Type: application/json" \
    -d '{
      "name": "Emergency Boiler Repair",
      "description": "Callout and repair for domestic boiler systems",
      "unitPrice": 150.00,
      "currency": "GBP",
      "type": "Service"
    }'
  ```

  ```javascript Node.js theme={null}
  const product = await fetch('https://api.dolfinai.co/products', {
    method: 'POST',
    headers: {
      'x-dolfin-api-key': 'dol_live_abc123',
      'x-dolfin-organisation-id': '9a658587-fe02-402e-b1ac-bfaf53274ef8',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      name: 'Emergency Boiler Repair',
      description: 'Callout and repair for domestic boiler systems',
      unitPrice: 150.00,
      currency: 'GBP',
      type: 'Service',
    }),
  }).then(r => r.json());
  ```
</CodeGroup>

**Response:**

```json theme={null}
{
  "id": "d4567890-abcd-ef01-2345-6789abcdef01",
  "organisationId": "9a658587-fe02-402e-b1ac-bfaf53274ef8",
  "name": "Emergency Boiler Repair",
  "description": "Callout and repair for domestic boiler systems",
  "unitPrice": 150.00,
  "currency": "GBP",
  "type": "Service",
  "createdAt": "2025-01-20T09:01:00Z",
  "updatedAt": "2025-01-20T09:01:00Z"
}
```

<Note>
  Save the product `id` - you'll reference it in the invoice line items. The `type` field accepts `Product` or `Service`.
</Note>

***

## Step 3: Create an Invoice

Create a draft invoice that ties together the customer and product. The `lineItems` array references the product by its `id`.

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.dolfinai.co/invoices \
    -H "x-dolfin-api-key: dol_live_abc123" \
    -H "x-dolfin-organisation-id: 9a658587-fe02-402e-b1ac-bfaf53274ef8" \
    -H "Content-Type: application/json" \
    -d '{
      "customerId": "c3456789-abcd-ef01-2345-6789abcdef01",
      "currency": "GBP",
      "dueDate": "2025-02-20T00:00:00Z",
      "memo": "Boiler repair at 12 Oak Lane - January 2025",
      "lineItems": [
        {
          "productId": "d4567890-abcd-ef01-2345-6789abcdef01",
          "quantity": 2
        }
      ]
    }'
  ```

  ```javascript Node.js theme={null}
  const invoice = await fetch('https://api.dolfinai.co/invoices', {
    method: 'POST',
    headers: {
      'x-dolfin-api-key': 'dol_live_abc123',
      'x-dolfin-organisation-id': '9a658587-fe02-402e-b1ac-bfaf53274ef8',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      customerId: 'c3456789-abcd-ef01-2345-6789abcdef01',
      currency: 'GBP',
      dueDate: '2025-02-20T00:00:00Z',
      memo: 'Boiler repair at 12 Oak Lane - January 2025',
      lineItems: [
        {
          productId: 'd4567890-abcd-ef01-2345-6789abcdef01',
          quantity: 2,
        },
      ],
    }),
  }).then(r => r.json());
  ```
</CodeGroup>

**Response:**

```json theme={null}
{
  "id": "e5678901-abcd-ef01-2345-6789abcdef01",
  "organisationId": "9a658587-fe02-402e-b1ac-bfaf53274ef8",
  "customerId": "c3456789-abcd-ef01-2345-6789abcdef01",
  "documentNumber": "INV-0001",
  "currency": "GBP",
  "issueDate": "2025-01-20T09:02:00Z",
  "dueDate": "2025-02-20T00:00:00Z",
  "status": "Draft",
  "subTotal": 300.00,
  "taxAmount": 0,
  "totalAmount": 300.00,
  "memo": "Boiler repair at 12 Oak Lane - January 2025",
  "lineItems": [
    {
      "productId": "d4567890-abcd-ef01-2345-6789abcdef01",
      "quantity": 2
    }
  ],
  "createdAt": "2025-01-20T09:02:00Z",
  "updatedAt": "2025-01-20T09:02:00Z"
}
```

The invoice is created in **Draft** status. You can add a `taxRateId` to each line item if you need to apply tax.

***

## Step 4: Send the Invoice

Send the draft invoice to the customer. This marks it as sent and delivers it, this will also set the issue date of the invoice.

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.dolfinai.co/invoices/e5678901-abcd-ef01-2345-6789abcdef01/send \
    -H "x-dolfin-api-key: dol_live_abc123" \
    -H "x-dolfin-organisation-id: 9a658587-fe02-402e-b1ac-bfaf53274ef8"
  ```

  ```javascript Node.js theme={null}
  const sentInvoice = await fetch(
    'https://api.dolfinai.co/invoices/e5678901-abcd-ef01-2345-6789abcdef01/send',
    {
      method: 'POST',
      headers: {
        'x-dolfin-api-key': 'dol_live_abc123',
        'x-dolfin-organisation-id': '9a658587-fe02-402e-b1ac-bfaf53274ef8',
      },
    }
  ).then(r => r.json());
  ```
</CodeGroup>

**Response:**

```json theme={null}
{
  "id": "e5678901-abcd-ef01-2345-6789abcdef01",
  "organisationId": "9a658587-fe02-402e-b1ac-bfaf53274ef8",
  "customerId": "c3456789-abcd-ef01-2345-6789abcdef01",
  "documentNumber": "INV-0001",
  "currency": "GBP",
  "issueDate": "2025-01-20T09:02:00Z",
  "dueDate": "2025-02-20T00:00:00Z",
  "status": "Sent",
  "subTotal": 300.00,
  "taxAmount": 0,
  "totalAmount": 300.00,
  "memo": "Boiler repair at 12 Oak Lane - January 2025",
  "createdAt": "2025-01-20T09:02:00Z",
  "updatedAt": "2025-01-20T09:03:00Z"
}
```

The invoice status changes from `Draft` to `Sent`.

***

## Summary

| Step | Endpoint                   | What it does                           |
| ---- | -------------------------- | -------------------------------------- |
| 1    | `POST /customers`          | Create the customer to bill            |
| 2    | `POST /products`           | Define the product or service          |
| 3    | `POST /invoices`           | Create a draft invoice with line items |
| 4    | `POST /invoices/{id}/send` | Send the invoice to the customer       |

## Next Steps

<CardGroup cols={2}>
  <Card title="API Reference" icon="code" href="/api-reference/introduction">
    Explore the full API reference for all endpoints.
  </Card>

  <Card title="Client Integration" icon="rocket" href="/guides/client-integration">
    Set up organisation provisioning and user authentication.
  </Card>
</CardGroup>
