Complete Daftora API integration guide
A secure REST API for synchronizing customers, invoices, products, inventory, journal entries, and account balances with your Daftora workspace. Every response is JSON and every key is isolated to one company.
1. Create a key and authenticate
In your company workspace, open Settings → API integration, give the integration a clear name, then select Create API key. The full key is displayed only once.
Authorization: Bearer dft_live_xxxxxxxxxxxxxxxxxxxxBase URL for all requests:
https://yusrplus.com/api/public/v12. Available endpoints
/api/public/v1/customers/api/public/v1/customers/api/public/v1/products/api/public/v1/products/api/public/v1/invoices/api/public/v1/invoices/api/public/v1/accounts/api/public/v1/journal-entries/api/public/v1/journal-entriesList endpoints support limit from 1 to 100 and offset pagination, for example ?limit=50&offset=100.
const response = await fetch(
"https://yusrplus.com/api/public/v1/invoices?limit=50",
{ headers: { Authorization: `Bearer ${process.env.DAFTORA_API_KEY}` } }
);
if (!response.ok) throw new Error(await response.text());
const { data, meta } = await response.json();3. Create customers automatically
Send your own code to keep a stable customer reference across both systems. The code must be unique within the company.
curl -X POST https://yusrplus.com/api/public/v1/customers \
-H "Authorization: Bearer $DAFTORA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"code": "WEB-1001",
"name": "شركة المثال",
"email": "finance@example.com",
"phone": "+201000000000"
}'4. Create and post invoices
Use either customerId or customerCode. Daftora automatically posts a balanced accounting entry when the invoice is created. Supported statuses are draft, sent, partially_paid, paid, overdue, and cancelled.
curl -X POST https://yusrplus.com/api/public/v1/invoices \
-H "Authorization: Bearer $DAFTORA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"customerCode": "WEB-1001",
"number": "STORE-INV-9001",
"totalMinor": 125000,
"paidMinor": 0,
"status": "sent",
"issueDate": "2026-09-09",
"dueDate": "2026-09-23"
}'5. Products and inventory
Creating a product immediately updates inventory screens and valuation. salePriceMinor uses minor units; stockQuantity and reorderLevel are integers.
curl -X POST https://yusrplus.com/api/public/v1/products \
-H "Authorization: Bearer $DAFTORA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"sku": "SKU-500",
"name": "منتج تجريبي",
"salePriceMinor": 49900,
"stockQuantity": 25,
"reorderLevel": 5
}'6. Accounts and journal entries
GET /accounts returns debit, credit, and balance totals by account code. You can also import a journal from another system, provided total debits equal total credits.
curl -X POST https://yusrplus.com/api/public/v1/journal-entries \
-H "Authorization: Bearer $DAFTORA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"reference": "ERP-ENTRY-1007",
"postingDate": "2026-09-09",
"lines": [
{"accountCode":"1100-CASH","debitMinor":50000,"creditMinor":0},
{"accountCode":"4100-SALES","debitMinor":0,"creditMinor":50000}
]
}'| Code | Account |
|---|---|
1100-CASH | Cash |
1200-AR | Accounts receivable |
2100-TAX | VAT payable |
4100-SALES | Sales revenue |
7. Errors and production safety
The API uses standard HTTP codes: 201 created, 401 invalid key or missing scope, 404 missing reference, 409 duplicate record, and 422 validation error.
{
"error": {
"code": "VALIDATION_ERROR",
"message": "totalMinor must be a positive integer"
}
}- Store the key in a server-side environment variable.
- Use a unique invoice number or reference to prevent duplicates during retries.
- Revoke the key immediately from Settings if exposure is suspected.
- Log response codes and error bodies, never the key itself.