BillOS v1
Console llms.txt OpenAPI
POST/businesses/{bid}/documents

Create a draft

POST /businesses/{bid}/documents

Requires the documents scope.

A draft is a קובץ זמני, not a tax document: no number is consumed and any rendering of it is watermarked "טיוטה". Patch and delete it freely until you issue.

Always send an idempotency key. A double-click or a network retry then returns the same draft with deduped: true instead of opening a second one.

Path parameters

NameTypeDescription
bidstringrequiredBusiness id, from POST /businesses.

Headers

NameTypeDescription
Idempotency-KeystringYour own stable id for this call. A retry returns the same row with deduped: true instead of creating a duplicate. Interchangeable with externalRef in the body.

Body

FieldTypeDescription
docTypeintegerrequired305 / 320 / 400. A 330 is created only through the credit-note endpoint. One of: 305, 320, 400.
partyobject{partyId} to reference a saved party, or an inline {name, taxId?, phone?, email?, address?}. Omit entirely for an anonymous cash receipt.
party.partyIdstring
party.namestring
party.taxIdstring
party.phonestring
party.emailstring
party.addressstring
priceModestringnet (the default: line prices are ex-VAT) or gross (line prices include VAT; the total anchors to the gross sum and VAT is derived). Gross is what a consumer-facing price list wants. One of: net, gross. Default net.
linesarray of DocumentLineRequired for 305/320.
paymentsarray of PaymentRequired for 320/400.
notestring≤500 chars.
documentDatestringDefaults to today, Asia/Jerusalem.
valueDatestringDefaults to today.
discountAmountintegerDocument-level discount. Integer agorot (₪1 = 100).
withholdingAmountintegerניכוי במקור. Integer agorot (₪1 = 100).
allocationNumberstringמספר הקצאה, when you already hold one.
externalRefstringIdempotency key, interchangeable with the Idempotency-Key header.

Response

201: { "ok": true, … }

FieldTypeDescription
okbooleanrequired
documentDocumentrequiredA draft is freely mutable. An issued document is immutable forever, blocked at the database engine, not merely in application code.
dedupedbooleanPresent and true when this call matched an earlier one.

Errors: 400, 401, 403, 404, 429. Every failure answers { "error": …, "reason": … }. Branch on reason.

POST /businesses/{bid}/documents
curl -X POST "$BASE/businesses/$BID/documents" \
  -H "X-Api-Key: $KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "docType": 320,
    "party": {
      "name": "דנה לוי",
      "taxId": "514667426",
      "phone": "0521111111",
      "email": "dana@example.com",
      "address": "הרצל 12, תל אביב"
    },
    "priceMode": "gross",
    "lines": [
      {
        "description": "איפור כלה",
        "quantity": 1,
        "unitPriceExVat": 120000
      }
    ],
    "payments": [
      {
        "method": 3,
        "amount": 190000
      }
    ],
    "externalRef": "order-8812"
  }'
const res = await fetch(`${BASE}/businesses/${BID}/documents`, {
  method: 'POST',
  headers: {
    'X-Api-Key': KEY,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "docType": 320,
    "party": {
      "name": "דנה לוי",
      "taxId": "514667426",
      "phone": "0521111111",
      "email": "dana@example.com",
      "address": "הרצל 12, תל אביב"
    },
    "priceMode": "gross",
    "lines": [
      {
        "description": "איפור כלה",
        "quantity": 1,
        "unitPriceExVat": 120000
      }
    ],
    "payments": [
      {
        "method": 3,
        "amount": 190000
      }
    ],
    "externalRef": "order-8812"
  }),
})
const data = await res.json()
if (!data.ok) throw new Error(data.reason)
import requests
res = requests.post(
    f"{BASE}/businesses/{BID}/documents",
    headers={"X-Api-Key": KEY},
    json={
      "docType": 320,
      "party": {
        "name": "דנה לוי",
        "taxId": "514667426",
        "phone": "0521111111",
        "email": "dana@example.com",
        "address": "הרצל 12, תל אביב"
      },
      "priceMode": "gross",
      "lines": [
        {
          "description": "איפור כלה",
          "quantity": 1,
          "unitPriceExVat": 120000
        }
      ],
      "payments": [
        {
          "method": 3,
          "amount": 190000
        }
      ],
      "externalRef": "order-8812"
    },
)
data = res.json()
Set BASE to https://api.billos.co.il/v1 and KEY to your bk_live_… key, or a bk_test_… key to run it against the sandbox.
Manage your businesses, keys and webhooks in the BillOS Console.