وثبة
Partner integration guideدليل تكامل الشركاء

Connect your API to Wathba.اربطوا API خدمتكم بوثبة.

For partner engineering teams: how member applications reach your service through Wathba, how fees are collected, how access is scoped, and what we test before going live. Step through each diagram.لفرق الهندسة لدى الشركاء: كيف تصل تطبيقات الأعضاء إلى خدمتكم عبر وثبة، وكيف تُحصَّل الرسوم، وكيف تُحدَّد صلاحيات الوصول، وما الذي نختبره قبل الإطلاق. تنقّلوا بين خطوات كل مخطط.

01How it fits togetherكيف تترابط الأجزاء

Runtime requestطلب أثناء التشغيل
Member applicationتطبيق العضو
runtime callerالمستدعي أثناء التشغيل
Wathbaوثبة
accounts · support · protected credentials · usage attributionالحسابات · الدعم · مفاتيح محمية · إسناد الاستخدام
Your serviceخدمتكم
operates the service · approval decisions (KYC)تشغيل الخدمة · قرارات الموافقة (KYC)
requestm1042 · proj_7
calls Wathba onlyيستدعي وثبة فقط
Protected credentialsمفاتيح محمية
acc_example → ••••
hidden from member appsمحمي عن تطبيقات الأعضاء
POST /v1/operationsAuthorization: Bearer ••••
scope: acc_example only
202 · op_example · pending
logged against acc_exampleيُسجَّل على acc_example
resultop_example
attributed: m1042 · proj_7
Sequence diagram: the member application calls Wathba; Wathba resolves the account and calls your API for that account server to server, sending the provider credential in the Authorization header. The credential is hidden from member apps. The result returns with usage attributed to the member and project.مخطط تسلسلي: يستدعي تطبيق العضو وثبة، فتحدد وثبة الحساب وتستدعي API خدمتكم لذلك الحساب من خادم إلى خادم مع إرسال اعتماد المزوّد في ترويسة Authorization، وهو محمي عن تطبيقات الأعضاء. ثم تعود النتيجة مع إسناد الاستخدام إلى العضو والمشروع.

02Two independent choicesقراران مستقلان

Agree on both before any code. They are independent: the charging model does not decide the key type.نتفق عليهما قبل كتابة أي كود، وهما مستقلان: نموذج تحصيل الرسوم لا يحدد نوع مفتاح الوصول.

Charging: how your fee is collectedالتحصيل: كيف تُحصَّل رسومكم

