/v1/account

account

الحساب: الرصيد والاستخدام واشتراك الأرصدة ومفاتيح API عبر الـ API.

التكاليف والحدود

التكاليف والحدود
ماذا الأرصدة
قراءة الحساب والرصيد والاستخدام واشتراك الأرصدة مجانًا

الحد: 30 طلب في الدقيقة. الإنشاء والتعديل والحذف: 10 في الدقيقة.

نقاط النهاية

الطريقة
الطريقة المسار الغرض الوصول
GET /v1/account حسابك. مفتاح API
GET /v1/account/credits الرصيد وتواريخ انتهاء الصلاحية. مفتاح API
GET /v1/account/usage الاستخدام في فترة ما، مجموعًا. مفتاح API
GET /v1/account/usage/transactions الطلبات الفردية مع التكاليف. مفتاح API
GET /v1/account/subscription اشتراك الأرصدة الخاص بك. مفتاح API
GET /v1/account/api-keys مفاتيح API الخاصة بك. مفتاح API
POST /v1/account/api-keys مفتاح API جديد. رمز المسؤول
DELETE /v1/account/api-keys/{id} حذف مفتاح API. رمز المسؤول
POST /v1/auth/tokens/create إنشاء Bearer token. مفتاح API
GET · DELETE /v1/auth/tokens عرض Bearer tokens وإلغاؤها. مفتاح API

الحساب

curl -G "https://handelsregister.ai/api/v1/account" \
  -H "x-api-key: YOUR_API_KEY"
1{2  "account": {3    "id": 2,4    "name": "Max Mustermann",5    "email": "[email protected]",6    "email_verified": true,7    "language": "de",8    "plan": "max",9    "member_since": "2026-09-02T17:07:10+00:00"10  },11  "meta": {12    "request_credit_cost": 0,13    "credits_remaining": 14514  }15}
200 · مثال على استجابة لحساب مع Max

الرصيد

curl -G "https://handelsregister.ai/api/v1/account/credits" \
  -H "x-api-key: YOUR_API_KEY"
الحقل
الحقل المعنى
balance.total إجمالي رصيدك.
balance.subscription الأرصدة من اشتراك الأرصدة، بما فيها المنقولة عند تغيير الخطة (rollover).
balance.purchased أرصدة الشحن وأرصدة البداية.
next_expiry الأرصدة التالية التي ستنتهي صلاحيتها، مع amount وexpires_at. وnull إذا لم ينتهِ شيء.
breakdown كل منحة أرصدة مع مبلغها المتبقي amount ومصدرها source وتاريخ انتهائها valid_until. وقيمة source هي subscription أو rollover أو purchase أو registration.
1{2  "balance": {3    "total": 145,4    "subscription": 0,5    "purchased": 1456  },7  "next_expiry": null,8  "meta": {9    "request_credit_cost": 0,10    "credits_remaining": 14511  }12}
200 · مثال على استجابة: رصيد حساب
لتنبيه انخفاض الرصيد، استعلم عن balance.total بانتظام. ولا يكلّف ذلك شيئًا.

الاستخدام

curl -G "https://handelsregister.ai/api/v1/account/usage" \
  -H "x-api-key: YOUR_API_KEY" \
  --data-urlencode 'from=2026-11-01' \
  --data-urlencode 'group_by=day'
المعاملات
الاسم النوع الوصف مثال
fromQuery نص (string)اختياري البداية بالصيغة YYYY-MM-DD أو ISO 8601. وإذا حُذفت: بداية الشهر. 2026-11-01
toQuery نص (string)اختياري النهاية، شاملة. والتاريخ المجرد يُحتسب حتى نهاية اليوم. وإذا حُذفت: الآن. –
group_byQuery نص (string)اختياري إذا حُذف، تجمّع الـ API الفترات حتى 92 يومًا حسب اليوم، والأطول حسب الشهر.القيم: day, month day
1{2  "period": {3    "from": "2026-11-01T00:00:00+00:00",4    "to": "2026-11-01T07:54:44+00:00"5  },6  "totals": {7    "requests": 80,8    "credits_used": 3209  },10  "by_endpoint": [11    {12      "endpoint": "/api/v1/signals",13      "requests": 7,14      "credits_used": 14015    },16    {17      "endpoint": "/api/v1/fetch-organization",18      "requests": 25,19      "credits_used": 12020    },21    {22      "endpoint": "/api/v1/search-companies",23      "requests": 47,24      "credits_used": 4025    },26    {27      "endpoint": "/api/v1/signals/e23c12835d697c00512944ebdfb8260f",28      "requests": 1,29      "credits_used": 2030    }31  ],32  "series": {33    "group_by": "day",34    "buckets": [35      {36        "date": "2026-11-01",37        "requests": 80,38        "credits_used": 32039      }40    ]41  },42  "meta": {43    "request_credit_cost": 0,44    "credits_remaining": 14545  }46}
200 · مثال على استجابة: الاستخدام في يوم واحد

