Перейти к содержимому
14 дней бесплатно, без карты9 языков176 типов бизнеса · 50 приложений
RU· USD
Попробовать живое демоПопробовать бесплатно

Эта страница пока недоступна на выбранном языке (Русский), поэтому показана на английском.

Create a lead and a draft invoice

Two real write calls with curl and with TypeScript fetch, including an Idempotency-Key for safe retries.

  • about 10 min

Create a lead (curl)

name and phone are required. The lead goes through the same notifications as the website form.

POST /inquiries
curl -X POST "$ZMLE_BASE/inquiries" \
  -H "Authorization: Bearer $ZMLE_KEY" \
  -H "content-type: application/json" \
  -H "Idempotency-Key: lead-landing-000123" \
  -d '{"type":"QUOTE","name":"Aisha Khan","phone":"+971501234567","email":"aisha@example.com","subject":"Villa painting","message":"3 bedrooms, JLT"}'

Create a draft invoice (TypeScript)

Pass a customerId, or customerName / customerEmail / customerPhone / countryCode / customerTaxId. Each line needs title and unitPrice (minor units per unit). Tax is computed exactly as in the admin editor and comes back as subtotal, taxTotal, total and taxBreakdown.

create-invoice.ts (Node 18+)
const BASE = process.env.ZMLE_BASE!; // https://your-workspace.zmle.com/api/v1
const KEY = process.env.ZMLE_KEY!;   // fx_live_… with invoices:write

type Invoice = { id: string; status: string; subtotal: number; taxTotal: number; total: number; currency: string; publicUrl: string };

async function createDraftInvoice(orderRef: string): Promise<Invoice> {
  const res = await fetch(BASE + "/invoices", {
    method: "POST",
    headers: {
      Authorization: "Bearer " + KEY,
      "content-type": "application/json",
      "Idempotency-Key": "invoice-" + orderRef, // a retry replays the first answer
    },
    body: JSON.stringify({
      customerName: "Aisha Khan",
      customerEmail: "aisha@example.com",
      subject: "Kitchen fit-out — stage 1",
      endDate: "2026-11-30T00:00:00.000Z", // due date
      items: [
        { title: "Joinery — kitchen units", quantity: 1, unitPrice: 1850000, itemKind: "material", taxClass: "standard" },
        { title: "Installation labour", quantity: 16, unit: "hour", unitPrice: 15000, itemKind: "labour" },
      ],
    }),
  });
  const body = await res.json();
  if (!res.ok) throw new Error(res.status + " " + body.error?.code + " (request " + res.headers.get("x-request-id") + ")");
  return body.data as Invoice;
}

createDraftInvoice("SO-1042").then((inv) => console.log(inv.id, inv.total / 100, inv.currency, inv.publicUrl));
The invoice is a DRAFT: staff review and issue it in the back office, where it gets its number. The API never sends or marks an invoice paid.

Written from: docs/API.md, src/lib/integrations/openapi.ts, src/lib/api-v1/pipeline.ts