Invoice Automation

Guide

Automate your billing workflow from quotation to invoice to receipt using the Glance Documents API.

Document Lifecycle

Glance supports the full document lifecycle:

QuotationOrderDeliveryInvoiceReceipt

Creating an Invoice

Create an invoice with line items, tax calculation, and payment terms:

cURL
curl -X POST https://api.glance.co.il/documents/create/invoice \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "clientId": 1,
    "products": [
      {
        "description": "Web Development Services",
        "units": 40,
        "price": 250,
        "typeOfUnit": "hours"
      },
      {
        "description": "Hosting (Monthly)",
        "units": 1,
        "price": 99
      }
    ],
    "payBy": "2024-04-20",
    "tax": 17,
    "taxMode": "beforeTax",
    "notes": "Payment due within 30 days",
    "sendToClient": true
  }'

Recording Payment

When payment is received, create a receipt and allocate it to the invoice:

Node.js SDK
// 1. Create a receipt
const { data: receipt } = await glance.documents.create("receipt", {
  clientId: 1,
  payments: [{
    amount: 11799,
    paymentMethod: "bankTransfer",
    date: "2024-04-15",
  }],
});

// 2. Allocate receipt to the invoice
await glance.documents.allocate(receipt.visibleId, {
  allocations: [{
    invoiceId: 42,
    amount: 11799,
  }],
});
REST API equivalent
JavaScript
// 1. Create a receipt
const receipt = await fetch(
  "https://api.glance.co.il/documents/create/receipt",
  {
    method: "POST",
    headers: {
      Authorization: `Bearer ${API_KEY}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      clientId: 1,
      payments: [{
        amount: 11799,
        paymentMethod: "bankTransfer",
        date: "2024-04-15",
      }],
    }),
  }
).then(r => r.json());

// 2. Allocate receipt to the invoice
await fetch(
  `https://api.glance.co.il/documents/allocate/${receipt.data.visibleId}`,
  {
    method: "POST",
    headers: {
      Authorization: `Bearer ${API_KEY}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      allocations: [{
        invoiceId: 42,
        amount: 11799,
      }],
    }),
  }
);

Recurring Invoices

For subscription billing, use the Retainers API to set up automatic recurring invoices.