الطلبات الفردية

curl -G "https://handelsregister.ai/api/v1/account/usage/transactions" \
  -H "x-api-key: YOUR_API_KEY" \
  --data-urlencode 'per_page=3'
المعاملات
الاسم النوع الوصف مثال
fromQuery نص (string)اختياري البداية بالصيغة YYYY-MM-DD أو ISO 8601. وإذا حُذفت: بداية الشهر. –
toQuery نص (string)اختياري النهاية، شاملة. والتاريخ المجرد يُحتسب حتى نهاية اليوم. وإذا حُذفت: الآن. –
endpointQuery نص (string)اختياري فقط الطلبات بهذه التسمية بالضبط، كما تظهر في endpoint. –
per_pageQuery عدد صحيح (integer)اختياري الإدخالات لكل صفحة. وتخفّض الـ API القيم الأكبر إلى 100.الافتراضي: 25الحدود: 1 على الأقل 3
cursorQuery نص (string)اختياري قيمة pagination.next_cursor من الصفحة السابقة، للصفحة التالية. –
1{2  "transactions": [3    {4      "id": 1116,5      "endpoint": "/api/v1/search-companies",6      "credits": 1,7      "parameters": {8        "q": "",9        "ai_search": false,10        "filters": {11          "postal_code": "91710",12          "active": true13        },14        "sort": null,15        "order": null,16        "status": 200,17        "search_type": "standard"18      },19      "created_at": "2026-11-01T07:55:02+00:00",20      "api_key_id": 1021    },22    {23      "id": 1115,24      "endpoint": "/api/v1/search-companies",25      "credits": 1,26      "parameters": {27        "q": "",28        "ai_search": false,29        "filters": {30          "postal_code": "91710",31          "active": true32        },33        "sort": null,34        "order": null,35        "status": 200,36        "search_type": "standard"37      },38      "created_at": "2026-11-01T07:55:01+00:00",39      "api_key_id": 1040    },41    {42      "id": 1114,43      "endpoint": "/api/v1/search-companies",44      "credits": 1,45      "parameters": {46        "q": "",47        "ai_search": false,48        "filters": {49          "industry_code": "62.1"50        },51        "sort": null,52        "order": null,53        "status": 200,54        "search_type": "standard"55      },56      "created_at": "2026-11-01T07:55:00+00:00",57      "api_key_id": 1058    }59  ],60  "pagination": {61    "per_page": 3,62    "next_cursor": "eyJjcmVhdGVkX2F0IjoiMjAyNi0xMS0wMSAwNzo1NTowMCIsImlkIjoxMTE0LCJfcG9pbnRzVG9OZXh0SXRlbXMiOnRydWV9"63  },64  "period": {65    "from": "2026-11-01T00:00:00+00:00",66    "to": "2026-11-01T07:55:02+00:00"67  },68  "meta": {69    "request_credit_cost": 0,70    "credits_remaining": 14571  }72}
200 · مثال على استجابة: أحدث ثلاثة طلبات

اشتراك الأرصدة

curl -G "https://handelsregister.ai/api/v1/account/subscription" \
  -H "x-api-key: YOUR_API_KEY"
1{2  "subscription": {3    "plan": "max",4    "status": "active",5    "billing_interval": "month",6    "cancel_at_period_end": false,7    "current_period_start": "2026-10-26T21:51:51+00:00",8    "current_period_end": "2026-11-26T21:51:51+00:00",9    "trial_ends_at": null,10    "canceled_at": null,11    "features": {12      "credits_per_month": 75000,13      "bonus_percentage": 15,14      "non_expiring_credits": true,15      "support_level": "priority"16    }17  },18  "meta": {19    "request_credit_cost": 0,20    "credits_remaining": 14521  }22}
200 · مثال على استجابة: اشتراك أرصدة Max نشط

إدارة مفاتيح API

curl -G "https://handelsregister.ai/api/v1/account/api-keys" \
  -H "x-api-key: YOUR_API_KEY"
