البدء السريع
ابدأ العمل في 5 دقائق
مرجع API
المنتجات والإيصالات والورديات
وضع بدون إنترنت
كيف تعمل المزامنة بدون إنترنت
البداية
مرحباً بك في SmartPOS AI! سيساعدك هذا الدليل في تشغيل نظام نقطة البيع بسرعة.
الإعداد
SmartPOS AI حل سحابي، لذا لا حاجة لتثبيت برنامج. ببساطة:
- Create your account at smartposai.com/register
- Verify your email address
- Set up your business profile
- Add your first products
الإعدادات
بعد التسجيل، اضبط إعداداتك في المكتب الخلفي:
- Business Details: Name, address, tax information
- Tax Rates: Configure your regional tax rates
- Payment Methods: Enable cash, card, and other payment options
- Receipt Settings: Customize your receipt layout
مصادقة API
يوفر SmartPOS API وصولاً للقراءة فقط لمنتجاتك وإيصالاتك وورديتك. يتطلب وصول API الخطة الاحترافية أو أعلى.
Getting Your API Key
- Log in to your Backoffice
- Go to Settings → API
- Click Generate API Key
- Copy the key immediately — it won't be shown in full again
Include your API key in the X-API-Key header with every request:
🔐 Keep Your API Key Secure
Never expose your API key in client-side code or public repositories. Use environment variables to store sensitive credentials. You can regenerate your key at any time in Settings → API.
Base URL
All API endpoints use your subdomain as the base URL:
API المنتجات
استرجاع كتالوج المنتجات ومستويات المخزون.
/api/v1/products
List all products with optional filtering
Query Parameters
store_id— Filter by store (integer)category_id— Filter by category (integer)status— Filter by status:activeorinactive(default: all)limit— Results per page (default: 50, max: 200)offset— Pagination offset (default: 0)
Example Response
/api/v1/products/{id}
Get a single product with per-store stock levels
Example Response
API الإيصالات
الوصول للإيصالات المكتملة وعناصرها.
/api/v1/receipts
List receipts with date range and store filtering
Query Parameters
start_date— Start date inYYYY-MM-DDformatend_date— End date inYYYY-MM-DDformatstore_id— Filter by store (integer)limit— Results per page (default: 50, max: 200)offset— Pagination offset (default: 0)
Example Response
/api/v1/receipts/{id}
Get a single receipt with all line items
Example Response
API الورديات
الوصول لبيانات ورديات الموظفين بما في ذلك تتبع النقد وإجمالي المبيعات.
/api/v1/shifts
List shifts with filtering by date, store, and status
Query Parameters
start_date— Start date inYYYY-MM-DDformatend_date— End date inYYYY-MM-DDformatstore_id— Filter by store (integer)status— Filter by status:openorclosedlimit— Results per page (default: 50, max: 200)offset— Pagination offset (default: 0)
Example Response
/api/v1/shifts/{id}
Get shift details including sales breakdown
Example Response
الأخطاء وحدود المعدل
يستخدم API رموز حالة HTTP القياسية. جميع استجابات الأخطاء تتضمن JSON مع رسالة وصفية.
Status Codes
200— Success401— Invalid or missing API key403— Feature not available on your plan404— Resource not found500— Internal server error
Error Response Format
Rate Limiting
API requests are limited to 100 requests per minute per API key. If you exceed this limit, you'll receive a 429 status code. Wait a moment before retrying.
الويب هوكس
تتيح لك الويب هوكس استقبال إشعارات HTTP في الوقت الفعلي عند وقوع الأحداث في حساب SmartPOS AI الخاص بك. عند وقوع حدث، نرسل طلب POST مع محتوى JSON إلى رابطك المسجل.
Plan Requirement
Webhooks require the Professional plan or above. Free and Starter plans do not have webhook access.
Supported Events
receipt.created— A new receipt/sale has been completedproduct.created— A new product was addedproduct.updated— A product was modified (name, price, stock, etc.)product.deleted— A product was deletedshift.opened— A new shift was startedshift.closed— A shift was endedcustomer.created— A new customer was addedcustomer.updated— A customer record was modifiedstock.adjusted— Stock level was manually adjustedrefund.created— A refund was issued
/api/v1/webhooks
List all registered webhooks
Example Response
/api/v1/webhooks
Register a new webhook endpoint
Request Body
/api/v1/webhooks/{id}
Delete a webhook by ID
Webhook Payload Format
When an event occurs, we send a POST request to your URL with this JSON structure:
Request Headers
Every webhook delivery includes these HTTP headers:
Content-Type: application/jsonUser-Agent: SmartPOS-Webhook/1.0X-SmartPOS-Event— The event name (e.g.receipt.created)X-SmartPOS-Signature— HMAC-SHA256 signature of the request body (see below)X-SmartPOS-Delivery-Id— Unique delivery ID for idempotencyX-SmartPOS-Timestamp— Unix timestamp of when the event was generated
Verifying the Signature (Recommended)
Each webhook is signed with HMAC-SHA256 using your webhook secret (shown once when you create the webhook). Verify the X-SmartPOS-Signature header to confirm the request really came from SmartPOS AI.
🔐 Always use timing-safe comparison
Use crypto.timingSafeEqual() (Node) or hash_equals() (PHP) when comparing signatures. Plain string comparison is vulnerable to timing attacks.
Retry Policy
If your endpoint does not return a 2xx status code within 10 seconds, the delivery is marked as failed and retried with exponential backoff:
- 1st retry: after 1 minute
- 2nd retry: after 5 minutes
- 3rd retry: after 30 minutes
- 4th retry: after 2 hours
- 5th retry: after 12 hours
After 5 failed retries (or 10 total consecutive failures across deliveries), the webhook is automatically deactivated. Use the X-SmartPOS-Delivery-Id header to handle duplicates idempotently if a retry succeeds after you already processed it.
/api/v1/webhooks/{id}/test
Send a test payload to your webhook endpoint (useful for verifying your handler before going live)
Webhook Reliability
If your endpoint returns a non-2xx status code, the delivery is marked as failed. After 10 consecutive failures, the webhook is automatically deactivated. You can re-activate it from Settings → API → Webhooks.
وضع بدون إنترنت
SmartPOS AI يعمل حتى بدون اتصال بالإنترنت. إليك كيف يعمل:
- Transactions are stored locally using IndexedDB
- Data automatically syncs when connection is restored
- Products and prices are cached for offline access
- Receipts can be printed locally