{
    "openapi": "3.0.3",
    "info": {
        "title": "wsign API",
        "description": "الواجهة البرمجية للتوقيع الإلكتروني من wsign.\n\nالمصادقة عبر مفتاح Bearer:\n- المفتاح السرّي `sk_` للاستخدام من الخادم (صلاحيات كاملة)، وصيغته `sk_` تليها 40 خانة سداسية عشرية.\n- المفتاح العام `pk_` للاستخدام في المتصفح (صلاحيات محدودة).\n- مفاتيح التجربة `sk_test_` و`pk_test_`: لا تخصم رصيدًا، ولا تُرسل دعوة ولا تذكيرًا ولا نسخة إلى أحد، ولا تتجاوز التوقيع البسيط، ولا يُختم لطلباتها محضر أدلّة، وتحمل كائناتها وأحداثها `livemode: false`. ويجب أن يكون بريد الموقّع أو رقمه لحسابك أو لأحد أعضاء فريقك.\n\n**قيود المفتاح العام (pk_)** — أي مخالفة تُرجع `403 forbidden`:\n- المسارات المتاحة فقط: `/`، `/templates`، `/signature_requests`، `/signers`، `/flows`. أي مسار آخر → 403.\n- `/templates` و`/signers` و`/flows` للقراءة فقط (GET). أي كتابة → 403.\n- `GET /signature_requests` (تعداد القائمة) ممنوع؛ اجلب طلبًا بعينه بمعرّفه.\n- المفتاح مقفول على النطاقات المضبوطة في اللوحة؛ طلب من نطاق آخر أو بلا ترويسة Origin → 403.\n- حصّة أضيق للعمليات التي تخصم رصيدًا: 5 عمليات `POST /signature_requests…` لكل ساعة لكل زائر (المفتاح + عنوان الـIP) → 429.\n- سقف يومي لكل مفتاح عام على العمليات نفسها مهما تعدّدت العناوين: عند بلوغه يُردّ `429 daily_cap_reached` مع `Retry-After` حتى بداية اليوم التالي (UTC)، ويصل صاحب الحساب إشعار عند 80% من السقف وعند بلوغه.\n\n**تعتيم الحقول للمفتاح العام:** في كل الردود عدا ردّ الإنشاء مباشرةً، تُفرَّغ `Signer.signing_url` إلى `null`، ويُقنَّع البريد (`a****@example.com`)، وتُفرَّغ حقول `ip` و`user_agent` في الأحداث وشهادة الإتمام. استخدم مفتاحًا سرّيًا (sk_) لقراءة هذه القيم.\n\n**حدود المعدّل:** 100 طلب لكل 10 ثوانٍ لكل **حساب** (لا لكل مفتاح)، وهو حدّ واحد يتشاركه وضعا التجربة والحيّ، وحدّ إضافي لكل عنوان IP قبل المصادقة. عند التجاوز: `429 too_many_requests` مع `Retry-After`، والترويسات `X-RateLimit-Limit`/`X-RateLimit-Remaining`/`X-RateLimit-Reset`.\n\n**تقييد المفتاح السرّي بعناوين IP:** تستطيع من لوحة المطوّرين تقييد كل مفتاح سرّي (sk_) بقائمة من عناوين IPv4 أو IPv6 أو نطاقات العناوين بصيغة CIDR، حتى 50 عنوانًا للمفتاح. الطلب الوارد من عنوان خارج القائمة يُردّ بـ`403 ip_not_allowed` قبل تنفيذ أي عملية، ولا يُحتسب من حدّ المعدّل، ويظهر في سجلّ الطلبات. والمفتاح بلا قائمة يُقبل من أي عنوان، والمفاتيح العامة (pk_) لا تخضع لهذه القائمة.\n\n**تدوير المفتاح:** تدوير المفتاح من اللوحة يُصدر مفتاحًا جديدًا بالاسم والصلاحيات وقائمة العناوين نفسها، ويبقى المفتاح السابق صالحًا 24 ساعة ثم يُردّ بـ`401 invalid_api_key`. وتستطيع إيقاف المفتاح السابق قبل انتهاء المدّة، أو اختيار إيقافه فور التدوير.\n\n**الوضع الحيّ وتوثيق الشركة:** مفاتيح التجربة مجانية في كل الباقات بحدّ يومي، ولا يُعتدّ بطلباتها قانونًا. والطلب الحيّ المُرسَل يتطلّب باقة مدفوعة سارية وشركة موثّقة: بلا باقة مدفوعة يُردّ `402 plan_required`، وبعد انتهاء سنة الاشتراك دون تجديد `402 plan_expired`، وقبل اعتماد توثيق الشركة `403 kyb_required`. وتُوثَّق الشركة من صفحة «توثيق الشركة» في لوحة المطوّرين: تأكيد هوية ممثّلها، ثم مراجعة مستنداتها.\n\n**الباقة والمحفظة:** كل موقّع في طلب توقيع حيّ يُحتسب إرسالًا من رصيد باقتك السنوي، والحدّ الأقصى خمسة موقّعين في الطلب الواحد (`too_many_signers`). وبعد نفاد الرصيد يُخصم كل إرسال زائد من المحفظة بسعر الزيادة في باقتك، ويُخصم تأكيد الهوية من المحفظة دائمًا لكل موقّع يتطلّبه. والمحفظة بعملة واحدة لحسابك. وإن لم يكفِ الرصيد رُدّ `402 insufficient_balance` ولم يُرسَل شيء. ويعود `GET /usage` بالباقة والرصيد والأسعار.\n\n**قدرات الباقة:** بعض الخصائص متاحة للطلبات الحيّة من باقة بعينها: التوقيع بالترتيب (`ordered`) ورابط العودة (`return_url` و`success_url` و`cancel_url`) ومسارات العمل المخصّصة من باقة «الأعمال»، والإرسال الجماعي (`/signature_requests/bulk`) والتوقيع بالتوكن (`legal_level: qes` أو `method: token`) ومرفقات الموقّع والكود السرّي من باقة «المؤسسات». والطلب الحيّ الذي يستعمل خاصية خارج باقتك يُردّ `403 plan_feature_unavailable` ومعه الحقلان `feature` و`required_plan`، ولا يُنشأ شيء ولا يُخصم شيء. أمّا مفاتيح التجربة فتتيح هذه الخصائص كلها في كل الباقات عدا الدومين الخاص، والمسار الافتراضي (`workflow_id: default`) متاح في كل الباقات.\n\n**الإصدار والصفحات:** الترويسة `Wsign-Version` اختيارية؛ والقيمة غير المدعومة تُردّ بـ`400` `api_version_invalid` (المدعوم اليوم `2026-07-01`). وقيمة `starting_after` التي لا تطابق عنصرًا في القائمة تُردّ بـ`400` `invalid_cursor` بدل العودة إلى الصفحة الأولى؛ فاستعمل `next_cursor` كما يصلك. والواجهة بلا حالة: لا تُعاد كوكيز جلسة.\n\n**وضع التجربة:** كل الخصائص متاحة بمفتاح التجربة عدا الدومين الخاص، وكل ما يصدر عنه معلَّم بأنه تجريبي: تصل الدعوات بالبريد وفي عنوانها «[تجربة]» وفي متنها شريط تنبيه، ولا تُرسَل رسائل واتساب بل يُسجَّل في أحداث الطلب الحدث `audit.whatsapp_simulated` («كان سيُرسَل عبر واتساب إلى …» برقم مخفي)، ولذلك يلزم بريد لكل موقّع. وتأكيد الهوية محاكاة بلا جلسة لدى المزوّد: يفتح الموقّع صفحة يختار فيها «اعتماد» أو «رفض»، فتصل النتيجة بالحدث `signer.identity_verified` أو `signer.identity_declined`. ويحمل الملف النهائي علامة مائية «تجريبي — بلا حجّية قانونية»، ولا يُختم المحضر ولا يُطلب له ختم زمني، وتذكر صفحة التحقّق العامّة أن الوثيقة تجريبية. والحدود لكل حساب: 20 طلبًا و50 رسالة بريد في اليوم، و5 موقّعين في الطلب، و10 مستلمين في الدفعة الجماعية؛ وتُرفض الزيادة بـ`429 test_daily_limit` أو `429 test_email_limit` أو `400 test_signer_limit` أو `400 test_bulk_limit`، والموقّع بلا بريد بـ`400 test_email_required`.\n\n**Idempotency:** أرسل ترويسة `Idempotency-Key` مع أي `POST` (حتى 200 حرف، صالحة 24 ساعة). تكرار الطلب بنفس المفتاح ونفس المسار يُعيد الاستجابة المحفوظة مع `Idempotent-Replayed: true`؛ وإن وصل التكرار والطلب الأوّل ما زال قيد التنفيذ رُدّ بـ`409 idempotency_in_progress` مع `Retry-After`؛ واستخدام المفتاح نفسه على مسار مختلف يُرجع `409 idempotency_key_reused`.\n\nكل طلب يُرجّع ترويسة `Wsign-Request-Id`. الأخطاء بصيغة موحّدة.\n\n**لغة رسائل الأخطاء:** الحقل `error.message` بالعربية افتراضيًّا، ويصدر بالإنجليزية حين يبدأ رأس الطلب `Accept-Language` بـ`en` (مثل `en-US,en;q=0.9`)، أو حين يُضاف المعامل `?lang=en`، أو حين يُرسَل الطلب إلى المسار `/en/api/v1/…` الذي يعمل كالمسار `/api/v1/…` تمامًا. والمعامل `?lang=ar` يُبقي العربية. ولا تتغيّر رموز الأخطاء `error.code` بتغيّر اللغة، فابنِ منطقك عليها لا على نصّ الرسالة.\n\n**حقول إضافية في الأخطاء:** يحمل `402 plan_required` و`402 plan_expired` و`403 plan_feature_unavailable` الحقل `upgrade_url` (صفحة الباقات في لوحة المطوّرين)، ويحمل `403 kyb_required` الحقل `verify_url` (صفحة «توثيق الشركة»)، ويحمل `400 too_many_signers` الحقل `max_signers` (الحدّ الأقصى للموقّعين في الطلب الحيّ، وهو 5).",
        "version": "2026-07-01",
        "contact": {
            "name": "دعم wsign",
            "url": "https://developers.wsign.io/docs"
        }
    },
    "servers": [
        {
            "url": "https://wsign.io/api/v1",
            "description": "الإنتاج"
        }
    ],
    "security": [
        {
            "bearerAuth": []
        }
    ],
    "tags": [
        {
            "name": "signature_requests",
            "description": "طلبات التوقيع"
        },
        {
            "name": "sessions",
            "description": "الجلسات — طلبات توقيع تُنشأ من مسار عمل"
        },
        {
            "name": "templates",
            "description": "العقود/القوالب"
        },
        {
            "name": "signers",
            "description": "الموقّعون"
        },
        {
            "name": "webhooks",
            "description": "نقاط الويب هوك"
        },
        {
            "name": "flows",
            "description": "التدفّقات الجاهزة للكونسول"
        },
        {
            "name": "account",
            "description": "الحساب والاستهلاك"
        },
        {
            "name": "events",
            "description": "سجل الأحداث (نفس حمولة الويب هوك)"
        },
        {
            "name": "identity",
            "description": "تأكيد الهوية"
        },
        {
            "name": "verifications",
            "description": "التحقّق العام من عقد موقّع"
        }
    ],
    "paths": {
        "/": {
            "get": {
                "tags": [
                    "account"
                ],
                "summary": "جذر الخدمة ومعلومات الحساب",
                "responses": {
                    "200": {
                        "description": "معلومات الخدمة، وفيها الحقل docs برابط التوثيق في لوحة المطوّرين."
                    }
                }
            }
        },
        "/usage": {
            "get": {
                "tags": [
                    "account"
                ],
                "summary": "الاستهلاك والرصيد",
                "responses": {
                    "200": {
                        "description": "الاستهلاك",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Usage"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/balance": {
            "get": {
                "tags": [
                    "account"
                ],
                "summary": "رصيد الحساب",
                "responses": {
                    "200": {
                        "description": "الرصيد",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Usage"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/templates": {
            "get": {
                "tags": [
                    "templates"
                ],
                "summary": "قائمة القوالب",
                "parameters": [
                    {
                        "name": "scope",
                        "in": "query",
                        "schema": {
                            "type": "string",
                            "enum": [
                                "mine"
                            ]
                        },
                        "description": "mine = عقودك المخصّصة فقط"
                    },
                    {
                        "name": "search",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "limit",
                        "in": "query",
                        "schema": {
                            "type": "integer",
                            "default": 20
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "قائمة القوالب"
                    }
                }
            },
            "post": {
                "tags": [
                    "templates"
                ],
                "summary": "إنشاء قالب (عقد مخصّص)",
                "description": "تتطلّب مفتاحًا سرّيًا (sk_) — الكتابة ممنوعة على المفاتيح العامة (403).",
                "parameters": [
                    {
                        "name": "Idempotency-Key",
                        "in": "header",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "maxLength": 200
                        },
                        "description": "مفتاح تكرار آمن للطلب (POST فقط، صالح 24 ساعة). إعادة الإرسال بنفس المفتاح على نفس المسار تُعيد الاستجابة المخزَّنة مع ترويسة Idempotent-Replayed: true؛ وإن وصلت والطلب الأوّل ما زال قيد التنفيذ رُدّت بـ409 مع Retry-After؛ واستخدامه على مسار آخر يُرجع 409."
                    }
                ],
                "responses": {
                    "201": {
                        "description": "أُنشئ",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Template"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "خطأ",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "402": {
                        "description": "خطأ",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "ممنوع — غالبًا قيد على المفتاح العام (pk_) أو قفل النطاق، أو طلب بمفتاح سرّي من عنوان IP خارج قائمته (ip_not_allowed).",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "409": {
                        "description": "مفتاح Idempotency مستخدَم مع نقطة نهاية أخرى (idempotency_key_reused)، أو طلب بالمفتاح نفسه ما زال قيد التنفيذ (idempotency_in_progress، مع Retry-After).",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/TemplateCreate"
                            }
                        }
                    }
                }
            }
        },
        "/templates/{id}": {
            "get": {
                "tags": [
                    "templates"
                ],
                "summary": "جلب قالب",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "معرّف المورد"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "القالب",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Template"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "خطأ",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/signature_requests": {
            "get": {
                "tags": [
                    "signature_requests"
                ],
                "summary": "قائمة طلبات التوقيع",
                "description": "يتطلّب مفتاحًا سرّيًا (sk_) — التعداد ممنوع على المفاتيح العامة (403).",
                "parameters": [
                    {
                        "name": "status",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "created_after",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        },
                        "description": "تاريخ ISO أو unix"
                    },
                    {
                        "name": "created_before",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "starting_after",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        },
                        "description": "مؤشّر الصفحة"
                    },
                    {
                        "name": "limit",
                        "in": "query",
                        "schema": {
                            "type": "integer",
                            "default": 20
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "قائمة الطلبات"
                    },
                    "403": {
                        "description": "ممنوع — غالبًا قيد على المفتاح العام (pk_) أو قفل النطاق، أو طلب بمفتاح سرّي من عنوان IP خارج قائمته (ip_not_allowed).",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "429": {
                        "description": "تجاوز حدّ المعدّل — راجع ترويسة Retry-After.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            },
            "post": {
                "tags": [
                    "signature_requests"
                ],
                "summary": "إنشاء طلب توقيع وإرساله",
                "description": "عملية تخصم من الرصيد. بمفتاح عام (pk_) تخضع لحصّة 5 عمليات/ساعة لكل زائر (429). والطلب الحيّ المُرسَل يتطلّب باقة مدفوعة سارية (`402 plan_required` أو `402 plan_expired`) وشركة موثّقة (`403 kyb_required`).",
                "parameters": [
                    {
                        "name": "Idempotency-Key",
                        "in": "header",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "maxLength": 200
                        },
                        "description": "مفتاح تكرار آمن للطلب (POST فقط، صالح 24 ساعة). إعادة الإرسال بنفس المفتاح على نفس المسار تُعيد الاستجابة المخزَّنة مع ترويسة Idempotent-Replayed: true؛ وإن وصلت والطلب الأوّل ما زال قيد التنفيذ رُدّت بـ409 مع Retry-After؛ واستخدامه على مسار آخر يُرجع 409."
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/SignatureRequestCreate"
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "أُنشئ",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/SignatureRequest"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "خطأ",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "402": {
                        "description": "خطأ",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "ممنوع — طلب حيّ قبل اعتماد توثيق الشركة (kyb_required)، أو خاصية غير متاحة في باقتك (plan_feature_unavailable)، أو قيد على المفتاح العام (pk_) أو قفل النطاق، أو طلب بمفتاح سرّي من عنوان IP خارج قائمته (ip_not_allowed).",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "409": {
                        "description": "مفتاح Idempotency مستخدَم مع نقطة نهاية أخرى (idempotency_key_reused)، أو طلب بالمفتاح نفسه ما زال قيد التنفيذ (idempotency_in_progress، مع Retry-After).",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "429": {
                        "description": "تجاوز حدّ المعدّل — راجع ترويسة Retry-After.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/signature_requests/bulk": {
            "post": {
                "tags": [
                    "signature_requests"
                ],
                "summary": "إرسال جماعي (نفس العقد لعدّة موقّعين)",
                "parameters": [
                    {
                        "name": "Idempotency-Key",
                        "in": "header",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "maxLength": 200
                        },
                        "description": "مفتاح تكرار آمن للطلب (POST فقط، صالح 24 ساعة). إعادة الإرسال بنفس المفتاح على نفس المسار تُعيد الاستجابة المخزَّنة مع ترويسة Idempotent-Replayed: true؛ وإن وصلت والطلب الأوّل ما زال قيد التنفيذ رُدّت بـ409 مع Retry-After؛ واستخدامه على مسار آخر يُرجع 409."
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/BulkSend"
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "ملخّص الدفعة"
                    },
                    "400": {
                        "description": "خطأ",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "402": {
                        "description": "خطأ",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "ممنوع — طلب حيّ قبل اعتماد توثيق الشركة (kyb_required)، أو خاصية غير متاحة في باقتك (plan_feature_unavailable)، أو قيد على المفتاح العام (pk_) أو قفل النطاق، أو طلب بمفتاح سرّي من عنوان IP خارج قائمته (ip_not_allowed).",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "409": {
                        "description": "مفتاح Idempotency مستخدَم مع نقطة نهاية أخرى (idempotency_key_reused)، أو طلب بالمفتاح نفسه ما زال قيد التنفيذ (idempotency_in_progress، مع Retry-After).",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "429": {
                        "description": "تجاوز حدّ المعدّل — راجع ترويسة Retry-After.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/signature_requests/{id}": {
            "get": {
                "tags": [
                    "signature_requests"
                ],
                "summary": "جلب طلب توقيع",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "معرّف المورد"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "الطلب",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/SignatureRequest"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "خطأ",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/signature_requests/{id}/send": {
            "post": {
                "tags": [
                    "signature_requests"
                ],
                "summary": "إرسال طلب مسودّة",
                "description": "يخصم تكلفة الإرسال مرّة واحدة. إعادة الإرسال لطلب مشحون سلفًا تُعامَل كتذكير: ساعة على الأقل بين رسالتين لكل موقّع، وسقف 10 تذكيرات للطلب (429).",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "معرّف المورد"
                    },
                    {
                        "name": "Idempotency-Key",
                        "in": "header",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "maxLength": 200
                        },
                        "description": "مفتاح تكرار آمن للطلب (POST فقط، صالح 24 ساعة). إعادة الإرسال بنفس المفتاح على نفس المسار تُعيد الاستجابة المخزَّنة مع ترويسة Idempotent-Replayed: true؛ وإن وصلت والطلب الأوّل ما زال قيد التنفيذ رُدّت بـ409 مع Retry-After؛ واستخدامه على مسار آخر يُرجع 409."
                    }
                ],
                "responses": {
                    "200": {
                        "description": "أُرسل"
                    },
                    "402": {
                        "description": "خطأ",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "ممنوع — طلب حيّ قبل اعتماد توثيق الشركة (kyb_required)، أو خاصية غير متاحة في باقتك (plan_feature_unavailable)، أو قيد على المفتاح العام (pk_) أو قفل النطاق، أو طلب بمفتاح سرّي من عنوان IP خارج قائمته (ip_not_allowed).",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "409": {
                        "description": "مفتاح Idempotency مستخدَم مع نقطة نهاية أخرى (idempotency_key_reused)، أو طلب بالمفتاح نفسه ما زال قيد التنفيذ (idempotency_in_progress، مع Retry-After).",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "429": {
                        "description": "تجاوز حدّ المعدّل — راجع ترويسة Retry-After.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/signature_requests/{id}/cancel": {
            "post": {
                "tags": [
                    "signature_requests"
                ],
                "summary": "إلغاء طلب",
                "description": "يُرفض بـ409 (request_not_cancelable) إن كان الطلب مكتملًا أو مُلغى سلفًا. ولا يُستردّ ما خُصم عن الطلب بعد إرساله، ولو أُلغي قبل أن يوقّعه أحد.",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "معرّف المورد"
                    },
                    {
                        "name": "Idempotency-Key",
                        "in": "header",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "maxLength": 200
                        },
                        "description": "مفتاح تكرار آمن للطلب (POST فقط، صالح 24 ساعة). إعادة الإرسال بنفس المفتاح على نفس المسار تُعيد الاستجابة المخزَّنة مع ترويسة Idempotent-Replayed: true؛ وإن وصلت والطلب الأوّل ما زال قيد التنفيذ رُدّت بـ409 مع Retry-After؛ واستخدامه على مسار آخر يُرجع 409."
                    }
                ],
                "responses": {
                    "200": {
                        "description": "أُلغي"
                    },
                    "409": {
                        "description": "مفتاح Idempotency مستخدَم مع نقطة نهاية أخرى (idempotency_key_reused)، أو طلب بالمفتاح نفسه ما زال قيد التنفيذ (idempotency_in_progress، مع Retry-After).",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "429": {
                        "description": "تجاوز حدّ المعدّل — راجع ترويسة Retry-After.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/signature_requests/{id}/reminders": {
            "post": {
                "tags": [
                    "signature_requests"
                ],
                "summary": "إرسال تذكير للموقّعين",
                "description": "تذكير واحد لكل موقّع كل ساعة كحدّ أقصى، وسقف 10 تذكيرات لكل طلب. المخالفة تُرجع 429 (reminder_too_soon / reminder_limit_reached). والطلب المسودّة أو المُلغى يُرجع 400.",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "معرّف المورد"
                    },
                    {
                        "name": "Idempotency-Key",
                        "in": "header",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "maxLength": 200
                        },
                        "description": "مفتاح تكرار آمن للطلب (POST فقط، صالح 24 ساعة). إعادة الإرسال بنفس المفتاح على نفس المسار تُعيد الاستجابة المخزَّنة مع ترويسة Idempotent-Replayed: true؛ وإن وصلت والطلب الأوّل ما زال قيد التنفيذ رُدّت بـ409 مع Retry-After؛ واستخدامه على مسار آخر يُرجع 409."
                    }
                ],
                "responses": {
                    "200": {
                        "description": "أُرسل التذكير"
                    },
                    "400": {
                        "description": "خطأ",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "409": {
                        "description": "مفتاح Idempotency مستخدَم مع نقطة نهاية أخرى (idempotency_key_reused)، أو طلب بالمفتاح نفسه ما زال قيد التنفيذ (idempotency_in_progress، مع Retry-After).",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "429": {
                        "description": "تجاوز حدّ المعدّل — راجع ترويسة Retry-After.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/signature_requests/{id}/download": {
            "get": {
                "tags": [
                    "signature_requests"
                ],
                "summary": "رابط تنزيل العقد الموقّع",
                "description": "يُرجع بيانات العقد الموقّع بصيغة JSON بعد اكتمال الطلب: `pdf_url` رابط ملف PDF النهائي (نصّ العقد المجمَّد مع شهادة التحقّق نفسها المستعملة في المنصّة بمرجعها ورمز QR)، و`pdf_status` حالته (`ready` جاهز، و`pending` قيد الإعداد، و`unavailable` تعذّر إنشاؤه على الخادم فاستعمل `final_document_url`)، و`pdf_sha256` بصمته، و`final_document_url` صفحة الوثيقة النهائية، و`reference` مرجع التحقّق. وفي الوضع الحيّ يصل رابط الملف نفسه إلى كل الموقّعين والمُرسِل عند الاكتمال. ولا يتضمّن الملف توقيع PAdES مضمّنًا؛ الدليل التشفيري المستقل هو محضر الأدلّة المختوم عبر GET /signature_requests/{id}/evidence. والطلب غير المكتمل يُرجع 400.",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "معرّف المورد"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "روابط الملف"
                    },
                    "400": {
                        "description": "خطأ",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/signature_requests/{id}/download/pdf": {
            "get": {
                "tags": [
                    "signature_requests"
                ],
                "summary": "تنزيل ملف PDF النهائي",
                "description": "يُرجع ملف PDF النهائي نفسه (application/pdf) بعد اكتمال الطلب، وتحمل الترويسة `X-File-Sha256` بصمته المطابقة لقيمة `pdf_sha256`. يتطلّب مفتاحًا سرّيًا (sk_). ويُرجع 409 بالرمز `pdf_not_ready` ما دام الملف قيد الإعداد، أو بالرمز `pdf_unavailable` إن تعذّر إنشاؤه على الخادم.",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "معرّف المورد"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "ملف PDF النهائي",
                        "content": {
                            "application/pdf": {
                                "schema": {
                                    "type": "string",
                                    "format": "binary"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "خطأ",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "409": {
                        "description": "خطأ",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/signature_requests/{id}/evidence": {
            "get": {
                "tags": [
                    "signature_requests"
                ],
                "summary": "محضر الأدلّة المختوم",
                "description": "يُرجع محضر الأدلّة المختوم للطلب المكتمل (record_raw وتوقيع Ed25519 والمفتاح العام والختم الزمني RFC3161) للتحقّق المستقلّ منه. يتطلّب مفتاحًا سرّيًا (sk_)، ويُرجع 404 ما لم يُختم المحضر؛ وطلبات التجربة لا يُختم لها محضر.",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "معرّف المورد"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "محضر الأدلّة"
                    },
                    "403": {
                        "description": "ممنوع — غالبًا قيد على المفتاح العام (pk_) أو قفل النطاق، أو طلب بمفتاح سرّي من عنوان IP خارج قائمته (ip_not_allowed).",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "خطأ",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/signature_requests/{id}/certificate": {
            "get": {
                "tags": [
                    "signature_requests"
                ],
                "summary": "شهادة الإتمام وسجل التدقيق",
                "description": "حقول `ip` في سجل التدقيق تُفرَّغ إلى null للمفاتيح العامة (pk_).",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "معرّف المورد"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "الشهادة"
                    }
                }
            }
        },
        "/signature_requests/{id}/events": {
            "get": {
                "tags": [
                    "signature_requests"
                ],
                "summary": "أحداث/سجل تدقيق الطلب",
                "description": "حقل `ip` يُفرَّغ إلى null للمفاتيح العامة (pk_).",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "معرّف المورد"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "الأحداث"
                    }
                }
            }
        },
        "/sessions": {
            "get": {
                "tags": [
                    "sessions"
                ],
                "summary": "قائمة الجلسات",
                "description": "تُرجع طلبات التوقيع المنشأة من مسارات العمل، من الأحدث إلى الأقدم، في وضع المفتاح نفسه (حيّ أو تجربة). تتطلّب مفتاحًا سرّيًا (sk_).",
                "parameters": [
                    {
                        "name": "workflow_id",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        },
                        "example": "wf_8f3a1c9e2b",
                        "description": "جلسات مسار عمل بعينه"
                    },
                    {
                        "name": "vendor_data",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        },
                        "description": "مرجعك كما أرسلته عند الإنشاء (مطابقة تامّة)"
                    },
                    {
                        "name": "status",
                        "in": "query",
                        "schema": {
                            "type": "string",
                            "enum": [
                                "draft",
                                "sent",
                                "partially_signed",
                                "completed",
                                "declined",
                                "expired",
                                "canceled"
                            ]
                        }
                    },
                    {
                        "name": "starting_after",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        },
                        "description": "مؤشّر الصفحة"
                    },
                    {
                        "name": "limit",
                        "in": "query",
                        "schema": {
                            "type": "integer",
                            "default": 20,
                            "minimum": 1,
                            "maximum": 100
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "قائمة الجلسات",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/SessionList"
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "ممنوع — غالبًا قيد على المفتاح العام (pk_) أو قفل النطاق، أو طلب بمفتاح سرّي من عنوان IP خارج قائمته (ip_not_allowed).",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "429": {
                        "description": "تجاوز حدّ المعدّل — راجع ترويسة Retry-After.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            },
            "post": {
                "tags": [
                    "sessions"
                ],
                "summary": "إنشاء جلسة من مسار عمل",
                "description": "يُنشئ طلب توقيع بإعدادات مسار عمل منشور ويرسله في الحال. معرّف الجلسة هو معرّف طلب التوقيع نفسه (`sr_…`)، فتعمل معه نقاط `/signature_requests/{id}` كلّها. تتطلّب مفتاحًا سرّيًا (sk_)؛ والمفتاح العام (pk_) ومفتاح القراءة فقط يُرفضان بـ403. ويُنشأ الطلب على المسار الافتراضي في كل الباقات بالمعرّف `default`: مستنده يُحدَّد مع كل طلب (`template_id`)، والقناة البريد، والتوقيع الموثّق، والصلاحية 7 أيام، ويجوز تغيير ما يجوز تغييره في أي مسار.\n\n**ما يجوز تغييره مع الطلب:** `signature_method` و`channel` و`cc` و`require_id_attachment` و`expires_in` و`language` و`return_url`، والمستند (`template_id` أو `document_id`) حين يكون مستند المسار «يُحدَّد مع كل طلب». أمّا `ordered` و`reminders` و`require_access_code` فتُضبط في المسار وحده، وتُرفض معها الحقول `send` و`legal_level` و`require_identity` و`source` و`document` و`signers[].method` و`signers[].require_identity` بـ`400 invalid_override`، ويحمل `param` اسم الحقل.\n\n**القنوات:** `email` تشترط بريدًا لكل موقّع، و`whatsapp` تشترط رقمًا لكل موقّع وهي بلا تكلفة إضافية، و`link` لا ترسل دعوة ولا تذكيرات وتعود الروابط كلها في الردّ.\n\n**رمز التحقّق:** يصل بقناة الطلب وحدها: بالبريد مع `email`، وبواتساب مع `whatsapp`؛ ويصل بالبريد إن لم يكن للموقّع رقم أو لم تكن رموز واتساب مفعَّلة على المنصّة. ومع `link` يصل إلى بريد الموقّع إن وُجد، وإلّا فإلى رقمه.\n\n**التوقيع بالترتيب:** في المسار الذي يوقّع أطرافه بالترتيب يُدعى كل طرف بعد توقيع سابقه، ويصل الحدث `signer.sent` عند حلول دوره. ومع القناة `link` تعود الروابط كلها في ردّ الإنشاء، ولا تقبل صفحة التوقيع طرفًا قبل أن يوقّع مَن قبله.\n\n**رابط العودة:** يُضبط في المسار أو يُرسَل في `return_url`: رابط `https` على دومين مقبول في حسابك (حتى 500 حرف، بلا اسم مستخدم ولا `#`)، وإلّا رُدّ `400 invalid_override` أو `400 domain_not_accepted`. بعد أن يوقّع الموقّع أو يرفض يُحوَّل إلى الرابط ومعه `session_id` و`signer_id` و`status` (`completed` أو `declined`). واعتمد النتيجة من الإشعار الموقَّع أو من `GET /sessions/{id}`، لا من العودة.\n\n**الوضع الحيّ:** الجلسة الحيّة تتطلّب باقة مدفوعة سارية وشركة موثّقة، وإلّا رُدّ `402 plan_required` أو `402 plan_expired` أو `403 kyb_required`.\n\n**التكلفة:** تُخصم مرّة واحدة عند الإرسال: تكلفة الطلب، وتُضاف تكلفة تأكيد الهوية عن كل موقّع حين تكون الطريقة `identity` (الأسعار في `GET /`). يُفحص الرصيد قبل الإنشاء، ويعود المخصوم في `cost`. وبمفتاح التجربة لا يُخصم شيء، وتصل الدعوة بالبريد بعلامة «تجربة»، ولا تُرسَل رسائل واتساب، ويُحاكى تأكيد الهوية. ولا يُستردّ ما خُصم عن الطلب بعد إرساله، ولو أُلغي قبل أن يوقّعه أحد.\n\n**الأخطاء:** `parameter_missing`، `workflow_not_found` (404)، `workflow_not_live` (409)، `invalid_override`، `invalid_signer`، `invalid_request`، `channel_unavailable`، `domain_not_accepted`، `insufficient_balance` (402)، `plan_required` (402)، `plan_expired` (402)، `kyb_required` (403)، `plan_feature_unavailable` (403)، `test_daily_limit` (429)، `test_email_limit` (429)، `test_signer_limit`، `test_email_required`، `delivery_failed` (502)، `feature_unavailable` (503).\n\n**الإشعارات:** أسماء الأحداث كما هي. تحمل أحداث `signature_request.*` الحقول `workflow_id` و`workflow_version` و`vendor_data` و`channel` داخل كائن الطلب، وتحمل أحداث `signer.*` الحقول `signature_request` و`workflow_id` و`workflow_version` و`vendor_data`.",
                "parameters": [
                    {
                        "name": "Idempotency-Key",
                        "in": "header",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "maxLength": 200
                        },
                        "description": "مفتاح تكرار آمن للطلب (POST فقط، صالح 24 ساعة). إعادة الإرسال بنفس المفتاح على نفس المسار تُعيد الاستجابة المخزَّنة مع ترويسة Idempotent-Replayed: true؛ وإن وصلت والطلب الأوّل ما زال قيد التنفيذ رُدّت بـ409 مع Retry-After؛ واستخدامه على مسار آخر يُرجع 409."
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/SessionCreate"
                            },
                            "example": {
                                "workflow_id": "wf_8f3a1c9e2b",
                                "vendor_data": "ORD-1001",
                                "signers": [
                                    {
                                        "name": "أحمد محمد",
                                        "email": "ahmed@example.com"
                                    }
                                ]
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "أُنشئت الجلسة",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Session"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "خطأ",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "402": {
                        "description": "خطأ",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "ممنوع — طلب حيّ قبل اعتماد توثيق الشركة (kyb_required)، أو خاصية غير متاحة في باقتك (plan_feature_unavailable)، أو قيد على المفتاح العام (pk_) أو قفل النطاق، أو طلب بمفتاح سرّي من عنوان IP خارج قائمته (ip_not_allowed).",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "خطأ",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "409": {
                        "description": "المسار لم يُنشَر بعد أو مؤرشف (workflow_not_live)، أو تعارض في مفتاح Idempotency (idempotency_key_reused / idempotency_in_progress).",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "429": {
                        "description": "تجاوز حدّ المعدّل — راجع ترويسة Retry-After.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "502": {
                        "description": "خطأ",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "503": {
                        "description": "خطأ",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/sessions/{id}": {
            "get": {
                "tags": [
                    "sessions"
                ],
                "summary": "جلب جلسة",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "معرّف المورد"
                    }
                ],
                "description": "يُرجع كائن الجلسة بحالته الحالية. ويُرجع 404 لطلب توقيع لم يُنشأ من مسار عمل. يتطلّب مفتاحًا سرّيًا (sk_).",
                "responses": {
                    "200": {
                        "description": "الجلسة",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Session"
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "ممنوع — غالبًا قيد على المفتاح العام (pk_) أو قفل النطاق، أو طلب بمفتاح سرّي من عنوان IP خارج قائمته (ip_not_allowed).",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "خطأ",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/signers/{id}": {
            "get": {
                "tags": [
                    "signers"
                ],
                "summary": "جلب موقّع",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "معرّف المورد"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "الموقّع",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Signer"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "خطأ",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/signers/{id}/signing_session": {
            "post": {
                "tags": [
                    "signers"
                ],
                "summary": "جلسة توقيع مضمّنة قصيرة العمر (30 دقيقة)",
                "description": "تُنشئ رابط توقيع مؤقّتًا صالحًا للتضمين في iframe. مسموحة لمفاتيح sk_ فقط (pk_ للقراءة على /signers ⇒ 403). `return_url` اختياري، ويجب أن يكون https على دومين مقبول في حسابك، وإلا 400 (domain_not_accepted للدومين غير المقبول). وبنمط `redirect` يُحوَّل المتصفّح من `signing_url` إلى صفحة التوقيع، ثم إلى `success_url` بعد التوقيع أو إلى `cancel_url` بعد رفضه، ومعهما `session_id` و`signer_id` و`status`.",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "معرّف المورد"
                    },
                    {
                        "name": "Idempotency-Key",
                        "in": "header",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "maxLength": 200
                        },
                        "description": "مفتاح تكرار آمن للطلب (POST فقط، صالح 24 ساعة). إعادة الإرسال بنفس المفتاح على نفس المسار تُعيد الاستجابة المخزَّنة مع ترويسة Idempotent-Replayed: true؛ وإن وصلت والطلب الأوّل ما زال قيد التنفيذ رُدّت بـ409 مع Retry-After؛ واستخدامه على مسار آخر يُرجع 409."
                    }
                ],
                "requestBody": {
                    "required": false,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "return_url": {
                                        "type": "string",
                                        "format": "uri",
                                        "example": "https://example.com/thanks",
                                        "description": "رابط https على دومين مقبول في حسابك، يُنتقل إليه بعد اكتمال التوقيع، ومتاح في باقة «الأعمال» فأعلى."
                                    },
                                    "mode": {
                                        "type": "string",
                                        "enum": [
                                            "iframe",
                                            "redirect"
                                        ],
                                        "default": "iframe",
                                        "description": "iframe للتضمين في إطار داخل صفحة على دومين مقبول في حسابك، أو redirect لتحويل المتصفّح ثم إعادته. ولا يُرسَل return_url مع redirect."
                                    },
                                    "success_url": {
                                        "type": "string",
                                        "format": "uri",
                                        "maxLength": 500,
                                        "example": "https://app.example.com/done?sr={signature_request}",
                                        "description": "مطلوب مع redirect: رابط https على دومين مقبول في حسابك يُحوَّل إليه الموقّع بعد التوقيع (status=completed). ويُستبدل {signature_request} و{signer} بمعرّفيهما."
                                    },
                                    "cancel_url": {
                                        "type": "string",
                                        "format": "uri",
                                        "maxLength": 500,
                                        "example": "https://app.example.com/canceled",
                                        "description": "اختياري مع redirect: يُحوَّل إليه الموقّع إن رفض التوقيع (status=declined). وبدونه يبقى في صفحة التوقيع."
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "الجلسة",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/SigningSession"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "خطأ",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "ممنوع — خاصية غير متاحة في باقتك (plan_feature_unavailable)، أو قيد على المفتاح العام (pk_) أو قفل النطاق، أو طلب بمفتاح سرّي من عنوان IP خارج قائمته (ip_not_allowed).",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "خطأ",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/signers/{id}/identity_match": {
            "post": {
                "tags": [
                    "signers"
                ],
                "summary": "قرار في اختلاف اسم الموقّع",
                "description": "حين يختلف الاسم في وثيقة هوية الموقّع عن الاسم المرسَل في الطلب، ويكون إعداد حسابك «أوقف التوقيع حتى القرار» (الافتراضي)، يصلك الحدث `signer.identity_match_hold` ولا يكتمل التوقيع حتى ترسل القرار هنا أو من صفحة «مراجعة الهوية» في لوحة المطوّرين. approve يستكمل التوقيع، و reject يوقف توقيع هذا الطرف. ومسموحة لمفاتيح sk_ وحدها. وإن لم يوجد قرار معلّق: 409 identity_match_not_pending.",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "معرّف المورد"
                    },
                    {
                        "name": "Idempotency-Key",
                        "in": "header",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "maxLength": 200
                        },
                        "description": "مفتاح تكرار آمن للطلب (POST فقط، صالح 24 ساعة). إعادة الإرسال بنفس المفتاح على نفس المسار تُعيد الاستجابة المخزَّنة مع ترويسة Idempotent-Replayed: true؛ وإن وصلت والطلب الأوّل ما زال قيد التنفيذ رُدّت بـ409 مع Retry-After؛ واستخدامه على مسار آخر يُرجع 409."
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "decision"
                                ],
                                "properties": {
                                    "decision": {
                                        "type": "string",
                                        "enum": [
                                            "approve",
                                            "reject"
                                        ]
                                    },
                                    "note": {
                                        "type": "string",
                                        "maxLength": 200,
                                        "description": "ملاحظة داخلية اختيارية تُحفظ مع القرار."
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "الموقّع بعد القرار، وفي identity.name_match الحالة الجديدة",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Signer"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "خطأ",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "خطأ",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "409": {
                        "description": "خطأ",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/events": {
            "get": {
                "tags": [
                    "events"
                ],
                "summary": "قائمة أحداث الحساب",
                "description": "نفس حمولة الويب هوك بالضبط — مفيدة للاستدراك بعد انقطاع نقطة الاستقبال. تتطلّب مفتاحًا سرّيًا (sk_).",
                "parameters": [
                    {
                        "name": "type",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        },
                        "description": "تصفية بنوع الحدث، مثل signature_request.completed"
                    },
                    {
                        "name": "starting_after",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        },
                        "description": "مؤشّر الصفحة (evt_…)"
                    },
                    {
                        "name": "limit",
                        "in": "query",
                        "schema": {
                            "type": "integer",
                            "default": 20
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "قائمة الأحداث"
                    },
                    "403": {
                        "description": "ممنوع — غالبًا قيد على المفتاح العام (pk_) أو قفل النطاق، أو طلب بمفتاح سرّي من عنوان IP خارج قائمته (ip_not_allowed).",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/events/{id}": {
            "get": {
                "tags": [
                    "events"
                ],
                "summary": "جلب حدث بعينه",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "معرّف المورد"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "الحدث",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Event"
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "ممنوع — غالبًا قيد على المفتاح العام (pk_) أو قفل النطاق، أو طلب بمفتاح سرّي من عنوان IP خارج قائمته (ip_not_allowed).",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "خطأ",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/events/{id}/redeliver": {
            "post": {
                "tags": [
                    "events"
                ],
                "summary": "إعادة إرسال إشعار حدث",
                "description": "إعادة إرسال إشعار حدث سابق بحمولته نفسها ومعرّفه نفسه، موقَّعًا بسرّ الوجهة الحالي. تُنشأ عملية تسليم جديدة تُحاوَل فورًا، وتتبع جدول إعادة المحاولة المعتاد إن لم يردّ خادمك برمز 2xx. والحدّ: خمس مرات للحدث الواحد وثلاثون للحساب كل عشر دقائق، ثم 429.",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "معرّف المورد"
                    },
                    {
                        "name": "Idempotency-Key",
                        "in": "header",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "maxLength": 200
                        },
                        "description": "مفتاح تكرار آمن للطلب (POST فقط، صالح 24 ساعة). إعادة الإرسال بنفس المفتاح على نفس المسار تُعيد الاستجابة المخزَّنة مع ترويسة Idempotent-Replayed: true؛ وإن وصلت والطلب الأوّل ما زال قيد التنفيذ رُدّت بـ409 مع Retry-After؛ واستخدامه على مسار آخر يُرجع 409."
                    }
                ],
                "requestBody": {
                    "required": false,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "endpoint": {
                                        "type": "string",
                                        "example": "we_123",
                                        "description": "معرّف وجهة مفعّلة (we_) لإعادة الإرسال إليها وحدها. وبدونه يُعاد الإرسال إلى كل وجهة مفعّلة مشتركة في نوع الحدث."
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "نتيجة إعادة الإرسال",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "object": {
                                            "type": "string",
                                            "example": "event_redelivery"
                                        },
                                        "event": {
                                            "type": "string",
                                            "example": "evt_123"
                                        },
                                        "deliveries": {
                                            "type": "array",
                                            "items": {
                                                "type": "object",
                                                "properties": {
                                                    "endpoint": {
                                                        "type": "string",
                                                        "example": "we_123"
                                                    },
                                                    "status": {
                                                        "type": "string",
                                                        "enum": [
                                                            "succeeded",
                                                            "pending",
                                                            "failed"
                                                        ]
                                                    },
                                                    "response_code": {
                                                        "type": "integer",
                                                        "nullable": true
                                                    },
                                                    "error": {
                                                        "type": "string",
                                                        "nullable": true
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "خطأ",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "ممنوع — غالبًا قيد على المفتاح العام (pk_) أو قفل النطاق، أو طلب بمفتاح سرّي من عنوان IP خارج قائمته (ip_not_allowed).",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "خطأ",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "429": {
                        "description": "تجاوز حدّ المعدّل — راجع ترويسة Retry-After.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/identity_verifications/{id}": {
            "get": {
                "tags": [
                    "identity"
                ],
                "summary": "حالة تأكيد الهوية (idv_…)",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "معرّف المورد"
                    }
                ],
                "description": "تتطلّب مفتاحًا سرّيًا (sk_). تُرجع 403 إن لم تكن العملية تخصّ حسابك.",
                "responses": {
                    "200": {
                        "description": "عملية التحقّق",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/IdentityVerification"
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "ممنوع — غالبًا قيد على المفتاح العام (pk_) أو قفل النطاق، أو طلب بمفتاح سرّي من عنوان IP خارج قائمته (ip_not_allowed).",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "خطأ",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/verifications/{reference}": {
            "get": {
                "tags": [
                    "verifications"
                ],
                "summary": "تحقّق من صحّة عقد موقّع بمرجع التحقّق",
                "description": "يُرجع حالة العقد وسلامة محتواه (intact/modified/recorded/unknown) والتزامه البنيويّ (structure) وأطرافه بأسماء وبريد مُقنَّعين. تتطلّب مفتاحًا سرّيًا (sk_).",
                "parameters": [
                    {
                        "name": "reference",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "example": "WTQ-1A2B3C4D5E6F",
                        "description": "مرجع التحقّق كما يظهر في شهادة الإتمام أو في رمز QR، دون شرطات داخلية، مثل WTQ-1A2B3C4D5E6F أو WTH-1A2B3C4D5E6F. ولا يُقبَل رقم الوثيقة."
                    }
                ],
                "responses": {
                    "200": {
                        "description": "نتيجة التحقّق",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Verification"
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "ممنوع — غالبًا قيد على المفتاح العام (pk_) أو قفل النطاق، أو طلب بمفتاح سرّي من عنوان IP خارج قائمته (ip_not_allowed).",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "لا توجد وثيقة بهذا المرجع: خطأ بالرمز not_found، ومعه الحقلان param و reference.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/flows": {
            "get": {
                "tags": [
                    "flows"
                ],
                "summary": "قائمة التدفّقات الجاهزة",
                "description": "التدفّقات صيغة قديمة تُقرأ هنا ولا تُنشأ منها تدفّقات جديدة، ولإعداد خطّ التوقيع استعمل مسارات العمل من لوحة المطوّرين. وتُستخدم مع الكونسول: `<wsign-console flow=\"flow_…\">`.",
                "responses": {
                    "200": {
                        "description": "قائمة التدفّقات"
                    }
                }
            }
        },
        "/flows/{id}": {
            "get": {
                "tags": [
                    "flows"
                ],
                "summary": "جلب تدفّق",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "معرّف المورد"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "التدفّق",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Flow"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "خطأ",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/webhook_endpoints": {
            "get": {
                "tags": [
                    "webhooks"
                ],
                "summary": "قائمة نقاط الويب هوك",
                "parameters": [
                    {
                        "name": "limit",
                        "in": "query",
                        "schema": {
                            "type": "integer",
                            "default": 20,
                            "minimum": 1,
                            "maximum": 100
                        }
                    },
                    {
                        "name": "starting_after",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        },
                        "description": "مؤشّر الصفحة (we_…)"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "القائمة من الأحدث إلى الأقدم، ومعها has_more و next_cursor.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "object": {
                                            "type": "string",
                                            "example": "list"
                                        },
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/components/schemas/WebhookEndpoint"
                                            }
                                        },
                                        "has_more": {
                                            "type": "boolean"
                                        },
                                        "next_cursor": {
                                            "type": "string",
                                            "nullable": true,
                                            "description": "أرسله في starting_after لجلب الصفحة التالية."
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            },
            "post": {
                "tags": [
                    "webhooks"
                ],
                "summary": "إنشاء نقطة ويب هوك",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/WebhookCreate"
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "أُنشئت",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/WebhookEndpoint"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "خطأ",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/webhook_endpoints/event_types": {
            "get": {
                "tags": [
                    "webhooks"
                ],
                "summary": "أنواع الأحداث المدعومة",
                "responses": {
                    "200": {
                        "description": "قائمة الأنواع"
                    }
                }
            }
        },
        "/webhook_endpoints/{id}": {
            "get": {
                "tags": [
                    "webhooks"
                ],
                "summary": "جلب نقطة",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "معرّف المورد"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "النقطة"
                    },
                    "404": {
                        "description": "خطأ",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            },
            "post": {
                "tags": [
                    "webhooks"
                ],
                "summary": "تحديث نقطة (الرابط/الأحداث/الحالة)",
                "description": "يقبل `url` و`enabled_events` و`status`. الرابط الجديد يُفحص كما عند الإنشاء: رابط `https` لا يشير إلى عنوان داخلي، وإلّا `400` بـ`param=url`؛ والمضيف الذي لا يُعثر عليه في DNS يُردّ بالرمز `url_unresolvable` لا بخطأ العنوان الداخلي. والسرّ لا يتغيّر بتغيير الرابط.",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "معرّف المورد"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "حُدّثت"
                    },
                    "400": {
                        "description": "خطأ",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            },
            "delete": {
                "tags": [
                    "webhooks"
                ],
                "summary": "حذف نقطة",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "معرّف المورد"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "حُذفت"
                    }
                }
            }
        },
        "/webhook_endpoints/{id}/deliveries": {
            "get": {
                "tags": [
                    "webhooks"
                ],
                "summary": "آخر عمليات التسليم",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "معرّف المورد"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "التسليمات"
                    }
                }
            }
        },
        "/webhook_endpoints/{id}/rotate_secret": {
            "post": {
                "tags": [
                    "webhooks"
                ],
                "summary": "تجديد سرّ التوقيع",
                "description": "يُصدر سرًّا جديدًا للنقطة ويعيده في `secret` مرّة واحدة، ويبطل السرّ القديم فورًا: تحقّق من الإشعارات التالية بالسرّ الجديد.",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "معرّف المورد"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "النقطة ومعها السرّ الجديد",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/WebhookEndpoint"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "خطأ",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/webhook_endpoints/{id}/test": {
            "post": {
                "tags": [
                    "webhooks"
                ],
                "summary": "إرسال حدث اختبار",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "معرّف المورد"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "نتيجة الاختبار"
                    }
                }
            }
        }
    },
    "components": {
        "securitySchemes": {
            "bearerAuth": {
                "type": "http",
                "scheme": "bearer",
                "description": "مفتاح API: `Authorization: Bearer sk_...` أو `pk_...`"
            }
        },
        "schemas": {
            "Error": {
                "type": "object",
                "properties": {
                    "error": {
                        "type": "object",
                        "properties": {
                            "type": {
                                "type": "string"
                            },
                            "code": {
                                "type": "string"
                            },
                            "message": {
                                "type": "string"
                            },
                            "param": {
                                "type": "string",
                                "nullable": true
                            },
                            "request_id": {
                                "type": "string"
                            },
                            "feature": {
                                "type": "string",
                                "nullable": true,
                                "description": "مع plan_feature_unavailable: الخاصية المطلوبة."
                            },
                            "required_plan": {
                                "type": "string",
                                "nullable": true,
                                "description": "مع plan_feature_unavailable: أقلّ باقة تتيح الخاصية."
                            },
                            "upgrade_url": {
                                "type": "string",
                                "format": "uri",
                                "nullable": true,
                                "description": "مع plan_required و plan_expired و plan_feature_unavailable: صفحة الباقات في لوحة المطوّرين."
                            },
                            "verify_url": {
                                "type": "string",
                                "format": "uri",
                                "nullable": true,
                                "description": "مع kyb_required: صفحة «توثيق الشركة» في لوحة المطوّرين."
                            },
                            "max_signers": {
                                "type": "integer",
                                "nullable": true,
                                "example": 5,
                                "description": "مع too_many_signers: الحدّ الأقصى للموقّعين في الطلب الحيّ الواحد."
                            },
                            "reference": {
                                "type": "string",
                                "nullable": true,
                                "description": "مع not_found في GET /verifications/{reference}: المرجع المطلوب."
                            }
                        }
                    }
                }
            },
            "Field": {
                "type": "object",
                "properties": {
                    "key": {
                        "type": "string"
                    },
                    "label": {
                        "type": "string"
                    },
                    "type": {
                        "type": "string",
                        "enum": [
                            "text",
                            "number",
                            "date",
                            "email",
                            "tel",
                            "signature"
                        ]
                    },
                    "required": {
                        "type": "boolean"
                    }
                }
            },
            "Template": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "string",
                        "example": "tpl_123"
                    },
                    "object": {
                        "type": "string"
                    },
                    "name": {
                        "type": "string"
                    },
                    "fields": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/Field"
                        }
                    },
                    "created_at": {
                        "type": "integer"
                    }
                }
            },
            "TemplateCreate": {
                "type": "object",
                "required": [
                    "name",
                    "content"
                ],
                "properties": {
                    "name": {
                        "type": "string",
                        "example": "عقد خدمات"
                    },
                    "content": {
                        "type": "string",
                        "description": "محتوى HTML مع حقول {{key}}",
                        "example": "<p>أقر أنا {{signer_name}} ...</p>"
                    },
                    "fields": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/Field"
                        }
                    }
                }
            },
            "SignerInput": {
                "type": "object",
                "required": [
                    "name"
                ],
                "properties": {
                    "name": {
                        "type": "string"
                    },
                    "email": {
                        "type": "string",
                        "format": "email",
                        "description": "اختياري إن وُجد `phone`. ويجب أن يوجد أحدهما على الأقل."
                    },
                    "phone": {
                        "type": "string",
                        "example": "201012345678",
                        "description": "رقم واتساب الموقّع. تُرسَل الدعوة إليه إضافةً إلى البريد إن وُجد الاثنان. ويُقبل الرقم **وحده** فقط حين يكون إرسال رمز التحقّق عبر واتساب مفعَّلًا؛ وإلّا رُدّ الطلب بـ400 وطُلب بريدٌ للموقّع — كي لا يقف أمام رمز لا سبيل لإيصاله. يُطبَّع تلقائيًّا إلى الصيغة الدولية."
                    },
                    "require_identity": {
                        "type": "boolean"
                    },
                    "fields": {
                        "type": "object",
                        "additionalProperties": {
                            "type": "string"
                        }
                    },
                    "type": {
                        "type": "string",
                        "enum": [
                            "individual",
                            "company"
                        ],
                        "default": "individual"
                    },
                    "method": {
                        "type": "string",
                        "enum": [
                            "draw",
                            "token"
                        ],
                        "default": "draw",
                        "description": "token للتوقيع بشهادة التوكن، ويُفرض مع legal_level بقيمة qes. والقيمة الافتراضية draw."
                    }
                }
            },
            "SignatureRequestCreate": {
                "type": "object",
                "required": [
                    "source",
                    "signers"
                ],
                "properties": {
                    "title": {
                        "type": "string",
                        "maxLength": 250
                    },
                    "require_identity": {
                        "type": "boolean",
                        "description": "تأكيد الهوية لكل الموقّعين، ويُفرض مع aes و qes. ويتخطّاه مفتاح التجربة."
                    },
                    "source": {
                        "type": "object",
                        "properties": {
                            "type": {
                                "type": "string",
                                "enum": [
                                    "template",
                                    "document"
                                ]
                            },
                            "template_id": {
                                "type": "string"
                            },
                            "document_id": {
                                "type": "string"
                            }
                        }
                    },
                    "signers": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/SignerInput"
                        }
                    },
                    "cc": {
                        "type": "array",
                        "description": "مستلمو نسخة — يستلمون العقد الموقّع دون أن يوقّعوا (حتى 20).",
                        "items": {
                            "type": "object",
                            "properties": {
                                "name": {
                                    "type": "string"
                                },
                                "email": {
                                    "type": "string",
                                    "format": "email"
                                }
                            }
                        }
                    },
                    "fields": {
                        "type": "object",
                        "additionalProperties": {
                            "type": "string"
                        }
                    },
                    "legal_level": {
                        "type": "string",
                        "enum": [
                            "ses",
                            "aes",
                            "qes"
                        ],
                        "default": "ses"
                    },
                    "format": {
                        "type": "string",
                        "enum": [
                            "pades-b",
                            "pades-t",
                            "pades-lt",
                            "pades-lta"
                        ],
                        "default": "pades-lt",
                        "description": "مستوى الضمان المطلوب. يُسجَّل على الطلب ويُعاد كما هو للتوافق الخلفي، لكنّ مسار الـAPI لا يُصدر حاليًا توقيع PAdES مضمّنًا داخل ملف الـPDF. الدليل التشفيري المستقل هو محضر الأدلّة المختوم (توقيع Ed25519 + ختم زمني RFC3161)، ويُجلب عبر GET /signature_requests/{id}/evidence، ومفتاح التحقّق العام منشور على /trust."
                    },
                    "ordered": {
                        "type": "boolean",
                        "description": "توقيع تسلسلي بترتيب الموقّعين في المصفوفة signers: يُدعى كل طرف بعد توقيع سابقه، ولا تقبل صفحة التوقيع طرفًا قبل أن يحين دوره."
                    },
                    "send": {
                        "type": "boolean",
                        "default": true,
                        "description": "false يُنشئ مسودّة لا تُرسَل ولا يعمل رابط توقيعها حتى POST /signature_requests/{id}/send."
                    },
                    "reminders": {
                        "type": "object",
                        "description": "{\"enabled\": true} يرسل حتى ثلاثة تذكيرات تلقائية للموقّع الذي حان دوره، قبل انتهاء المهلة بخمسة أيام ثم ثلاثة ثم يوم (للطلبات الحيّة المُرسَلة وحدها). ويُحفظ interval_hours و max ويُعادان كما أُرسلا دون أن يُستخدما."
                    },
                    "metadata": {
                        "type": "object"
                    },
                    "support": {
                        "type": "object",
                        "properties": {
                            "email": {
                                "type": "string",
                                "format": "email",
                                "maxLength": 190,
                                "example": "help@example.com"
                            },
                            "url": {
                                "type": "string",
                                "format": "uri",
                                "maxLength": 500,
                                "example": "https://example.com/help"
                            },
                            "phone": {
                                "type": "string",
                                "maxLength": 24,
                                "example": "+201012345678"
                            }
                        },
                        "description": "بيانات الدعم التي يراها الموقّع حين يضغط زرّ المساعدة في صفحة التوقيع، بدل دعم wsign: بريد أو رابط `https` أو رقم بالصيغة الدولية، واحد منها على الأقل. وبلا هذا الحقل تُعرض بيانات الدعم المحفوظة في إعدادات العلامة، ثم دعم wsign إن لم تحفظ شيئًا (ولا يظهر الزرّ أصلًا مع إخفاء «بواسطة wsign» وبلا بيانات دعم). القيمة غير الصحيحة تُرفض بـ`400` ويحمل `param` اسم الحقل، مثل `support.url`."
                    }
                }
            },
            "BulkSend": {
                "type": "object",
                "required": [
                    "source",
                    "recipients"
                ],
                "properties": {
                    "source": {
                        "type": "object"
                    },
                    "recipients": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/SignerInput"
                        }
                    },
                    "legal_level": {
                        "type": "string",
                        "enum": [
                            "ses",
                            "aes",
                            "qes"
                        ]
                    },
                    "fields": {
                        "type": "object"
                    }
                }
            },
            "Signer": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "string",
                        "example": "sgr_123"
                    },
                    "object": {
                        "type": "string"
                    },
                    "name": {
                        "type": "string"
                    },
                    "email": {
                        "type": "string",
                        "description": "مُقنَّع للمفاتيح العامة (pk_): a****@example.com"
                    },
                    "phone": {
                        "type": "string",
                        "nullable": true,
                        "description": "رقم واتساب الموقّع إن وُجد. مُقنَّع للمفاتيح العامة (pk_): ********5678"
                    },
                    "status": {
                        "type": "string",
                        "enum": [
                            "pending",
                            "sent",
                            "viewed",
                            "otp_verified",
                            "identity_verified",
                            "signed",
                            "declined"
                        ]
                    },
                    "require_identity": {
                        "type": "boolean"
                    },
                    "identity": {
                        "type": "object",
                        "description": "يظهر عند تفعيل تأكيد الهوية للموقّع، وتتغيّر حالته مع أحداث signer.identity_*.",
                        "properties": {
                            "status": {
                                "type": "string",
                                "enum": [
                                    "none",
                                    "required",
                                    "in_review",
                                    "resubmission_requested",
                                    "declined",
                                    "approved"
                                ]
                            },
                            "provider": {
                                "type": "string",
                                "example": "external"
                            },
                            "level": {
                                "type": "string",
                                "example": "aes"
                            },
                            "verification_id": {
                                "type": "string",
                                "nullable": true,
                                "example": "idv_123"
                            },
                            "reason_code": {
                                "type": "string",
                                "nullable": true,
                                "enum": [
                                    "reviewer_decision",
                                    "face_mismatch",
                                    "face_unclear",
                                    "document_expired",
                                    "document_unreadable",
                                    "document_not_original",
                                    "document_not_supported",
                                    "not_accepted",
                                    null
                                ]
                            },
                            "resubmit_steps": {
                                "type": "array",
                                "items": {
                                    "type": "string",
                                    "enum": [
                                        "document",
                                        "liveness"
                                    ]
                                }
                            },
                            "updated_at": {
                                "type": "integer",
                                "nullable": true
                            }
                        }
                    },
                    "signing_url": {
                        "type": "string",
                        "nullable": true,
                        "description": "يُفرَّغ إلى null دائمًا مع المفاتيح العامة (pk_) — الاستثناء الوحيد ردّ إنشاء الطلب نفسه (POST /signature_requests و /bulk). لقراءته لاحقًا استخدم مفتاحًا سرّيًا (sk_) أو أنشئ جلسة توقيع عبر /signers/{id}/signing_session."
                    },
                    "signed_at": {
                        "type": "integer",
                        "nullable": true
                    }
                }
            },
            "SigningSession": {
                "type": "object",
                "properties": {
                    "object": {
                        "type": "string",
                        "example": "signing_session"
                    },
                    "signer": {
                        "type": "string",
                        "example": "sgr_123"
                    },
                    "mode": {
                        "type": "string",
                        "enum": [
                            "iframe",
                            "redirect"
                        ]
                    },
                    "signing_url": {
                        "type": "string",
                        "example": "https://wsign.io/embed/sign/…"
                    },
                    "success_url": {
                        "type": "string",
                        "description": "يظهر بنمط redirect وحده، بعد استبدال {signature_request} و{signer}."
                    },
                    "cancel_url": {
                        "type": "string",
                        "nullable": true,
                        "description": "يظهر بنمط redirect وحده."
                    },
                    "expires_at": {
                        "type": "integer",
                        "description": "unix — بعد 30 دقيقة من الإنشاء"
                    }
                }
            },
            "Event": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "string",
                        "example": "evt_123"
                    },
                    "object": {
                        "type": "string",
                        "example": "event"
                    },
                    "type": {
                        "type": "string",
                        "example": "signature_request.completed"
                    },
                    "created_at": {
                        "type": "integer"
                    },
                    "livemode": {
                        "type": "boolean"
                    },
                    "data": {
                        "type": "object",
                        "properties": {
                            "object": {
                                "type": "object",
                                "description": "الكائن المتأثّر بالحدث. كائن الطلب المنشأ من مسار عمل يحمل workflow_id و workflow_version و vendor_data و channel، وكائن الموقّع في أحداث signer.* يحمل الثلاثة الأولى ومعها signature_request (معرّف الطلب)."
                            }
                        }
                    }
                }
            },
            "IdentityVerification": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "string",
                        "example": "idv_123"
                    },
                    "object": {
                        "type": "string"
                    },
                    "provider": {
                        "type": "string",
                        "example": "external"
                    },
                    "signer": {
                        "type": "string",
                        "nullable": true,
                        "example": "sgr_123"
                    },
                    "status": {
                        "type": "string",
                        "enum": [
                            "pending",
                            "in_review",
                            "resubmission_requested",
                            "approved",
                            "declined",
                            "expired"
                        ]
                    },
                    "level": {
                        "type": "string",
                        "example": "aes"
                    },
                    "verification_url": {
                        "type": "string",
                        "nullable": true
                    },
                    "created_at": {
                        "type": "integer",
                        "nullable": true
                    }
                }
            },
            "Verification": {
                "type": "object",
                "properties": {
                    "object": {
                        "type": "string",
                        "example": "verification"
                    },
                    "reference": {
                        "type": "string",
                        "example": "WTQ-1A2B3C4D5E6F"
                    },
                    "found": {
                        "type": "boolean"
                    },
                    "status": {
                        "type": "string",
                        "enum": [
                            "completed",
                            "in_progress"
                        ]
                    },
                    "integrity": {
                        "type": "string",
                        "enum": [
                            "intact",
                            "modified",
                            "recorded",
                            "unknown"
                        ]
                    },
                    "structure": {
                        "type": "string",
                        "enum": [
                            "match",
                            "changed",
                            "absent"
                        ]
                    },
                    "document": {
                        "type": "object",
                        "properties": {
                            "title": {
                                "type": "string"
                            },
                            "sha256": {
                                "type": "string",
                                "nullable": true,
                                "description": "البصمة المسجّلة. خوارزميتها في hash_alg."
                            },
                            "hash_alg": {
                                "type": "string",
                                "enum": [
                                    "hmac-sha256",
                                    "sha256"
                                ],
                                "description": "hmac-sha256: بصمة نصّ الوثيقة بمفتاح سرّي لدى المنصّة (مراجع WTQ-)، تُطابَق عبر صفحة التحقّق ولا يعيد حسابها طرف خارجي. sha256: تجزئة الملف النهائي (مراجع WTH-) ويعيد حسابها أي طرف."
                            },
                            "format": {
                                "type": "string",
                                "enum": [
                                    "pades-b",
                                    "pades-t",
                                    "pades-lt",
                                    "pades-lta",
                                    "platform-evidence"
                                ],
                                "description": "مستوى توقيع PAdES المضمَّن فعلًا في الملف (حين يوقّع الطرف بالتوكن)، وإلّا platform-evidence: محضر أدلّة مختوم بالوقت بلا توقيع مضمَّن في الملف."
                            },
                            "legal_level": {
                                "type": "string",
                                "enum": [
                                    "ses",
                                    "aes"
                                ]
                            }
                        }
                    },
                    "signed_at": {
                        "type": "integer",
                        "nullable": true
                    },
                    "parties": {
                        "type": "array",
                        "items": {
                            "type": "object"
                        },
                        "description": "الأسماء والبريد مُقنَّعة دائمًا"
                    },
                    "events": {
                        "type": "array",
                        "items": {
                            "type": "object"
                        }
                    },
                    "qr": {
                        "type": "string"
                    }
                }
            },
            "SessionSignerInput": {
                "type": "object",
                "required": [
                    "name"
                ],
                "properties": {
                    "name": {
                        "type": "string"
                    },
                    "email": {
                        "type": "string",
                        "format": "email",
                        "description": "مطلوب مع قناة `email`. ويلزم كل موقّع بريد أو رقم على الأقل."
                    },
                    "phone": {
                        "type": "string",
                        "example": "201012345678",
                        "description": "رقم واتساب الموقّع بالصيغة الدولية. مطلوب مع قناة `whatsapp`."
                    },
                    "type": {
                        "type": "string",
                        "enum": [
                            "individual",
                            "company"
                        ],
                        "default": "individual"
                    },
                    "fields": {
                        "type": "object",
                        "additionalProperties": {
                            "type": "string"
                        },
                        "description": "قيم حقول القالب الخاصّة بهذا الموقّع."
                    },
                    "access_code": {
                        "type": "string",
                        "minLength": 4,
                        "maxLength": 32,
                        "description": "كود سرّي يُدخله الموقّع قبل أن يُفتح المستند. مطلوب حين يشترطه المسار، ويُحفظ مجزَّأً ولا يُكتب في رسالة الدعوة."
                    }
                }
            },
            "SessionCreate": {
                "type": "object",
                "required": [
                    "workflow_id",
                    "signers"
                ],
                "properties": {
                    "workflow_id": {
                        "type": "string",
                        "example": "wf_8f3a1c9e2b",
                        "description": "معرّف مسار عمل منشور في حسابك."
                    },
                    "signers": {
                        "type": "array",
                        "minItems": 1,
                        "maxItems": 20,
                        "items": {
                            "$ref": "#/components/schemas/SessionSignerInput"
                        }
                    },
                    "vendor_data": {
                        "type": "string",
                        "maxLength": 190,
                        "example": "ORD-1001",
                        "description": "مرجعك في نظامك. يُحفظ مع الجلسة ويعود في كائنها وفي الإشعارات، وتُصفّى به قائمة الجلسات."
                    },
                    "template_id": {
                        "type": "string",
                        "example": "tpl_123",
                        "description": "قالب الطلب (`tpl_` متبوعة برقم القالب). يُقبل حين يكون مستند المسار «يُحدَّد مع كل طلب»، ويلزم إن لم يكن للمسار قالب افتراضي. ويُرفض مع مسار قالبه ثابت."
                    },
                    "document_id": {
                        "type": "string",
                        "example": "doc_123",
                        "description": "بديل `template_id` لمستند نصّي في حسابك. لا يُرسَل الاثنان معًا، ولا يُقبل ملفّ PDF مرفوع."
                    },
                    "title": {
                        "type": "string"
                    },
                    "fields": {
                        "type": "object",
                        "additionalProperties": {
                            "type": "string"
                        }
                    },
                    "metadata": {
                        "type": "object"
                    },
                    "signature_method": {
                        "type": "string",
                        "enum": [
                            "simple",
                            "identity",
                            "token"
                        ],
                        "description": "يغيّر طريقة التوقيع لهذا الطلب: `simple` توقيع موثّق بالرسم ورمز التحقّق، `identity` توقيع بعد تأكيد الهوية، `token` ختم بشهادة التوكن."
                    },
                    "channel": {
                        "type": "string",
                        "enum": [
                            "email",
                            "whatsapp",
                            "link"
                        ],
                        "description": "يغيّر قناة إيصال الرابط لهذا الطلب، ويصل رمز التحقّق بالقناة نفسها. `whatsapp` بلا تكلفة إضافية، و`link` لا ترسل شيئًا ويعود الرابط في الردّ."
                    },
                    "cc": {
                        "type": "array",
                        "maxItems": 20,
                        "items": {
                            "type": "string",
                            "format": "email"
                        },
                        "description": "عناوين تصلها نسخة من العقد بعد اكتمال التوقيع. تحلّ محلّ قائمة المسار."
                    },
                    "require_id_attachment": {
                        "type": "boolean",
                        "description": "إلزام الموقّع بإرفاق صورة هويته قبل أن يكتمل توقيعه."
                    },
                    "expires_in": {
                        "type": "integer",
                        "minimum": 1,
                        "maximum": 30,
                        "description": "مدّة صلاحية الرابط بالأيام."
                    },
                    "language": {
                        "type": "string",
                        "enum": [
                            "ar",
                            "en"
                        ],
                        "description": "لغة صفحة التوقيع ورسالة الدعوة."
                    },
                    "return_url": {
                        "type": "string",
                        "format": "uri",
                        "maxLength": 500,
                        "nullable": true,
                        "example": "https://app.example.com/signed",
                        "description": "رابط `https` على دومين مقبول في حسابك، يعود إليه الموقّع بعد أن يوقّع أو يرفض. يحلّ محلّ رابط المسار في هذا الطلب، والقيمة الفارغة أو null تلغيه لهذا الطلب."
                    }
                }
            },
            "SessionSigner": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "string",
                        "example": "sgr_123"
                    },
                    "name": {
                        "type": "string"
                    },
                    "email": {
                        "type": "string",
                        "nullable": true
                    },
                    "phone": {
                        "type": "string",
                        "nullable": true
                    },
                    "status": {
                        "type": "string",
                        "enum": [
                            "pending",
                            "sent",
                            "viewed",
                            "otp_verified",
                            "identity_verified",
                            "signed",
                            "declined"
                        ],
                        "example": "sent"
                    },
                    "sign_url": {
                        "type": "string",
                        "nullable": true,
                        "description": "رابط توقيع هذا الموقّع. قيمته null ما دام الطلب مسودّة."
                    }
                }
            },
            "Session": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "string",
                        "example": "sr_123",
                        "description": "معرّف الجلسة، وهو معرّف طلب التوقيع نفسه."
                    },
                    "object": {
                        "type": "string",
                        "example": "session"
                    },
                    "status": {
                        "type": "string",
                        "enum": [
                            "draft",
                            "sent",
                            "partially_signed",
                            "completed",
                            "declined",
                            "canceled",
                            "expired"
                        ],
                        "example": "sent"
                    },
                    "workflow_id": {
                        "type": "string",
                        "example": "wf_8f3a1c9e2b"
                    },
                    "workflow_version": {
                        "type": "integer",
                        "nullable": true,
                        "description": "رقم الإصدار المنشور الذي أُنشئت به الجلسة."
                    },
                    "vendor_data": {
                        "type": "string",
                        "nullable": true
                    },
                    "channel": {
                        "type": "string",
                        "enum": [
                            "email",
                            "whatsapp",
                            "link"
                        ]
                    },
                    "signers": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/SessionSigner"
                        }
                    },
                    "sign_url": {
                        "type": "string",
                        "nullable": true,
                        "description": "رابط التوقيع حين يكون الموقّع واحدًا، و null عند تعدّد الموقّعين."
                    },
                    "created_at": {
                        "type": "integer"
                    },
                    "expires_at": {
                        "type": "integer",
                        "nullable": true
                    },
                    "livemode": {
                        "type": "boolean"
                    },
                    "cost": {
                        "type": "object",
                        "description": "ما خُصم من المحفظة عن هذا الطلب بعملتها. القيمة 0 بمفتاح التجربة، وحين يُحتسب الطلب من رصيد الباقة بلا تأكيد هوية.",
                        "properties": {
                            "amount": {
                                "type": "number"
                            },
                            "currency": {
                                "type": "string",
                                "enum": [
                                    "EGP",
                                    "USD"
                                ]
                            },
                            "source": {
                                "type": "string",
                                "nullable": true,
                                "enum": [
                                    "plan",
                                    "overage"
                                ],
                                "description": "plan = من رصيد الباقة السنوي، overage = من المحفظة بسعر الزيادة بعد نفاد الرصيد."
                            }
                        }
                    },
                    "return_url": {
                        "type": "string",
                        "format": "uri",
                        "description": "رابط العودة بعد التوقيع. يظهر حين يكون للطلب رابط عودة وحده."
                    },
                    "support": {
                        "type": "object",
                        "properties": {
                            "email": {
                                "type": "string",
                                "format": "email",
                                "maxLength": 190,
                                "example": "help@example.com"
                            },
                            "url": {
                                "type": "string",
                                "format": "uri",
                                "maxLength": 500,
                                "example": "https://example.com/help"
                            },
                            "phone": {
                                "type": "string",
                                "maxLength": 24,
                                "example": "+201012345678"
                            }
                        },
                        "description": "بيانات الدعم المرسَلة مع الطلب. يظهر حين يكون للطلب بيانات دعم وحده."
                    },
                    "trial": {
                        "type": "boolean",
                        "description": "true في طلب حيّ قديم أُرسل ضمن الطلبات المجانية التي كانت تُتاح قبل توثيق الحساب، ويغيب الحقل في غيره."
                    }
                }
            },
            "SessionList": {
                "type": "object",
                "properties": {
                    "object": {
                        "type": "string",
                        "example": "list"
                    },
                    "data": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/Session"
                        }
                    },
                    "has_more": {
                        "type": "boolean"
                    },
                    "next_cursor": {
                        "type": "string",
                        "nullable": true,
                        "description": "أرسله في starting_after لجلب الصفحة التالية."
                    }
                }
            },
            "SignatureRequest": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "string",
                        "example": "sr_123"
                    },
                    "object": {
                        "type": "string"
                    },
                    "status": {
                        "type": "string",
                        "enum": [
                            "draft",
                            "sent",
                            "partially_signed",
                            "completed",
                            "declined",
                            "canceled",
                            "expired"
                        ]
                    },
                    "title": {
                        "type": "string"
                    },
                    "legal_level": {
                        "type": "string"
                    },
                    "format": {
                        "type": "string",
                        "enum": [
                            "pades-b",
                            "pades-t",
                            "pades-lt",
                            "pades-lta"
                        ],
                        "description": "مستوى الضمان المطلوب المسجَّل على الكائن. ليس توقيع PAdES مضمّنًا؛ الإثبات هو محضر الأدلّة المختوم (Ed25519 + RFC3161) — المفتاح العام على /trust."
                    },
                    "signers": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/Signer"
                        }
                    },
                    "warnings": {
                        "type": "array",
                        "description": "يظهر في ردّ الإنشاء وحده حين لا يرد اسم موقّع في نصّ العقد (`code: name_not_in_text`). تنبيه لا يرفض الطلب: راجع الاسم في القالب أو في الموقّع. ولا يُفحص ملفّ PDF.",
                        "items": {
                            "type": "object",
                            "properties": {
                                "code": {
                                    "type": "string",
                                    "example": "name_not_in_text"
                                },
                                "signer": {
                                    "type": "string"
                                },
                                "message": {
                                    "type": "string"
                                }
                            }
                        }
                    },
                    "reference": {
                        "type": "string",
                        "nullable": true
                    },
                    "download_url": {
                        "type": "string",
                        "nullable": true
                    },
                    "created_at": {
                        "type": "integer"
                    },
                    "completed_at": {
                        "type": "integer",
                        "nullable": true
                    },
                    "workflow_id": {
                        "type": "string",
                        "example": "wf_8f3a1c9e2b",
                        "description": "يظهر للطلب المنشأ من مسار عمل وحده، ومعه workflow_version و vendor_data و channel حين تكون لها قيمة."
                    },
                    "workflow_version": {
                        "type": "integer",
                        "nullable": true
                    },
                    "vendor_data": {
                        "type": "string"
                    },
                    "channel": {
                        "type": "string",
                        "enum": [
                            "email",
                            "whatsapp",
                            "link"
                        ]
                    },
                    "return_url": {
                        "type": "string",
                        "format": "uri",
                        "description": "رابط العودة بعد التوقيع. يظهر حين يكون للطلب رابط عودة وحده."
                    },
                    "support": {
                        "type": "object",
                        "properties": {
                            "email": {
                                "type": "string",
                                "format": "email",
                                "maxLength": 190,
                                "example": "help@example.com"
                            },
                            "url": {
                                "type": "string",
                                "format": "uri",
                                "maxLength": 500,
                                "example": "https://example.com/help"
                            },
                            "phone": {
                                "type": "string",
                                "maxLength": 24,
                                "example": "+201012345678"
                            }
                        },
                        "description": "بيانات الدعم المرسَلة مع الطلب. يظهر حين يكون للطلب بيانات دعم وحده."
                    },
                    "trial": {
                        "type": "boolean",
                        "description": "true في طلب حيّ قديم أُرسل ضمن الطلبات المجانية التي كانت تُتاح قبل توثيق الحساب، ويغيب الحقل في غيره."
                    }
                }
            },
            "WebhookCreate": {
                "type": "object",
                "required": [
                    "url"
                ],
                "properties": {
                    "url": {
                        "type": "string",
                        "format": "uri",
                        "example": "https://api.example.com/hooks/wsign"
                    },
                    "enabled_events": {
                        "type": "array",
                        "items": {
                            "type": "string"
                        },
                        "example": [
                            "*"
                        ]
                    }
                }
            },
            "WebhookEndpoint": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "string",
                        "example": "we_123"
                    },
                    "object": {
                        "type": "string"
                    },
                    "url": {
                        "type": "string"
                    },
                    "enabled_events": {
                        "type": "array",
                        "items": {
                            "type": "string"
                        }
                    },
                    "secret": {
                        "type": "string",
                        "description": "يظهر مرة واحدة عند الإنشاء"
                    },
                    "status": {
                        "type": "string"
                    }
                }
            },
            "Flow": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "string",
                        "example": "flow_a1b2c3"
                    },
                    "object": {
                        "type": "string"
                    },
                    "name": {
                        "type": "string"
                    },
                    "template_id": {
                        "type": "string",
                        "nullable": true
                    },
                    "legal_level": {
                        "type": "string",
                        "enum": [
                            "ses",
                            "aes",
                            "qes"
                        ]
                    },
                    "reminders": {
                        "type": "boolean"
                    },
                    "lock_contract": {
                        "type": "boolean"
                    },
                    "cc": {
                        "type": "array",
                        "items": {
                            "type": "object"
                        }
                    },
                    "created_at": {
                        "type": "integer"
                    }
                }
            },
            "PdfField": {
                "type": "object",
                "required": [
                    "key",
                    "page",
                    "x",
                    "y",
                    "w",
                    "h"
                ],
                "properties": {
                    "key": {
                        "type": "string"
                    },
                    "label": {
                        "type": "string"
                    },
                    "type": {
                        "type": "string",
                        "enum": [
                            "text",
                            "number",
                            "date",
                            "email",
                            "tel",
                            "signature"
                        ]
                    },
                    "page": {
                        "type": "integer",
                        "example": 1
                    },
                    "x": {
                        "type": "number",
                        "example": 0.12
                    },
                    "y": {
                        "type": "number",
                        "example": 0.34
                    },
                    "w": {
                        "type": "number",
                        "example": 0.3
                    },
                    "h": {
                        "type": "number",
                        "example": 0.04
                    },
                    "required": {
                        "type": "boolean"
                    },
                    "signer": {
                        "type": "string"
                    }
                }
            },
            "Document": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "string",
                        "example": "doc_123"
                    },
                    "object": {
                        "type": "string"
                    },
                    "kind": {
                        "type": "string",
                        "enum": [
                            "pdf",
                            "contract"
                        ]
                    },
                    "filename": {
                        "type": "string"
                    },
                    "pages": {
                        "type": "integer",
                        "nullable": true
                    },
                    "bytes": {
                        "type": "integer",
                        "nullable": true
                    },
                    "sha256": {
                        "type": "string",
                        "nullable": true
                    },
                    "fields": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/PdfField"
                        }
                    },
                    "created_at": {
                        "type": "integer"
                    }
                }
            },
            "Money": {
                "type": "object",
                "properties": {
                    "amount": {
                        "type": "number"
                    },
                    "amount_minor": {
                        "type": "integer"
                    },
                    "currency": {
                        "type": "string",
                        "enum": [
                            "EGP",
                            "USD"
                        ]
                    }
                }
            },
            "Usage": {
                "type": "object",
                "properties": {
                    "object": {
                        "type": "string"
                    },
                    "balance": {
                        "$ref": "#/components/schemas/Money"
                    },
                    "month_spent": {
                        "$ref": "#/components/schemas/Money"
                    },
                    "plan": {
                        "type": "object",
                        "description": "الباقة السارية ورصيد إرسالاتها السنوي.",
                        "properties": {
                            "id": {
                                "type": "string",
                                "enum": [
                                    "ap_trial",
                                    "ap_dev",
                                    "ap_biz",
                                    "ap_ent",
                                    "ap_custom"
                                ]
                            },
                            "name": {
                                "type": "string"
                            },
                            "paid": {
                                "type": "boolean"
                            },
                            "period_start": {
                                "type": "integer",
                                "nullable": true
                            },
                            "period_end": {
                                "type": "integer",
                                "nullable": true
                            },
                            "sends_quota": {
                                "type": "integer"
                            },
                            "sends_used": {
                                "type": "integer"
                            },
                            "sends_left": {
                                "type": "integer"
                            },
                            "auto_renew": {
                                "type": "boolean"
                            }
                        }
                    },
                    "pricing": {
                        "type": "object",
                        "properties": {
                            "overage_per_request": {
                                "$ref": "#/components/schemas/Money"
                            },
                            "identity_per_signer": {
                                "$ref": "#/components/schemas/Money"
                            },
                            "min_topup": {
                                "$ref": "#/components/schemas/Money"
                            },
                            "currency": {
                                "type": "string"
                            }
                        }
                    },
                    "signature_requests": {
                        "type": "object"
                    }
                }
            }
        }
    }
}