Company X · fees deducted from paymentsالشركة X · رسوم تُخصم من المدفوعات
Payment proceeds · Company Xحصيلة الدفعة · الشركة X
paid by the member’s customer · net after the feeيدفعها عميل العضو · الصافي بعد الرسوم
98.00−2.00 fee
example amountsمبالغ توضيحية
Member wallet · held by Wathbaمحفظة العضو · لدى وثبة
funded by the member · debited by Wathbaيشحنها العضو · تخصم منها وثبة
50.000.00not debited for this feeلا خصم مقابل هذه الرسوم
example amountsمبالغ توضيحية
Payment proceeds and member wallet are separateحصيلة الدفعة منفصلة عن محفظة العضو
Member applicationتطبيق العضو
runtime callerالمستدعي أثناء التشغيل
Wathbaوثبة
holds the member walletتحتفظ بمحفظة العضو
Company Xالشركة X
payment gateway · exampleبوابة دفع · مثال
payment requestm1042 · proj_7
amount: 100.00 (example)
POST /v1/operationsAuthorization: Bearer ••••
key per project, or delegated accessمفتاح المشروع أو وصول مفوّض
Payment processedتُعالَج الدفعة
100.00 − 2.00 fee = 98.00
fee collected inside the paymentالرسوم تُحصَّل ضمن الدفعة
200 · op_example · succeededwebhook operation.succeeded
result
attributed: m1042 · proj_7 · wallet unchanged
Company Y · prepaid balanceالشركة Y · رصيد مسبق
Wathba prepaid balance · held by Company Yرصيد وثبة المسبق · لدى الشركة Y
funded by Wathba · debited by Company Yتشحنه وثبة · تخصم منه الشركة Y
999.00requested · not creditedمطلوب · لم يُقيَّد بعد+1,000.00−1.000.00
example amountsمبالغ توضيحية
Member wallet · held by Wathbaمحفظة العضو · لدى وثبة
funded by the member · debited by Wathbaيشحنها العضو · تخصم منها وثبة
48.80−1.200.00
example amountsمبالغ توضيحية
two separate balances · no transfer between themرصيدان منفصلان · لا تحويل بينهما
Member applicationتطبيق العضو
runtime callerالمستدعي أثناء التشغيل
Wathbaوثبة
holds the member walletتحتفظ بمحفظة العضو
Company Yالشركة Y
prepaid service · exampleخدمة برصيد مسبق · مثال
top-up request
pending · no credit yetمعلّق · لا رصيد بعد
Top-up confirmedتأكيد الشحن
+1,000.00 (example) confirmedمؤكَّد
operation requestm1042 · proj_7
billable event, agreed in writingعملية ذات تكلفة متفق عليها كتابةً
POST /v1/operationsAuthorization: Bearer ••••
application key or delegated accessمفتاح التطبيق أو وصول مفوّض
Company Y debits Wathba’s balanceالشركة Y تخصم من رصيد وثبة
−1.00 provider cost (example)
202 → succeededwebhook operation.succeeded
Wathba charges the member walletوثبة تخصم من محفظة العضو
−1.20 member price (example)
can differ from the provider costقد يختلف عن تكلفة المزوّد attributed: m1042 · proj_7
GET /v1/operations/{id}GET /partner/balance · GET /partner/usage
non-billable · nothing debitedبلا تكلفة · لا خصم
Two charging scenarios with example amounts. Company X: the gateway deducts its fee inside the payment and the member wallet is not debited. Company Y: Wathba funds a prepaid balance held by the provider, which is credited only after confirmation and debited per billable operation; separately, Wathba debits the member wallet at the member price. Reads are non-billable.سيناريوهان لتحصيل الرسوم بمبالغ توضيحية. الشركة X: تخصم البوابة رسومها ضمن الدفعة ولا تُخصم محفظة العضو. الشركة Y: تشحن وثبة رصيداً مسبقاً لدى المزوّد لا يُقيَّد إلا بعد التأكيد ويُخصم منه عند كل عملية ذات تكلفة؛ وبصورة منفصلة تخصم وثبة من محفظة العضو بسعر العضو. القراءات بلا تكلفة.
agreed in writing:يُتفق كتابةً على:billable eventالعملية ذات التكلفةtop-up confirmationتأكيد الشحنpricing unitsوحدات التسعيرfailures, refunds, reversalsالإخفاقات والاسترداد والعكسusage recordsسجلات الاستخدامreconciliationالمطابقة

Access: how Wathba acts for one accountالوصول: كيف تتصرف وثبة باسم حساب واحد

