# Creating Sales Invoices

Create and send professional sales invoices directly from your application when orders are placed in your system.

## Overview

Sales invoices are the primary billing documents you send to customers for products or services. This integration pattern is ideal when:

- You process payments elsewhere but want Moneybird to handle invoice generation
- You need to create invoices that will be paid later
- You want to maintain professional invoicing while managing orders in your own system

## Prerequisites

- You have an access token and your administration ID. See [Getting started](/integration/getting-started) and [Authentication](/authentication).
- You know the correct `ledger_account_id` and `tax_rate_id` for your revenue. See the API reference for [Ledger accounts](/api/ledger-accounts) and [Tax rates](/api/tax-rates).

## Step-by-step

### 1. Create or Find Contact

Before creating an invoice, ensure you have a contact record in Moneybird. You can either create a new contact or find an existing one.

**Create a new contact:**

When creating a contact, you can store your external system’s contact ID in the `customer_id` field. This makes it easy to look up the contact in Moneybird later using your own identifier.

```bash
curl -X POST "https://moneybird.com/api/v2/{ADMINISTRATION_ID}/contacts.json" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer {ACCESS_TOKEN}" \
  -d '{
    "contact": {
      "company_name": "TechStart Inc.",
      "firstname": "John",
      "lastname": "Smith",
      "address1": "123 Business St",
      "zipcode": "1234 AB",
      "city": "Amsterdam",
      "country": "NL",
      "email": "john@techstart.com",
      "customer_id": "external_id_12345"
    }
  }'
```

**Find existing contact by external customer ID:**

```bash
curl -X GET "https://moneybird.com/api/v2/{ADMINISTRATION_ID}/contacts/customer_id/external_id_12345.json" \
  -H "Authorization: Bearer {ACCESS_TOKEN}"
```


### 2. Create Sales Invoice

Create a sales invoice with all necessary details. Make sure to set the correct ledger account and tax rate IDs to ensure proper bookkeeping.

```bash
curl -X POST "https://moneybird.com/api/v2/{ADMINISTRATION_ID}/sales_invoices.json" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer {ACCESS_TOKEN}" \
  -d '{
    "sales_invoice": {
      "contact_id": "{CONTACT_ID}",
      "reference": "INV-2025-001",
      "invoice_date": "2025-09-16",
      "due_date": "2025-10-16",
      "currency": "EUR",
      "details_attributes": [
        {
          "description": "Premium Software License",
          "price": "299.00",
          "amount": "1",
          "tax_rate_id": "{TAX_RATE_ID}",
          "ledger_account_id": "{LEDGER_ACCOUNT_ID}"
        },
        {
          "description": "Setup Fee",
          "price": "50.00",
          "amount": "1",
          "tax_rate_id": "{TAX_RATE_ID}",
          "ledger_account_id": "{LEDGER_ACCOUNT_ID}"
        }
      ]
    }
  }'
```

### 3. Send Invoice to Customer
Once the invoice is created, [send the invoice](/api/sales-invoices#sends-an-invoice) to your customer via email or other delivery methods like [Peppol](/integration/sending-sales-invoices-peppol). Sending the invoice automatically updates it from `draft` to `open`.

You can also schedule the invoice to be sent later, or use custom delivery methods. 

```bash
curl -X PATCH "https://moneybird.com/api/v2/{ADMINISTRATION_ID}/sales_invoices/{SALES_INVOICE_ID}/send_invoice.json" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer {ACCESS_TOKEN}" \
  -d '{
    "sales_invoice_sending": {
      "delivery_method": "Email",
      "deliver_ubl": true,
      "email_address": "john@techstart.com",
      "email_message": "Dear John, please find your invoice attached. Thank you for your business!"
    }
  }'
```


After sending, the invoice status changes from `draft` to `open`. Track payment status with [Webhooks](/webhooks/getting-started) or retrieve through the API.

## Next Steps

After creating and sending sales invoices, you may want to:

1. Track payment status with [Webhooks](/webhooks/getting-started) or retrieve through the API for reconciliation when payments are received
2. Set up [webhooks](/webhooks/getting-started) for real-time notifications about payment status changes