1{2  "api_keys": [3    {4      "id": 10,5      "key_last_8": "Ab12Cd34",6      "is_current": true,7      "created_at": "2026-11-01T04:17:31+00:00",8      "last_used_at": "2026-11-01T07:55:12+00:00",9      "usage_last_30d": {10        "requests": 97,11        "credits_used": 41112      }13    }14  ],15  "total": 1,16  "meta": {17    "request_credit_cost": 0,18    "credits_remaining": 14519  }20}
200 · مثال على استجابة: مفاتيح API لحساب
curl -X POST "https://handelsregister.ai/api/v1/account/api-keys" \
  -H "Authorization: Bearer YOUR_ADMIN_TOKEN"
1{2  "api_key": {3    "id": 13,4    "key": "…",5    "created_at": "2026-11-01T08:32:00+00:00"6  },7  "meta": {8    "message": "Store this key securely. It grants full data access to this account.",9    "request_credit_cost": 0,10    "credits_remaining": 14511  }12}
201 · مثال على استجابة: مفتاح API جديد، مختصر هنا

Bearer tokens

curl -X POST "https://handelsregister.ai/api/v1/auth/tokens/create" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "token_name": "CRM-Sync",
    "abilities": [
        "api:data",
        "account:read"
    ]
}'
المعاملات
الاسم النوع الوصف مثال
token_nameBody نص (string)إلزامي اسم تتعرف به على الرمز، مثل اسم تطبيقك.الحدود: 255 حرفًا على الأكثر CRM-Sync
abilitiesBody قائمة من stringاختياري الصلاحيات كقائمة. وإذا حُذفت، يحصل الرمز على api:data لنقاط نهاية البيانات وaccount:read لنقاط نهاية الحساب. ويسمح monitoring:manage بالتغييرات على المراقبات.الافتراضي: ["*"] ["api:data","account:read"]
expires_atBody نص (string) (date-time)اختياري تاريخ انتهاء في المستقبل. وإذا حُذف، يبقى الرمز صالحًا حتى تلغيه. –
1{2  "token": "…",3  "name": "CRM-Sync",4  "abilities": [5    "api:data",6    "account:read"7  ],8  "expires_at": null,9  "created_at": "2026-11-01T08:31:26.000000Z",10  "meta": {11    "message": "Token created successfully. Store this token securely as it will not be shown again.",12    "credits_remaining": 14513  }14}
201 · مثال على استجابة: رمز جديد، مختصر هنا
يلغي DELETE /v1/auth/tokens جميع الرموز دفعة واحدة، بما في ذلك رمز المسؤول. وبعد ذلك تحتاج إلى رمز مسؤول جديد لإدارة المفاتيح.

الأخطاء

الأخطاء
الحالة السبب ما يمكنك فعله
400 api_key موجود في الـ URL. أرسل المفتاح في الـ Header ‏x-api-key.
400 معامل غير صالح، مثل تاريخ أو group_by أو فترة طويلة جدًا. صحّح القيمة كما يصف meta.message.
401 لا يوجد مفتاح API أو رمز، أو أحدهما غير صالح. أرسل المفتاح في الـ Header ‏x-api-key.
401 لا يوجد مفتاح API، أو المفتاح غير صالح. لا يعمل Bearer token تحت /v1/auth. أرسل مفتاح API في الـ Header ‏x-api-key.
403 ينقص Bearer token الصلاحية account:read. استخدم مفتاح API أو رمزًا بـ account:read.
403 لم يُؤكَّد عنوان البريد الإلكتروني لحسابك بعد، أو الحساب مقفل. افتح الرابط من بريد التأكيد. وإذا كان الحساب مقفلًا، يمكن للدعم المساعدة.
403 يحتاج هذا الاستدعاء إلى رمز المسؤول. لا يكفي مفتاح API، ولا أي رمز آخر. أرسله مع Authorization: Bearer ورمز المسؤول.
404 لا يوجد مفتاح أو رمز بهذا المعرّف. خذ المعرّف من القائمة.
422 تم بلوغ الحد الأقصى لعدد مفاتيح API (too_many_keys). احذف مفتاحًا قديمًا.
429 طلبات كثيرة جدًا. أعد المحاولة بعد Retry-After.
500 قيمة غير صالحة: token_name مفقود أو طويل جدًا، أو abilities ليست قائمة، أو expires_at ليس في المستقبل. صحّح القيم. ومع Accept: application/json يأتي الخطأ بصيغة JSON.
1{2  "error": "invalid_request",3  "meta": {4    "message": "'group_by' must be one of: day, month.",5    "request_credit_cost": 0,6    "credits_remaining": 1457  }8}
400 · قيمة غير صالحة لـ group_by