Option A · a key per account or applicationالخيار أ · مفتاح لكل حساب أو تطبيق
Wathbaوثبة
partner credential · vaultاعتماد الشراكة · الخزنة
Your serviceخدمتكم
accounts · approvals · runtime checksالحسابات · الموافقات · فحوص التشغيل
POST /partner/accountsAuthorization: Bearer <partner_credential>Idempotency-Key: 7c1e-…
client_reference: wathba-m1042-p7 · proj_7
Account createdأُنشئ الحساب
acc_example pendingactive ✓
Your review and approval (KYC)مراجعتكم وموافقتكم (KYC)
webhook, or GET /partner/accounts/{id}
POST /partner/accounts/{id}/keysAuthorization: Bearer <partner_credential>
restricted administrative scopeصلاحية إدارية مقيّدة
201 · account_keyreturned once
over the API, never by email or chatعبر API، لا بالبريد ولا الدردشة
Wathba vaultخزنة وثبة
acc_example → enc:••••
encrypted · not shown to membersمشفّر · لا يُعرض للأعضاء
POST /v1/operationsAuthorization: Bearer <account_key>
scope: acc_example only
partner_credential ✗ runtime
Checked, then executedيُفحص ثم يُنفَّذ
owner ✓ · status active ✓ · operation allowed ✓
scoped · logged ✓
Option B · delegated partner accessالخيار ب · وصول شراكة مفوّض
Wathbaوثبة
partner credential · vaultاعتماد الشراكة · الخزنة
Your serviceخدمتكم
accounts · approvals · runtime checksالحسابات · الموافقات · فحوص التشغيل
POST /partner/accountsAuthorization: Bearer <partner_credential>Idempotency-Key: 7c1e-…
client_reference: wathba-m1042-p7 · proj_7
Account createdأُنشئ الحساب
acc_example pendingactive ✓
Your review and approval (KYC)مراجعتكم وموافقتكم (KYC)
webhook, or GET /partner/accounts/{id}
Delegated runtime credentialاعتماد تشغيل مفوّض
scope: operations:create · operations:read
explicit grant · agreed in the partnershipتفويض صريح · ضمن اتفاقية الشراكة
delegated_partner_keydelivered once
over a secure channel, never by email or chatعبر قناة آمنة، لا بالبريد ولا الدردشة
Wathba vaultخزنة وثبة
delegated_partner_key → enc:••••
encrypted · not shown to membersمشفّر · لا يُعرض للأعضاء
POST /v1/operationsAuthorization: Bearer <delegated_partner_key>X-Account-Id: acc_example
generic admin key ✗ runtime
Checked, then executedيُفحص ثم يُنفَّذ
owner = Wathba ✓ · status active ✓ · operation allowed ✓
logged against acc_example
Two access scenarios. Both start by creating the account with the partner credential and waiting for your approval (pending, then active). Option A: you issue a key scoped to that account, delivered once and stored encrypted; runtime calls use it. Option B: an explicitly delegated runtime credential plus the account id on every call; you verify ownership, status and permission before executing. An administrative key alone never runs operations.سيناريوهان للوصول. يبدأ كلاهما بإنشاء الحساب باعتماد الشراكة وانتظار موافقتكم (معلّق ثم فعّال). الخيار أ: تُصدرون مفتاحاً محدوداً بذلك الحساب يُسلَّم مرة واحدة ويُحفظ مشفّراً، وتستخدمه طلبات التشغيل. الخيار ب: اعتماد تشغيل مفوّض صراحةً مع معرّف الحساب في كل طلب، وتتحققون من الملكية والحالة والصلاحية قبل التنفيذ. المفتاح الإداري وحده لا ينفّذ العمليات.
Option A · key per accountالخيار أ · مفتاح لكل حساب
Option B · delegatedالخيار ب · مفوّض
Company X · fees from paymentsالشركة X · رسوم من المدفوعات
✓
✓
Company Y · prepaid balanceالشركة Y · رصيد مسبق
✓
✓

Any combination is valid: the charging model does not choose the key scope, and an administrative key alone never runs operations.أي تركيبة صالحة: نموذج التحصيل لا يحدد نطاق المفتاح، والمفتاح الإداري وحده لا ينفّذ العمليات.

03Example endpointsأمثلة على نقاط النهاية

Method · pathالطريقة والمسارWhat it doesالوظيفةCredentialالاعتماد
POST /partner/accountsCreate a member’s account or project under Wathba. Idempotent by Idempotency-Key, reused on retry. client_reference correlates the request and deduplicates only if the partner contract explicitly promises uniqueness and replay behavior; the body carries an external project reference.إنشاء حساب أو مشروع للعضو تحت وثبة. آمن عند التكرار عبر Idempotency-Key نفسه في كل إعادة محاولة. يربط client_reference الطلب بين الطرفين ولا يمنع التكرار إلا إذا نص عقد الشراكة صراحةً على تفرّده وسلوك الإعادة؛ ويحمل الطلب مرجع المشروع الخارجي.partner credentialاعتماد الشراكة
GET /partner/accounts/{id}Read the account and its status: pending, active, rejected or suspended.قراءة الحساب وحالته: pending أو active أو rejected أو suspended.partner credentialاعتماد الشراكة
POST /partner/accounts/{id}/keysOption A only. Issue a key scoped to that account, returned once.الخيار أ فقط. إصدار مفتاح محدود بذلك الحساب، يُعاد مرة واحدة.partner credential, restrictedاعتماد الشراكة، بصلاحية مقيّدة
POST /v1/operationsPlaceholder for your service endpoint: a payment, a verification, a shipment.بديل عام لنقطة نهاية خدمتكم: دفعة، أو تحقق، أو شحنة.account key (A), or delegated key + X-Account-Id (B)مفتاح الحساب (أ)، أو المفتاح المفوّض مع X-Account-Id (ب)
GET /v1/operations/{id}Resolve a pending or uncertain result, under the same credential and account scope as the operation.الاستعلام عن نتيجة معلّقة أو غير مؤكدة، بنفس الاعتماد ونطاق الحساب اللذين نُفّذت بهما العملية.same as the row aboveكما في السطر السابق
GET /partner/balancePrepaid partners: Wathba’s balance with you.للشركاء بالرصيد المسبق: رصيد وثبة لديكم.partner credentialاعتماد الشراكة
GET /partner/usage?account_id=…Prepaid partners: billable usage per account, for reconciliation.للشركاء بالرصيد المسبق: الاستخدام ذو التكلفة لكل حساب، للمطابقة.partner credentialاعتماد الشراكة

