ادمج CleverInvo في سير عملك. قم بإدارة العملاء وإنشاء الفواتير وتنزيل ملفات PDF برمجياً.
تتطلب جميع طلبات API رمز Bearer. أنشئ مفتاح API من لوحة التحكم، ثم قم بتضمينه في رأس Authorization.
curl -X GET https://cleverinvo.com/api/v1/clients \ -H "Authorization: Bearer cinv_your_api_key"
/api/v1/clientsعرض جميع العملاء النشطين. يدعم التصفح والبحث.
{
"data": [
{
"id": "clx...",
"name": "Acme Corp",
"email": "[email protected]",
"address": "123 Main St, New York, NY 10001",
"taxId": "US-123456789",
"phone": "+1-555-0100",
"notes": "Net 30 terms",
"isActive": true,
"createdAt": "2024-01-15T00:00:00.000Z",
"updatedAt": "2024-01-15T00:00:00.000Z"
}
],
"total": 1,
"page": 1,
"limit": 20,
"totalPages": 1
}/api/v1/clientsإنشاء عميل جديد. يخضع لحد العملاء في خطتك.
{
"name": "Acme Corp",
"email": "[email protected]",
"address": "123 Main St, New York, NY 10001",
"taxId": "US-123456789",
"phone": "+1-555-0100",
"notes": "Net 30 terms"
}{
"data": {
"id": "clx...",
"name": "Acme Corp",
"email": "[email protected]",
"address": "123 Main St, New York, NY 10001",
"taxId": "US-123456789",
"phone": "+1-555-0100",
"notes": "Net 30 terms",
"isActive": true,
"createdAt": "2024-01-15T00:00:00.000Z",
"updatedAt": "2024-01-15T00:00:00.000Z"
}
}/api/v1/clients/:idالحصول على عميل واحد بواسطة المعرف.
{
"data": {
"id": "clx...",
"name": "Acme Corp",
"email": "[email protected]",
"address": "123 Main St, New York, NY 10001",
"taxId": "US-123456789",
"phone": "+1-555-0100",
"notes": "Net 30 terms",
"isActive": true,
"createdAt": "2024-01-15T00:00:00.000Z",
"updatedAt": "2024-01-15T00:00:00.000Z"
}
}/api/v1/clients/:idتحديث عميل. يمكن تعديل جميع الحقول.
{
"name": "Acme Corporation",
"email": "[email protected]",
"phone": "+1-555-0200"
}{
"data": {
"id": "clx...",
"name": "Acme Corporation",
"email": "[email protected]",
"address": "123 Main St, New York, NY 10001",
"taxId": "US-123456789",
"phone": "+1-555-0200",
"notes": "Net 30 terms",
"isActive": true,
"createdAt": "2024-01-15T00:00:00.000Z",
"updatedAt": "2024-06-01T00:00:00.000Z"
}
}/api/v1/clients/:idحذف ناعم لعميل. يضبط isActive على false. لا يمكن حذف العملاء الذين لديهم فواتير حالية بشكل نهائي.
204 No Content
/api/v1/invoicesعرض الفواتير. يدعم التصفح والبحث والتصفية حسب clientId أو الحالة.
{
"data": [
{
"id": "clx...",
"clientId": "clx...",
"invoiceNumber": "INV-0001",
"currency": "USD",
"issueDate": "2024-06-01",
"dueDate": "2024-07-01",
"subtotal": 5000.00,
"taxTotal": 500.00,
"discountTotal": 0,
"total": 5500.00,
"status": "SENT",
"createdAt": "2024-06-01T00:00:00.000Z",
"client": {
"name": "Acme Corp",
"email": "[email protected]"
}
}
],
"total": 1,
"page": 1,
"limit": 20,
"totalPages": 1
}/api/v1/invoicesإنشاء فاتورة وتوليد PDF تلقائياً. يخضع لحدود الخطة.
{
"clientId": "clx...",
"invoiceNumber": "INV-0042",
"currency": "USD",
"issueDate": "2024-06-01",
"dueDate": "2024-07-01",
"lineItems": [
{
"description": "Web Development",
"quantity": 40,
"unitPrice": 125.00,
"taxRate": 10
}
],
"notes": "Thank you for your business",
"terms": "Payment due within 30 days"
}{
"data": {
"id": "clx...",
"invoiceNumber": "INV-0042",
"total": 5500.00,
"status": "DRAFT"
}
}/api/v1/invoices/:idالحصول على تفاصيل الفاتورة الكاملة بما في ذلك البنود ومعلومات العميل.
{
"data": {
"id": "clx...",
"clientId": "clx...",
"invoiceNumber": "INV-0042",
"currency": "USD",
"issueDate": "2024-06-01",
"dueDate": "2024-07-01",
"lineItems": [
{
"description": "Web Development",
"quantity": 40,
"unitPrice": 125.00,
"amount": 5000.00,
"taxRate": 10
}
],
"subtotal": 5000.00,
"taxTotal": 500.00,
"discountTotal": 0,
"total": 5500.00,
"status": "SENT",
"notes": "Thank you for your business",
"terms": "Payment due within 30 days",
"sentViaEmail": true,
"sentAt": "2024-06-01T12:00:00.000Z",
"paidAt": null,
"createdAt": "2024-06-01T00:00:00.000Z",
"client": {
"name": "Acme Corp",
"email": "[email protected]"
}
}
}/api/v1/invoices/:idتحديث فاتورة. يمكن تعديل الفواتير المسودة فقط.
{
"dueDate": "2024-07-15",
"lineItems": [
{
"description": "Web Development",
"quantity": 50,
"unitPrice": 125.00,
"taxRate": 10
}
],
"notes": "Updated scope"
}{
"data": {
"id": "clx...",
"invoiceNumber": "INV-0042",
"total": 6875.00,
"status": "DRAFT"
}
}/api/v1/invoices/:idحذف الفاتورة وملف PDF المُنشأ بشكل دائم.
204 No Content
/api/v1/invoices/:id/pdfتنزيل الفاتورة كملف PDF. يُرجع PDF ثنائي مع رأس Content-Disposition.
Content-Type: application/pdf Content-Disposition: attachment; filename="INV-0042.pdf" <binary PDF data>
تقبل نقاط نهاية القائمة معاملات الاستعلام التالية:
| المعامل | الافتراضي | الوصف |
|---|---|---|
| page | 1 | رقم الصفحة (الحد الأدنى: 1) |
| limit | 20 | العناصر لكل صفحة (1–100) |
| search | — | التصفية بالاسم أو البريد الإلكتروني أو رقم الفاتورة (بحد أقصى 255 حرفاً) |
| clientId | — | تصفية الفواتير حسب العميل (الفواتير فقط) |
| status | — | التصفية حسب الحالة: DRAFT، SENT، VIEWED، PAID، PARTIALLY_PAID، OVERDUE |
GET /api/v1/clients?page=2&limit=10&search=acme
تُرجع API رموز حالة HTTP القياسية. تتضمن استجابات الخطأ نص JSON مع حقل error.
| الحالة | الوصف |
|---|---|
| 400 | Bad Request — معاملات غير صالحة أو حقول مطلوبة مفقودة |
| 401 | Unauthorized — مفتاح API غير صالح أو مفقود |
| 403 | Forbidden — تم الوصول إلى حد الخطة (العملاء أو الفواتير أو الميزة) |
| 404 | Not Found — المورد غير موجود أو غير قابل للوصول |
| 429 | Too Many Requests — تم تجاوز حد المعدل |
| 500 | Internal Server Error — فشل غير متوقع، حاول مرة أخرى لاحقاً |
{
"error": "Missing required field: name"
}طلبات API محدودة بـ 120 طلباً في الدقيقة لكل مفتاح API.
عند تجاوز الحد، تُرجع الطلبات 429 Too Many Requests. انتظر قبل إعادة المحاولة.