مرجع الواجهة البرمجية
أوامر الشراء
أوامر الشراء المؤكدة، تُفوتر عند وصول فاتورة المورّد.
الأوصاف التقنية أدناه بالإنجليزية كما يولّدها خادم الواجهة، وهي اللغة التي تُكتب بها رسائل الأخطاء أيضًا. العناوين والجداول بالعربية.
فوترة أمر شراء
POST/purchase-orders/{id}/bills
أرسل ترويسة Idempotency-Key.
A draft vendor bill for what is not billed yet on the order, with the order's VAT. Requires Idempotency-Key.
المعاملات
| الحقل | النوع | الوصف |
|---|---|---|
idالمسارإلزامي | string | |
Idempotency-Keyالترويسةإلزامي | string | 1 to 100 visible ASCII characters, such as a UUID, unique to this request. Sent again with the same request, the first answer is replayed (Idempotent-Replayed: true); with another request, 422 IDEMPOTENCY_KEY_REUSED. |
أمثلة برمجية
curl -sS -X POST "https://app.kwn.tax/api/v1/purchase-orders/<id>/bills" \
-H "X-Api-Key: $KWN_API_KEY" \
-H "Idempotency-Key: $(uuidgen)"الاستجابات
201Created
الحقل النوع الوصف idstringtypeRFQ | ORDER | BILL | REFUND | DEBIT_NOTEnumberstringstatusDRAFT | SENT | CONFIRMED | RECEIVED | POSTED | PAID | CANCELLEDissueDatedatedueDatedatevendorobjectvendorRefstringbuyerIdstringpaymentTermIdstringnotesstringlinesobject[]subtotalnumberdiscountTotalnumbertaxTotalnumbertotalnumberpaidTotalnumbercreditedTotalnumberoriginMANUAL | API | EINVOICEsourceobjectderivedobject[]externalIdstringduplicatebooleanAlways false here; true only on the legacy push when it answered a bill it already had. createdAtdateupdatedAtdate400Refused: 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" }422That Idempotency-Key was used for a different request (IDEMPOTENCY_KEY_REUSED).
{ "error": "That Idempotency-Key was used for a different request.", "code": "IDEMPOTENCY_KEY_REUSED" }429Too many requests: wait retryAfter seconds (RATE_LIMITED).
{ "error": "Too many requests. Wait a little and try again.", "code": "RATE_LIMITED" }
إلغاء أمر
POST/purchase-orders/{id}/cancel
An order with bills is refused. Cancelled already: alreadyDone.
المعاملات
| الحقل | النوع | الوصف |
|---|---|---|
idالمسارإلزامي | string |
أمثلة برمجية
curl -sS -X POST "https://app.kwn.tax/api/v1/purchase-orders/<id>/cancel" \
-H "X-Api-Key: $KWN_API_KEY"الاستجابات
200OK
الحقل النوع الوصف alreadyDonebooleanTrue when the document was already where the action takes it; nothing changed. documentobject400Refused: 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" }
عرض القائمة
GET/purchase-orders
Newest first, a page at a time. Filter by status, partnerId (the vendor), issueFrom/issueTo, number, externalId, createdFrom/createdTo, or updatedSince.
المعاملات
| الحقل | النوع | الوصف |
|---|---|---|
statusالاستعلام | string | A status, by name. |
partnerIdالاستعلام | string | The customer (sales) or the vendor (purchases). |
issueFromالاستعلام | date | Issued on or after this day. |
issueToالاستعلام | date | Issued on or before this day. |
numberالاستعلام | string | |
limitالاستعلام | integer | 1 to 200; 50 by default. |
cursorالاستعلام | string | The previous page's next. |
updatedSinceالاستعلام | date | Only rows changed at or after this instant. |
createdFromالاستعلام | date | |
createdToالاستعلام | date | |
externalIdالاستعلام | string | Only the row your system gave this id. |
أمثلة برمجية
curl -sS -X GET "https://app.kwn.tax/api/v1/purchase-orders" \
-H "X-Api-Key: $KWN_API_KEY"الاستجابات
200OK
الحقل النوع الوصف dataobject[]The rows of this page. nextstringThe cursor of the next page, to send as ?cursor=; null on the last page. 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" }
قراءة مستند
GET/purchase-orders/{id}
The document with its lines and what it came from and led to. A document of another type under this route is NOT_FOUND.
المعاملات
| الحقل | النوع | الوصف |
|---|---|---|
idالمسارإلزامي | string |
أمثلة برمجية
curl -sS -X GET "https://app.kwn.tax/api/v1/purchase-orders/<id>" \
-H "X-Api-Key: $KWN_API_KEY"الاستجابات
200OK
الحقل النوع الوصف idstringtypeRFQ | ORDER | BILL | REFUND | DEBIT_NOTEnumberstringstatusDRAFT | SENT | CONFIRMED | RECEIVED | POSTED | PAID | CANCELLEDissueDatedatedueDatedatevendorobjectvendorRefstringbuyerIdstringpaymentTermIdstringnotesstringorderDeadlinedateexpectedArrivaldatelinesobject[]subtotalnumberdiscountTotalnumbertaxTotalnumbertotalnumberpaidTotalnumbercreditedTotalnumberoriginMANUAL | API | EINVOICEsourceobjectderivedobject[]externalIdstringcreatedAtdateupdatedAtdate400Refused: 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" }
طباعة
GET/purchase-orders/{id}/pdf
The printed document as the app prints it, in English or Arabic (?lang=ar). Counted against the apikey-heavy budget.
المعاملات
| الحقل | النوع | الوصف |
|---|---|---|
idالمسارإلزامي | string | |
langالاستعلام | string |
أمثلة برمجية
curl -sS -X GET "https://app.kwn.tax/api/v1/purchase-orders/<id>/pdf" \
-H "X-Api-Key: $KWN_API_KEY"الاستجابات
200OK
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" }