Every read is scoped by ownership: a partner sees only its own accounts, and an account sees only its own operations. Member wallet accounting stays inside Wathba; a top-up is a funding and confirmation process, not an endpoint that credits a balance on request.كل قراءة محدودة بالملكية: لا يرى الشريك إلا حساباته، ولا يرى الحساب إلا عملياته. تبقى محاسبة محفظة العضو داخل وثبة، والشحن إجراء للتمويل والتأكيد لا نقطة نهاية تضيف رصيداً عند الطلب.

Create an account (partner credential)إنشاء حساب (اعتماد الشراكة)
POST /partner/accounts
Authorization: Bearer <partner_credential>
Idempotency-Key: 7c1e-…                  # same key on every retry
Content-Type: application/json

{
  "client_reference": "wathba-m1042-p7",
  "external_project_ref": "proj_7",
  "business": { "…": "the fields your approval process needs" }
}

201 Created
{ "id": "acc_example", "status": "pending", "client_reference": "wathba-m1042-p7" }
Run an operation, then resolve it (runtime)تنفيذ عملية ثم الاستعلام عنها (التشغيل)
POST /v1/operations
Authorization: Bearer <account_key>                 # Option A
# — or —
Authorization: Bearer <delegated_partner_key>       # Option B
X-Account-Id: acc_example                           # Option B
Idempotency-Key: 9f4a-…                             # same key on every retry
Content-Type: application/json

{ "client_reference": "op-8c2d", "type": "verification", "…": "…" }

202 Accepted
{ "operation_id": "op_example", "status": "pending", "client_reference": "op-8c2d" }

GET /v1/operations/op_example
Authorization: Bearer <same credential as the POST>
X-Account-Id: acc_example                           # Option B
200 OK
{ "operation_id": "op_example", "status": "succeeded", "client_reference": "op-8c2d" }

Names and states are illustrative. What matters: an operation returns an id, a status such as pending, succeeded or failed, and the client reference, so both sides can correlate it.الأسماء والحالات توضيحية. المهم أن تعيد العملية معرّفاً، وحالة مثل pending أو succeeded أو failed، ومرجع العميل، حتى يربطها الطرفان.

04Operation lifecycle and webhooksدورة حياة العملية والإشعارات Webhooks

