Skip to main content

Overview

Customer data is managed as part of invoice creation and updates. There is no separate customer API endpoint. Customer information is embedded within invoice objects.

Customer object structure

The customer object is included in every invoice and contains the following fields:
id
string
required
Unique customer identifier
name
string
required
Customer or company name
email
string
required
Customer email address for invoice delivery
address
string
required
Street address
city
string
required
City
state
string
required
State or province
zipCode
string
required
Postal or ZIP code
country
string
required
Country name
Optional URL to customer logo image

Example customer object

{
  "id": "cust_123",
  "name": "Acme Corporation",
  "email": "[email protected]",
  "address": "123 Main Street",
  "city": "New York",
  "state": "NY",
  "zipCode": "10001",
  "country": "USA",
  "logo": "https://example.com/logos/acme.png"
}

Working with customers

Creating an invoice with customer data

When creating an invoice, include the complete customer object in the request body:
curl -X POST https://your-domain.com/api/invoices \
  -H "Content-Type: application/json" \
  -d '{
    "invoiceNumber": "INV-001",
    "date": "2026-03-03",
    "dueDate": "2026-03-17",
    "status": "draft",
    "customer": {
      "id": "cust_123",
      "name": "Acme Corporation",
      "email": "[email protected]",
      "address": "123 Main Street",
      "city": "New York",
      "state": "NY",
      "zipCode": "10001",
      "country": "USA"
    },
    "items": [],
    "currency": "USD"
  }'

Updating customer information

To update customer information for an existing invoice, use the PATCH endpoint:
curl -X PATCH https://your-domain.com/api/invoices/inv_123 \
  -H "Content-Type: application/json" \
  -d '{
    "customer": {
      "email": "[email protected]",
      "address": "456 New Address"
    }
  }'

Using customer data in templates

Templates can include partial customer data that will be pre-filled when creating new invoices:
const template = {
  name: "Monthly Consulting Template",
  customer: {
    name: "Acme Corporation",
    email: "[email protected]"
    // Other fields can be filled in when using the template
  },
  // ... other template fields
};

Storage implementation

Currently, the Invoice Generator application uses localStorage on the client side to store customer data. Customer information persists as part of invoice objects and can be reused across multiple invoices. When implementing a database backend, consider:
  • Creating a separate customers table for normalized data storage
  • Linking invoices to customers via foreign key relationships
  • Implementing a dedicated customer API for CRUD operations
  • Adding customer search and filtering capabilities
See the type definitions at app/lib/types.ts:6-16 for the complete Customer interface.

Build docs developers (and LLMs) love