KWNللمطورينEnglishافتح KWN

مرجع الواجهة البرمجية

إرسال الفواتير (قديم)

أول مسار في الواجهة، باقٍ كما هو للأنظمة التي تستخدمه. التكاملات الجديدة تستخدم فواتير المورّدين.

الأوصاف التقنية أدناه بالإنجليزية كما يولّدها خادم الواجهة، وهي اللغة التي تُكتب بها رسائل الأخطاء أيضًا. العناوين والجداول بالعربية.

إرسال فاتورة مورّد (الطريقة القديمة)

POST/bills

يتطلب
purchases.write
النطاقات
purchase:write

Drafts a vendor bill with no VAT, matching the vendor by TRN and then by name, or creating it. Sending it again with the same vendor reference — or, for a bill with no reference, the same Idempotency-Key header — returns the first bill with duplicate: true. A bill with VAT is made from a purchase order: POST /api/v1/purchase-orders/{id}/bills.

المعاملات

الحقلالنوعالوصف
Idempotency-Keyالترويسةstring

جسم الطلب

16 حقلًا
الحقلالنوعالوصف
vendorobject
vendor.namestring
vendor.trnstring
vendor.emailstring
vendor.phonestring
referencestring
billDatedate
dueDatedate
linesobject[]
lines[].descriptionstring
lines[].quantitynumber
lines[].unitPricenumber
lines[].discountnumber
lines[].uomstring
lines[].productCodestring
notesstring

أمثلة برمجية

curl -sS -X POST "https://app.kwn.tax/api/v1/bills" \
  -H "X-Api-Key: $KWN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "vendor": {
    "name": "Gulf Office Supplies L.L.C.",
    "trn": "100456789100003"
  },
  "reference": "GOS-INV-88213",
  "billDate": "2026-10-12",
  "dueDate": "2026-11-11",
  "lines": [
    {
      "description": "A4 copier paper, box of 5 reams",
      "quantity": 20,
      "unitPrice": 95
    }
  ]
}'

الاستجابات

  • 200OK
    الحقلالنوعالوصف
    idstring
    numberstring
    statusDRAFT | SENT | CONFIRMED | RECEIVED | POSTED | PAID | CANCELLED
    subtotalnumber
    taxTotalnumber
    totalnumber
    duplicateboolean
  • 201Created
    الحقلالنوعالوصف
    idstring
    numberstring
    statusDRAFT | SENT | CONFIRMED | RECEIVED | POSTED | PAID | CANCELLED
    subtotalnumber
    taxTotalnumber
    totalnumber
    duplicateboolean
  • 400Refused: the request or a business rule. The code says which (REQUEST_INVALID, RULE_REFUSED, …).
    مثال
    {
      "error": "Lines: at least one line is required.",
      "code": "REQUEST_INVALID"
    }
  • 401No key, a key that is not ours, or one revoked (API_KEY_INVALID); a merchant not active (MERCHANT_INACTIVE).
    مثال
    {
      "error": "That API key is not valid, or it was revoked.",
      "code": "API_KEY_INVALID"
    }
  • 403The key's scopes do not carry the capability (APP_NOT_GRANTED, ROLE_TOO_LOW), or the plan lacks the app (APP_LOCKED).
    مثال
    {
      "error": "This key's scopes do not include sales.approve.",
      "code": "ROLE_TOO_LOW"
    }
  • 404Not found: another type under this route, or another company's (NOT_FOUND).
    مثال
    {
      "error": "Not found.",
      "code": "NOT_FOUND"
    }
  • 409A conflict: an externalId taken, or a change that could not be saved (EXTERNAL_ID_TAKEN, CONFLICT).
    مثال
    {
      "error": "That externalId is already used by another record of this company.",
      "code": "EXTERNAL_ID_TAKEN"
    }
  • 429Too many requests: wait retryAfter seconds (RATE_LIMITED).
    مثال
    {
      "error": "Too many requests. Wait a little and try again.",
      "code": "RATE_LIMITED"
    }