Happy pathالمسار الطبيعي
operationالعمليةsucceededoperationsالعمليات 1chargesالرسوم 1
Wathbaوثبة
idempotency keys · signature checks · reconciliationمفاتيح التكرار · فحص التوقيع · المطابقة
Your serviceخدمتكم
operations · webhooksالعمليات · الإشعارات
POST /v1/operationsIdempotency-Key: 9f4a-…client_reference: op-8c2d
202 Acceptedop_example · pending
Processedنُفِّذت
succeeded billable event → 1 charge
POST <wathba-webhook-url>X-Signature: sha256=…event_id: evt_example · operation.succeeded
Verified, then appliedتحقق ثم تطبيق
signature ✓ → status: succeeded
Retry with the same Idempotency-Keyإعادة المحاولة بمفتاح التكرار نفسه
operationالعمليةpendingoperationsالعمليات 1chargesالرسوم 1
Wathbaوثبة
idempotency keys · signature checks · reconciliationمفاتيح التكرار · فحص التوقيع · المطابقة
Your serviceخدمتكم
operations · webhooksالعمليات · الإشعارات
POST /v1/operationsIdempotency-Key: 9f4a-…
Operation createdأُنشئت العملية
op_example · charged once
202 · lost in transit
unknownغير معروفة
POST /v1/operationsIdempotency-Key: 9f4a-… (same)
retryإعادة المحاولة
Same key recognisedالمفتاح نفسه
same operation · no extra chargeالعملية نفسها · لا رسم إضافي
202 · op_examplesame id
Webhooks · signature and duplicatesالإشعارات · التوقيع والتكرار
operationالعمليةsucceededevents processedأحداث معالجة 1rejectedمرفوضة 1ignoredمتجاهلة 1
Wathbaوثبة
idempotency keys · signature checks · reconciliationمفاتيح التكرار · فحص التوقيع · المطابقة
Your serviceخدمتكم
operations · webhooksالعمليات · الإشعارات
POST <wathba-webhook-url>X-Signature: invalid
Signature checkفحص التوقيع
rejected · body not processedمرفوض · لم يُعالَج المحتوى
POST <wathba-webhook-url>X-Signature: sha256=… ✓event_id: evt_example
Signature checkفحص التوقيع
processed onceعولج مرة واحدة
POST (redelivery)event_id: evt_example
Already processedسبقت معالجته
duplicate event_id · ignoredevent_id مكرر · يُتجاهَل 200 OK
Timeout · reconcile by GETانتهاء المهلة · المطابقة عبر GET
operationالعمليةsucceededoperationsالعمليات 1chargesالرسوم 1
Wathbaوثبة
idempotency keys · signature checks · reconciliationمفاتيح التكرار · فحص التوقيع · المطابقة
Your serviceخدمتكم
operations · webhooksالعمليات · الإشعارات
POST /v1/operationsIdempotency-Key: 9f4a-…
202 · pending
Waiting… no webhookانتظار… لا إشعار
pending / unknownمعلّقة / غير معروفة
not failed · no new charge · no new POST
GET /v1/operations/op_exampleAuthorization: same credentialX-Account-Id: acc_example (B)
200 · succeeded
Reconciledتمت المطابقة
succeeded 1 operation · 1 charge
Operation lifecycle scenarios. Happy path: POST, 202 pending, processed once, signed webhook verified and applied. Retry: the same Idempotency-Key returns the same operation with no extra charge. Webhooks: a bad signature is rejected; a duplicate event_id is ignored. Timeout: a missing webhook leaves the operation pending or unknown, never failed and never re-charged, until Wathba reconciles with GET status under the same credential and account scope.سيناريوهات دورة حياة العملية. المسار الطبيعي: POST ثم 202 معلّقة، ثم تنفيذ واحد، ثم إشعار موقّع يُتحقق منه ويُطبَّق. إعادة المحاولة: مفتاح التكرار نفسه يعيد العملية نفسها دون رسم إضافي. الإشعارات: التوقيع غير الصحيح يُرفض، وevent_id المكرر يُتجاهل. انتهاء المهلة: غياب الإشعار يُبقي العملية معلّقة أو غير معروفة، لا فاشلة ولا مُعاد تحصيلها، حتى تطابق وثبة الحالة عبر GET بالاعتماد ونطاق الحساب نفسيهما.
Signed event (partner → Wathba)حدث موقّع (من الشريك إلى وثبة)
POST https://<wathba-webhook-url>
X-Signature: sha256=<hmac of the raw body, shared secret>
Content-Type: application/json

{
  "event_id": "evt_example",
  "type": "operation.succeeded",
  "account_id": "acc_example",
  "project_ref": "proj_7",
  "operation_id": "op_example",
  "occurred_at": "2026-09-14T09:30:00Z"
}

05Ready to integrateجاهزون للتكامل

We go to production when every line is checked.ننتقل إلى الإنتاج عند استيفاء كل بند.