{
 "components": {
  "schemas": {
   "aun_Error": {
    "properties": {
     "error": {
      "properties": {
       "code": {
        "type": "string"
       },
       "message": {
        "type": "string"
       }
      },
      "required": [
       "code",
       "message"
      ],
      "type": "object"
     },
     "ok": {
      "enum": [
       false
      ],
      "type": "boolean"
     }
    },
    "required": [
     "ok",
     "error"
    ],
    "type": "object"
   },
   "booking_Error": {
    "properties": {
     "error": {
      "properties": {
       "code": {
        "type": "string"
       },
       "message": {
        "type": "string"
       }
      },
      "required": [
       "code",
       "message"
      ],
      "type": "object"
     },
     "ok": {
      "enum": [
       false
      ],
      "type": "boolean"
     }
    },
    "required": [
     "ok",
     "error"
    ],
    "type": "object"
   },
   "booking_List": {
    "properties": {
     "items": {
      "type": "array"
     },
     "limit": {
      "type": "integer"
     },
     "offset": {
      "type": "integer"
     },
     "total": {
      "type": "integer"
     }
    },
    "type": "object"
   },
   "contracts_Contract": {
    "description": "نموذج عقد",
    "properties": {
     "after_sign": {
      "items": {
       "type": "string"
      },
      "type": "array"
     },
     "category": {
      "description": "الفئة",
      "type": "string"
     },
     "clauses": {
      "items": {
       "properties": {
        "help": {
         "description": "إرشاد",
         "type": "string"
        },
        "id": {
         "description": "معرّف البند",
         "type": "string"
        },
        "label": {
         "description": "التسمية",
         "type": "string"
        }
       },
       "type": "object"
      },
      "type": "array"
     },
     "disclaimer": {
      "description": "إخلاء المسؤولية",
      "type": "string"
     },
     "fields": {
      "items": {
       "properties": {
        "default": {
         "description": "قيمة افتراضية",
         "type": "string"
        },
        "group": {
         "description": "مجموعة النموذج",
         "type": "string"
        },
        "help": {
         "description": "إرشاد التعبئة",
         "type": "string"
        },
        "id": {
         "description": "معرّف الحقل",
         "type": "string"
        },
        "label": {
         "description": "التسمية",
         "type": "string"
        },
        "required": {
         "type": "boolean"
        },
        "show_if": {
         "description": "بند يُظهر الحقل",
         "type": "string"
        },
        "type": {
         "description": "text|textarea|id|money|date|…",
         "type": "string"
        }
       },
       "type": "object"
      },
      "type": "array"
     },
     "guidance": {
      "items": {
       "type": "string"
      },
      "type": "array"
     },
     "id": {
      "enum": [
       "nda",
       "supply",
       "maintenance",
       "partnership",
       "lease-commercial",
       "lease-home",
       "design",
       "dev",
       "marketing",
       "consulting",
       "freelance",
       "employment"
      ],
      "type": "string"
     },
     "name": {
      "description": "الاسم بالعربي",
      "type": "string"
     },
     "party_a": {
      "description": "الطرف الأول",
      "type": "string"
     },
     "party_b": {
      "description": "الطرف الثاني",
      "type": "string"
     },
     "price_sar": {
      "type": "string"
     },
     "sections": {
      "items": {
       "type": "string"
      },
      "type": "array"
     },
     "summary": {
      "description": "الملخص",
      "type": "string"
     },
     "url": {
      "description": "الصفحة العامة",
      "type": "string"
     },
     "use_for": {
      "description": "متى تستخدمه",
      "type": "string"
     }
    },
    "type": "object"
   },
   "contracts_Doc": {
    "description": "عقد مُعبّأ",
    "properties": {
     "access": {
      "properties": {
       "can_docx": {
        "type": "boolean"
       },
       "can_edit": {
        "type": "boolean"
       },
       "edit_until": {
        "description": "YYYY-MM-DD",
        "type": "string"
       },
       "next": {
        "description": "ما يجب فعله تالياً",
        "type": "string"
       },
       "state": {
        "description": "free/pending/paid/refunded/member",
        "type": "string"
       },
       "via": {
        "description": "member | single | free",
        "type": "string"
       },
       "watermarked": {
        "type": "boolean"
       }
      },
      "type": "object"
     },
     "clauses": {
      "additionalProperties": {
       "type": "boolean"
      },
      "type": "object"
     },
     "contract": {
      "description": "معرّف النموذج",
      "type": "string"
     },
     "contract_name": {
      "description": "اسم النموذج بالعربي",
      "type": "string"
     },
     "created_at": {
      "format": "date-time",
      "type": "string"
     },
     "download_url": {
      "properties": {
       "docx": {
        "format": "uri",
        "type": "string"
       },
       "pdf": {
        "format": "uri",
        "type": "string"
       }
      },
      "type": "object"
     },
     "editor_url": {
      "description": "المحرر",
      "type": "string"
     },
     "extra_clauses": {
      "description": "بنود إضافية",
      "type": "string"
     },
     "fields": {
      "additionalProperties": {
       "type": "string"
      },
      "type": "object"
     },
     "id": {
      "type": "integer"
     },
     "invoice_id": {
      "description": "رقم الفاتورة",
      "type": "string"
     },
     "order_ref": {
      "description": "مرجع الدفع",
      "type": "string"
     },
     "public_links": {
      "description": "روابط /d/\u003ctoken\u003e (بعد الدفع فقط)",
      "properties": {
       "docx": {
        "format": "uri",
        "type": "string"
       },
       "pdf": {
        "format": "uri",
        "type": "string"
       }
      },
      "type": "object"
     },
     "state": {
      "enum": [
       "free",
       "pending",
       "paid",
       "refunded"
      ],
      "type": "string"
     },
     "title": {
      "description": "اسم تعريفي",
      "type": "string"
     },
     "updated_at": {
      "format": "date-time",
      "type": "string"
     }
    },
    "type": "object"
   },
   "contracts_Error": {
    "properties": {
     "error": {
      "properties": {
       "code": {
        "type": "string"
       },
       "message": {
        "type": "string"
       }
      },
      "required": [
       "code",
       "message"
      ],
      "type": "object"
     },
     "ok": {
      "enum": [
       false
      ],
      "type": "boolean"
     }
    },
    "type": "object"
   },
   "cv_CV": {
    "description": "سيرة ذاتية",
    "properties": {
     "accent": {
      "description": "لون التمييز",
      "type": "string"
     },
     "ats": {
      "properties": {
       "grade": {
        "type": "string"
       },
       "pages": {
        "type": "integer"
       },
       "score": {
        "type": "integer"
       },
       "words": {
        "type": "integer"
       }
      },
      "type": "object"
     },
     "ats_url": {
      "description": "فحص ATS",
      "type": "string"
     },
     "content": {
      "additionalProperties": {
       "type": "object"
      },
      "description": "مستند السيرة (personal, experience, education, skills, languages, certifications, projects)",
      "type": "object"
     },
     "created_at": {
      "format": "date-time",
      "type": "string"
     },
     "dir": {
      "enum": [
       "rtl",
       "ltr"
      ],
      "type": "string"
     },
     "editor_url": {
      "description": "المحرر",
      "type": "string"
     },
     "headline": {
      "description": "العنوان المهني",
      "type": "string"
     },
     "id": {
      "type": "integer"
     },
     "lang": {
      "enum": [
       "ar",
       "en"
      ],
      "type": "string"
     },
     "name": {
      "description": "الاسم من بيانات السيرة",
      "type": "string"
     },
     "render_url": {
      "properties": {
       "pdf": {
        "format": "uri",
        "type": "string"
       },
       "png": {
        "format": "uri",
        "type": "string"
       },
       "txt": {
        "format": "uri",
        "type": "string"
       }
      },
      "type": "object"
     },
     "template": {
      "enum": [
       "classic",
       "modern",
       "executive",
       "minimal",
       "twocol",
       "compact"
      ],
      "type": "string"
     },
     "title": {
      "description": "اسم تعريفي",
      "type": "string"
     },
     "updated_at": {
      "format": "date-time",
      "type": "string"
     }
    },
    "type": "object"
   },
   "cv_Error": {
    "properties": {
     "error": {
      "properties": {
       "code": {
        "type": "string"
       },
       "message": {
        "type": "string"
       }
      },
      "required": [
       "code",
       "message"
      ],
      "type": "object"
     },
     "ok": {
      "enum": [
       false
      ],
      "type": "boolean"
     }
    },
    "type": "object"
   },
   "cv_Letter": {
    "description": "خطاب تقديم",
    "properties": {
     "body": {
      "description": "نص الخطاب",
      "type": "string"
     },
     "company": {
      "description": "الشركة",
      "type": "string"
     },
     "created_at": {
      "format": "date-time",
      "type": "string"
     },
     "cv_id": {
      "type": "integer"
     },
     "date": {
      "description": "تاريخ الخطاب ميلادي",
      "type": "string"
     },
     "editor_url": {
      "description": "صفحة الخطاب",
      "type": "string"
     },
     "id": {
      "type": "integer"
     },
     "job_title": {
      "description": "المسمى الوظيفي",
      "type": "string"
     },
     "lang": {
      "enum": [
       "ar",
       "en"
      ],
      "type": "string"
     },
     "recipient": {
      "description": "مسؤول التوظيف",
      "type": "string"
     },
     "render_url": {
      "properties": {
       "pdf": {
        "format": "uri",
        "type": "string"
       }
      },
      "type": "object"
     },
     "updated_at": {
      "format": "date-time",
      "type": "string"
     }
    },
    "type": "object"
   },
   "event_Error": {
    "properties": {
     "error": {
      "properties": {
       "code": {
        "type": "string"
       },
       "message": {
        "type": "string"
       }
      },
      "required": [
       "code",
       "message"
      ],
      "type": "object"
     },
     "ok": {
      "enum": [
       false
      ],
      "type": "boolean"
     }
    },
    "required": [
     "ok",
     "error"
    ],
    "type": "object"
   },
   "event_List": {
    "properties": {
     "items": {
      "type": "array"
     },
     "limit": {
      "type": "integer"
     },
     "offset": {
      "type": "integer"
     },
     "total": {
      "type": "integer"
     }
    },
    "type": "object"
   },
   "form_Error": {
    "properties": {
     "error": {
      "properties": {
       "code": {
        "type": "string"
       },
       "message": {
        "type": "string"
       }
      },
      "required": [
       "code",
       "message"
      ],
      "type": "object"
     },
     "ok": {
      "enum": [
       false
      ],
      "type": "boolean"
     }
    },
    "required": [
     "ok",
     "error"
    ],
    "type": "object"
   },
   "form_List": {
    "properties": {
     "items": {
      "type": "array"
     },
     "limit": {
      "type": "integer"
     },
     "offset": {
      "type": "integer"
     },
     "total": {
      "type": "integer"
     }
    },
    "type": "object"
   },
   "form_WebhookPayload": {
    "properties": {
     "created_at": {
      "format": "date-time",
      "type": "string"
     },
     "event": {
      "enum": [
       "submission.paid",
       "webhook.test"
      ],
      "type": "string"
     },
     "reference": {
      "description": "FM-XXXXXX",
      "type": "string"
     },
     "submission": {
      "nullable": true,
      "type": "object"
     }
    },
    "required": [
     "event",
     "created_at",
     "submission"
    ],
    "type": "object"
   },
   "invoice_Error": {
    "properties": {
     "error": {
      "properties": {
       "code": {
        "type": "string"
       },
       "message": {
        "type": "string"
       }
      },
      "required": [
       "code",
       "message"
      ],
      "type": "object"
     },
     "ok": {
      "enum": [
       false
      ],
      "type": "boolean"
     }
    },
    "required": [
     "ok",
     "error"
    ],
    "type": "object"
   },
   "invoice_List": {
    "properties": {
     "items": {
      "type": "array"
     },
     "limit": {
      "type": "integer"
     },
     "offset": {
      "type": "integer"
     },
     "total": {
      "type": "integer"
     }
    },
    "type": "object"
   },
   "lahnak_Error": {
    "properties": {
     "error": {
      "properties": {
       "code": {
        "type": "string"
       },
       "message": {
        "type": "string"
       }
      },
      "required": [
       "code",
       "message"
      ],
      "type": "object"
     },
     "ok": {
      "enum": [
       false
      ],
      "type": "boolean"
     }
    },
    "type": "object"
   },
   "lahnak_Order": {
    "description": "طلب أغنية",
    "properties": {
     "audio_ready": {
      "type": "boolean"
     },
     "created_at": {
      "format": "date-time",
      "type": "string"
     },
     "currency": {
      "enum": [
       "SAR"
      ],
      "type": "string"
     },
     "email": {
      "description": "بريد المُهدي",
      "type": "string"
     },
     "generation_status": {
      "description": "حالة التلحين",
      "type": "string"
     },
     "genre": {
      "description": "النوع",
      "type": "string"
     },
     "id": {
      "type": "integer"
     },
     "links": {
      "properties": {
       "api": {
        "description": "GET order",
        "type": "string"
       },
       "checkout": {
        "description": "صفحة الدفع داخل lahnak.emm.sa",
        "type": "string"
       },
       "page": {
        "description": "صفحة الخطة",
        "type": "string"
       },
       "song": {
        "description": "صفحة الأغنية",
        "type": "string"
       },
       "status": {
        "description": "GET status",
        "type": "string"
       }
      },
      "type": "object"
     },
     "memory": {
      "description": "الذكرى",
      "type": "string"
     },
     "message": {
      "description": "الرسالة",
      "type": "string"
     },
     "name": {
      "description": "الاسم",
      "type": "string"
     },
     "occasion": {
      "description": "المناسبة",
      "type": "string"
     },
     "paid": {
      "type": "boolean"
     },
     "payment_link_id": {
      "description": "معرّف رابط الدفع",
      "type": "string"
     },
     "plan": {
      "enum": [
       "standard",
       "express"
      ],
      "type": "string"
     },
     "price": {
      "description": "SAR decimal string, e.g. 149.00",
      "type": "string"
     },
     "pronunciation": {
      "description": "نطق الاسم",
      "type": "string"
     },
     "recipient": {
      "description": "لمن",
      "type": "string"
     },
     "source": {
      "enum": [
       "web",
       "api"
      ],
      "type": "string"
     },
     "status": {
      "enum": [
       "draft",
       "pending",
       "awaiting",
       "paid",
       "failed",
       "done"
      ],
      "type": "string"
     },
     "token": {
      "description": "رمز الطلب (32 hex) — يُستخدم في كل المسارات",
      "type": "string"
     },
     "traits": {
      "description": "الصفات",
      "type": "string"
     },
     "voice": {
      "description": "الصوت",
      "type": "string"
     }
    },
    "type": "object"
   },
   "lahnak_Plan": {
    "properties": {
     "currency": {
      "type": "string"
     },
     "eta_hours": {
      "type": "integer"
     },
     "id": {
      "type": "string"
     },
     "price": {
      "type": "string"
     }
    },
    "type": "object"
   },
   "lahnak_Status": {
    "properties": {
     "audio_ready": {
      "type": "boolean"
     },
     "created_at": {
      "format": "date-time",
      "type": "string"
     },
     "currency": {
      "type": "string"
     },
     "generation_status": {
      "type": "string"
     },
     "links": {
      "type": "object"
     },
     "next_ar": {
      "description": "الخطوة التالية",
      "type": "string"
     },
     "paid": {
      "type": "boolean"
     },
     "payment_status": {
      "description": "حالة الدفع لدى المزود",
      "type": "string"
     },
     "plan": {
      "type": "string"
     },
     "price": {
      "type": "string"
     },
     "status": {
      "type": "string"
     },
     "token": {
      "type": "string"
     }
    },
    "type": "object"
   },
   "menu_Error": {
    "properties": {
     "error": {
      "properties": {
       "code": {
        "type": "string"
       },
       "message": {
        "type": "string"
       }
      },
      "required": [
       "code",
       "message"
      ],
      "type": "object"
     },
     "ok": {
      "enum": [
       false
      ],
      "type": "boolean"
     }
    },
    "required": [
     "ok",
     "error"
    ],
    "type": "object"
   },
   "menu_List": {
    "properties": {
     "items": {
      "type": "array"
     },
     "limit": {
      "type": "integer"
     },
     "offset": {
      "type": "integer"
     },
     "total": {
      "type": "integer"
     }
    },
    "type": "object"
   },
   "menu_OrderStatus": {
    "description": "new → (paid → preparing → ready → delivered) | cancelled | refunded — الانتقالات المسموحة في next_statuses",
    "enum": [
     "new",
     "paid",
     "preparing",
     "ready",
     "delivered",
     "cancelled",
     "refunded"
    ],
    "type": "string"
   },
   "qr_Code": {
    "description": "رمز QR",
    "properties": {
     "code": {
      "type": "string"
     },
     "created_at": {
      "format": "date-time",
      "type": "string"
     },
     "destination": {
      "type": "string"
     },
     "expires_on": {
      "format": "date",
      "type": "string"
     },
     "fields": {
      "additionalProperties": {
       "type": "string"
      },
      "type": "object"
     },
     "id": {
      "type": "integer"
     },
     "image_url": {
      "format": "uri",
      "type": "string"
     },
     "kind": {
      "enum": [
       "dynamic",
       "static"
      ],
      "type": "string"
     },
     "name": {
      "type": "string"
     },
     "paused": {
      "type": "boolean"
     },
     "scans": {
      "properties": {
       "month": {
        "type": "integer"
       },
       "month_limit": {
        "type": "integer"
       },
       "today": {
        "type": "integer"
       },
       "total": {
        "type": "integer"
       }
      },
      "type": "object"
     },
     "short_url": {
      "format": "uri",
      "type": "string"
     },
     "state": {
      "enum": [
       "ok",
       "limit",
       "paused_limit"
      ],
      "type": "string"
     },
     "style": {
      "type": "object"
     },
     "svg_url": {
      "format": "uri",
      "type": "string"
     },
     "type": {
      "enum": [
       "url",
       "text",
       "vcard",
       "wifi",
       "phone",
       "email",
       "whatsapp",
       "location",
       "event"
      ],
      "type": "string"
     }
    },
    "type": "object"
   },
   "qr_Error": {
    "properties": {
     "error": {
      "properties": {
       "code": {
        "type": "string"
       },
       "message": {
        "type": "string"
       }
      },
      "required": [
       "code",
       "message"
      ],
      "type": "object"
     },
     "ok": {
      "enum": [
       false
      ],
      "type": "boolean"
     }
    },
    "type": "object"
   },
   "staff_Error": {
    "properties": {
     "error": {
      "properties": {
       "code": {
        "type": "string"
       },
       "message": {
        "type": "string"
       }
      },
      "required": [
       "code",
       "message"
      ],
      "type": "object"
     },
     "ok": {
      "enum": [
       false
      ],
      "type": "boolean"
     }
    },
    "required": [
     "ok",
     "error"
    ],
    "type": "object"
   },
   "staff_List": {
    "properties": {
     "items": {
      "type": "array"
     },
     "limit": {
      "type": "integer"
     },
     "offset": {
      "type": "integer"
     },
     "total": {
      "type": "integer"
     }
    },
    "type": "object"
   },
   "zatca_Business": {
    "properties": {
     "gaps": {
      "type": "array"
     },
     "id": {
      "type": "integer"
     },
     "name": {
      "type": "string"
     },
     "result": {
      "$ref": "#/components/schemas/zatca_PhaseResult"
     },
     "vat_number": {
      "type": "string"
     }
    },
    "type": "object"
   },
   "zatca_Envelope": {
    "oneOf": [
     {
      "properties": {
       "data": {},
       "ok": {
        "const": true
       }
      },
      "required": [
       "ok",
       "data"
      ],
      "type": "object"
     },
     {
      "properties": {
       "error": {
        "$ref": "#/components/schemas/zatca_Error"
       },
       "ok": {
        "const": false
       }
      },
      "required": [
       "ok",
       "error"
      ],
      "type": "object"
     }
    ]
   },
   "zatca_Error": {
    "properties": {
     "code": {
      "type": "string"
     },
     "message": {
      "type": "string"
     }
    },
    "required": [
     "code",
     "message"
    ],
    "type": "object"
   },
   "zatca_Kit": {
    "properties": {
     "id": {
      "type": "integer"
     },
     "price_sar": {
      "type": "string"
     },
     "status": {
      "enum": [
       "pending",
       "paid",
       "refunded"
      ],
      "type": "string"
     }
    },
    "type": "object"
   },
   "zatca_List": {
    "properties": {
     "items": {
      "type": "array"
     },
     "limit": {
      "type": "integer"
     },
     "offset": {
      "type": "integer"
     },
     "total": {
      "type": "integer"
     }
    },
    "type": "object"
   },
   "zatca_PhaseResult": {
    "properties": {
     "days_left": {
      "type": "integer"
     },
     "deadline": {
      "type": "string"
     },
     "phase": {
      "type": "integer"
     },
     "status": {
      "type": "string"
     },
     "wave": {}
    },
    "type": "object"
   },
   "zatca_Report": {
    "properties": {
     "checks": {
      "type": "array"
     },
     "errors": {
      "type": "integer"
     },
     "grade": {
      "type": "string"
     },
     "score": {
      "type": "integer"
     },
     "warnings": {
      "type": "integer"
     }
    },
    "type": "object"
   }
  },
  "securitySchemes": {
   "aun_apiKeyHeader": {
    "in": "header",
    "name": "X-API-Key",
    "type": "apiKey"
   },
   "aun_bearerAuth": {
    "description": "مفتاح API من /app/api — emm_aun_\u003cid8\u003e_\u003csecret32\u003e",
    "scheme": "bearer",
    "type": "http"
   },
   "booking_apiKeyAuth": {
    "in": "header",
    "name": "X-API-Key",
    "type": "apiKey"
   },
   "booking_bearerAuth": {
    "description": "مفتاح API من /app/api — يُقبل أيضاً في X-API-Key",
    "scheme": "bearer",
    "type": "http"
   },
   "contracts_apiKeyHeader": {
    "in": "header",
    "name": "X-API-Key",
    "type": "apiKey"
   },
   "contracts_bearerAuth": {
    "description": "مفتاح API من /app/api — emm_contracts_\u003cid\u003e_\u003csecret\u003e",
    "scheme": "bearer",
    "type": "http"
   },
   "cv_apiKeyHeader": {
    "in": "header",
    "name": "X-API-Key",
    "type": "apiKey"
   },
   "cv_bearerAuth": {
    "description": "مفتاح API من /app/api — emm_cv_\u003cid\u003e_\u003csecret\u003e",
    "scheme": "bearer",
    "type": "http"
   },
   "event_apiKeyAuth": {
    "in": "header",
    "name": "X-API-Key",
    "type": "apiKey"
   },
   "event_bearerAuth": {
    "description": "مفتاح API من /app/api — يُقبل أيضاً في X-API-Key",
    "scheme": "bearer",
    "type": "http"
   },
   "form_apiKeyAuth": {
    "in": "header",
    "name": "X-API-Key",
    "type": "apiKey"
   },
   "form_bearerAuth": {
    "description": "مفتاح API من /api — يُقبل أيضاً في X-API-Key",
    "scheme": "bearer",
    "type": "http"
   },
   "invoice_apiKeyAuth": {
    "in": "header",
    "name": "X-API-Key",
    "type": "apiKey"
   },
   "invoice_bearerAuth": {
    "description": "مفتاح API من /app/api — يُقبل أيضاً في X-API-Key",
    "scheme": "bearer",
    "type": "http"
   },
   "lahnak_apiKeyHeader": {
    "in": "header",
    "name": "X-API-Key",
    "type": "apiKey"
   },
   "lahnak_bearerAuth": {
    "description": "مفتاح API من /admin/api — emm_lahnak_\u003cid\u003e_\u003csecret\u003e",
    "scheme": "bearer",
    "type": "http"
   },
   "menu_apiKeyAuth": {
    "in": "header",
    "name": "X-API-Key",
    "type": "apiKey"
   },
   "menu_bearerAuth": {
    "description": "مفتاح API من /api — يُقبل أيضاً في X-API-Key",
    "scheme": "bearer",
    "type": "http"
   },
   "qr_apiKeyHeader": {
    "in": "header",
    "name": "X-API-Key",
    "type": "apiKey"
   },
   "qr_bearerAuth": {
    "description": "مفتاح API من /app/api — emm_qr_\u003cid\u003e_\u003csecret\u003e",
    "scheme": "bearer",
    "type": "http"
   },
   "staff_apiKeyAuth": {
    "in": "header",
    "name": "X-API-Key",
    "type": "apiKey"
   },
   "staff_bearerAuth": {
    "description": "مفتاح API من /app/api — يُقبل أيضاً في X-API-Key",
    "scheme": "bearer",
    "type": "http"
   },
   "zatca_apiKeyHeader": {
    "in": "header",
    "name": "X-API-Key",
    "type": "apiKey"
   },
   "zatca_bearerAuth": {
    "description": "API key from /app/api — shown once: emm_zatca_\u003cid8\u003e_\u003csecret32\u003e",
    "scheme": "bearer",
    "type": "http"
   }
  }
 },
 "info": {
  "description": "All EMM services in one document. Paths are namespaced by app (/\u003cslug\u003e/…) and tagged with x-emm-app; call them on the app's own host (servers per path). Apps with status coming_soon have no public API yet.",
  "title": "EMM API — aggregated OpenAPI",
  "version": "2026-12-04"
 },
 "openapi": "3.1.0",
 "paths": {
  "/aun/conversation": {
   "get": {
    "operationId": "aun_get_conversation",
    "parameters": [
     {
      "in": "query",
      "name": "limit",
      "required": false,
      "schema": {
       "description": "عدد الرسائل 1-200 (افتراضي 20)",
       "enum": 20,
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "type": "object"
        }
       }
      },
      "description": "نجاح — {\"ok\":true,\"data\":…}"
     },
     "400": {
      "description": "جسم غير صالح (validation / invalid_json)"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى"
     },
     "403": {
      "description": "المفتاح لا يملك صلاحية read"
     },
     "429": {
      "description": "تجاوز 60 طلباً/دقيقة — راجع Retry-After"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "المحادثة مع عون: آخر N رسالة (الأقدم أولاً)",
    "tags": [
     "aun",
     "conversation"
    ],
    "x-emm-app": "aun",
    "x-scope": "read"
   },
   "servers": [
    {
     "description": "aun",
     "url": "https://aun.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "aun"
  },
  "/aun/credit": {
   "get": {
    "operationId": "aun_get_credit",
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "type": "object"
        }
       }
      },
      "description": "نجاح — {\"ok\":true,\"data\":…}"
     },
     "400": {
      "description": "جسم غير صالح (validation / invalid_json)"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى"
     },
     "403": {
      "description": "المفتاح لا يملك صلاحية read"
     },
     "429": {
      "description": "تجاوز 60 طلباً/دقيقة — راجع Retry-After"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "حالة الخدمة: تاريخ الانتهاء، الأيام المتبقية، الباقات",
    "tags": [
     "aun",
     "credit"
    ],
    "x-emm-app": "aun",
    "x-scope": "read"
   },
   "servers": [
    {
     "description": "aun",
     "url": "https://aun.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "aun"
  },
  "/aun/credit/checkout": {
   "post": {
    "operationId": "aun_post_checkout",
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "properties": {
         "dry_run": {
          "description": "true = محاكاة بدون إنشاء رابط دفع",
          "example": false,
          "type": "boolean"
         },
         "plan": {
          "description": "30d | 90d | 365d",
          "enum": [
           "30d",
           "90d",
           "365d"
          ],
          "example": true,
          "type": "string"
         }
        },
        "required": [
         "plan",
         "dry_run"
        ],
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "type": "object"
        }
       }
      },
      "description": "نجاح — {\"ok\":true,\"data\":…}"
     },
     "400": {
      "description": "جسم غير صالح (validation / invalid_json)"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى"
     },
     "403": {
      "description": "المفتاح لا يملك صلاحية write"
     },
     "429": {
      "description": "تجاوز 60 طلباً/دقيقة — راجع Retry-After"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "إنشاء طلب شحن عبر emm-pay — dry_run=true يحسب السعر فقط بلا طلب حقيقي",
    "tags": [
     "aun",
     "checkout"
    ],
    "x-emm-app": "aun",
    "x-scope": "write"
   },
   "servers": [
    {
     "description": "aun",
     "url": "https://aun.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "aun"
  },
  "/aun/me": {
   "get": {
    "operationId": "aun_get_me",
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "type": "object"
        }
       }
      },
      "description": "نجاح — {\"ok\":true,\"data\":…}"
     },
     "400": {
      "description": "جسم غير صالح (validation / invalid_json)"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى"
     },
     "403": {
      "description": "المفتاح لا يملك صلاحية read"
     },
     "429": {
      "description": "تجاوز 60 طلباً/دقيقة — راجع Retry-After"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "المستخدم والخطة والحصص — اختبار مفتاحك",
    "tags": [
     "aun",
     "me"
    ],
    "x-emm-app": "aun",
    "x-scope": "read"
   },
   "servers": [
    {
     "description": "aun",
     "url": "https://aun.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "aun"
  },
  "/aun/messages": {
   "get": {
    "operationId": "aun_get_messages",
    "parameters": [
     {
      "in": "query",
      "name": "limit",
      "required": false,
      "schema": {
       "description": "عدد النتائج 1-200 (افتراضي 50)",
       "enum": 50,
       "type": "integer"
      }
     },
     {
      "in": "query",
      "name": "offset",
      "required": false,
      "schema": {
       "description": "إزاحة الترحيل",
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "type": "object"
        }
       }
      },
      "description": "نجاح — {\"ok\":true,\"data\":…}"
     },
     "400": {
      "description": "جسم غير صالح (validation / invalid_json)"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى"
     },
     "403": {
      "description": "المفتاح لا يملك صلاحية read"
     },
     "429": {
      "description": "تجاوز 60 طلباً/دقيقة — راجع Retry-After"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "رسائل المستخدم فقط (ترحيل، الأحدث أولاً)",
    "tags": [
     "aun",
     "messages"
    ],
    "x-emm-app": "aun",
    "x-scope": "read"
   },
   "post": {
    "operationId": "aun_post_send",
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "properties": {
         "text": {
          "description": "نص الرسالة (1-4000 حرف)",
          "example": true,
          "type": "string"
         }
        },
        "required": [
         "text"
        ],
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "201": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "type": "object"
        }
       }
      },
      "description": "نجاح — {\"ok\":true,\"data\":…}"
     },
     "400": {
      "description": "جسم غير صالح (validation / invalid_json)"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى"
     },
     "403": {
      "description": "المفتاح لا يملك صلاحية write"
     },
     "429": {
      "description": "تجاوز 60 طلباً/دقيقة — راجع Retry-After"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "إرسال نص إلى وكيل المستخدم وإرجاع الرد (لا يُرسل شيء إلى واتساب)",
    "tags": [
     "aun",
     "send"
    ],
    "x-emm-app": "aun",
    "x-scope": "write"
   },
   "servers": [
    {
     "description": "aun",
     "url": "https://aun.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "aun"
  },
  "/aun/notes": {
   "get": {
    "operationId": "aun_get_notes",
    "parameters": [
     {
      "in": "query",
      "name": "limit",
      "required": false,
      "schema": {
       "description": "عدد النتائج 1-200 (افتراضي 50)",
       "enum": 50,
       "type": "integer"
      }
     },
     {
      "in": "query",
      "name": "offset",
      "required": false,
      "schema": {
       "description": "إزاحة الترحيل",
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "type": "object"
        }
       }
      },
      "description": "نجاح — {\"ok\":true,\"data\":…}"
     },
     "400": {
      "description": "جسم غير صالح (validation / invalid_json)"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى"
     },
     "403": {
      "description": "المفتاح لا يملك صلاحية read"
     },
     "429": {
      "description": "تجاوز 60 طلباً/دقيقة — راجع Retry-After"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "ملاحظات/ذكريات المستخدم (ترحيل)",
    "tags": [
     "aun",
     "notes"
    ],
    "x-emm-app": "aun",
    "x-scope": "read"
   },
   "servers": [
    {
     "description": "aun",
     "url": "https://aun.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "aun"
  },
  "/aun/orders": {
   "get": {
    "operationId": "aun_get_orders",
    "parameters": [
     {
      "in": "query",
      "name": "limit",
      "required": false,
      "schema": {
       "description": "عدد النتائج 1-200 (افتراضي 50)",
       "enum": 50,
       "type": "integer"
      }
     },
     {
      "in": "query",
      "name": "offset",
      "required": false,
      "schema": {
       "description": "إزاحة الترحيل",
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "type": "object"
        }
       }
      },
      "description": "نجاح — {\"ok\":true,\"data\":…}"
     },
     "400": {
      "description": "جسم غير صالح (validation / invalid_json)"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى"
     },
     "403": {
      "description": "المفتاح لا يملك صلاحية read"
     },
     "429": {
      "description": "تجاوز 60 طلباً/دقيقة — راجع Retry-After"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "سجل شحنات الخدمة (ترحيل)",
    "tags": [
     "aun",
     "orders"
    ],
    "x-emm-app": "aun",
    "x-scope": "read"
   },
   "servers": [
    {
     "description": "aun",
     "url": "https://aun.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "aun"
  },
  "/aun/plans": {
   "get": {
    "operationId": "aun_get_plans",
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "type": "object"
        }
       }
      },
      "description": "نجاح — {\"ok\":true,\"data\":…}"
     },
     "400": {
      "description": "جسم غير صالح (validation / invalid_json)"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى"
     },
     "403": {
      "description": "المفتاح لا يملك صلاحية read"
     },
     "429": {
      "description": "تجاوز 60 طلباً/دقيقة — راجع Retry-After"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "باقات الشحن 30/90/365 يوماً بالريال وأين تُدفع",
    "tags": [
     "aun",
     "plans"
    ],
    "x-emm-app": "aun",
    "x-scope": "read"
   },
   "servers": [
    {
     "description": "aun",
     "url": "https://aun.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "aun"
  },
  "/aun/reminders": {
   "get": {
    "operationId": "aun_get_reminders",
    "parameters": [
     {
      "in": "query",
      "name": "limit",
      "required": false,
      "schema": {
       "description": "عدد النتائج 1-200 (افتراضي 50)",
       "enum": 50,
       "type": "integer"
      }
     },
     {
      "in": "query",
      "name": "offset",
      "required": false,
      "schema": {
       "description": "إزاحة الترحيل",
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "type": "object"
        }
       }
      },
      "description": "نجاح — {\"ok\":true,\"data\":…}"
     },
     "400": {
      "description": "جسم غير صالح (validation / invalid_json)"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى"
     },
     "403": {
      "description": "المفتاح لا يملك صلاحية read"
     },
     "429": {
      "description": "تجاوز 60 طلباً/دقيقة — راجع Retry-After"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "تذكيرات المستخدم (ترحيل)",
    "tags": [
     "aun",
     "reminders"
    ],
    "x-emm-app": "aun",
    "x-scope": "read"
   },
   "servers": [
    {
     "description": "aun",
     "url": "https://aun.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "aun"
  },
  "/booking/api/v1/availability": {
   "get": {
    "description": "المواعيد المتاحة لنطاق تاريخي (≤ 31 يوماً) لخدمة أو مزوّد. Free slots per day for a service or provider.",
    "parameters": [
     {
      "description": "معرّف الخدمة (يحدد المزوّد والمدة)",
      "in": "query",
      "name": "service_id",
      "schema": {
       "type": "integer"
      }
     },
     {
      "description": "فلتر/معرّف مزوّد الخدمة",
      "in": "query",
      "name": "provider_id",
      "schema": {
       "type": "integer"
      }
     },
     {
      "description": "مدة الخدمة بالدقائق عند الاستعلام بمزوّد فقط",
      "in": "query",
      "name": "duration_min",
      "schema": {
       "type": "integer"
      }
     },
     {
      "description": "بداية النطاق YYYY-MM-DD (افتراضي اليوم)",
      "in": "query",
      "name": "from",
      "schema": {
       "format": "date",
       "type": "string"
      }
     },
     {
      "description": "نهاية النطاق YYYY-MM-DD (حصري، افتراضي +30 يوماً)",
      "in": "query",
      "name": "to",
      "schema": {
       "format": "date",
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "الأوقات المتاحة / Availability",
    "tags": [
     "booking",
     "availability"
    ],
    "x-emm-app": "booking"
   },
   "servers": [
    {
     "description": "booking",
     "url": "https://booking.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "booking"
  },
  "/booking/api/v1/bookings": {
   "get": {
    "description": "حجوزات في نطاق تاريخي (from/to بتاريخ ISO، الافتراضي اليوم→+30 يوماً) مع فلتر status وprovider_id. Bookings in a date range with status/provider filters.",
    "parameters": [
     {
      "description": "بداية النطاق YYYY-MM-DD (افتراضي اليوم)",
      "in": "query",
      "name": "from",
      "schema": {
       "format": "date",
       "type": "string"
      }
     },
     {
      "description": "نهاية النطاق YYYY-MM-DD (حصري، افتراضي +30 يوماً)",
      "in": "query",
      "name": "to",
      "schema": {
       "format": "date",
       "type": "string"
      }
     },
     {
      "description": "فلتر الحالة",
      "in": "query",
      "name": "status",
      "schema": {
       "enum": [
        "pending",
        "confirmed",
        "cancelled",
        "no_show",
        "completed",
        "blocked"
       ],
       "type": "string"
      }
     },
     {
      "description": "فلتر/معرّف مزوّد الخدمة",
      "in": "query",
      "name": "provider_id",
      "schema": {
       "type": "integer"
      }
     },
     {
      "description": "عدد النتائج (1–200، افتراضي 50)",
      "in": "query",
      "name": "limit",
      "schema": {
       "default": 50,
       "maximum": 200,
       "minimum": 1,
       "type": "integer"
      }
     },
     {
      "description": "تخطي النتائج",
      "in": "query",
      "name": "offset",
      "schema": {
       "default": 0,
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "الحجوزات / Bookings",
    "tags": [
     "booking",
     "bookings"
    ],
    "x-emm-app": "booking"
   },
   "post": {
    "description": "ينشئ حجزاً كصفحة الحجز: الوقت يجب أن يكون حراً (409 slot_taken). Creates a booking for a walk-in/phone customer.",
    "requestBody": {
     "content": {
      "application/json": {
       "example": {
        "customer_name": "أحمد العلي",
        "customer_phone": "0551234567",
        "service_id": 2,
        "start": "2026-12-10T14:30"
       },
       "schema": {
        "properties": {
         "confirm": {
          "description": "تأكيد فوري (مسموح فقط بلا تأمين غير مدفوع)",
          "type": "boolean"
         },
         "customer_name": {
          "description": "اسم العميل",
          "example": "أحمد العلي",
          "type": "string"
         },
         "customer_phone": {
          "description": "جوال العميل 05XXXXXXXX أو +9665XXXXXXXX",
          "example": "0551234567",
          "type": "string"
         },
         "service_id": {
          "description": "معرّف الخدمة (يحدد المزوّد والمدة)",
          "example": "2",
          "type": "number"
         },
         "start": {
          "description": "بداية الموعد ISO-8601 بتوقيت الرياض: 2026-12-10T14:30 أو 2026-12-10T14:30:00+03:00",
          "example": "2026-12-10T14:30",
          "type": "string"
         }
        },
        "required": [
         "service_id",
         "start",
         "customer_name",
         "customer_phone"
        ],
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "created_at": "2026-12-02T09:00:00+03:00",
          "customer": {
           "name": "أحمد العلي",
           "phone": "+966551234567"
          },
          "deposit": {
           "amount": "0.00",
           "currency": "SAR",
           "paid_manually": false,
           "status": "none"
          },
          "end": "2026-12-10T15:00:00+03:00",
          "id": 7,
          "provider": {
           "id": 1,
           "name": "نورة"
          },
          "ref_code": "BK-7K3M9Q",
          "service": {
           "currency": "SAR",
           "duration_min": 30,
           "id": 2,
           "name": "كشف",
           "price": "200.00"
          },
          "start": "2026-12-10T14:30:00+03:00",
          "status": "pending",
          "status_ar": "بانتظار التأكيد"
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "201": {
      "description": "أُنشئ / created"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "409": {
      "description": "تعارض / conflict (slot_taken, quota_exceeded, deposit_pending)"
     },
     "422": {
      "description": "تحقق / validation error"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "حجز نيابةً عن عميل / Create booking on behalf of a customer",
    "tags": [
     "booking",
     "bookings"
    ],
    "x-emm-app": "booking"
   },
   "servers": [
    {
     "description": "booking",
     "url": "https://booking.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "booking"
  },
  "/booking/api/v1/bookings/{id}": {
   "get": {
    "description": "حجز واحد بالمعرّف (ref_code داخل البيانات). One booking by id.",
    "parameters": [
     {
      "description": "معرّف رقمي",
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "تفاصيل حجز / Booking",
    "tags": [
     "booking",
     "bookings"
    ],
    "x-emm-app": "booking"
   },
   "servers": [
    {
     "description": "booking",
     "url": "https://booking.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "booking"
  },
  "/booking/api/v1/bookings/{id}/actions": {
   "post": {
    "description": "action: confirm | cancel | no_show | complete (confirm يُرفض قبل دفع التأمين). confirm / cancel / no_show / complete; confirm is refused while a deposit is unpaid.",
    "parameters": [
     {
      "description": "معرّف رقمي",
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "example": {
        "action": "cancel"
       },
       "schema": {
        "properties": {
         "action": {
          "description": "confirm | cancel | no_show | complete",
          "enum": [
           "confirm",
           "cancel",
           "no_show",
           "complete"
          ],
          "example": "confirm",
          "type": "string"
         }
        },
        "required": [
         "action"
        ],
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "created_at": "2026-12-02T09:00:00+03:00",
          "customer": {
           "name": "أحمد العلي",
           "phone": "+966551234567"
          },
          "deposit": {
           "amount": "0.00",
           "currency": "SAR",
           "paid_manually": false,
           "status": "none"
          },
          "end": "2026-12-10T15:00:00+03:00",
          "id": 7,
          "provider": {
           "id": 1,
           "name": "نورة"
          },
          "ref_code": "BK-7K3M9Q",
          "service": {
           "currency": "SAR",
           "duration_min": 30,
           "id": 2,
           "name": "كشف",
           "price": "200.00"
          },
          "start": "2026-12-10T14:30:00+03:00",
          "status": "pending",
          "status_ar": "بانتظار التأكيد"
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "201": {
      "description": "أُنشئ / created"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "409": {
      "description": "تعارض / conflict (slot_taken, quota_exceeded, deposit_pending)"
     },
     "422": {
      "description": "تحقق / validation error"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "تغيير حالة / Transition",
    "tags": [
     "booking",
     "bookings"
    ],
    "x-emm-app": "booking"
   },
   "servers": [
    {
     "description": "booking",
     "url": "https://booking.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "booking"
  },
  "/booking/api/v1/me": {
   "get": {
    "description": "يتحقق من المفتاح ويعيد المستخدم والخطة الحالية والحدود الشهرية. Checks a key; returns user, current plan and monthly quotas.",
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "plan": {
           "currency": "SAR",
           "deposits": false,
           "features": [
            "مزوّد خدمة واحد",
            "30 حجز شهرياً",
            "صفحة حجز عامة بالعربية",
            "تأكيد عبر واتساب",
            "تقويم اليوم والأسبوع"
           ],
           "id": "starter",
           "limits": {
            "monthly_bookings": 30,
            "providers": 1
           },
           "name": "ابدأ",
           "period": "month",
           "price": "0.00"
          },
          "quotas": {
           "monthly_bookings": {
            "limit": 30,
            "month": "2026-12",
            "used": 4
           }
          },
          "service": "booking",
          "user": {
           "email": "user@example.com"
          }
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "الهوية والخطة والحدود / Identity, plan, quotas",
    "tags": [
     "booking",
     "me"
    ],
    "x-emm-app": "booking"
   },
   "servers": [
    {
     "description": "booking",
     "url": "https://booking.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "booking"
  },
  "/booking/api/v1/plan": {
   "get": {
    "description": "الخطة الحالية مع الاستهلاك، وكل الخطط بأسعارها وحدودها. Current plan with usage plus every plan (SAR/month).",
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "الخطة الحالية وكل الخطط / Current plan and catalogue",
    "tags": [
     "booking",
     "plan"
    ],
    "x-emm-app": "booking"
   },
   "servers": [
    {
     "description": "booking",
     "url": "https://booking.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "booking"
  },
  "/booking/api/v1/providers": {
   "get": {
    "description": "قائمة مزوّدي الخدمة مع خدماتهم. Lists providers with their services (ids are needed to create a booking).",
    "parameters": [
     {
      "description": "عدد النتائج (1–200، افتراضي 50)",
      "in": "query",
      "name": "limit",
      "schema": {
       "default": 50,
       "maximum": 200,
       "minimum": 1,
       "type": "integer"
      }
     },
     {
      "description": "تخطي النتائج",
      "in": "query",
      "name": "offset",
      "schema": {
       "default": 0,
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "مزوّدو الخدمة / Service providers",
    "tags": [
     "booking",
     "providers"
    ],
    "x-emm-app": "booking"
   },
   "post": {
    "description": "يضيف مزوّد خدمة ضمن حد الخطة. Adds a provider within the plan limit (409 quota_exceeded).",
    "requestBody": {
     "content": {
      "application/json": {
       "example": {
        "name": "نورة"
       },
       "schema": {
        "properties": {
         "name": {
          "description": "اسم المزوّد",
          "example": "نورة",
          "type": "string"
         }
        },
        "required": [
         "name"
        ],
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "active": true,
          "id": 1,
          "name": "نورة"
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "201": {
      "description": "أُنشئ / created"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "409": {
      "description": "تعارض / conflict (slot_taken, quota_exceeded, deposit_pending)"
     },
     "422": {
      "description": "تحقق / validation error"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "إضافة مزوّد / Add provider",
    "tags": [
     "booking",
     "providers"
    ],
    "x-emm-app": "booking"
   },
   "servers": [
    {
     "description": "booking",
     "url": "https://booking.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "booking"
  },
  "/booking/api/v1/providers/{id}": {
   "delete": {
    "description": "يحذف مزوّداً بلا مواعيد قادمة (409 إن وُجدت). Deletes a provider without upcoming bookings (409 otherwise).",
    "parameters": [
     {
      "description": "معرّف رقمي",
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "data": {
           "deleted": true
          },
          "ok": true
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "409": {
      "description": "تعارض / conflict (slot_taken, quota_exceeded, deposit_pending)"
     },
     "422": {
      "description": "تحقق / validation error"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "حذف مزوّد / Delete provider",
    "tags": [
     "booking",
     "providers"
    ],
    "x-emm-app": "booking"
   },
   "patch": {
    "description": "يعيد تسمية مزوّد. Renames a provider.",
    "parameters": [
     {
      "description": "معرّف رقمي",
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "example": {
        "name": "نورة أحمد"
       },
       "schema": {
        "properties": {
         "name": {
          "description": "اسم المزوّد",
          "example": "نورة",
          "type": "string"
         }
        },
        "required": [
         "name"
        ],
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "active": true,
          "id": 1,
          "name": "نورة"
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "409": {
      "description": "تعارض / conflict (slot_taken, quota_exceeded, deposit_pending)"
     },
     "422": {
      "description": "تحقق / validation error"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "تعديل مزوّد / Rename provider",
    "tags": [
     "booking",
     "providers"
    ],
    "x-emm-app": "booking"
   },
   "servers": [
    {
     "description": "booking",
     "url": "https://booking.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "booking"
  },
  "/booking/api/v1/public-page": {
   "get": {
    "description": "ما يراه العميل في /b/{slug}: الخدمات والمزوّدون والساعات. What the customer sees on /b/{slug}.",
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "صفحة الحجز العامة / Public booking page",
    "tags": [
     "booking",
     "public-page"
    ],
    "x-emm-app": "booking"
   },
   "servers": [
    {
     "description": "booking",
     "url": "https://booking.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "booking"
  },
  "/booking/api/v1/services": {
   "get": {
    "description": "قائمة الخدمات (اختياري حسب provider_id). Lists services, optionally filtered by provider_id.",
    "parameters": [
     {
      "description": "عدد النتائج (1–200، افتراضي 50)",
      "in": "query",
      "name": "limit",
      "schema": {
       "default": 50,
       "maximum": 200,
       "minimum": 1,
       "type": "integer"
      }
     },
     {
      "description": "تخطي النتائج",
      "in": "query",
      "name": "offset",
      "schema": {
       "default": 0,
       "type": "integer"
      }
     },
     {
      "description": "فلتر/معرّف مزوّد الخدمة",
      "in": "query",
      "name": "provider_id",
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "الخدمات / Services",
    "tags": [
     "booking",
     "services"
    ],
    "x-emm-app": "booking"
   },
   "post": {
    "description": "خدمة باسم ومدة (دقائق) وسعر بالريال. Service with name, duration_min and price in SAR.",
    "requestBody": {
     "content": {
      "application/json": {
       "example": {
        "duration_min": 30,
        "name": "كشف",
        "price": "200.00",
        "provider_id": 1
       },
       "schema": {
        "properties": {
         "duration_min": {
          "description": "المدة بالدقائق (\u003e0)",
          "example": "30",
          "type": "number"
         },
         "name": {
          "description": "اسم الخدمة",
          "example": "كشف",
          "type": "string"
         },
         "price": {
          "description": "السعر بالريال، نص بمنزلتين",
          "example": "200.00",
          "type": "string"
         },
         "provider_id": {
          "description": "معرّف المزوّد",
          "example": "1",
          "type": "number"
         }
        },
        "required": [
         "name",
         "provider_id",
         "duration_min",
         "price"
        ],
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "currency": "SAR",
          "duration_min": 30,
          "id": 2,
          "name": "كشف",
          "price": "200.00",
          "provider_id": 1
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "201": {
      "description": "أُنشئ / created"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "409": {
      "description": "تعارض / conflict (slot_taken, quota_exceeded, deposit_pending)"
     },
     "422": {
      "description": "تحقق / validation error"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "إضافة خدمة / Add service",
    "tags": [
     "booking",
     "services"
    ],
    "x-emm-app": "booking"
   },
   "servers": [
    {
     "description": "booking",
     "url": "https://booking.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "booking"
  },
  "/booking/api/v1/services/{id}": {
   "delete": {
    "description": "يحذف الخدمة. Deletes a service.",
    "parameters": [
     {
      "description": "معرّف رقمي",
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "data": {
           "deleted": true
          },
          "ok": true
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "409": {
      "description": "تعارض / conflict (slot_taken, quota_exceeded, deposit_pending)"
     },
     "422": {
      "description": "تحقق / validation error"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "حذف خدمة / Delete service",
    "tags": [
     "booking",
     "services"
    ],
    "x-emm-app": "booking"
   },
   "patch": {
    "description": "تعديل بيانات الخدمة أو مزوّدها (يجب أن يتبع نفس النشاط). Update a service or move it to another provider of the same business.",
    "parameters": [
     {
      "description": "معرّف رقمي",
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "example": {
        "duration_min": 45,
        "name": "كشف",
        "price": "250.00",
        "provider_id": 1
       },
       "schema": {
        "properties": {
         "duration_min": {
          "description": "المدة بالدقائق (\u003e0)",
          "example": "30",
          "type": "number"
         },
         "name": {
          "description": "اسم الخدمة",
          "example": "كشف",
          "type": "string"
         },
         "price": {
          "description": "السعر بالريال، نص بمنزلتين",
          "example": "200.00",
          "type": "string"
         },
         "provider_id": {
          "description": "معرّف المزوّد",
          "example": "1",
          "type": "number"
         }
        },
        "required": [
         "name",
         "provider_id",
         "duration_min",
         "price"
        ],
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "currency": "SAR",
          "duration_min": 30,
          "id": 2,
          "name": "كشف",
          "price": "200.00",
          "provider_id": 1
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "409": {
      "description": "تعارض / conflict (slot_taken, quota_exceeded, deposit_pending)"
     },
     "422": {
      "description": "تحقق / validation error"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "تعديل خدمة / Update service",
    "tags": [
     "booking",
     "services"
    ],
    "x-emm-app": "booking"
   },
   "servers": [
    {
     "description": "booking",
     "url": "https://booking.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "booking"
  },
  "/booking/api/v1/settings": {
   "get": {
    "description": "بيانات النشاط وساعات العمل لكل يوم وطول الفترة والتأمين. Business identity, per-weekday hours, slot length, deposit rule.",
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "business": {
           "address": "الرياض",
           "currency": "SAR",
           "name": "عيادة النور",
           "phone": "+966551234567",
           "public_url": "https://booking.emm.sa/b/clinic",
           "slot_min": 30,
           "slug": "clinic",
           "timezone": "Asia/Riyadh",
           "type": "clinic"
          },
          "deposit": {
           "mode": "none",
           "value": "0.00"
          },
          "hours": [
           {
            "close": "22:00",
            "enabled": true,
            "open": "10:00",
            "weekday": 0
           }
          ]
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "إعدادات النشاط / Business settings",
    "tags": [
     "booking",
     "settings"
    ],
    "x-emm-app": "booking"
   },
   "put": {
    "description": "تحديث جزئي: name, phone, address, slot_min (15|30|60), deposit_mode (none|fixed|percent) + deposit_value, hours[]. Partial update; hours replace all 7 weekdays.",
    "requestBody": {
     "content": {
      "application/json": {
       "example": {
        "deposit_mode": "fixed",
        "deposit_value": 20,
        "hours": [
         {
          "close": "22:00",
          "enabled": true,
          "open": "10:00",
          "weekday": 0
         },
         {
          "close": "22:00",
          "enabled": true,
          "open": "10:00",
          "weekday": 1
         },
         {
          "close": "22:00",
          "enabled": true,
          "open": "10:00",
          "weekday": 2
         },
         {
          "close": "22:00",
          "enabled": true,
          "open": "10:00",
          "weekday": 3
         },
         {
          "close": "22:00",
          "enabled": true,
          "open": "10:00",
          "weekday": 4
         },
         {
          "close": "22:00",
          "enabled": false,
          "open": "10:00",
          "weekday": 5
         },
         {
          "close": "22:00",
          "enabled": false,
          "open": "10:00",
          "weekday": 6
         }
        ],
        "name": "عيادة النور",
        "slot_min": 30
       },
       "schema": {
        "properties": {
         "address": {
          "description": "العنوان",
          "type": "string"
         },
         "deposit_mode": {
          "description": "none|fixed|percent (يتطلب خطة تدعم التأمين)",
          "example": "fixed",
          "type": "string"
         },
         "deposit_value": {
          "description": "قيمة التأمين (مبلغ ثابت أو نسبة 1–100)",
          "example": "20",
          "type": "number"
         },
         "hours": {
          "description": "7 أيام (تستبدل الكل)",
          "items": {
           "properties": {
            "close": {
             "description": "HH:MM بعد الفتح",
             "example": "22:00",
             "type": "string"
            },
            "enabled": {
             "description": "يوم عمل",
             "type": "boolean"
            },
            "open": {
             "description": "HH:MM",
             "example": "10:00",
             "type": "string"
            },
            "weekday": {
             "description": "0=الأحد … 6=السبت",
             "example": "0",
             "type": "number"
            }
           },
           "required": [
            "weekday",
            "open",
            "close",
            "enabled"
           ],
           "type": "object"
          },
          "type": "array"
         },
         "name": {
          "description": "اسم النشاط",
          "example": "عيادة النور",
          "type": "string"
         },
         "phone": {
          "description": "جوال/واتساب 05XXXXXXXX",
          "example": "0551234567",
          "type": "string"
         },
         "slot_min": {
          "description": "طول الفترة بالدقائق 15|30|60",
          "example": "30",
          "type": "number"
         }
        },
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "business": {
           "address": "الرياض",
           "currency": "SAR",
           "name": "عيادة النور",
           "phone": "+966551234567",
           "public_url": "https://booking.emm.sa/b/clinic",
           "slot_min": 30,
           "slug": "clinic",
           "timezone": "Asia/Riyadh",
           "type": "clinic"
          },
          "deposit": {
           "mode": "none",
           "value": "0.00"
          },
          "hours": [
           {
            "close": "22:00",
            "enabled": true,
            "open": "10:00",
            "weekday": 0
           }
          ]
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "409": {
      "description": "تعارض / conflict (slot_taken, quota_exceeded, deposit_pending)"
     },
     "422": {
      "description": "تحقق / validation error"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "تحديث الإعدادات / Update settings",
    "tags": [
     "booking",
     "settings"
    ],
    "x-emm-app": "booking"
   },
   "servers": [
    {
     "description": "booking",
     "url": "https://booking.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "booking"
  },
  "/booking/api/v1/slots/block": {
   "post": {
    "description": "يحجز فترة لمزوّد (إجازة/اجتماع) فلا تظهر للعملاء. Blocks a provider's time range so customers cannot book it.",
    "requestBody": {
     "content": {
      "application/json": {
       "example": {
        "end": "2026-12-10T16:00",
        "note": "اجتماع",
        "provider_id": 1,
        "start": "2026-12-10T14:30"
       },
       "schema": {
        "properties": {
         "end": {
          "description": "نهاية الفترة المحجوبة ISO-8601",
          "example": "2026-12-10T16:00",
          "type": "string"
         },
         "note": {
          "description": "سبب الحجب (داخلي)",
          "example": "اجتماع",
          "type": "string"
         },
         "provider_id": {
          "description": "معرّف المزوّد",
          "example": "1",
          "type": "number"
         },
         "start": {
          "description": "بداية الفترة المحجوبة ISO-8601",
          "example": "2026-12-10T14:30",
          "type": "string"
         }
        },
        "required": [
         "provider_id",
         "start",
         "end"
        ],
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "created_at": "2026-12-02T09:00:00+03:00",
          "customer": {
           "name": "أحمد العلي",
           "phone": "+966551234567"
          },
          "deposit": {
           "amount": "0.00",
           "currency": "SAR",
           "paid_manually": false,
           "status": "none"
          },
          "end": "2026-12-10T15:00:00+03:00",
          "id": 7,
          "provider": {
           "id": 1,
           "name": "نورة"
          },
          "ref_code": "BK-7K3M9Q",
          "service": {
           "currency": "SAR",
           "duration_min": 30,
           "id": 2,
           "name": "كشف",
           "price": "200.00"
          },
          "start": "2026-12-10T14:30:00+03:00",
          "status": "pending",
          "status_ar": "بانتظار التأكيد"
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "201": {
      "description": "أُنشئ / created"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "409": {
      "description": "تعارض / conflict (slot_taken, quota_exceeded, deposit_pending)"
     },
     "422": {
      "description": "تحقق / validation error"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "حجب فترة / Block a slot",
    "tags": [
     "booking",
     "slots"
    ],
    "x-emm-app": "booking"
   },
   "servers": [
    {
     "description": "booking",
     "url": "https://booking.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "booking"
  },
  "/contracts/catalogue": {
   "get": {
    "operationId": "contracts_get__catalogue",
    "parameters": [
     {
      "in": "query",
      "name": "category",
      "required": false,
      "schema": {
       "description": "العمل والأفراد · الإيجارات · الأعمال التجارية · الخدمات والتقنية",
       "type": "string"
      }
     },
     {
      "in": "query",
      "name": "limit",
      "required": false,
      "schema": {
       "description": "عدد النتائج 1-200 (افتراضي 50)",
       "example": 50,
       "type": "integer"
      }
     },
     {
      "in": "query",
      "name": "offset",
      "required": false,
      "schema": {
       "description": "إزاحة الترحيل",
       "example": 0,
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "data": {
           "description": "نفس مخرجات هذه النقطة (راجع التوثيق)",
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "type": "object"
        }
       }
      },
      "description": "نجاح — {\"ok\":true, \"data\":…}"
     },
     "400": {
      "description": "تحقق (نفس قواعد المحرر) أو JSON غير صالح"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية (read)، أو plan_required (members)، أو payment_required (docx بلا دفع)، أو edit_window_closed"
     },
     "404": {
      "description": "عقد أو بند غير موجود ضمن حسابك"
     },
     "429": {
      "description": "تجاوز 60 طلباً/دقيقة — راجع Retry-After"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "كتالوج العقود (12 نموذجاً، فلتر ?category=)",
    "tags": [
     "contracts",
     "catalogue"
    ],
    "x-emm-app": "contracts",
    "x-scope": "read"
   },
   "servers": [
    {
     "description": "contracts",
     "url": "https://contracts.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "contracts"
  },
  "/contracts/catalogue/{slug}": {
   "get": {
    "operationId": "contracts_get__catalogue_slug",
    "parameters": [
     {
      "in": "path",
      "name": "slug",
      "required": true,
      "schema": {
       "enum": [
        "nda",
        "supply",
        "maintenance",
        "partnership",
        "lease-commercial",
        "lease-home",
        "design",
        "dev",
        "marketing",
        "consulting",
        "freelance",
        "employment"
       ],
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "data": {
           "description": "نفس مخرجات هذه النقطة (راجع التوثيق)",
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "type": "object"
        }
       }
      },
      "description": "نجاح — {\"ok\":true, \"data\":…}"
     },
     "400": {
      "description": "تحقق (نفس قواعد المحرر) أو JSON غير صالح"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية (read)، أو plan_required (members)، أو payment_required (docx بلا دفع)، أو edit_window_closed"
     },
     "404": {
      "description": "عقد أو بند غير موجود ضمن حسابك"
     },
     "429": {
      "description": "تجاوز 60 طلباً/دقيقة — راجع Retry-After"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "مخطط عقد واحد: الحقول (id/label/help/type/required/default/show_if) + البنود + الإرشادات",
    "tags": [
     "contracts",
     "catalogue"
    ],
    "x-emm-app": "contracts",
    "x-scope": "read"
   },
   "servers": [
    {
     "description": "contracts",
     "url": "https://contracts.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "contracts"
  },
  "/contracts/clauses": {
   "get": {
    "operationId": "contracts_get__clauses",
    "parameters": [
     {
      "in": "query",
      "name": "limit",
      "required": false,
      "schema": {
       "description": "عدد النتائج 1-200 (افتراضي 50)",
       "example": 50,
       "type": "integer"
      }
     },
     {
      "in": "query",
      "name": "offset",
      "required": false,
      "schema": {
       "description": "إزاحة الترحيل",
       "example": 0,
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "data": {
           "description": "نفس مخرجات هذه النقطة (راجع التوثيق)",
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "type": "object"
        }
       }
      },
      "description": "نجاح — {\"ok\":true, \"data\":…}"
     },
     "400": {
      "description": "تحقق (نفس قواعد المحرر) أو JSON غير صالح"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية (read)، أو plan_required (members)، أو payment_required (docx بلا دفع)، أو edit_window_closed"
     },
     "404": {
      "description": "عقد أو بند غير موجود ضمن حسابك"
     },
     "429": {
      "description": "تجاوز 60 طلباً/دقيقة — راجع Retry-After"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "مكتبة البنود (members only)",
    "tags": [
     "contracts",
     "clause library"
    ],
    "x-emm-app": "contracts",
    "x-scope": "read"
   },
   "post": {
    "operationId": "contracts_post__clauses",
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "additionalProperties": true,
        "properties": {
         "body": {
          "description": "نص البند (مطلوب، ≥ 10 أحرف)",
          "example": "يسدد العميل 50% من المقابل قبل بدء التنفيذ.",
          "type": "string"
         },
         "title": {
          "description": "عنوان البند (مطلوب)",
          "example": "دفع مسبق",
          "type": "string"
         }
        },
        "required": [
         "title",
         "body"
        ],
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "201": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "data": {
           "description": "نفس مخرجات هذه النقطة (راجع التوثيق)",
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "type": "object"
        }
       }
      },
      "description": "نجاح — {\"ok\":true, \"data\":…}"
     },
     "400": {
      "description": "تحقق (نفس قواعد المحرر) أو JSON غير صالح"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية (write)، أو plan_required (members)، أو payment_required (docx بلا دفع)، أو edit_window_closed"
     },
     "404": {
      "description": "عقد أو بند غير موجود ضمن حسابك"
     },
     "429": {
      "description": "تجاوز 60 طلباً/دقيقة — راجع Retry-After"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "حفظ بند (title + body ≥ 10 أحرف) — members only",
    "tags": [
     "contracts",
     "clause library"
    ],
    "x-emm-app": "contracts",
    "x-scope": "write"
   },
   "servers": [
    {
     "description": "contracts",
     "url": "https://contracts.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "contracts"
  },
  "/contracts/clauses/{id}": {
   "delete": {
    "operationId": "contracts_delete__clauses_id",
    "parameters": [
     {
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "data": {
           "description": "نفس مخرجات هذه النقطة (راجع التوثيق)",
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "type": "object"
        }
       }
      },
      "description": "نجاح — {\"ok\":true, \"data\":…}"
     },
     "400": {
      "description": "تحقق (نفس قواعد المحرر) أو JSON غير صالح"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية (write)، أو plan_required (members)، أو payment_required (docx بلا دفع)، أو edit_window_closed"
     },
     "404": {
      "description": "عقد أو بند غير موجود ضمن حسابك"
     },
     "429": {
      "description": "تجاوز 60 طلباً/دقيقة — راجع Retry-After"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "حذف بند — members only",
    "tags": [
     "contracts",
     "clause library"
    ],
    "x-emm-app": "contracts",
    "x-scope": "write"
   },
   "servers": [
    {
     "description": "contracts",
     "url": "https://contracts.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "contracts"
  },
  "/contracts/docs": {
   "get": {
    "operationId": "contracts_get__docs",
    "parameters": [
     {
      "in": "query",
      "name": "contract",
      "required": false,
      "schema": {
       "description": "معرّف النموذج",
       "type": "string"
      }
     },
     {
      "in": "query",
      "name": "limit",
      "required": false,
      "schema": {
       "description": "عدد النتائج 1-200 (افتراضي 50)",
       "example": 50,
       "type": "integer"
      }
     },
     {
      "in": "query",
      "name": "offset",
      "required": false,
      "schema": {
       "description": "إزاحة الترحيل",
       "example": 0,
       "type": "integer"
      }
     },
     {
      "in": "query",
      "name": "state",
      "required": false,
      "schema": {
       "description": "free | pending | paid | refunded",
       "enum": [
        "free",
        "pending",
        "paid",
        "refunded"
       ],
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "data": {
           "description": "نفس مخرجات هذه النقطة (راجع التوثيق)",
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "type": "object"
        }
       }
      },
      "description": "نجاح — {\"ok\":true, \"data\":…}"
     },
     "400": {
      "description": "تحقق (نفس قواعد المحرر) أو JSON غير صالح"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية (read)، أو plan_required (members)، أو payment_required (docx بلا دفع)، أو edit_window_closed"
     },
     "404": {
      "description": "عقد أو بند غير موجود ضمن حسابك"
     },
     "429": {
      "description": "تجاوز 60 طلباً/دقيقة — راجع Retry-After"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "عقودي (ترحيل، فلتر ?contract= و ?state=)",
    "tags": [
     "contracts",
     "docs"
    ],
    "x-emm-app": "contracts",
    "x-scope": "read"
   },
   "post": {
    "operationId": "contracts_post__docs",
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "additionalProperties": true,
        "properties": {
         "clauses": {
          "description": "معرّفات البنود الاختيارية المفعّلة (مثال: [\"penalty\",\"data\"])",
          "items": {
           "type": "string"
          },
          "type": "array"
         },
         "extra_clauses": {
          "description": "بنود إضافية بنص حر (فقرات يفصلها سطر فارغ)",
          "example": "",
          "type": "string"
         },
         "slug": {
          "description": "معرّف النموذج (مطلوب) — قائمة /catalogue",
          "example": "freelance",
          "type": "string"
         },
         "title": {
          "description": "اسم تعريفي للعقد (≤80) — افتراضي اسم النموذج",
          "example": "عقد عمل حر — مشروع نور",
          "type": "string"
         },
         "values": {
          "additionalProperties": {
           "type": "string"
          },
          "description": "field_id → القيمة. الحقول من /catalogue/{slug} (a_name, a_id, b_name, b_id, fee, start_date…)",
          "type": "object"
         }
        },
        "required": [
         "slug"
        ],
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "201": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "data": {
           "description": "نفس مخرجات هذه النقطة (راجع التوثيق)",
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "type": "object"
        }
       }
      },
      "description": "نجاح — {\"ok\":true, \"data\":…}"
     },
     "400": {
      "description": "تحقق (نفس قواعد المحرر) أو JSON غير صالح"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية (write)، أو plan_required (members)، أو payment_required (docx بلا دفع)، أو edit_window_closed"
     },
     "404": {
      "description": "عقد أو بند غير موجود ضمن حسابك"
     },
     "429": {
      "description": "تجاوز 60 طلباً/دقيقة — راجع Retry-After"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "إنشاء عقد من slug + values + clauses (تحقق مطابق للمحرر → 400 عند نقص حقل مطلوب)",
    "tags": [
     "contracts",
     "docs"
    ],
    "x-emm-app": "contracts",
    "x-scope": "write"
   },
   "servers": [
    {
     "description": "contracts",
     "url": "https://contracts.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "contracts"
  },
  "/contracts/docs/{id}": {
   "delete": {
    "operationId": "contracts_delete__docs_id",
    "parameters": [
     {
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "data": {
           "description": "نفس مخرجات هذه النقطة (راجع التوثيق)",
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "type": "object"
        }
       }
      },
      "description": "نجاح — {\"ok\":true, \"data\":…}"
     },
     "400": {
      "description": "تحقق (نفس قواعد المحرر) أو JSON غير صالح"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية (write)، أو plan_required (members)، أو payment_required (docx بلا دفع)، أو edit_window_closed"
     },
     "404": {
      "description": "عقد أو بند غير موجود ضمن حسابك"
     },
     "429": {
      "description": "تجاوز 60 طلباً/دقيقة — راجع Retry-After"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "حذف العقد نهائياً",
    "tags": [
     "contracts",
     "docs"
    ],
    "x-emm-app": "contracts",
    "x-scope": "write"
   },
   "get": {
    "operationId": "contracts_get__docs_id",
    "parameters": [
     {
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "data": {
           "description": "نفس مخرجات هذه النقطة (راجع التوثيق)",
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "type": "object"
        }
       }
      },
      "description": "نجاح — {\"ok\":true, \"data\":…}"
     },
     "400": {
      "description": "تحقق (نفس قواعد المحرر) أو JSON غير صالح"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية (read)، أو plan_required (members)، أو payment_required (docx بلا دفع)، أو edit_window_closed"
     },
     "404": {
      "description": "عقد أو بند غير موجود ضمن حسابك"
     },
     "429": {
      "description": "تجاوز 60 طلباً/دقيقة — راجع Retry-After"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "عقد واحد كامل (الحقول، البنود، الحالة، الروابط)",
    "tags": [
     "contracts",
     "docs"
    ],
    "x-emm-app": "contracts",
    "x-scope": "read"
   },
   "patch": {
    "operationId": "contracts_patch__docs_id",
    "parameters": [
     {
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "additionalProperties": true,
        "properties": {
         "clauses": {
          "description": "معرّفات البنود الاختيارية المفعّلة (مثال: [\"penalty\",\"data\"])",
          "items": {
           "type": "string"
          },
          "type": "array"
         },
         "doc_id": {
          "description": "رقم العقد (في المسار)",
          "example": 123,
          "type": "integer"
         },
         "extra_clauses": {
          "description": "بنود إضافية بنص حر (فقرات يفصلها سطر فارغ)",
          "example": "",
          "type": "string"
         },
         "title": {
          "description": "اسم تعريفي للعقد (≤80) — افتراضي اسم النموذج",
          "example": "عقد عمل حر — مشروع نور",
          "type": "string"
         },
         "values": {
          "additionalProperties": {
           "type": "string"
          },
          "description": "field_id → القيمة. الحقول من /catalogue/{slug} (a_name, a_id, b_name, b_id, fee, start_date…)",
          "type": "object"
         }
        },
        "required": [],
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "data": {
           "description": "نفس مخرجات هذه النقطة (راجع التوثيق)",
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "type": "object"
        }
       }
      },
      "description": "نجاح — {\"ok\":true, \"data\":…}"
     },
     "400": {
      "description": "تحقق (نفس قواعد المحرر) أو JSON غير صالح"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية (write)، أو plan_required (members)، أو payment_required (docx بلا دفع)، أو edit_window_closed"
     },
     "404": {
      "description": "عقد أو بند غير موجود ضمن حسابك"
     },
     "429": {
      "description": "تجاوز 60 طلباً/دقيقة — راجع Retry-After"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "تعديل عقد (PUT مقبول أيضاً): الحقول الغائبة تبقى؛ requires مهلة تعديل مفتوحة → 403 edit_window_closed",
    "tags": [
     "contracts",
     "docs"
    ],
    "x-emm-app": "contracts",
    "x-scope": "write"
   },
   "put": {
    "operationId": "contracts_put__docs_id",
    "parameters": [
     {
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "additionalProperties": true,
        "properties": {
         "clauses": {
          "description": "معرّفات البنود الاختيارية المفعّلة (مثال: [\"penalty\",\"data\"])",
          "items": {
           "type": "string"
          },
          "type": "array"
         },
         "doc_id": {
          "description": "رقم العقد (في المسار)",
          "example": 123,
          "type": "integer"
         },
         "extra_clauses": {
          "description": "بنود إضافية بنص حر (فقرات يفصلها سطر فارغ)",
          "example": "",
          "type": "string"
         },
         "title": {
          "description": "اسم تعريفي للعقد (≤80) — افتراضي اسم النموذج",
          "example": "عقد عمل حر — مشروع نور",
          "type": "string"
         },
         "values": {
          "additionalProperties": {
           "type": "string"
          },
          "description": "field_id → القيمة. الحقول من /catalogue/{slug} (a_name, a_id, b_name, b_id, fee, start_date…)",
          "type": "object"
         }
        },
        "required": [],
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "data": {
           "description": "نفس مخرجات هذه النقطة (راجع التوثيق)",
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "type": "object"
        }
       }
      },
      "description": "نجاح — {\"ok\":true, \"data\":…}"
     },
     "400": {
      "description": "تحقق (نفس قواعد المحرر) أو JSON غير صالح"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية (write)، أو plan_required (members)، أو payment_required (docx بلا دفع)، أو edit_window_closed"
     },
     "404": {
      "description": "عقد أو بند غير موجود ضمن حسابك"
     },
     "429": {
      "description": "تجاوز 60 طلباً/دقيقة — راجع Retry-After"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "تعديل عقد (PUT مقبول أيضاً): الحقول الغائبة تبقى؛ requires مهلة تعديل مفتوحة → 403 edit_window_closed",
    "tags": [
     "contracts",
     "docs"
    ],
    "x-emm-app": "contracts",
    "x-scope": "write"
   },
   "servers": [
    {
     "description": "contracts",
     "url": "https://contracts.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "contracts"
  },
  "/contracts/docs/{id}/download/{format}": {
   "get": {
    "operationId": "contracts_get__docs_id_download_format",
    "parameters": [
     {
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     },
     {
      "in": "path",
      "name": "format",
      "required": true,
      "schema": {
       "enum": [
        "pdf",
        "docx"
       ],
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/pdf": {
        "schema": {
         "format": "binary",
         "type": "string"
        }
       },
       "application/vnd.openxmlformats-officedocument.wordprocessingml.document": {
        "schema": {
         "format": "binary",
         "type": "string"
        }
       }
      },
      "description": "application/pdf أو docx"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "تحميل العقد — pdf (بعلامة مائية في المجاني) أو docx (بعد الدفع/العضوية → 403 payment_required). ثنائي خارج المغلّف",
    "tags": [
     "contracts",
     "docs"
    ],
    "x-emm-app": "contracts",
    "x-scope": "read"
   },
   "servers": [
    {
     "description": "contracts",
     "url": "https://contracts.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "contracts"
  },
  "/contracts/docs/{id}/duplicate": {
   "post": {
    "operationId": "contracts_post__docs_id_duplicate",
    "parameters": [
     {
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "additionalProperties": true,
        "properties": {
         "title": {
          "description": "اسم النسخة",
          "type": "string"
         }
        },
        "required": [],
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "201": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "data": {
           "description": "نفس مخرجات هذه النقطة (راجع التوثيق)",
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "type": "object"
        }
       }
      },
      "description": "نجاح — {\"ok\":true, \"data\":…}"
     },
     "400": {
      "description": "تحقق (نفس قواعد المحرر) أو JSON غير صالح"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية (write)، أو plan_required (members)، أو payment_required (docx بلا دفع)، أو edit_window_closed"
     },
     "404": {
      "description": "عقد أو بند غير موجود ضمن حسابك"
     },
     "429": {
      "description": "تجاوز 60 طلباً/دقيقة — راجع Retry-After"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "نسخ العقد (members only → 403 plan_required)؛ ?title=",
    "tags": [
     "contracts",
     "docs"
    ],
    "x-emm-app": "contracts",
    "x-scope": "write"
   },
   "servers": [
    {
     "description": "contracts",
     "url": "https://contracts.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "contracts"
  },
  "/contracts/docs/{id}/links": {
   "get": {
    "operationId": "contracts_get__docs_id_links",
    "parameters": [
     {
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "data": {
           "description": "نفس مخرجات هذه النقطة (راجع التوثيق)",
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "type": "object"
        }
       }
      },
      "description": "نجاح — {\"ok\":true, \"data\":…}"
     },
     "400": {
      "description": "تحقق (نفس قواعد المحرر) أو JSON غير صالح"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية (read)، أو plan_required (members)، أو payment_required (docx بلا دفع)، أو edit_window_closed"
     },
     "404": {
      "description": "عقد أو بند غير موجود ضمن حسابك"
     },
     "429": {
      "description": "تجاوز 60 طلباً/دقيقة — راجع Retry-After"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "روابط /d/\u003ctoken\u003e العامة للتحميل (بعد الدفع أو بالعضوية)",
    "tags": [
     "contracts",
     "docs"
    ],
    "x-emm-app": "contracts",
    "x-scope": "read"
   },
   "servers": [
    {
     "description": "contracts",
     "url": "https://contracts.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "contracts"
  },
  "/contracts/docs/{id}/unlock": {
   "get": {
    "operationId": "contracts_get__docs_id_unlock",
    "parameters": [
     {
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "data": {
           "description": "نفس مخرجات هذه النقطة (راجع التوثيق)",
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "type": "object"
        }
       }
      },
      "description": "نجاح — {\"ok\":true, \"data\":…}"
     },
     "400": {
      "description": "تحقق (نفس قواعد المحرر) أو JSON غير صالح"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية (read)، أو plan_required (members)، أو payment_required (docx بلا دفع)، أو edit_window_closed"
     },
     "404": {
      "description": "عقد أو بند غير موجود ضمن حسابك"
     },
     "429": {
      "description": "تجاوز 60 طلباً/دقيقة — راجع Retry-After"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "حالة الفتح: state، ما يمكن تحميله، مهلة التعديل، السعر إن لم يُدفع",
    "tags": [
     "contracts",
     "docs"
    ],
    "x-emm-app": "contracts",
    "x-scope": "read"
   },
   "servers": [
    {
     "description": "contracts",
     "url": "https://contracts.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "contracts"
  },
  "/contracts/me": {
   "get": {
    "operationId": "contracts_get__me",
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "data": {
           "description": "نفس مخرجات هذه النقطة (راجع التوثيق)",
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "type": "object"
        }
       }
      },
      "description": "نجاح — {\"ok\":true, \"data\":…}"
     },
     "400": {
      "description": "تحقق (نفس قواعد المحرر) أو JSON غير صالح"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية (read)، أو plan_required (members)، أو payment_required (docx بلا دفع)، أو edit_window_closed"
     },
     "404": {
      "description": "عقد أو بند غير موجود ضمن حسابك"
     },
     "429": {
      "description": "تجاوز 60 طلباً/دقيقة — راجع Retry-After"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "المستخدم والخطة والحصص — اختبار مفتاحك",
    "tags": [
     "contracts",
     "account"
    ],
    "x-emm-app": "contracts",
    "x-scope": "read"
   },
   "servers": [
    {
     "description": "contracts",
     "url": "https://contracts.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "contracts"
  },
  "/contracts/plan": {
   "get": {
    "operationId": "contracts_get__plan",
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "data": {
           "description": "نفس مخرجات هذه النقطة (راجع التوثيق)",
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "type": "object"
        }
       }
      },
      "description": "نجاح — {\"ok\":true, \"data\":…}"
     },
     "400": {
      "description": "تحقق (نفس قواعد المحرر) أو JSON غير صالح"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية (read)، أو plan_required (members)، أو payment_required (docx بلا دفع)، أو edit_window_closed"
     },
     "404": {
      "description": "عقد أو بند غير موجود ضمن حسابك"
     },
     "429": {
      "description": "تجاوز 60 طلباً/دقيقة — راجع Retry-After"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "كل الخطط والحدود وأين يُدفع",
    "tags": [
     "contracts",
     "account"
    ],
    "x-emm-app": "contracts",
    "x-scope": "read"
   },
   "servers": [
    {
     "description": "contracts",
     "url": "https://contracts.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "contracts"
  },
  "/cv/ats/check": {
   "post": {
    "operationId": "cv_post_ats_check",
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "additionalProperties": true,
        "properties": {
         "content": {
          "description": "مستند السيرة (نفس شكل content)",
          "type": "object"
         },
         "template": {
          "description": "القالب (افتراضي classic)",
          "enum": [
           "classic",
           "modern",
           "executive",
           "minimal",
           "twocol",
           "compact"
          ],
          "example": "classic",
          "type": "string"
         }
        },
        "required": [],
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "data": {
           "description": "سيرة (نفس مخرجات /api/v1/cvs/{id})",
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "type": "object"
        }
       }
      },
      "description": "نجاح — {\"ok\":true, \"data\":…}"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية (read) أو الخطة لا تشمل الميزة (plan_required)"
     },
     "429": {
      "description": "تجاوز 60 طلباً/دقيقة — راجع Retry-After"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "فحص ATS لمحتوى غير محفوظ (قبل الحفظ) — {content, template?}",
    "tags": [
     "cv",
     "ats"
    ],
    "x-emm-app": "cv",
    "x-scope": "read"
   },
   "servers": [
    {
     "description": "cv",
     "url": "https://cv.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "cv"
  },
  "/cv/cover-letters": {
   "get": {
    "operationId": "cv_get_cover-letters",
    "parameters": [
     {
      "in": "query",
      "name": "cv_id",
      "required": false,
      "schema": {
       "description": "خطابات سيرة معينة",
       "type": "integer"
      }
     },
     {
      "in": "query",
      "name": "limit",
      "required": false,
      "schema": {
       "description": "عدد النتائج 1-200 (افتراضي 50)",
       "example": 50,
       "type": "integer"
      }
     },
     {
      "in": "query",
      "name": "offset",
      "required": false,
      "schema": {
       "description": "إزاحة الترحيل",
       "example": 0,
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "data": {
           "description": "خطاب تقديم (نفس مخرجات /api/v1/cover-letters/{id})",
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "type": "object"
        }
       }
      },
      "description": "نجاح — {\"ok\":true, \"data\":…}"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية (read) أو الخطة لا تشمل الميزة (plan_required)"
     },
     "429": {
      "description": "تجاوز 60 طلباً/دقيقة — راجع Retry-After"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "خطاباتي (ترحيل، فلتر ?cv_id=)",
    "tags": [
     "cv",
     "cover letters"
    ],
    "x-emm-app": "cv",
    "x-scope": "read"
   },
   "post": {
    "operationId": "cv_post_cover-letters",
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "additionalProperties": true,
        "properties": {
         "accent": {
          "description": "لون التمييز (افتراضي لون السيرة)",
          "enum": [
           "navy",
           "teal",
           "burgundy",
           "green",
           "blue",
           "slate"
          ],
          "example": "navy",
          "type": "string"
         },
         "body": {
          "description": "نص الخطاب (فقرات يفصلها سطر فارغ) — اتركه فارغاً ليُولَّد من السيرة",
          "example": "",
          "type": "string"
         },
         "company": {
          "description": "الشركة أو الجهة (مطلوب)",
          "example": "شركة التقنية",
          "type": "string"
         },
         "cv_id": {
          "description": "رقم السيرة",
          "example": 123,
          "type": "integer"
         },
         "job_title": {
          "description": "المسمى الوظيفي (مطلوب)",
          "example": "مهندس برمجيات أول",
          "type": "string"
         },
         "lang": {
          "description": "لغة الخطاب (افتراضي لغة السيرة)",
          "enum": [
           "ar",
           "en"
          ],
          "example": "ar",
          "type": "string"
         },
         "recipient": {
          "description": "اسم مسؤول التوظيف (اختياري — وإلا «قسم الموارد البشرية»)",
          "example": "أ. سارة العتيبي",
          "type": "string"
         }
        },
        "required": [
         "job_title",
         "cv_id",
         "company"
        ],
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "201": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "data": {
           "description": "خطاب تقديم (نفس مخرجات /api/v1/cover-letters/{id})",
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "type": "object"
        }
       }
      },
      "description": "نجاح — {\"ok\":true, \"data\":…}"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية (write) أو الخطة لا تشمل الميزة (plan_required)"
     },
     "429": {
      "description": "تجاوز 60 طلباً/دقيقة — راجع Retry-After"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "توليد خطاب تقديم لسيرة (cv_id) — بديل للمسار المتداخل",
    "tags": [
     "cv",
     "cover letters"
    ],
    "x-emm-app": "cv",
    "x-scope": "write"
   },
   "servers": [
    {
     "description": "cv",
     "url": "https://cv.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "cv"
  },
  "/cv/cover-letters/{id}": {
   "delete": {
    "operationId": "cv_delete_cover-letters_id",
    "parameters": [
     {
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "data": {
           "description": "خطاب تقديم (نفس مخرجات /api/v1/cover-letters/{id})",
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "type": "object"
        }
       }
      },
      "description": "نجاح — {\"ok\":true, \"data\":…}"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية (write) أو الخطة لا تشمل الميزة (plan_required)"
     },
     "429": {
      "description": "تجاوز 60 طلباً/دقيقة — راجع Retry-After"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "حذف خطاب",
    "tags": [
     "cv",
     "cover letters"
    ],
    "x-emm-app": "cv",
    "x-scope": "write"
   },
   "get": {
    "operationId": "cv_get_cover-letters_id",
    "parameters": [
     {
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "data": {
           "description": "خطاب تقديم (نفس مخرجات /api/v1/cover-letters/{id})",
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "type": "object"
        }
       }
      },
      "description": "نجاح — {\"ok\":true, \"data\":…}"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية (read) أو الخطة لا تشمل الميزة (plan_required)"
     },
     "429": {
      "description": "تجاوز 60 طلباً/دقيقة — راجع Retry-After"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "خطاب واحد مع النص",
    "tags": [
     "cv",
     "cover letters"
    ],
    "x-emm-app": "cv",
    "x-scope": "read"
   },
   "patch": {
    "operationId": "cv_patch_cover-letters_id",
    "parameters": [
     {
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "additionalProperties": true,
        "properties": {
         "accent": {
          "description": "لون التمييز (افتراضي لون السيرة)",
          "enum": [
           "navy",
           "teal",
           "burgundy",
           "green",
           "blue",
           "slate"
          ],
          "example": "navy",
          "type": "string"
         },
         "body": {
          "description": "نص الخطاب (فقرات يفصلها سطر فارغ) — اتركه فارغاً ليُولَّد من السيرة",
          "example": "",
          "type": "string"
         },
         "company": {
          "description": "الشركة أو الجهة (مطلوب)",
          "example": "شركة التقنية",
          "type": "string"
         },
         "job_title": {
          "description": "المسمى الوظيفي (مطلوب)",
          "example": "مهندس برمجيات أول",
          "type": "string"
         },
         "lang": {
          "description": "لغة الخطاب (افتراضي لغة السيرة)",
          "enum": [
           "ar",
           "en"
          ],
          "example": "ar",
          "type": "string"
         },
         "recipient": {
          "description": "اسم مسؤول التوظيف (اختياري — وإلا «قسم الموارد البشرية»)",
          "example": "أ. سارة العتيبي",
          "type": "string"
         }
        },
        "required": [],
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "data": {
           "description": "خطاب تقديم (نفس مخرجات /api/v1/cover-letters/{id})",
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "type": "object"
        }
       }
      },
      "description": "نجاح — {\"ok\":true, \"data\":…}"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية (write) أو الخطة لا تشمل الميزة (plan_required)"
     },
     "429": {
      "description": "تجاوز 60 طلباً/دقيقة — راجع Retry-After"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "تعديل خطاب (الحقول الغائبة تبقى؛ body يستبدل النص)",
    "tags": [
     "cv",
     "cover letters"
    ],
    "x-emm-app": "cv",
    "x-scope": "write"
   },
   "put": {
    "operationId": "cv_patch_cover-letters_id",
    "parameters": [
     {
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "additionalProperties": true,
        "properties": {
         "accent": {
          "description": "لون التمييز (افتراضي لون السيرة)",
          "enum": [
           "navy",
           "teal",
           "burgundy",
           "green",
           "blue",
           "slate"
          ],
          "example": "navy",
          "type": "string"
         },
         "body": {
          "description": "نص الخطاب (فقرات يفصلها سطر فارغ) — اتركه فارغاً ليُولَّد من السيرة",
          "example": "",
          "type": "string"
         },
         "company": {
          "description": "الشركة أو الجهة (مطلوب)",
          "example": "شركة التقنية",
          "type": "string"
         },
         "job_title": {
          "description": "المسمى الوظيفي (مطلوب)",
          "example": "مهندس برمجيات أول",
          "type": "string"
         },
         "lang": {
          "description": "لغة الخطاب (افتراضي لغة السيرة)",
          "enum": [
           "ar",
           "en"
          ],
          "example": "ar",
          "type": "string"
         },
         "recipient": {
          "description": "اسم مسؤول التوظيف (اختياري — وإلا «قسم الموارد البشرية»)",
          "example": "أ. سارة العتيبي",
          "type": "string"
         }
        },
        "required": [],
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "data": {
           "description": "خطاب تقديم (نفس مخرجات /api/v1/cover-letters/{id})",
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "type": "object"
        }
       }
      },
      "description": "نجاح — {\"ok\":true, \"data\":…}"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية (write) أو الخطة لا تشمل الميزة (plan_required)"
     },
     "429": {
      "description": "تجاوز 60 طلباً/دقيقة — راجع Retry-After"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "تعديل خطاب (الحقول الغائبة تبقى؛ body يستبدل النص)",
    "tags": [
     "cv",
     "cover letters"
    ],
    "x-emm-app": "cv",
    "x-scope": "write"
   },
   "servers": [
    {
     "description": "cv",
     "url": "https://cv.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "cv"
  },
  "/cv/cover-letters/{id}/render/pdf": {
   "get": {
    "operationId": "cv_get_cover-letters_id_render_pdf",
    "parameters": [
     {
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/pdf": {
        "schema": {
         "format": "binary",
         "type": "string"
        }
       }
      },
      "description": "application/pdf"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "PDF الخطاب (A4، ثنائي خارج المغلّف)",
    "tags": [
     "cv",
     "cover letters"
    ],
    "x-emm-app": "cv",
    "x-scope": "read"
   },
   "servers": [
    {
     "description": "cv",
     "url": "https://cv.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "cv"
  },
  "/cv/cvs": {
   "get": {
    "operationId": "cv_get_cvs",
    "parameters": [
     {
      "in": "query",
      "name": "lang",
      "required": false,
      "schema": {
       "description": "ar أو en",
       "enum": [
        "ar",
        "en"
       ],
       "type": "string"
      }
     },
     {
      "in": "query",
      "name": "limit",
      "required": false,
      "schema": {
       "description": "عدد النتائج 1-200 (افتراضي 50)",
       "example": 50,
       "type": "integer"
      }
     },
     {
      "in": "query",
      "name": "offset",
      "required": false,
      "schema": {
       "description": "إزاحة الترحيل",
       "example": 0,
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "data": {
           "description": "سيرة (نفس مخرجات /api/v1/cvs/{id})",
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "type": "object"
        }
       }
      },
      "description": "نجاح — {\"ok\":true, \"data\":…}"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية (read) أو الخطة لا تشمل الميزة (plan_required)"
     },
     "429": {
      "description": "تجاوز 60 طلباً/دقيقة — راجع Retry-After"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "قائمة السِيَر (ترحيل، فلتر ?lang=)",
    "tags": [
     "cv",
     "cvs"
    ],
    "x-emm-app": "cv",
    "x-scope": "read"
   },
   "post": {
    "operationId": "cv_post_cvs",
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "additionalProperties": true,
        "properties": {
         "accent": {
          "description": "لون التمييز: اسم من اللوحة أو #rrggbb",
          "enum": [
           "navy",
           "teal",
           "burgundy",
           "green",
           "blue",
           "slate"
          ],
          "example": "navy",
          "type": "string"
         },
         "content": {
          "description": "مستند السيرة: personal{full_name,headline,summary,city,phone,email,linkedin,website,birth_year,nationality,license}, experience[]{company,title,location,start,end,current,bullets}, education[]{degree,institution,start,end,grade}, skills[], languages[]{name,level}, certifications[]{name,issuer,year}, projects[]{name,link,desc}. في PATCH: الأقسام المذكورة فقط تُستبدل",
          "type": "object"
         },
         "lang": {
          "description": "لغة السيرة: ar (RTL) أو en (LTR)",
          "enum": [
           "ar",
           "en"
          ],
          "example": "ar",
          "type": "string"
         },
         "template": {
          "description": "القالب — قالبان مجاناً والستة في Pro وخبير",
          "enum": [
           "classic",
           "modern",
           "executive",
           "minimal",
           "twocol",
           "compact"
          ],
          "example": "classic",
          "type": "string"
         },
         "title": {
          "description": "اسم تعريفي للسيرة (≤80 حرفاً)",
          "example": "سيرة أحمد",
          "type": "string"
         }
        },
        "required": [
         "lang"
        ],
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "201": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "data": {
           "description": "سيرة (نفس مخرجات /api/v1/cvs/{id})",
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "type": "object"
        }
       }
      },
      "description": "نجاح — {\"ok\":true, \"data\":…}"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية (write) أو الخطة لا تشمل الميزة (plan_required)"
     },
     "429": {
      "description": "تجاوز 60 طلباً/دقيقة — راجع Retry-After"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "إنشاء سيرة (نفس تحقق المحرر؛ حد السِيَر للخطة المجانية → 409 quota)",
    "tags": [
     "cv",
     "cvs"
    ],
    "x-emm-app": "cv",
    "x-scope": "write"
   },
   "servers": [
    {
     "description": "cv",
     "url": "https://cv.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "cv"
  },
  "/cv/cvs/{id}": {
   "delete": {
    "operationId": "cv_delete_cvs_id",
    "parameters": [
     {
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "data": {
           "description": "سيرة (نفس مخرجات /api/v1/cvs/{id})",
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "type": "object"
        }
       }
      },
      "description": "نجاح — {\"ok\":true, \"data\":…}"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية (write) أو الخطة لا تشمل الميزة (plan_required)"
     },
     "429": {
      "description": "تجاوز 60 طلباً/دقيقة — راجع Retry-After"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "حذف السيرة نهائياً (مع خطاباتها)",
    "tags": [
     "cv",
     "cvs"
    ],
    "x-emm-app": "cv",
    "x-scope": "write"
   },
   "get": {
    "operationId": "cv_get_cvs_id",
    "parameters": [
     {
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "data": {
           "description": "سيرة (نفس مخرجات /api/v1/cvs/{id})",
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "type": "object"
        }
       }
      },
      "description": "نجاح — {\"ok\":true, \"data\":…}"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية (read) أو الخطة لا تشمل الميزة (plan_required)"
     },
     "429": {
      "description": "تجاوز 60 طلباً/دقيقة — راجع Retry-After"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "سيرة واحدة مع content ودرجة ATS",
    "tags": [
     "cv",
     "cvs"
    ],
    "x-emm-app": "cv",
    "x-scope": "read"
   },
   "patch": {
    "operationId": "cv_patch_cvs_id",
    "parameters": [
     {
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "additionalProperties": true,
        "properties": {
         "accent": {
          "description": "لون التمييز: اسم من اللوحة أو #rrggbb",
          "enum": [
           "navy",
           "teal",
           "burgundy",
           "green",
           "blue",
           "slate"
          ],
          "example": "navy",
          "type": "string"
         },
         "content": {
          "description": "مستند السيرة: personal{full_name,headline,summary,city,phone,email,linkedin,website,birth_year,nationality,license}, experience[]{company,title,location,start,end,current,bullets}, education[]{degree,institution,start,end,grade}, skills[], languages[]{name,level}, certifications[]{name,issuer,year}, projects[]{name,link,desc}. في PATCH: الأقسام المذكورة فقط تُستبدل",
          "type": "object"
         },
         "lang": {
          "description": "لغة السيرة: ar (RTL) أو en (LTR)",
          "enum": [
           "ar",
           "en"
          ],
          "example": "ar",
          "type": "string"
         },
         "replace_content": {
          "description": "true = استبدال المستند كاملاً بـ content",
          "example": false,
          "type": "boolean"
         },
         "template": {
          "description": "القالب — قالبان مجاناً والستة في Pro وخبير",
          "enum": [
           "classic",
           "modern",
           "executive",
           "minimal",
           "twocol",
           "compact"
          ],
          "example": "classic",
          "type": "string"
         },
         "title": {
          "description": "اسم تعريفي للسيرة (≤80 حرفاً)",
          "example": "سيرة أحمد",
          "type": "string"
         }
        },
        "required": [],
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "data": {
           "description": "سيرة (نفس مخرجات /api/v1/cvs/{id})",
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "type": "object"
        }
       }
      },
      "description": "نجاح — {\"ok\":true, \"data\":…}"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية (write) أو الخطة لا تشمل الميزة (plan_required)"
     },
     "429": {
      "description": "تجاوز 60 طلباً/دقيقة — راجع Retry-After"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "تعديل سيرة (PUT مقبول أيضاً): الحقول الغائبة تبقى؛ content يستبدل الأقسام المذكورة فقط إلا مع replace_content=true",
    "tags": [
     "cv",
     "cvs"
    ],
    "x-emm-app": "cv",
    "x-scope": "write"
   },
   "put": {
    "operationId": "cv_patch_cvs_id",
    "parameters": [
     {
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "additionalProperties": true,
        "properties": {
         "accent": {
          "description": "لون التمييز: اسم من اللوحة أو #rrggbb",
          "enum": [
           "navy",
           "teal",
           "burgundy",
           "green",
           "blue",
           "slate"
          ],
          "example": "navy",
          "type": "string"
         },
         "content": {
          "description": "مستند السيرة: personal{full_name,headline,summary,city,phone,email,linkedin,website,birth_year,nationality,license}, experience[]{company,title,location,start,end,current,bullets}, education[]{degree,institution,start,end,grade}, skills[], languages[]{name,level}, certifications[]{name,issuer,year}, projects[]{name,link,desc}. في PATCH: الأقسام المذكورة فقط تُستبدل",
          "type": "object"
         },
         "lang": {
          "description": "لغة السيرة: ar (RTL) أو en (LTR)",
          "enum": [
           "ar",
           "en"
          ],
          "example": "ar",
          "type": "string"
         },
         "replace_content": {
          "description": "true = استبدال المستند كاملاً بـ content",
          "example": false,
          "type": "boolean"
         },
         "template": {
          "description": "القالب — قالبان مجاناً والستة في Pro وخبير",
          "enum": [
           "classic",
           "modern",
           "executive",
           "minimal",
           "twocol",
           "compact"
          ],
          "example": "classic",
          "type": "string"
         },
         "title": {
          "description": "اسم تعريفي للسيرة (≤80 حرفاً)",
          "example": "سيرة أحمد",
          "type": "string"
         }
        },
        "required": [],
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "data": {
           "description": "سيرة (نفس مخرجات /api/v1/cvs/{id})",
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "type": "object"
        }
       }
      },
      "description": "نجاح — {\"ok\":true, \"data\":…}"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية (write) أو الخطة لا تشمل الميزة (plan_required)"
     },
     "429": {
      "description": "تجاوز 60 طلباً/دقيقة — راجع Retry-After"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "تعديل سيرة (PUT مقبول أيضاً): الحقول الغائبة تبقى؛ content يستبدل الأقسام المذكورة فقط إلا مع replace_content=true",
    "tags": [
     "cv",
     "cvs"
    ],
    "x-emm-app": "cv",
    "x-scope": "write"
   },
   "servers": [
    {
     "description": "cv",
     "url": "https://cv.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "cv"
  },
  "/cv/cvs/{id}/ats": {
   "get": {
    "operationId": "cv_get_cvs_id_ats",
    "parameters": [
     {
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "data": {
           "description": "سيرة (نفس مخرجات /api/v1/cvs/{id})",
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "type": "object"
        }
       }
      },
      "description": "نجاح — {\"ok\":true, \"data\":…}"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية (read) أو الخطة لا تشمل الميزة (plan_required)"
     },
     "429": {
      "description": "تجاوز 60 طلباً/دقيقة — راجع Retry-After"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "فحص ATS لسيرة محفوظة: درجة من 100 + الفحوص + النصائح",
    "tags": [
     "cv",
     "ats"
    ],
    "x-emm-app": "cv",
    "x-scope": "read"
   },
   "servers": [
    {
     "description": "cv",
     "url": "https://cv.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "cv"
  },
  "/cv/cvs/{id}/cover-letter": {
   "post": {
    "operationId": "cv_post_cvs_id_cover-letter",
    "parameters": [
     {
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "additionalProperties": true,
        "properties": {
         "accent": {
          "description": "لون التمييز (افتراضي لون السيرة)",
          "enum": [
           "navy",
           "teal",
           "burgundy",
           "green",
           "blue",
           "slate"
          ],
          "example": "navy",
          "type": "string"
         },
         "body": {
          "description": "نص الخطاب (فقرات يفصلها سطر فارغ) — اتركه فارغاً ليُولَّد من السيرة",
          "example": "",
          "type": "string"
         },
         "company": {
          "description": "الشركة أو الجهة (مطلوب)",
          "example": "شركة التقنية",
          "type": "string"
         },
         "job_title": {
          "description": "المسمى الوظيفي (مطلوب)",
          "example": "مهندس برمجيات أول",
          "type": "string"
         },
         "lang": {
          "description": "لغة الخطاب (افتراضي لغة السيرة)",
          "enum": [
           "ar",
           "en"
          ],
          "example": "ar",
          "type": "string"
         },
         "recipient": {
          "description": "اسم مسؤول التوظيف (اختياري — وإلا «قسم الموارد البشرية»)",
          "example": "أ. سارة العتيبي",
          "type": "string"
         }
        },
        "required": [
         "company",
         "job_title"
        ],
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "201": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "data": {
           "description": "سيرة (نفس مخرجات /api/v1/cvs/{id})",
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "type": "object"
        }
       }
      },
      "description": "نجاح — {\"ok\":true, \"data\":…}"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية (write) أو الخطة لا تشمل الميزة (plan_required)"
     },
     "429": {
      "description": "تجاوز 60 طلباً/دقيقة — راجع Retry-After"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "توليد خطاب تقديم من السيرة (Pro وخبير) — 403 plan_required في المجانية",
    "tags": [
     "cv",
     "cover letters"
    ],
    "x-emm-app": "cv",
    "x-scope": "write"
   },
   "servers": [
    {
     "description": "cv",
     "url": "https://cv.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "cv"
  },
  "/cv/cvs/{id}/duplicate": {
   "post": {
    "operationId": "cv_post_cvs_id_duplicate",
    "parameters": [
     {
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "additionalProperties": true,
        "properties": {
         "lang": {
          "description": "لغة النسخة (افتراضي اللغة الأخرى)",
          "enum": [
           "ar",
           "en"
          ],
          "type": "string"
         },
         "title": {
          "description": "اسم النسخة",
          "type": "string"
         }
        },
        "required": [],
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "201": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "data": {
           "description": "سيرة (نفس مخرجات /api/v1/cvs/{id})",
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "type": "object"
        }
       }
      },
      "description": "نجاح — {\"ok\":true, \"data\":…}"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية (write) أو الخطة لا تشمل الميزة (plan_required)"
     },
     "429": {
      "description": "تجاوز 60 طلباً/دقيقة — راجع Retry-After"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "نسخة باللغة الأخرى (Pro وخبير → 403 plan_required في المجانية)؛ ?lang= لتحديد اللغة",
    "tags": [
     "cv",
     "cvs"
    ],
    "x-emm-app": "cv",
    "x-scope": "write"
   },
   "servers": [
    {
     "description": "cv",
     "url": "https://cv.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "cv"
  },
  "/cv/cvs/{id}/render/{format}": {
   "get": {
    "operationId": "cv_get_cvs_id_render_format",
    "parameters": [
     {
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     },
     {
      "in": "path",
      "name": "format",
      "required": true,
      "schema": {
       "enum": [
        "pdf",
        "png",
        "txt"
       ],
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/pdf": {
        "schema": {
         "format": "binary",
         "type": "string"
        }
       }
      },
      "description": "application/pdf"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "تحميل السيرة — pdf (A4) أو png (الصفحة الأولى) أو txt (LinkedIn). ثنائية/نصية خارج المغلّف",
    "tags": [
     "cv",
     "cvs"
    ],
    "x-emm-app": "cv",
    "x-scope": "read"
   },
   "servers": [
    {
     "description": "cv",
     "url": "https://cv.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "cv"
  },
  "/cv/me": {
   "get": {
    "operationId": "cv_get_me",
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "data": {
           "description": "سيرة (نفس مخرجات /api/v1/cvs/{id})",
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "type": "object"
        }
       }
      },
      "description": "نجاح — {\"ok\":true, \"data\":…}"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية (read) أو الخطة لا تشمل الميزة (plan_required)"
     },
     "429": {
      "description": "تجاوز 60 طلباً/دقيقة — راجع Retry-After"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "المستخدم والخطة والحصص — اختبار مفتاحك",
    "tags": [
     "cv",
     "account"
    ],
    "x-emm-app": "cv",
    "x-scope": "read"
   },
   "servers": [
    {
     "description": "cv",
     "url": "https://cv.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "cv"
  },
  "/cv/plan": {
   "get": {
    "operationId": "cv_get_plan",
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "data": {
           "description": "سيرة (نفس مخرجات /api/v1/cvs/{id})",
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "type": "object"
        }
       }
      },
      "description": "نجاح — {\"ok\":true, \"data\":…}"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية (read) أو الخطة لا تشمل الميزة (plan_required)"
     },
     "429": {
      "description": "تجاوز 60 طلباً/دقيقة — راجع Retry-After"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "كل الخطط والحدود والقوالب والألوان والخطة الحالية",
    "tags": [
     "cv",
     "account"
    ],
    "x-emm-app": "cv",
    "x-scope": "read"
   },
   "servers": [
    {
     "description": "cv",
     "url": "https://cv.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "cv"
  },
  "/event/api/v1/events": {
   "get": {
    "description": "قائمة فعالياتك (الأحدث أولاً) مع إحصاءات مباعة/محجوزة/دخل/إيراد وروابطها العامة. فلتر status اختياري.",
    "parameters": [
     {
      "description": "عدد النتائج (1–200، افتراضي 50)",
      "in": "query",
      "name": "limit",
      "schema": {
       "default": 50,
       "maximum": 200,
       "minimum": 1,
       "type": "integer"
      }
     },
     {
      "description": "تخطي النتائج / offset",
      "in": "query",
      "name": "offset",
      "schema": {
       "default": 0,
       "minimum": 0,
       "type": "integer"
      }
     },
     {
      "description": "draft | published | cancelled",
      "in": "query",
      "name": "status",
      "schema": {
       "enum": [
        "draft",
        "published",
        "cancelled"
       ],
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى / missing, invalid or revoked key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "404": {
      "description": "غير موجود أو لا يخص المنظّم / not found (organizer-scoped)"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "فعاليات المنظّم",
    "tags": [
     "event",
     "الفعاليات / Events"
    ],
    "x-emm-app": "event"
   },
   "post": {
    "description": "عنوان ومكان وتاريخ ميلادي بتوقيت الرياض وسعة → مسودة. أضف أنواع تذاكر ثم انشرها. الخطة المجانية: فعالية واحدة حتى 50 تذكرة.",
    "requestBody": {
     "content": {
      "application/json": {
       "example": {
        "capacity": 100,
        "description": "ورشة عملية",
        "refund_note": "",
        "starts_at": "2026-12-20T18:00",
        "title": "ورشة الذكاء الاصطناعي",
        "venue": "الرياض — قاعة الملك فهد"
       },
       "schema": {
        "properties": {
         "capacity": {
          "description": "السعة 1–100000 (الخطة المجانية ≤ 50) / capacity",
          "type": "number"
         },
         "description": {
          "description": "الوصف (نص عادي، أسطر جديدة مسموحة) / plain-text description",
          "type": "string"
         },
         "refund_note": {
          "description": "سياسة استرجاع خاصة بالفعالية تظهر للمشتري (اختياري) / event-specific refund note",
          "type": "string"
         },
         "starts_at": {
          "description": "بداية الفعالية: YYYY-MM-DDTHH:MM بتوقيت الرياض أو ISO-8601 مع +03:00، في المستقبل / start (Riyadh local), must be in the future",
          "type": "string"
         },
         "title": {
          "description": "عنوان الفعالية (2–120 حرفاً) / event title",
          "type": "string"
         },
         "venue": {
          "description": "المكان / venue",
          "type": "string"
         }
        },
        "required": [
         "title",
         "description",
         "venue",
         "starts_at",
         "capacity",
         "refund_note"
        ],
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "201": {
      "description": "أُنشئ / created"
     },
     "400": {
      "description": "JSON غير صالح / invalid JSON"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى / missing, invalid or revoked key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "404": {
      "description": "غير موجود أو لا يخص المنظّم / not found (organizer-scoped)"
     },
     "409": {
      "description": "تعارض / conflict (plan_limit, no_ticket_types, capacity_below_sold, in_use, invalid_state, already_requested, not_published)"
     },
     "422": {
      "description": "تحقق / validation error"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "إنشاء فعالية (مسودة)",
    "tags": [
     "event",
     "الفعاليات / Events"
    ],
    "x-emm-app": "event"
   },
   "servers": [
    {
     "description": "event",
     "url": "https://event.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "event"
  },
  "/event/api/v1/events/{event_id}": {
   "get": {
    "description": "تفاصيل الفعالية مع أنواع التذاكر والمتبقي والرابط العام ورمز صفحة تسجيل الحضور.",
    "parameters": [
     {
      "description": "معرّف الفعالية / event id",
      "in": "path",
      "name": "event_id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى / missing, invalid or revoked key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "404": {
      "description": "غير موجود أو لا يخص المنظّم / not found (organizer-scoped)"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "فعالية واحدة",
    "tags": [
     "event",
     "الفعاليات / Events"
    ],
    "x-emm-app": "event"
   },
   "patch": {
    "description": "تعديل العنوان/الوصف/المكان/التاريخ/السعة/سياسة الاسترجاع (الحقول المرسلة فقط). السعة لا تقل عن المباع.",
    "parameters": [
     {
      "description": "معرّف الفعالية / event id",
      "in": "path",
      "name": "event_id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "example": {
        "capacity": 200,
        "venue": "الرياض — مركز الملك عبدالعزيز"
       },
       "schema": {
        "properties": {
         "capacity": {
          "description": "لا تقل عن التذاكر المباعة / cannot go below tickets sold",
          "nullable": true,
          "type": "number"
         },
         "description": {
          "nullable": true,
          "type": "string"
         },
         "refund_note": {
          "nullable": true,
          "type": "string"
         },
         "starts_at": {
          "description": "YYYY-MM-DDTHH:MM أو ISO-8601 +03:00",
          "nullable": true,
          "type": "string"
         },
         "title": {
          "nullable": true,
          "type": "string"
         },
         "venue": {
          "nullable": true,
          "type": "string"
         }
        },
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "400": {
      "description": "JSON غير صالح / invalid JSON"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى / missing, invalid or revoked key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "404": {
      "description": "غير موجود أو لا يخص المنظّم / not found (organizer-scoped)"
     },
     "409": {
      "description": "تعارض / conflict (plan_limit, no_ticket_types, capacity_below_sold, in_use, invalid_state, already_requested, not_published)"
     },
     "422": {
      "description": "تحقق / validation error"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "تعديل فعالية",
    "tags": [
     "event",
     "الفعاليات / Events"
    ],
    "x-emm-app": "event"
   },
   "servers": [
    {
     "description": "event",
     "url": "https://event.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "event"
  },
  "/event/api/v1/events/{event_id}/attendees": {
   "get": {
    "description": "كل تذاكر الفعالية: الرمز، اسم المشتري، الجوال، النوع، الحالة (صادرة/تم الدخول)، وقت الدخول، مرجع الطلب.",
    "parameters": [
     {
      "description": "معرّف الفعالية / event id",
      "in": "path",
      "name": "event_id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     },
     {
      "description": "عدد النتائج (1–200، افتراضي 50)",
      "in": "query",
      "name": "limit",
      "schema": {
       "default": 50,
       "maximum": 200,
       "minimum": 1,
       "type": "integer"
      }
     },
     {
      "description": "تخطي النتائج / offset",
      "in": "query",
      "name": "offset",
      "schema": {
       "default": 0,
       "minimum": 0,
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى / missing, invalid or revoked key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "404": {
      "description": "غير موجود أو لا يخص المنظّم / not found (organizer-scoped)"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "قائمة الحضور",
    "tags": [
     "event",
     "الفعاليات / Events"
    ],
    "x-emm-app": "event"
   },
   "servers": [
    {
     "description": "event",
     "url": "https://event.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "event"
  },
  "/event/api/v1/events/{event_id}/checkin": {
   "post": {
    "description": "يرجع state: ok (أول دخول) · already (دخل سابقاً) · notfound · other (تذكرة فعالية أخرى). يقبل الرمز أو رابط التذكرة أو حمولة QR.",
    "parameters": [
     {
      "description": "معرّف الفعالية / event id",
      "in": "path",
      "name": "event_id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "example": {
        "code": "TK-7K3M9Q2A"
       },
       "schema": {
        "properties": {
         "code": {
          "description": "رمز التذكرة TK-XXXXXXXX أو رابط /t/… أو حمولة QR / ticket code",
          "type": "string"
         }
        },
        "required": [
         "code"
        ],
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "201": {
      "description": "أُنشئ / created"
     },
     "400": {
      "description": "JSON غير صالح / invalid JSON"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى / missing, invalid or revoked key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "404": {
      "description": "غير موجود أو لا يخص المنظّم / not found (organizer-scoped)"
     },
     "409": {
      "description": "تعارض / conflict (plan_limit, no_ticket_types, capacity_below_sold, in_use, invalid_state, already_requested, not_published)"
     },
     "422": {
      "description": "تحقق / validation error"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "تسجيل حضور برمز التذكرة",
    "tags": [
     "event",
     "الفعاليات / Events"
    ],
    "x-emm-app": "event"
   },
   "servers": [
    {
     "description": "event",
     "url": "https://event.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "event"
  },
  "/event/api/v1/events/{event_id}/publish": {
   "post": {
    "description": "نشر المسودة → تصبح صفحتها العامة /e/{slug} متاحة للبيع. يشترط نوع تذكرة واحداً على الأقل.",
    "parameters": [
     {
      "description": "معرّف الفعالية / event id",
      "in": "path",
      "name": "event_id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "201": {
      "description": "أُنشئ / created"
     },
     "400": {
      "description": "JSON غير صالح / invalid JSON"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى / missing, invalid or revoked key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "404": {
      "description": "غير موجود أو لا يخص المنظّم / not found (organizer-scoped)"
     },
     "409": {
      "description": "تعارض / conflict (plan_limit, no_ticket_types, capacity_below_sold, in_use, invalid_state, already_requested, not_published)"
     },
     "422": {
      "description": "تحقق / validation error"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "نشر فعالية",
    "tags": [
     "event",
     "الفعاليات / Events"
    ],
    "x-emm-app": "event"
   },
   "servers": [
    {
     "description": "event",
     "url": "https://event.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "event"
  },
  "/event/api/v1/events/{event_id}/settlement.csv": {
   "get": {
    "description": "نفس زر «تقرير التسوية CSV» في اللوحة: إجمالي، رسوم بوابة تقديرية، رسوم منصة، صافي المنظّم لكل طلب مدفوع (text/csv بترميز UTF-8 مع BOM).",
    "parameters": [
     {
      "description": "معرّف الفعالية / event id",
      "in": "path",
      "name": "event_id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "text/csv": {
        "example": "المرجع,تاريخ الدفع,…",
        "schema": {
         "type": "string"
        }
       }
      },
      "description": "تقرير CSV / settlement CSV"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى / missing, invalid or revoked key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "404": {
      "description": "غير موجود أو لا يخص المنظّم / not found (organizer-scoped)"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "تقرير التسوية CSV",
    "tags": [
     "event",
     "الفعاليات / Events"
    ],
    "x-emm-app": "event"
   },
   "servers": [
    {
     "description": "event",
     "url": "https://event.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "event"
  },
  "/event/api/v1/events/{event_id}/ticket-types": {
   "get": {
    "description": "الأنواع مع السعر والحصة والمباع والمحجوز والمتبقي ونوافذ البيع.",
    "parameters": [
     {
      "description": "معرّف الفعالية / event id",
      "in": "path",
      "name": "event_id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى / missing, invalid or revoked key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "404": {
      "description": "غير موجود أو لا يخص المنظّم / not found (organizer-scoped)"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "أنواع تذاكر فعالية",
    "tags": [
     "event",
     "الفعاليات / Events"
    ],
    "x-emm-app": "event"
   },
   "post": {
    "description": "اسم + سعر بالريال (0 = مجاني) + حصة اختيارية + نافذة بيع اختيارية. التذاكر المدفوعة تتطلب الخطة القياسية أو الاحترافية؛ أقل سعر 1 ر.س.",
    "parameters": [
     {
      "description": "معرّف الفعالية / event id",
      "in": "path",
      "name": "event_id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "example": {
        "name": "مبكرة",
        "price": "80.00",
        "quota": 50,
        "sales_end": "",
        "sales_start": ""
       },
       "schema": {
        "properties": {
         "name": {
          "description": "اسم النوع (مبكرة/عادية/VIP) / type name",
          "type": "string"
         },
         "price": {
          "description": "السعر بالريال (نص أو رقم، 0 = مجاني؛ أقل سعر مدفوع 1.00) / price in SAR",
          "oneOf": [
           {
            "type": "number"
           },
           {
            "type": "string"
           }
          ]
         },
         "quota": {
          "description": "عدد التذاكر المتاحة (0 = غير محدود ضمن سعة الفعالية) / quota, 0 = unlimited",
          "type": "number"
         },
         "sales_end": {
          "description": "نهاية البيع (اختياري) / sales window end",
          "type": "string"
         },
         "sales_start": {
          "description": "بداية البيع YYYY-MM-DDTHH:MM (اختياري) / sales window start",
          "type": "string"
         }
        },
        "required": [
         "name",
         "price",
         "quota",
         "sales_start",
         "sales_end"
        ],
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "201": {
      "description": "أُنشئ / created"
     },
     "400": {
      "description": "JSON غير صالح / invalid JSON"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى / missing, invalid or revoked key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "404": {
      "description": "غير موجود أو لا يخص المنظّم / not found (organizer-scoped)"
     },
     "409": {
      "description": "تعارض / conflict (plan_limit, no_ticket_types, capacity_below_sold, in_use, invalid_state, already_requested, not_published)"
     },
     "422": {
      "description": "تحقق / validation error"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "إضافة نوع تذكرة",
    "tags": [
     "event",
     "الفعاليات / Events"
    ],
    "x-emm-app": "event"
   },
   "servers": [
    {
     "description": "event",
     "url": "https://event.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "event"
  },
  "/event/api/v1/events/{event_id}/unpublish": {
   "post": {
    "description": "إخفاء الصفحة العامة (التذاكر الصادرة تبقى صالحة).",
    "parameters": [
     {
      "description": "معرّف الفعالية / event id",
      "in": "path",
      "name": "event_id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "201": {
      "description": "أُنشئ / created"
     },
     "400": {
      "description": "JSON غير صالح / invalid JSON"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى / missing, invalid or revoked key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "404": {
      "description": "غير موجود أو لا يخص المنظّم / not found (organizer-scoped)"
     },
     "409": {
      "description": "تعارض / conflict (plan_limit, no_ticket_types, capacity_below_sold, in_use, invalid_state, already_requested, not_published)"
     },
     "422": {
      "description": "تحقق / validation error"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "إرجاع فعالية إلى مسودة",
    "tags": [
     "event",
     "الفعاليات / Events"
    ],
    "x-emm-app": "event"
   },
   "servers": [
    {
     "description": "event",
     "url": "https://event.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "event"
  },
  "/event/api/v1/me": {
   "get": {
    "description": "اختبر مفتاحك: المستخدم، الخطة الحالية، الحصص، كتالوج الخطط.",
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى / missing, invalid or revoked key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "404": {
      "description": "غير موجود أو لا يخص المنظّم / not found (organizer-scoped)"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "هوية المفتاح والمستخدم والخطة",
    "tags": [
     "event",
     "الحساب / Account"
    ],
    "x-emm-app": "event"
   },
   "servers": [
    {
     "description": "event",
     "url": "https://event.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "event"
  },
  "/event/api/v1/orders": {
   "get": {
    "description": "طلبات كل فعالياتك (الأحدث أولاً) أو فعالية واحدة عبر event_id، مع فلتر status. الطلبات تُنشأ من صفحة الشراء العامة أو أداة MCP.",
    "parameters": [
     {
      "description": "عدد النتائج (1–200، افتراضي 50)",
      "in": "query",
      "name": "limit",
      "schema": {
       "default": 50,
       "maximum": 200,
       "minimum": 1,
       "type": "integer"
      }
     },
     {
      "description": "تخطي النتائج / offset",
      "in": "query",
      "name": "offset",
      "schema": {
       "default": 0,
       "minimum": 0,
       "type": "integer"
      }
     },
     {
      "description": "قصر النتائج على فعالية / filter by event",
      "in": "query",
      "name": "event_id",
      "schema": {
       "type": "integer"
      }
     },
     {
      "description": "pending | paid | failed | refunded | cancelled",
      "in": "query",
      "name": "status",
      "schema": {
       "enum": [
        "pending",
        "paid",
        "failed",
        "refunded",
        "cancelled"
       ],
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى / missing, invalid or revoked key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "404": {
      "description": "غير موجود أو لا يخص المنظّم / not found (organizer-scoped)"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "طلبات المنظّم",
    "tags": [
     "event",
     "الطلبات / Orders"
    ],
    "x-emm-app": "event"
   },
   "servers": [
    {
     "description": "event",
     "url": "https://event.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "event"
  },
  "/event/api/v1/orders/{order_id}": {
   "get": {
    "description": "الطلب مع بنوده وتذاكره (رمز كل تذكرة وحالته) وبيانات المشتري والفعالية.",
    "parameters": [
     {
      "description": "معرّف الطلب / order id",
      "in": "path",
      "name": "order_id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى / missing, invalid or revoked key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "404": {
      "description": "غير موجود أو لا يخص المنظّم / not found (organizer-scoped)"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "طلب واحد",
    "tags": [
     "event",
     "الطلبات / Orders"
    ],
    "x-emm-app": "event"
   },
   "servers": [
    {
     "description": "event",
     "url": "https://event.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "event"
  },
  "/event/api/v1/orders/{order_id}/refund": {
   "post": {
    "description": "يسجّل طلب استرجاع للطلب (يُنفَّذ يدوياً من لوحة StreamPay — لا استرجاع تلقائي). التذاكر تبقى صالحة حتى يقرر المالك.",
    "parameters": [
     {
      "description": "معرّف الطلب / order id",
      "in": "path",
      "name": "order_id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "example": {
        "reason": "العميل لم يحضر"
       },
       "schema": {
        "properties": {
         "reason": {
          "description": "سبب الطلب / reason (shown to the owner)",
          "type": "string"
         }
        },
        "required": [
         "reason"
        ],
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "201": {
      "description": "أُنشئ / created"
     },
     "400": {
      "description": "JSON غير صالح / invalid JSON"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى / missing, invalid or revoked key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "404": {
      "description": "غير موجود أو لا يخص المنظّم / not found (organizer-scoped)"
     },
     "409": {
      "description": "تعارض / conflict (plan_limit, no_ticket_types, capacity_below_sold, in_use, invalid_state, already_requested, not_published)"
     },
     "422": {
      "description": "تحقق / validation error"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "طلب استرجاع",
    "tags": [
     "event",
     "الطلبات / Orders"
    ],
    "x-emm-app": "event"
   },
   "servers": [
    {
     "description": "event",
     "url": "https://event.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "event"
  },
  "/event/api/v1/plan": {
   "get": {
    "description": "الخطة الفعالة (مع انتهاء الاشتراك)، الرسوم، الحصص، وكل الخطط بالريال.",
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى / missing, invalid or revoked key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "404": {
      "description": "غير موجود أو لا يخص المنظّم / not found (organizer-scoped)"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "الخطة الحالية والكتالوج",
    "tags": [
     "event",
     "الحساب / Account"
    ],
    "x-emm-app": "event"
   },
   "servers": [
    {
     "description": "event",
     "url": "https://event.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "event"
  },
  "/event/api/v1/ticket-types/{type_id}": {
   "delete": {
    "description": "لا يُحذف نوع بيعت منه تذاكر (409 in_use).",
    "parameters": [
     {
      "description": "معرّف نوع التذكرة / ticket type id",
      "in": "path",
      "name": "type_id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "400": {
      "description": "JSON غير صالح / invalid JSON"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى / missing, invalid or revoked key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "404": {
      "description": "غير موجود أو لا يخص المنظّم / not found (organizer-scoped)"
     },
     "409": {
      "description": "تعارض / conflict (plan_limit, no_ticket_types, capacity_below_sold, in_use, invalid_state, already_requested, not_published)"
     },
     "422": {
      "description": "تحقق / validation error"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "حذف نوع تذكرة",
    "tags": [
     "event",
     "أنواع التذاكر / Ticket types"
    ],
    "x-emm-app": "event"
   },
   "servers": [
    {
     "description": "event",
     "url": "https://event.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "event"
  },
  "/form/api/v1/forms": {
   "get": {
    "description": "قائمة نماذجك مع عدد الردود والمعلّقة. Lists your forms with response counts.",
    "parameters": [
     {
      "description": "عدد النتائج (1–200، افتراضي 50)",
      "in": "query",
      "name": "limit",
      "schema": {
       "default": 50,
       "maximum": 200,
       "minimum": 1,
       "type": "integer"
      }
     },
     {
      "description": "تخطي النتائج",
      "in": "query",
      "name": "offset",
      "schema": {
       "default": 0,
       "type": "integer"
      }
     },
     {
      "description": "فلتر الحالة",
      "in": "query",
      "name": "status",
      "schema": {
       "enum": [
        "open",
        "closed"
       ],
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "النماذج / Forms",
    "tags": [
     "form",
     "forms"
    ],
    "x-emm-app": "form"
   },
   "post": {
    "description": "ينشئ نموذجاً (ضمن حد الخطة) مع حقول اختيارية. Creates a form within the plan limit (409 quota_exceeded), optionally with its fields.",
    "requestBody": {
     "content": {
      "application/json": {
       "example": {
        "description": "نموذج تقديم على المنحة",
        "fee": "0.00",
        "fields": [
         {
          "label": "الاسم الكامل",
          "required": true,
          "type": "short"
         },
         {
          "label": "الهوية",
          "required": true,
          "type": "national_id"
         },
         {
          "label": "جوال",
          "required": true,
          "type": "phone"
         },
         {
          "label": "الفئة",
          "options": [
           "طالب",
           "موظف"
          ],
          "type": "select"
         },
         {
          "cond_index": 3,
          "cond_value": "طالب",
          "label": "السيرة الذاتية",
          "type": "file"
         }
        ],
        "max_submissions": 200,
        "slug": "grant",
        "status": "open",
        "title": "طلب منحة"
       },
       "schema": {
        "properties": {
         "brand_color": {
          "description": "لون العلامة #RRGGBB (يتطلب خطة برو وما فوق)",
          "type": "string"
         },
         "close_at": {
          "description": "يوم الإغلاق YYYY-MM-DD (اختياري)",
          "type": "string"
         },
         "confirmation_msg": {
          "description": "رسالة التأكيد بعد التقديم",
          "type": "string"
         },
         "description": {
          "description": "وصف يظهر أعلى النموذج",
          "type": "string"
         },
         "fee": {
          "description": "رسم التقديم بالريال نص بمنزلتين؛ \"0.00\" بلا رسم (يتطلب خطة برو وما فوق)",
          "example": "50.00",
          "type": "string"
         },
         "fields": {
          "description": "الحقول: عند الإنشاء تُضاف كلها؛ عند التعديل عنصر بـ id يعدّل وبلا id يُضاف",
          "items": {
           "properties": {
            "cond_clear": {
             "description": "احذف شرط الظهور (تعديل حقل)",
             "type": "boolean"
            },
            "cond_field_id": {
             "description": "معرّف حقل موجود: يظهر هذا الحقل فقط عندما يساوي جوابه cond_value",
             "type": "number"
            },
            "cond_index": {
             "description": "بديل داخل مصفوفة fields: ترتيب (0-based) للحقل الشرطي",
             "type": "number"
            },
            "cond_value": {
             "description": "قيمة الشرط",
             "type": "string"
            },
            "help": {
             "description": "نص مساعدة تحت الحقل",
             "type": "string"
            },
            "id": {
             "description": "معرّف حقل موجود (للتعديل)",
             "type": "number"
            },
            "label": {
             "description": "عنوان الحقل (حتى 120 حرفاً)",
             "example": "الاسم الكامل",
             "type": "string"
            },
            "options": {
             "description": "خيارات select/radio/checkbox",
             "items": {
              "type": "string"
             },
             "type": "array"
            },
            "required": {
             "description": "إلزامي",
             "example": "true",
             "type": "boolean"
            },
            "type": {
             "description": "short|long|number|date|select|radio|checkbox|file|national_id|phone|email",
             "example": "short",
             "type": "string"
            }
           },
           "required": [
            "type",
            "label"
           ],
           "type": "object"
          },
          "type": "array"
         },
         "max_submissions": {
          "description": "الحد الأقصى للطلبات المقبولة (0 = غير محدود)",
          "type": "number"
         },
         "open_at": {
          "description": "يوم الفتح YYYY-MM-DD (اختياري)",
          "type": "string"
         },
         "slug": {
          "description": "رابط: أحرف إنجليزية صغيرة وأرقام وشرطات (3–60) — يُولَّد تلقائياً إن تُرك",
          "type": "string"
         },
         "status": {
          "description": "open | closed",
          "example": "open",
          "type": "string"
         },
         "title": {
          "description": "عنوان النموذج (1–200)",
          "type": "string"
         }
        },
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "close_at": "",
          "currency": "SAR",
          "fee": "0.00",
          "fields": [
           {
            "id": 7,
            "label": "الاسم الكامل",
            "options": [],
            "required": true,
            "type": "short"
           }
          ],
          "id": 3,
          "max_submissions": 200,
          "open_at": "",
          "pending_count": 2,
          "public_url": "https://form.emm.sa/f/grant",
          "slug": "grant",
          "status": "open",
          "submissions_count": 12,
          "title": "طلب منحة"
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "201": {
      "description": "أُنشئ / created"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "409": {
      "description": "تعارض / conflict (quota_exceeded, slug_taken, not_submitted, plan_required)"
     },
     "422": {
      "description": "تحقق / validation error"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "إنشاء نموذج / Create form",
    "tags": [
     "form",
     "forms"
    ],
    "x-emm-app": "form"
   },
   "servers": [
    {
     "description": "form",
     "url": "https://form.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "form"
  },
  "/form/api/v1/forms/{id}": {
   "get": {
    "description": "نموذج واحد بحقوله. One form with its fields.",
    "parameters": [
     {
      "description": "معرّف رقمي",
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "close_at": "",
          "currency": "SAR",
          "fee": "0.00",
          "fields": [
           {
            "id": 7,
            "label": "الاسم الكامل",
            "options": [],
            "required": true,
            "type": "short"
           }
          ],
          "id": 3,
          "max_submissions": 200,
          "open_at": "",
          "pending_count": 2,
          "public_url": "https://form.emm.sa/f/grant",
          "slug": "grant",
          "status": "open",
          "submissions_count": 12,
          "title": "طلب منحة"
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "نموذج / Form",
    "tags": [
     "form",
     "forms"
    ],
    "x-emm-app": "form"
   },
   "patch": {
    "description": "تعديل جزئي (العنوان، الرابط، الرسم، التواريخ، الحد الأقصى، الحالة، اللون). fields عند إرسالها: عنصر بـ id يعدّل الحقل، وبلا id يضيفه (لا يحذف شيئاً). Partial update; fields sync (update by id, create without id).",
    "parameters": [
     {
      "description": "معرّف رقمي",
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "example": {
        "close_at": "2027-01-31",
        "fee": "50.00",
        "title": "طلب منحة 2027"
       },
       "schema": {
        "properties": {
         "brand_color": {
          "description": "لون العلامة #RRGGBB (يتطلب خطة برو وما فوق)",
          "type": "string"
         },
         "close_at": {
          "description": "يوم الإغلاق YYYY-MM-DD (اختياري)",
          "type": "string"
         },
         "confirmation_msg": {
          "description": "رسالة التأكيد بعد التقديم",
          "type": "string"
         },
         "description": {
          "description": "وصف يظهر أعلى النموذج",
          "type": "string"
         },
         "fee": {
          "description": "رسم التقديم بالريال نص بمنزلتين؛ \"0.00\" بلا رسم (يتطلب خطة برو وما فوق)",
          "example": "50.00",
          "type": "string"
         },
         "fields": {
          "description": "الحقول: عند الإنشاء تُضاف كلها؛ عند التعديل عنصر بـ id يعدّل وبلا id يُضاف",
          "items": {
           "properties": {
            "cond_clear": {
             "description": "احذف شرط الظهور (تعديل حقل)",
             "type": "boolean"
            },
            "cond_field_id": {
             "description": "معرّف حقل موجود: يظهر هذا الحقل فقط عندما يساوي جوابه cond_value",
             "type": "number"
            },
            "cond_index": {
             "description": "بديل داخل مصفوفة fields: ترتيب (0-based) للحقل الشرطي",
             "type": "number"
            },
            "cond_value": {
             "description": "قيمة الشرط",
             "type": "string"
            },
            "help": {
             "description": "نص مساعدة تحت الحقل",
             "type": "string"
            },
            "id": {
             "description": "معرّف حقل موجود (للتعديل)",
             "type": "number"
            },
            "label": {
             "description": "عنوان الحقل (حتى 120 حرفاً)",
             "example": "الاسم الكامل",
             "type": "string"
            },
            "options": {
             "description": "خيارات select/radio/checkbox",
             "items": {
              "type": "string"
             },
             "type": "array"
            },
            "required": {
             "description": "إلزامي",
             "example": "true",
             "type": "boolean"
            },
            "type": {
             "description": "short|long|number|date|select|radio|checkbox|file|national_id|phone|email",
             "example": "short",
             "type": "string"
            }
           },
           "required": [
            "type",
            "label"
           ],
           "type": "object"
          },
          "type": "array"
         },
         "max_submissions": {
          "description": "الحد الأقصى للطلبات المقبولة (0 = غير محدود)",
          "type": "number"
         },
         "open_at": {
          "description": "يوم الفتح YYYY-MM-DD (اختياري)",
          "type": "string"
         },
         "slug": {
          "description": "رابط: أحرف إنجليزية صغيرة وأرقام وشرطات (3–60) — يُولَّد تلقائياً إن تُرك",
          "type": "string"
         },
         "status": {
          "description": "open | closed",
          "example": "open",
          "type": "string"
         },
         "title": {
          "description": "عنوان النموذج (1–200)",
          "type": "string"
         }
        },
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "close_at": "",
          "currency": "SAR",
          "fee": "0.00",
          "fields": [
           {
            "id": 7,
            "label": "الاسم الكامل",
            "options": [],
            "required": true,
            "type": "short"
           }
          ],
          "id": 3,
          "max_submissions": 200,
          "open_at": "",
          "pending_count": 2,
          "public_url": "https://form.emm.sa/f/grant",
          "slug": "grant",
          "status": "open",
          "submissions_count": 12,
          "title": "طلب منحة"
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "409": {
      "description": "تعارض / conflict (quota_exceeded, slug_taken, not_submitted, plan_required)"
     },
     "422": {
      "description": "تحقق / validation error"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "تعديل نموذج / Update form",
    "tags": [
     "form",
     "forms"
    ],
    "x-emm-app": "form"
   },
   "servers": [
    {
     "description": "form",
     "url": "https://form.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "form"
  },
  "/form/api/v1/forms/{id}/close": {
   "post": {
    "description": "يغلق النموذج فوراً. Closes the form immediately.",
    "parameters": [
     {
      "description": "معرّف رقمي",
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "close_at": "",
          "currency": "SAR",
          "fee": "0.00",
          "fields": [
           {
            "id": 7,
            "label": "الاسم الكامل",
            "options": [],
            "required": true,
            "type": "short"
           }
          ],
          "id": 3,
          "max_submissions": 200,
          "open_at": "",
          "pending_count": 2,
          "public_url": "https://form.emm.sa/f/grant",
          "slug": "grant",
          "status": "open",
          "submissions_count": 12,
          "title": "طلب منحة"
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "201": {
      "description": "أُنشئ / created"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "409": {
      "description": "تعارض / conflict (quota_exceeded, slug_taken, not_submitted, plan_required)"
     },
     "422": {
      "description": "تحقق / validation error"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "إغلاق النموذج / Close form",
    "tags": [
     "form",
     "forms"
    ],
    "x-emm-app": "form"
   },
   "servers": [
    {
     "description": "form",
     "url": "https://form.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "form"
  },
  "/form/api/v1/forms/{id}/duplicate": {
   "post": {
    "description": "ينسخ النموذج بحقوله إلى نموذج جديد مفتوح. Copies the form with its fields (409 quota_exceeded on the free plan).",
    "parameters": [
     {
      "description": "معرّف رقمي",
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "close_at": "",
          "currency": "SAR",
          "fee": "0.00",
          "fields": [
           {
            "id": 7,
            "label": "الاسم الكامل",
            "options": [],
            "required": true,
            "type": "short"
           }
          ],
          "id": 3,
          "max_submissions": 200,
          "open_at": "",
          "pending_count": 2,
          "public_url": "https://form.emm.sa/f/grant",
          "slug": "grant",
          "status": "open",
          "submissions_count": 12,
          "title": "طلب منحة"
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "201": {
      "description": "أُنشئ / created"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "409": {
      "description": "تعارض / conflict (quota_exceeded, slug_taken, not_submitted, plan_required)"
     },
     "422": {
      "description": "تحقق / validation error"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "تكرار النموذج / Duplicate form",
    "tags": [
     "form",
     "forms"
    ],
    "x-emm-app": "form"
   },
   "servers": [
    {
     "description": "form",
     "url": "https://form.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "form"
  },
  "/form/api/v1/forms/{id}/fields": {
   "post": {
    "description": "يضيف حقلآ في نهاية النموذج بنفس تحقق المنشئ. Appends a field (same validation as the builder).",
    "parameters": [
     {
      "description": "معرّف رقمي",
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "example": {
        "label": "الاسم الكامل",
        "required": true,
        "type": "short"
       },
       "schema": {
        "properties": {
         "cond_clear": {
          "description": "احذف شرط الظهور (تعديل حقل)",
          "type": "boolean"
         },
         "cond_field_id": {
          "description": "معرّف حقل موجود: يظهر هذا الحقل فقط عندما يساوي جوابه cond_value",
          "type": "number"
         },
         "cond_index": {
          "description": "بديل داخل مصفوفة fields: ترتيب (0-based) للحقل الشرطي",
          "type": "number"
         },
         "cond_value": {
          "description": "قيمة الشرط",
          "type": "string"
         },
         "help": {
          "description": "نص مساعدة تحت الحقل",
          "type": "string"
         },
         "id": {
          "description": "معرّف حقل موجود (للتعديل)",
          "type": "number"
         },
         "label": {
          "description": "عنوان الحقل (حتى 120 حرفاً)",
          "example": "الاسم الكامل",
          "type": "string"
         },
         "options": {
          "description": "خيارات select/radio/checkbox",
          "items": {
           "type": "string"
          },
          "type": "array"
         },
         "required": {
          "description": "إلزامي",
          "example": "true",
          "type": "boolean"
         },
         "type": {
          "description": "short|long|number|date|select|radio|checkbox|file|national_id|phone|email",
          "example": "short",
          "type": "string"
         }
        },
        "required": [
         "type",
         "label"
        ],
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "conditional": null,
          "help": "",
          "id": 7,
          "label": "الاسم الكامل",
          "options": [],
          "position": 0,
          "required": true,
          "type": "short"
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "201": {
      "description": "أُنشئ / created"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "409": {
      "description": "تعارض / conflict (quota_exceeded, slug_taken, not_submitted, plan_required)"
     },
     "422": {
      "description": "تحقق / validation error"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "إضافة حقل / Add field",
    "tags": [
     "form",
     "forms"
    ],
    "x-emm-app": "form"
   },
   "servers": [
    {
     "description": "form",
     "url": "https://form.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "form"
  },
  "/form/api/v1/forms/{id}/fields/{fid}": {
   "delete": {
    "description": "يحذف الحقل (الردود السابقة تبقى محفوظة). Deletes a field; past answers stay stored.",
    "parameters": [
     {
      "description": "معرّف رقمي",
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     },
     {
      "description": "معرّف الحقل",
      "in": "path",
      "name": "fid",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "data": {
           "deleted": true
          },
          "ok": true
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "409": {
      "description": "تعارض / conflict (quota_exceeded, slug_taken, not_submitted, plan_required)"
     },
     "422": {
      "description": "تحقق / validation error"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "حذف حقل / Delete field",
    "tags": [
     "form",
     "forms"
    ],
    "x-emm-app": "form"
   },
   "patch": {
    "description": "يعدّل نوع الحقل وعنوانه وخياراته وشرطه. Updates type, label, help, required, options and condition.",
    "parameters": [
     {
      "description": "معرّف رقمي",
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     },
     {
      "description": "معرّف الحقل",
      "in": "path",
      "name": "fid",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "example": {
        "label": "الاسم الكامل",
        "required": true,
        "type": "short"
       },
       "schema": {
        "properties": {
         "cond_clear": {
          "description": "احذف شرط الظهور (تعديل حقل)",
          "type": "boolean"
         },
         "cond_field_id": {
          "description": "معرّف حقل موجود: يظهر هذا الحقل فقط عندما يساوي جوابه cond_value",
          "type": "number"
         },
         "cond_index": {
          "description": "بديل داخل مصفوفة fields: ترتيب (0-based) للحقل الشرطي",
          "type": "number"
         },
         "cond_value": {
          "description": "قيمة الشرط",
          "type": "string"
         },
         "help": {
          "description": "نص مساعدة تحت الحقل",
          "type": "string"
         },
         "id": {
          "description": "معرّف حقل موجود (للتعديل)",
          "type": "number"
         },
         "label": {
          "description": "عنوان الحقل (حتى 120 حرفاً)",
          "example": "الاسم الكامل",
          "type": "string"
         },
         "options": {
          "description": "خيارات select/radio/checkbox",
          "items": {
           "type": "string"
          },
          "type": "array"
         },
         "required": {
          "description": "إلزامي",
          "example": "true",
          "type": "boolean"
         },
         "type": {
          "description": "short|long|number|date|select|radio|checkbox|file|national_id|phone|email",
          "example": "short",
          "type": "string"
         }
        },
        "required": [
         "type",
         "label"
        ],
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "conditional": null,
          "help": "",
          "id": 7,
          "label": "الاسم الكامل",
          "options": [],
          "position": 0,
          "required": true,
          "type": "short"
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "409": {
      "description": "تعارض / conflict (quota_exceeded, slug_taken, not_submitted, plan_required)"
     },
     "422": {
      "description": "تحقق / validation error"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "تعديل حقل / Update field",
    "tags": [
     "form",
     "forms"
    ],
    "x-emm-app": "form"
   },
   "servers": [
    {
     "description": "form",
     "url": "https://form.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "form"
  },
  "/form/api/v1/forms/{id}/open": {
   "post": {
    "description": "يفتح النموذج لاستقبال الردود. Opens the form for submissions.",
    "parameters": [
     {
      "description": "معرّف رقمي",
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "close_at": "",
          "currency": "SAR",
          "fee": "0.00",
          "fields": [
           {
            "id": 7,
            "label": "الاسم الكامل",
            "options": [],
            "required": true,
            "type": "short"
           }
          ],
          "id": 3,
          "max_submissions": 200,
          "open_at": "",
          "pending_count": 2,
          "public_url": "https://form.emm.sa/f/grant",
          "slug": "grant",
          "status": "open",
          "submissions_count": 12,
          "title": "طلب منحة"
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "201": {
      "description": "أُنشئ / created"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "409": {
      "description": "تعارض / conflict (quota_exceeded, slug_taken, not_submitted, plan_required)"
     },
     "422": {
      "description": "تحقق / validation error"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "فتح النموذج / Open form",
    "tags": [
     "form",
     "forms"
    ],
    "x-emm-app": "form"
   },
   "servers": [
    {
     "description": "form",
     "url": "https://form.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "form"
  },
  "/form/api/v1/me": {
   "get": {
    "description": "يتحقق من المفتاح ويعيد المستخدم والخطة الحالية وحدود النماذج والردود الشهرية. Checks a key; returns user, current plan and quotas.",
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "plan": {
           "api": true,
           "csv_export": false,
           "currency": "SAR",
           "features": [
            "نموذج واحد",
            "100 رد شهرياً",
            "بدون رسوم",
            "11 نوع حقل مع التحقق",
            "منطق شرطي (تخطي الأسئلة)",
            "REST API وMCP وWebhooks (متاحة في كل الخطط)"
           ],
           "id": "free",
           "limits": {
            "forms": 1,
            "monthly_responses": 100
           },
           "name": "مجاني",
           "paid_applications": false,
           "period": "month",
           "price": "0.00"
          },
          "quotas": {
           "forms": {
            "limit": 1,
            "used": 0
           },
           "responses": {
            "limit": 100,
            "month": "2026-12",
            "used": 4
           }
          },
          "service": "form",
          "user": {
           "email": "user@example.com",
           "org_name": "جهة"
          }
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "الهوية والخطة والحدود / Identity, plan, quotas",
    "tags": [
     "form",
     "me"
    ],
    "x-emm-app": "form"
   },
   "servers": [
    {
     "description": "form",
     "url": "https://form.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "form"
  },
  "/form/api/v1/plan": {
   "get": {
    "description": "الخطة الحالية مع الاستهلاك، وكل الخطط بأسعارها وحدودها. Current plan with usage plus every plan (SAR/month).",
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "الخطة الحالية وكل الخطط / Current plan and catalogue",
    "tags": [
     "form",
     "plan"
    ],
    "x-emm-app": "form"
   },
   "servers": [
    {
     "description": "form",
     "url": "https://form.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "form"
  },
  "/form/api/v1/public-forms/{slug}": {
   "get": {
    "description": "ما يراه المتقدّم في /f/{slug}: الحقول العامة والرسم وهل يستقبل ردوداً الآن. What the applicant sees on /f/{slug}.",
    "parameters": [
     {
      "description": "رابط النموذج",
      "in": "path",
      "name": "slug",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "accepts_submissions": true,
          "currency": "SAR",
          "description": "",
          "fee": "0.00",
          "fields": [
           {
            "id": 7,
            "label": "الاسم الكامل",
            "required": true,
            "type": "short"
           }
          ],
          "org_name": "جهة",
          "public_url": "https://form.emm.sa/f/grant",
          "slug": "grant",
          "status": "open",
          "title": "طلب منحة"
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "النموذج العام / Public form",
    "tags": [
     "form",
     "public-forms"
    ],
    "x-emm-app": "form"
   },
   "servers": [
    {
     "description": "form",
     "url": "https://form.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "form"
  },
  "/form/api/v1/submissions": {
   "get": {
    "description": "ردودك مع فلاتر form_id وpayment (paid|pending|none) وreview وq (بحث). Submissions with form/payment/review filters and free-text search.",
    "parameters": [
     {
      "description": "فلتر/معرّف النموذج",
      "in": "query",
      "name": "form_id",
      "schema": {
       "type": "integer"
      }
     },
     {
      "description": "فلتر الدفع",
      "in": "query",
      "name": "payment",
      "schema": {
       "enum": [
        "paid",
        "pending",
        "none"
       ],
       "type": "string"
      }
     },
     {
      "description": "فلتر المراجعة",
      "in": "query",
      "name": "review",
      "schema": {
       "enum": [
        "under_review",
        "accepted",
        "rejected"
       ],
       "type": "string"
      }
     },
     {
      "description": "بحث في رقم المرجع أو الإجابات",
      "in": "query",
      "name": "q",
      "schema": {
       "type": "string"
      }
     },
     {
      "description": "عدد النتائج (1–200، افتراضي 50)",
      "in": "query",
      "name": "limit",
      "schema": {
       "default": 50,
       "maximum": 200,
       "minimum": 1,
       "type": "integer"
      }
     },
     {
      "description": "تخطي النتائج",
      "in": "query",
      "name": "offset",
      "schema": {
       "default": 0,
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "الردود / Submissions",
    "tags": [
     "form",
     "submissions"
    ],
    "x-emm-app": "form"
   },
   "servers": [
    {
     "description": "form",
     "url": "https://form.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "form"
  },
  "/form/api/v1/submissions.csv": {
   "get": {
    "description": "نفس فلاتر القوائم؛ يتطلب خطة مؤسسة (403). Same filters as the list; org plan only (403).",
    "parameters": [
     {
      "description": "فلتر/معرّف النموذج",
      "in": "query",
      "name": "form_id",
      "schema": {
       "type": "integer"
      }
     },
     {
      "description": "فلتر الدفع",
      "in": "query",
      "name": "payment",
      "schema": {
       "enum": [
        "paid",
        "pending",
        "none"
       ],
       "type": "string"
      }
     },
     {
      "description": "فلتر المراجعة",
      "in": "query",
      "name": "review",
      "schema": {
       "enum": [
        "under_review",
        "accepted",
        "rejected"
       ],
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "text/csv": {
        "example": "reference,form,submitted_at,state,payment,fee_sar,review,note,…",
        "schema": {
         "type": "string"
        }
       }
      },
      "description": "CSV / text/csv"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "تصدير CSV / CSV export",
    "tags": [
     "form",
     "submissions.csv"
    ],
    "x-emm-app": "form"
   },
   "servers": [
    {
     "description": "form",
     "url": "https://form.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "form"
  },
  "/form/api/v1/submissions/{id}": {
   "get": {
    "description": "رد واحد بالإجابات المرتبة والمراجعة والمرفقات. One submission with ordered answers, review state and files.",
    "parameters": [
     {
      "description": "معرّف رقمي",
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "answers": [
           {
            "field_id": 7,
            "label": "الاسم الكامل",
            "type": "short",
            "value": "أحمد"
           }
          ],
          "currency": "SAR",
          "fee": "50.00",
          "files": [],
          "form": {
           "id": 3,
           "slug": "grant",
           "title": "طلب منح"
          },
          "id": 9,
          "note": "",
          "paid_at": "2026-12-03T10:16:02+03:00",
          "payment": "paid",
          "reference": "FM-7K3M9Q",
          "review": "under_review",
          "state": "submitted",
          "submitted_at": "2026-12-03T10:15:00+03:00"
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "رد / Submission",
    "tags": [
     "form",
     "submissions"
    ],
    "x-emm-app": "form"
   },
   "patch": {
    "description": "review: under_review | accepted | rejected + note (حتى 2000 حرف) — للردود المكتملة فقط (409). Set the review status and internal note (409 while unpaid).",
    "parameters": [
     {
      "description": "معرّف رقمي",
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "example": {
        "note": "مستندات مكتملة",
        "review": "accepted"
       },
       "schema": {
        "properties": {
         "note": {
          "description": "ملاحظة داخلية (حتى 2000 حرف)",
          "type": "string"
         },
         "review": {
          "description": "under_review | accepted | rejected",
          "example": "accepted",
          "type": "string"
         }
        },
        "required": [
         "review"
        ],
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "answers": [
           {
            "field_id": 7,
            "label": "الاسم الكامل",
            "type": "short",
            "value": "أحمد"
           }
          ],
          "currency": "SAR",
          "fee": "50.00",
          "files": [],
          "form": {
           "id": 3,
           "slug": "grant",
           "title": "طلب منح"
          },
          "id": 9,
          "note": "",
          "paid_at": "2026-12-03T10:16:02+03:00",
          "payment": "paid",
          "reference": "FM-7K3M9Q",
          "review": "under_review",
          "state": "submitted",
          "submitted_at": "2026-12-03T10:15:00+03:00"
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "409": {
      "description": "تعارض / conflict (quota_exceeded, slug_taken, not_submitted, plan_required)"
     },
     "422": {
      "description": "تحقق / validation error"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "مراجعة / Review",
    "tags": [
     "form",
     "submissions"
    ],
    "x-emm-app": "form"
   },
   "servers": [
    {
     "description": "form",
     "url": "https://form.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "form"
  },
  "/form/api/v1/webhooks": {
   "get": {
    "description": "قائمة عناوين الـWebhook المسجّلة (لكل نموذج أو لكل النماذج). Lists registered webhook endpoints.",
    "parameters": [
     {
      "description": "عدد النتائج (1–200، افتراضي 50)",
      "in": "query",
      "name": "limit",
      "schema": {
       "default": 50,
       "maximum": 200,
       "minimum": 1,
       "type": "integer"
      }
     },
     {
      "description": "تخطي النتائج",
      "in": "query",
      "name": "offset",
      "schema": {
       "default": 0,
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "Webhooks الصادرة / Outgoing webhooks",
    "tags": [
     "form",
     "webhooks"
    ],
    "x-emm-app": "form"
   },
   "post": {
    "description": "يسجّل https URL مع سر HMAC (أو يولّده) لحدث submission.paid — form_id = 0 لكل نماذجك. Registers a URL + HMAC secret for paid submissions.",
    "requestBody": {
     "content": {
      "application/json": {
       "example": {
        "url": "https://example.com/hooks/emm"
       },
       "schema": {
        "properties": {
         "active": {
          "description": "مفعّل افتراضياً",
          "type": "boolean"
         },
         "form_id": {
          "description": "0 أو محذوف = كل نماذجك",
          "type": "number"
         },
         "secret": {
          "description": "سر HMAC مشترك (8–128 حرفاً) — يُولَّد عشوائياً إن تُرك",
          "type": "string"
         },
         "url": {
          "description": "https فقط (بلا معلومات دخول) — يستقبل POST JSON",
          "example": "https://example.com/hooks/emm",
          "type": "string"
         }
        },
        "required": [
         "url"
        ],
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "active": true,
          "created_at": "2026-12-03T12:00:00+03:00",
          "event": "submission.paid",
          "form_id": 0,
          "id": 1,
          "secret": "whsec_…",
          "url": "https://example.com/hooks/emm"
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "201": {
      "description": "أُنشئ / created"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "409": {
      "description": "تعارض / conflict (quota_exceeded, slug_taken, not_submitted, plan_required)"
     },
     "422": {
      "description": "تحقق / validation error"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "تسجيل Webhook / Register webhook",
    "tags": [
     "form",
     "webhooks"
    ],
    "x-emm-app": "form"
   },
   "servers": [
    {
     "description": "form",
     "url": "https://form.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "form"
  },
  "/form/api/v1/webhooks/{id}": {
   "delete": {
    "description": "يحذف التسجيل (مع سجل التسليم). Deletes the registration and its delivery log.",
    "parameters": [
     {
      "description": "معرّف الـWebhook",
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "data": {
           "deleted": true
          },
          "ok": true
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "409": {
      "description": "تعارض / conflict (quota_exceeded, slug_taken, not_submitted, plan_required)"
     },
     "422": {
      "description": "تحقق / validation error"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "حذف Webhook / Delete webhook",
    "tags": [
     "form",
     "webhooks"
    ],
    "x-emm-app": "form"
   },
   "get": {
    "description": "تفاصيل التسجيل مع السر. Registration details with the secret.",
    "parameters": [
     {
      "description": "معرّف الـWebhook",
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "active": true,
          "created_at": "2026-12-03T12:00:00+03:00",
          "event": "submission.paid",
          "form_id": 0,
          "id": 1,
          "secret": "whsec_…",
          "url": "https://example.com/hooks/emm"
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "Webhook / Webhook",
    "tags": [
     "form",
     "webhooks"
    ],
    "x-emm-app": "form"
   },
   "servers": [
    {
     "description": "form",
     "url": "https://form.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "form"
  },
  "/form/api/v1/webhooks/{id}/deliveries": {
   "get": {
    "description": "آخر 100 محاولة تسليم (الحالة والاستجابة والمدة). Last 100 delivery attempts with status, response and duration.",
    "parameters": [
     {
      "description": "معرّف الـWebhook",
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "سجل التسليم / Delivery log",
    "tags": [
     "form",
     "webhooks"
    ],
    "x-emm-app": "form"
   },
   "servers": [
    {
     "description": "form",
     "url": "https://form.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "form"
  },
  "/form/api/v1/webhooks/{id}/test": {
   "post": {
    "description": "يرسل حدث webhook.test الآن ويعيد نتيجة التسليم. Sends a webhook.test event now and returns the delivery result.",
    "parameters": [
     {
      "description": "معرّف الـWebhook",
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "attempt": 1,
          "created_at": "2026-12-03T12:00:00+03:00",
          "duration_ms": 120,
          "event": "webhook.test",
          "id": 5,
          "ok": true,
          "response": "ok",
          "status_code": 200,
          "webhook_id": 1
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "201": {
      "description": "أُنشئ / created"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "409": {
      "description": "تعارض / conflict (quota_exceeded, slug_taken, not_submitted, plan_required)"
     },
     "422": {
      "description": "تحقق / validation error"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "اختبار Webhook / Test delivery",
    "tags": [
     "form",
     "webhooks"
    ],
    "x-emm-app": "form"
   },
   "servers": [
    {
     "description": "form",
     "url": "https://form.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "form"
  },
  "/invoice/api/v1/clients": {
   "get": {
    "description": "قائمة العملاء مع بحث وترقيم صفحات. Lists clients with search and pagination.",
    "parameters": [
     {
      "description": "بحث في اسم العميل أو بريده أو رقمه الضريبي",
      "in": "query",
      "name": "q",
      "schema": {
       "type": "string"
      }
     },
     {
      "description": "عدد النتائج (1–200، افتراضي 50)",
      "in": "query",
      "name": "limit",
      "schema": {
       "default": 50,
       "maximum": 200,
       "minimum": 1,
       "type": "integer"
      }
     },
     {
      "description": "تخطي النتائج",
      "in": "query",
      "name": "offset",
      "schema": {
       "default": 0,
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى / missing, invalid or revoked key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "404": {
      "description": "غير موجود / not found (tenant-scoped)"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "العملاء / Clients",
    "tags": [
     "invoice",
     "العملاء / Clients"
    ],
    "x-emm-app": "invoice"
   },
   "post": {
    "description": "عميل باسم (مطلوب) وبريد وهاتف ورقم ضريبي وعنوان. Client with name (required), email, phone, VAT number (15 digits 3…3 when given) and address.",
    "requestBody": {
     "content": {
      "application/json": {
       "example": {
        "address": "الرياض — حي العليا",
        "email": "accounts@client.sa",
        "name": "شركة العميل التجريبي",
        "phone": "0551234567",
        "vat_number": "310987654300003"
       },
       "schema": {
        "properties": {
         "address": {
          "description": "العنوان",
          "example": "الرياض — حي العليا",
          "type": "string"
         },
         "email": {
          "description": "البريد الإلكتروني",
          "example": "accounts@client.sa",
          "type": "string"
         },
         "name": {
          "description": "اسم العميل (مطلوب) / client name",
          "example": "شركة العميل التجريبي",
          "type": "string"
         },
         "phone": {
          "description": "الجوال 05XXXXXXXX",
          "example": "0551234567",
          "type": "string"
         },
         "vat_number": {
          "description": "الرقم الضريبي 15 رقماً يبدأ وينتهي بـ 3 (اختياري)",
          "example": "310987654300003",
          "type": "string"
         }
        },
        "required": [
         "name",
         "email",
         "phone",
         "vat_number",
         "address"
        ],
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "address": "الرياض — حي العليا",
          "email": "accounts@client.sa",
          "id": 1,
          "name": "شركة العميل التجريبي",
          "phone": "0551234567",
          "vat_number": "310987654300003"
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "201": {
      "description": "أُنشئ / created"
     },
     "400": {
      "description": "JSON غير صالح / invalid JSON"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى / missing, invalid or revoked key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "404": {
      "description": "غير موجود / not found (tenant-scoped)"
     },
     "409": {
      "description": "تعارض / conflict (quota_exceeded, locked, not_draft, in_use, invalid_transition)"
     },
     "422": {
      "description": "تحقق / validation error"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "إضافة عميل / Add client",
    "tags": [
     "invoice",
     "العملاء / Clients"
    ],
    "x-emm-app": "invoice"
   },
   "servers": [
    {
     "description": "invoice",
     "url": "https://invoice.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "invoice"
  },
  "/invoice/api/v1/clients/{id}": {
   "delete": {
    "description": "يحذف عميلاً بلا فواتير (409 in_use). Deletes a client without invoices (409 otherwise).",
    "parameters": [
     {
      "description": "معرّف رقمي داخلي / numeric id",
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "deleted": true,
          "ok": true
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "400": {
      "description": "JSON غير صالح / invalid JSON"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى / missing, invalid or revoked key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "404": {
      "description": "غير موجود / not found (tenant-scoped)"
     },
     "409": {
      "description": "تعارض / conflict (quota_exceeded, locked, not_draft, in_use, invalid_transition)"
     },
     "422": {
      "description": "تحقق / validation error"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "حذف عميل / Delete client",
    "tags": [
     "invoice",
     "العملاء / Clients"
    ],
    "x-emm-app": "invoice"
   },
   "get": {
    "description": "عميل واحد بالمعرّف. One client by id.",
    "parameters": [
     {
      "description": "معرّف رقمي داخلي / numeric id",
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "address": "الرياض — حي العليا",
          "email": "accounts@client.sa",
          "id": 1,
          "name": "شركة العميل التجريبي",
          "phone": "0551234567",
          "vat_number": "310987654300003"
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى / missing, invalid or revoked key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "404": {
      "description": "غير موجود / not found (tenant-scoped)"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "عميل / Client",
    "tags": [
     "invoice",
     "العملاء / Clients"
    ],
    "x-emm-app": "invoice"
   },
   "put": {
    "description": "تعديل بيانات العميل (استبدال كامل للحقول المرسلة). Replaces the client's fields.",
    "parameters": [
     {
      "description": "معرّف رقمي داخلي / numeric id",
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "example": {
        "address": "الرياض — حي العليا",
        "email": "accounts@client.sa",
        "name": "شركة العميل التجريبي",
        "phone": "0551234567",
        "vat_number": "310987654300003"
       },
       "schema": {
        "properties": {
         "address": {
          "description": "العنوان",
          "example": "الرياض — حي العليا",
          "type": "string"
         },
         "email": {
          "description": "البريد الإلكتروني",
          "example": "accounts@client.sa",
          "type": "string"
         },
         "name": {
          "description": "اسم العميل (مطلوب) / client name",
          "example": "شركة العميل التجريبي",
          "type": "string"
         },
         "phone": {
          "description": "الجوال 05XXXXXXXX",
          "example": "0551234567",
          "type": "string"
         },
         "vat_number": {
          "description": "الرقم الضريبي 15 رقماً يبدأ وينتهي بـ 3 (اختياري)",
          "example": "310987654300003",
          "type": "string"
         }
        },
        "required": [
         "name",
         "email",
         "phone",
         "vat_number",
         "address"
        ],
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "address": "الرياض — حي العليا",
          "email": "accounts@client.sa",
          "id": 1,
          "name": "شركة العميل التجريبي",
          "phone": "0551234567",
          "vat_number": "310987654300003"
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "400": {
      "description": "JSON غير صالح / invalid JSON"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى / missing, invalid or revoked key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "404": {
      "description": "غير موجود / not found (tenant-scoped)"
     },
     "409": {
      "description": "تعارض / conflict (quota_exceeded, locked, not_draft, in_use, invalid_transition)"
     },
     "422": {
      "description": "تحقق / validation error"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "تعديل عميل / Update client",
    "tags": [
     "invoice",
     "العملاء / Clients"
    ],
    "x-emm-app": "invoice"
   },
   "servers": [
    {
     "description": "invoice",
     "url": "https://invoice.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "invoice"
  },
  "/invoice/api/v1/invoices": {
   "get": {
    "description": "فواتير المنشأة مع فلتر status (draft|sent|paid|overdue) وclient_id وترقيم صفحات. Invoices with status/client filters and pagination.",
    "parameters": [
     {
      "description": "فلتر الحالة (overdue = مرسلة ومتأخرة الاستحقاق)",
      "in": "query",
      "name": "status",
      "schema": {
       "default": "all",
       "enum": [
        "draft",
        "sent",
        "paid",
        "overdue"
       ],
       "type": "string"
      }
     },
     {
      "description": "فلتر حسب العميل",
      "in": "query",
      "name": "client_id",
      "schema": {
       "type": "integer"
      }
     },
     {
      "description": "عدد النتائج (1–200، افتراضي 50)",
      "in": "query",
      "name": "limit",
      "schema": {
       "default": 50,
       "maximum": 200,
       "minimum": 1,
       "type": "integer"
      }
     },
     {
      "description": "تخطي النتائج",
      "in": "query",
      "name": "offset",
      "schema": {
       "default": 0,
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى / missing, invalid or revoked key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "404": {
      "description": "غير موجود / not found (tenant-scoped)"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "الفواتير / Invoices",
    "tags": [
     "invoice",
     "الفواتير / Invoices"
    ],
    "x-emm-app": "invoice"
   },
   "post": {
    "description": "تنشئ فاتورة زاتكا مبسطة (مسودة، أو مرسلة مع send=true) ضمن حصة الشهر (409 quota_exceeded). المبالغ نص بالريال. Creates a ZATCA simplified invoice (draft, or sent with send=true) within the monthly quota.",
    "requestBody": {
     "content": {
      "application/json": {
       "example": {
        "client_id": 1,
        "due_date": "2026-12-16",
        "items": [
         {
          "description": "تصميم شعار",
          "discount": "100",
          "qty": "1",
          "unit_price": "1000"
         },
         {
          "description": "طباعة",
          "discount": "0",
          "qty": "2",
          "unit_price": "250.5"
         }
        ],
        "notes": "الدفع خلال 14 يوماً"
       },
       "schema": {
        "properties": {
         "client_id": {
          "description": "معرّف العميل (مطلوب) / client id (required)",
          "example": "1",
          "type": "number"
         },
         "due_date": {
          "description": "تاريخ الاستحقاق YYYY-MM-DD (افتراضي +14 يوماً) / due date (default +14d)",
          "example": "2026-12-16",
          "type": "string"
         },
         "issue_date": {
          "description": "تاريخ الإصدار YYYY-MM-DD (افتراضي اليوم، الرياض) / issue date (default today)",
          "type": "string"
         },
         "items": {
          "description": "البنود (بند واحد على الأقل) / lines (at least one)",
          "items": {
           "properties": {
            "description": {
             "description": "وصف البند (مطلوب) / line description",
             "example": "تصميم شعار",
             "type": "string"
            },
            "discount": {
             "description": "خصم ثابت على البند بالريال / flat line discount in SAR",
             "oneOf": [
              {
               "type": "number"
              },
              {
               "type": "string"
              }
             ]
            },
            "qty": {
             "description": "الكمية (رقم أو نص، حتى 3 منازل) / quantity, e.g. 1.5",
             "oneOf": [
              {
               "type": "number"
              },
              {
               "type": "string"
              }
             ]
            },
            "unit_price": {
             "description": "سعر الوحدة بالريال / unit price in SAR",
             "oneOf": [
              {
               "type": "number"
              },
              {
               "type": "string"
              }
             ]
            }
           },
           "required": [
            "description",
            "qty",
            "unit_price",
            "discount"
           ],
           "type": "object"
          },
          "type": "array"
         },
         "notes": {
          "description": "ملاحظات تظهر على الفاتورة / notes printed on the invoice",
          "example": "الدفع خلال 14 يوماً",
          "type": "string"
         },
         "send": {
          "description": "true = معتمدة للإرسال (sent) بدل مسودة / create as sent instead of draft",
          "type": "boolean"
         },
         "vat_pct": {
          "description": "نسبة الضريبة 0 أو 15 (افتراضي ضريبة المنشأة) / VAT 0 or 15",
          "example": "15",
          "nullable": true,
          "type": "number"
         }
        },
        "required": [
         "client_id",
         "items"
        ],
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "client": {
           "id": 1,
           "name": "شركة العميل التجريبي"
          },
          "currency": "SAR",
          "discount": "100.00",
          "due_date": "2026-12-16",
          "id": 7,
          "issue_at": "2026-12-02T10:30:00+03:00",
          "number": "INV-2026-0007",
          "public_id": "k3Jd…",
          "share_url": "https://invoice.emm.sa/i/k3Jd…",
          "status": "sent",
          "subtotal": "1401.00",
          "total": "1611.15",
          "vat_amount": "210.15",
          "vat_pct": 15
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "201": {
      "description": "أُنشئ / created"
     },
     "400": {
      "description": "JSON غير صالح / invalid JSON"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى / missing, invalid or revoked key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "404": {
      "description": "غير موجود / not found (tenant-scoped)"
     },
     "409": {
      "description": "تعارض / conflict (quota_exceeded, locked, not_draft, in_use, invalid_transition)"
     },
     "422": {
      "description": "تحقق / validation error"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "إنشاء فاتورة / Create invoice",
    "tags": [
     "invoice",
     "الفواتير / Invoices"
    ],
    "x-emm-app": "invoice"
   },
   "servers": [
    {
     "description": "invoice",
     "url": "https://invoice.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "invoice"
  },
  "/invoice/api/v1/invoices/{id}": {
   "delete": {
    "description": "يحذف المسودات فقط (409 not_draft لغيرها). Deletes drafts only.",
    "parameters": [
     {
      "description": "معرّف رقمي داخلي / numeric id",
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "deleted": true,
          "ok": true
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "400": {
      "description": "JSON غير صالح / invalid JSON"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى / missing, invalid or revoked key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "404": {
      "description": "غير موجود / not found (tenant-scoped)"
     },
     "409": {
      "description": "تعارض / conflict (quota_exceeded, locked, not_draft, in_use, invalid_transition)"
     },
     "422": {
      "description": "تحقق / validation error"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "حذف مسودة / Delete draft",
    "tags": [
     "invoice",
     "الفواتير / Invoices"
    ],
    "x-emm-app": "invoice"
   },
   "get": {
    "description": "فاتورة كاملة: البنود، الإجماليات، UUID، رمز QR (TLV base64)، رابط المشاركة. One invoice with items, totals, UUID, ZATCA QR payload and share link.",
    "parameters": [
     {
      "description": "معرّف رقمي داخلي / numeric id",
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "client": {
           "id": 1,
           "name": "شركة العميل التجريبي"
          },
          "currency": "SAR",
          "discount": "100.00",
          "due_date": "2026-12-16",
          "id": 7,
          "issue_at": "2026-12-02T10:30:00+03:00",
          "number": "INV-2026-0007",
          "public_id": "k3Jd…",
          "share_url": "https://invoice.emm.sa/i/k3Jd…",
          "status": "sent",
          "subtotal": "1401.00",
          "total": "1611.15",
          "vat_amount": "210.15",
          "vat_pct": 15
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى / missing, invalid or revoked key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "404": {
      "description": "غير موجود / not found (tenant-scoped)"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "فاتورة / Invoice",
    "tags": [
     "invoice",
     "الفواتير / Invoices"
    ],
    "x-emm-app": "invoice"
   },
   "put": {
    "description": "تعديل البنود والعميل وتاريخ الاستحقاق والضريبة والملاحظات — مسودة أو مرسلة فقط (409 locked للمدفوعة). Replaces lines and header fields of a non-paid invoice.",
    "parameters": [
     {
      "description": "معرّف رقمي داخلي / numeric id",
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "example": {
        "client_id": 1,
        "due_date": "2026-12-16",
        "items": [
         {
          "description": "تصميم شعار",
          "discount": "100",
          "qty": "1",
          "unit_price": "1000"
         },
         {
          "description": "طباعة",
          "discount": "0",
          "qty": "2",
          "unit_price": "250.5"
         }
        ],
        "notes": "الدفع خلال 14 يوماً"
       },
       "schema": {
        "properties": {
         "client_id": {
          "description": "معرّف العميل (مطلوب) / client id (required)",
          "example": "1",
          "type": "number"
         },
         "due_date": {
          "description": "تاريخ الاستحقاق YYYY-MM-DD (افتراضي +14 يوماً) / due date (default +14d)",
          "example": "2026-12-16",
          "type": "string"
         },
         "issue_date": {
          "description": "تاريخ الإصدار YYYY-MM-DD (افتراضي اليوم، الرياض) / issue date (default today)",
          "type": "string"
         },
         "items": {
          "description": "البنود (بند واحد على الأقل) / lines (at least one)",
          "items": {
           "properties": {
            "description": {
             "description": "وصف البند (مطلوب) / line description",
             "example": "تصميم شعار",
             "type": "string"
            },
            "discount": {
             "description": "خصم ثابت على البند بالريال / flat line discount in SAR",
             "oneOf": [
              {
               "type": "number"
              },
              {
               "type": "string"
              }
             ]
            },
            "qty": {
             "description": "الكمية (رقم أو نص، حتى 3 منازل) / quantity, e.g. 1.5",
             "oneOf": [
              {
               "type": "number"
              },
              {
               "type": "string"
              }
             ]
            },
            "unit_price": {
             "description": "سعر الوحدة بالريال / unit price in SAR",
             "oneOf": [
              {
               "type": "number"
              },
              {
               "type": "string"
              }
             ]
            }
           },
           "required": [
            "description",
            "qty",
            "unit_price",
            "discount"
           ],
           "type": "object"
          },
          "type": "array"
         },
         "notes": {
          "description": "ملاحظات تظهر على الفاتورة / notes printed on the invoice",
          "example": "الدفع خلال 14 يوماً",
          "type": "string"
         },
         "send": {
          "description": "true = معتمدة للإرسال (sent) بدل مسودة / create as sent instead of draft",
          "type": "boolean"
         },
         "vat_pct": {
          "description": "نسبة الضريبة 0 أو 15 (افتراضي ضريبة المنشأة) / VAT 0 or 15",
          "example": "15",
          "nullable": true,
          "type": "number"
         }
        },
        "required": [
         "client_id",
         "items"
        ],
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "client": {
           "id": 1,
           "name": "شركة العميل التجريبي"
          },
          "currency": "SAR",
          "discount": "100.00",
          "due_date": "2026-12-16",
          "id": 7,
          "issue_at": "2026-12-02T10:30:00+03:00",
          "number": "INV-2026-0007",
          "public_id": "k3Jd…",
          "share_url": "https://invoice.emm.sa/i/k3Jd…",
          "status": "sent",
          "subtotal": "1401.00",
          "total": "1611.15",
          "vat_amount": "210.15",
          "vat_pct": 15
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "400": {
      "description": "JSON غير صالح / invalid JSON"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى / missing, invalid or revoked key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "404": {
      "description": "غير موجود / not found (tenant-scoped)"
     },
     "409": {
      "description": "تعارض / conflict (quota_exceeded, locked, not_draft, in_use, invalid_transition)"
     },
     "422": {
      "description": "تحقق / validation error"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "تعديل فاتورة / Update invoice",
    "tags": [
     "invoice",
     "الفواتير / Invoices"
    ],
    "x-emm-app": "invoice"
   },
   "servers": [
    {
     "description": "invoice",
     "url": "https://invoice.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "invoice"
  },
  "/invoice/api/v1/invoices/{id}/mark-paid": {
   "post": {
    "description": "اختصار لتغيير الحالة إلى paid مع مرجع دفع اختياري. Shortcut for status=paid with an optional payment reference.",
    "parameters": [
     {
      "description": "معرّف رقمي داخلي / numeric id",
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "example": {
        "paid_at": "",
        "payment_ref": "TRF-1200"
       },
       "schema": {
        "properties": {
         "paid_at": {
          "description": "ISO-8601 +03:00 (افتراضي الآن)",
          "example": "2026-12-03T10:00:00+03:00",
          "type": "string"
         },
         "payment_ref": {
          "description": "مرجع الدفع",
          "example": "TRF-1200",
          "type": "string"
         }
        },
        "required": [
         "paid_at",
         "payment_ref"
        ],
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "client": {
           "id": 1,
           "name": "شركة العميل التجريبي"
          },
          "currency": "SAR",
          "discount": "100.00",
          "due_date": "2026-12-16",
          "id": 7,
          "issue_at": "2026-12-02T10:30:00+03:00",
          "number": "INV-2026-0007",
          "public_id": "k3Jd…",
          "share_url": "https://invoice.emm.sa/i/k3Jd…",
          "status": "sent",
          "subtotal": "1401.00",
          "total": "1611.15",
          "vat_amount": "210.15",
          "vat_pct": 15
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "201": {
      "description": "أُنشئ / created"
     },
     "400": {
      "description": "JSON غير صالح / invalid JSON"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى / missing, invalid or revoked key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "404": {
      "description": "غير موجود / not found (tenant-scoped)"
     },
     "409": {
      "description": "تعارض / conflict (quota_exceeded, locked, not_draft, in_use, invalid_transition)"
     },
     "422": {
      "description": "تحقق / validation error"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "تعليم كمدفوعة / Mark paid",
    "tags": [
     "invoice",
     "الفواتير / Invoices"
    ],
    "x-emm-app": "invoice"
   },
   "servers": [
    {
     "description": "invoice",
     "url": "https://invoice.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "invoice"
  },
  "/invoice/api/v1/invoices/{id}/share": {
   "get": {
    "description": "الرابط العام للفاتورة، رابط الطباعة، ونص واتساب جاهز مع رابط wa.me. Public URL, print URL and a ready WhatsApp reminder with its wa.me link.",
    "parameters": [
     {
      "description": "معرّف رقمي داخلي / numeric id",
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى / missing, invalid or revoked key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "404": {
      "description": "غير موجود / not found (tenant-scoped)"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "رابط المشاركة / Public share link",
    "tags": [
     "invoice",
     "الفواتير / Invoices"
    ],
    "x-emm-app": "invoice"
   },
   "servers": [
    {
     "description": "invoice",
     "url": "https://invoice.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "invoice"
  },
  "/invoice/api/v1/invoices/{id}/status": {
   "post": {
    "description": "status: sent (اعتماد للإرسال) | paid (تعليم كمدفوعة، مع paid_at وpayment_ref اختيارياً) — يتخطى الحالة المدفوعة. sent / paid; paid invoices are final.",
    "parameters": [
     {
      "description": "معرّف رقمي داخلي / numeric id",
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "example": {
        "paid_at": "",
        "payment_ref": "TRF-1200",
        "status": "paid"
       },
       "schema": {
        "properties": {
         "paid_at": {
          "description": "ISO-8601 +03:00 (افتراضي الآن) / paid timestamp (default now)",
          "type": "string"
         },
         "payment_ref": {
          "description": "مرجع الدفع / payment reference",
          "example": "TRF-1200",
          "type": "string"
         },
         "status": {
          "description": "sent | paid",
          "enum": [
           "sent",
           "paid"
          ],
          "example": "paid",
          "type": "string"
         }
        },
        "required": [
         "status",
         "paid_at",
         "payment_ref"
        ],
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "client": {
           "id": 1,
           "name": "شركة العميل التجريبي"
          },
          "currency": "SAR",
          "discount": "100.00",
          "due_date": "2026-12-16",
          "id": 7,
          "issue_at": "2026-12-02T10:30:00+03:00",
          "number": "INV-2026-0007",
          "public_id": "k3Jd…",
          "share_url": "https://invoice.emm.sa/i/k3Jd…",
          "status": "sent",
          "subtotal": "1401.00",
          "total": "1611.15",
          "vat_amount": "210.15",
          "vat_pct": 15
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "201": {
      "description": "أُنشئ / created"
     },
     "400": {
      "description": "JSON غير صالح / invalid JSON"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى / missing, invalid or revoked key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "404": {
      "description": "غير موجود / not found (tenant-scoped)"
     },
     "409": {
      "description": "تعارض / conflict (quota_exceeded, locked, not_draft, in_use, invalid_transition)"
     },
     "422": {
      "description": "تحقق / validation error"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "تغيير الحالة / Transition",
    "tags": [
     "invoice",
     "الفواتير / Invoices"
    ],
    "x-emm-app": "invoice"
   },
   "servers": [
    {
     "description": "invoice",
     "url": "https://invoice.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "invoice"
  },
  "/invoice/api/v1/invoices/{id}/zatca": {
   "get": {
    "description": "الحقائق الخمسة بترميز TLV: اسم البائع، الرقم الضريبي، الطابع الزمني +03:00، الإجمالي شامل الضريبة، مبلغ الضريبة + base64 وصورة PNG. The five TLV tags plus base64 and a PNG data URI.",
    "parameters": [
     {
      "description": "معرّف رقمي داخلي / numeric id",
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى / missing, invalid or revoked key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "404": {
      "description": "غير موجود / not found (tenant-scoped)"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "حمولة QR الزاتكاوية / ZATCA QR payload",
    "tags": [
     "invoice",
     "الفواتير / Invoices"
    ],
    "x-emm-app": "invoice"
   },
   "servers": [
    {
     "description": "invoice",
     "url": "https://invoice.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "invoice"
  },
  "/invoice/api/v1/me": {
   "get": {
    "description": "يتحقق من المفتاح ويعيد المستخدم والمنشأة والخطة الحالية وحصص الشهر. Checks a key; returns user, business, current plan and monthly quota.",
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "business": {
           "name": "منشأتي"
          },
          "plan": {
           "current": "free",
           "quota": {
            "monthly_invoices": {
             "limit": 3,
             "used": 1
            }
           }
          },
          "service": "invoice",
          "user": {
           "email": "me@company.sa"
          }
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى / missing, invalid or revoked key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "404": {
      "description": "غير موجود / not found (tenant-scoped)"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "الهوية والخطة والحدود / Identity, plan, quotas",
    "tags": [
     "invoice",
     "الحساب / Account"
    ],
    "x-emm-app": "invoice"
   },
   "servers": [
    {
     "description": "invoice",
     "url": "https://invoice.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "invoice"
  },
  "/invoice/api/v1/plan": {
   "get": {
    "description": "الخطة الحالية مع الاستهلاك وكل الخطط بأسعارها بالريال. Current plan with usage plus every plan (SAR/month, final, no VAT).",
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى / missing, invalid or revoked key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "404": {
      "description": "غير موجود / not found (tenant-scoped)"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "الخطة الحالية وكل الخطط / Current plan and catalogue",
    "tags": [
     "invoice",
     "الحساب / Account"
    ],
    "x-emm-app": "invoice"
   },
   "servers": [
    {
     "description": "invoice",
     "url": "https://invoice.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "invoice"
  },
  "/invoice/api/v1/quota": {
   "get": {
    "description": "عدد الفواتير المنشأة هذا الشهر ميلادياً وحد الخطة (3 للمجاني، غير محدود لـ Pro). Invoices created this Gregorian month and the plan limit.",
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "limit": 3,
          "month": "2026-12",
          "remaining": 2,
          "unlimited": false,
          "used": 1
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى / missing, invalid or revoked key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "404": {
      "description": "غير موجود / not found (tenant-scoped)"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "حصة الشهر / Monthly quota",
    "tags": [
     "invoice",
     "الحساب / Account"
    ],
    "x-emm-app": "invoice"
   },
   "servers": [
    {
     "description": "invoice",
     "url": "https://invoice.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "invoice"
  },
  "/invoice/api/v1/reminders": {
   "get": {
    "description": "الفواتير غير المدفوعة (المتأخرة أولاً) مع نص تذكير ورابط واتساب لكل منها — ميزة Pro (403 plan_required). Unpaid invoices with a reminder text + wa.me link each — Pro feature.",
    "parameters": [
     {
      "description": "عدد النتائج (1–200، افتراضي 50)",
      "in": "query",
      "name": "limit",
      "schema": {
       "default": 50,
       "maximum": 200,
       "minimum": 1,
       "type": "integer"
      }
     },
     {
      "description": "تخطي النتائج",
      "in": "query",
      "name": "offset",
      "schema": {
       "default": 0,
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى / missing, invalid or revoked key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "404": {
      "description": "غير موجود / not found (tenant-scoped)"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "قائمة التذكيرات / Payment reminders",
    "tags": [
     "invoice",
     "التذكيرات / Reminders"
    ],
    "x-emm-app": "invoice"
   },
   "servers": [
    {
     "description": "invoice",
     "url": "https://invoice.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "invoice"
  },
  "/lahnak/me": {
   "get": {
    "operationId": "lahnak_get_me",
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "data": {
           "description": "user, role, plan, key{name,prefix,scopes}, quotas, endpoints",
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "type": "object"
        }
       }
      },
      "description": "نجاح — {\"ok\":true, \"data\":…}"
     },
     "400": {
      "description": "تحقق: حقل مفقود أو غير صالح (validation)"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية (read)"
     },
     "404": {
      "description": "الطلب غير موجود أو خارج نطاق المفتاح"
     },
     "409": {
      "description": "تعارض: الطلب مدفوع بالفعل أو غير مؤكد"
     },
     "429": {
      "description": "تجاوز 60 طلباً/دقيقة — راجع Retry-After"
     },
     "502": {
      "description": "خدمة الدفع غير متاحة — لم يُنشأ أي رابط"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "المستخدم (مالك المفتاح) والخطة والحصص — اختبار مفتاحك",
    "tags": [
     "lahnak",
     "account"
    ],
    "x-emm-app": "lahnak",
    "x-scope": "read"
   },
   "servers": [
    {
     "description": "lahnak",
     "url": "https://lahnak.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "lahnak"
  },
  "/lahnak/orders": {
   "get": {
    "operationId": "lahnak_get_orders",
    "parameters": [
     {
      "in": "query",
      "name": "limit",
      "required": false,
      "schema": {
       "description": "عدد النتائج 1-200 (افتراضي 50)",
       "example": 50,
       "type": "integer"
      }
     },
     {
      "in": "query",
      "name": "offset",
      "required": false,
      "schema": {
       "description": "إزاحة الترحيل",
       "example": 0,
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "data": {
           "description": "items[] (طلب بدون حقول النص الحر) + total + limit + offset",
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "type": "object"
        }
       }
      },
      "description": "نجاح — {\"ok\":true, \"data\":…}"
     },
     "400": {
      "description": "تحقق: حقل مفقود أو غير صالح (validation)"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية (read)"
     },
     "404": {
      "description": "الطلب غير موجود أو خارج نطاق المفتاح"
     },
     "409": {
      "description": "تعارض: الطلب مدفوع بالفعل أو غير مؤكد"
     },
     "429": {
      "description": "تجاوز 60 طلباً/دقيقة — راجع Retry-After"
     },
     "502": {
      "description": "خدمة الدفع غير متاحة — لم يُنشأ أي رابط"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "قائمة الطلبات (ترحيل) — مفاتيح admin ترى الكل، ومفاتيح الشركاء طلباتها فقط",
    "tags": [
     "lahnak",
     "orders"
    ],
    "x-emm-app": "lahnak",
    "x-scope": "read"
   },
   "post": {
    "operationId": "lahnak_post_orders",
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "additionalProperties": false,
        "properties": {
         "email": {
          "description": "بريد المُهدي — تصل إليه الأغنية",
          "example": "someone@example.sa",
          "type": "string"
         },
         "genre": {
          "description": "النوع الموسيقي (طرب، خليجي، راب، بوب…)",
          "example": "خليجي",
          "type": "string"
         },
         "memory": {
          "description": "ذكرى حقيقية تُبنى عليها الكلمات (سطر إلى ثلاثة)",
          "example": "ليلة المطر في جدة",
          "type": "string"
         },
         "message": {
          "description": "رسالة المُهدي في نهاية الأغنية",
          "example": "شكراً لأنك صبرتيني",
          "type": "string"
         },
         "name": {
          "description": "اسم المُهدى إليه كما يُنطق في الأغنية",
          "example": "نورة",
          "type": "string"
         },
         "occasion": {
          "description": "المناسبة (زواج، عيد ميلاد، ذكرى…)",
          "example": "ذكرى زواج",
          "type": "string"
         },
         "plan": {
          "description": "مع وجودها يُؤكَّد الطلب فوراً بالسعر: standard (149) أو express (199)",
          "enum": [
           "standard",
           "express"
          ],
          "example": "standard",
          "type": "string"
         },
         "pronunciation": {
          "description": "طريقة النطق (اختياري)",
          "example": "",
          "type": "string"
         },
         "recipient": {
          "description": "لمن الأغنية (زوجتي، أمي، صديق…)",
          "example": "زوجتي",
          "type": "string"
         },
         "traits": {
          "description": "صفات المُهدى إليه مفصولة بفواصل",
          "example": "طيبة، صبورة",
          "type": "string"
         },
         "voice": {
          "description": "الصوت: رجل / امرأة / ثنائي",
          "enum": [
           "رجل",
           "امرأة",
           "ثنائي"
          ],
          "example": "امرأة",
          "type": "string"
         }
        },
        "required": [
         "recipient",
         "name",
         "genre",
         "memory",
         "email"
        ],
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "201": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "data": {
           "description": "نفس مخرجات /api/v1/orders/{token}",
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "type": "object"
        }
       }
      },
      "description": "نجاح — {\"ok\":true, \"data\":…}"
     },
     "400": {
      "description": "تحقق: حقل مفقود أو غير صالح (validation)"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية (write)"
     },
     "404": {
      "description": "الطلب غير موجود أو خارج نطاق المفتاح"
     },
     "409": {
      "description": "تعارض: الطلب مدفوع بالفعل أو غير مؤكد"
     },
     "429": {
      "description": "تجاوز 60 طلباً/دقيقة — راجع Retry-After"
     },
     "502": {
      "description": "خدمة الدفع غير متاحة — لم يُنشأ أي رابط"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "إنشاء طلب أغنية (مسودة؛ مع plan يُؤكَّد بالسعر) — نفس تحقق نموذج الموقع، لا ينشئ أي دفع",
    "tags": [
     "lahnak",
     "orders"
    ],
    "x-emm-app": "lahnak",
    "x-scope": "write"
   },
   "servers": [
    {
     "description": "lahnak",
     "url": "https://lahnak.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "lahnak"
  },
  "/lahnak/orders/{token}": {
   "get": {
    "operationId": "lahnak_get_orders_token",
    "parameters": [
     {
      "in": "path",
      "name": "token",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "data": {
           "description": "نفس مخرجات /api/v1/orders/{token}",
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "type": "object"
        }
       }
      },
      "description": "نجاح — {\"ok\":true, \"data\":…}"
     },
     "400": {
      "description": "تحقق: حقل مفقود أو غير صالح (validation)"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية (read)"
     },
     "404": {
      "description": "الطلب غير موجود أو خارج نطاق المفتاح"
     },
     "409": {
      "description": "تعارض: الطلب مدفوع بالفعل أو غير مؤكد"
     },
     "429": {
      "description": "تجاوز 60 طلباً/دقيقة — راجع Retry-After"
     },
     "502": {
      "description": "خدمة الدفع غير متاحة — لم يُنشأ أي رابط"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "طلب واحد مع كل الحقول (الذكرى، الرسالة، رابط الدفع)",
    "tags": [
     "lahnak",
     "orders"
    ],
    "x-emm-app": "lahnak",
    "x-scope": "read"
   },
   "servers": [
    {
     "description": "lahnak",
     "url": "https://lahnak.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "lahnak"
  },
  "/lahnak/orders/{token}/checkout": {
   "post": {
    "operationId": "lahnak_post_orders_token_checkout",
    "parameters": [
     {
      "in": "query",
      "name": "dry_run",
      "required": false,
      "schema": {
       "description": "1 = محاكاة فقط",
       "example": 1,
       "type": "integer"
      }
     },
     {
      "in": "path",
      "name": "token",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "data": {
           "description": "dry_run, order_ref, amount, currency, checkout_url, payment_link_id, status",
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "type": "object"
        }
       }
      },
      "description": "نجاح — {\"ok\":true, \"data\":…}"
     },
     "400": {
      "description": "تحقق: حقل مفقود أو غير صالح (validation)"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية (write)"
     },
     "404": {
      "description": "الطلب غير موجود أو خارج نطاق المفتاح"
     },
     "409": {
      "description": "تعارض: الطلب مدفوع بالفعل أو غير مؤكد"
     },
     "429": {
      "description": "تجاوز 60 طلباً/دقيقة — راجع Retry-After"
     },
     "502": {
      "description": "خدمة الدفع غير متاحة — لم يُنشأ أي رابط"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "إنشاء صفحة الدفع (رابط StreamPay عبر emm-pay، idempotent) — ?dry_run=1 يعيد الحمولة دون إنشاء رابط",
    "tags": [
     "lahnak",
     "orders"
    ],
    "x-emm-app": "lahnak",
    "x-scope": "write"
   },
   "servers": [
    {
     "description": "lahnak",
     "url": "https://lahnak.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "lahnak"
  },
  "/lahnak/orders/{token}/confirm": {
   "post": {
    "operationId": "lahnak_post_orders_token_confirm",
    "parameters": [
     {
      "in": "path",
      "name": "token",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "additionalProperties": false,
        "properties": {
         "plan": {
          "description": "سرعة التسليم",
          "enum": [
           "standard",
           "express"
          ],
          "example": "express",
          "type": "string"
         }
        },
        "required": [
         "plan"
        ],
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "data": {
           "description": "نفس مخرجات /api/v1/orders/{token}",
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "type": "object"
        }
       }
      },
      "description": "نجاح — {\"ok\":true, \"data\":…}"
     },
     "400": {
      "description": "تحقق: حقل مفقود أو غير صالح (validation)"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية (write)"
     },
     "404": {
      "description": "الطلب غير موجود أو خارج نطاق المفتاح"
     },
     "409": {
      "description": "تعارض: الطلب مدفوع بالفعل أو غير مؤكد"
     },
     "429": {
      "description": "تجاوز 60 طلباً/دقيقة — راجع Retry-After"
     },
     "502": {
      "description": "خدمة الدفع غير متاحة — لم يُنشأ أي رابط"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "تأكيد الطلب بخطة: standard 149 ر.س أو express 199 ر.س (السعر يُحدَّد خادمياً)",
    "tags": [
     "lahnak",
     "orders"
    ],
    "x-emm-app": "lahnak",
    "x-scope": "write"
   },
   "servers": [
    {
     "description": "lahnak",
     "url": "https://lahnak.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "lahnak"
  },
  "/lahnak/orders/{token}/status": {
   "get": {
    "operationId": "lahnak_get_orders_token_status",
    "parameters": [
     {
      "in": "path",
      "name": "token",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "data": {
           "properties": {
            "audio_ready": {
             "type": "boolean"
            },
            "created_at": {
             "format": "date-time",
             "type": "string"
            },
            "currency": {
             "type": "string"
            },
            "generation_status": {
             "type": "string"
            },
            "links": {
             "type": "object"
            },
            "next_ar": {
             "description": "الخطوة التالية",
             "type": "string"
            },
            "paid": {
             "type": "boolean"
            },
            "payment_status": {
             "description": "حالة الدفع لدى المزود",
             "type": "string"
            },
            "plan": {
             "type": "string"
            },
            "price": {
             "type": "string"
            },
            "status": {
             "type": "string"
            },
            "token": {
             "type": "string"
            }
           },
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "type": "object"
        }
       }
      },
      "description": "نجاح — {\"ok\":true, \"data\":…}"
     },
     "400": {
      "description": "تحقق: حقل مفقود أو غير صالح (validation)"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية (read)"
     },
     "404": {
      "description": "الطلب غير موجود أو خارج نطاق المفتاح"
     },
     "409": {
      "description": "تعارض: الطلب مدفوع بالفعل أو غير مؤكد"
     },
     "429": {
      "description": "تجاوز 60 طلباً/دقيقة — راجع Retry-After"
     },
     "502": {
      "description": "خدمة الدفع غير متاحة — لم يُنشأ أي رابط"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "حالة الطلب (draft/pending/awaiting/paid/failed/done) مع تحديث من مزود الدفع وخطوة تالية",
    "tags": [
     "lahnak",
     "orders"
    ],
    "x-emm-app": "lahnak",
    "x-scope": "read"
   },
   "servers": [
    {
     "description": "lahnak",
     "url": "https://lahnak.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "lahnak"
  },
  "/lahnak/plan": {
   "get": {
    "operationId": "lahnak_get_plan",
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "data": {
           "description": "الخطط: plans[] {id, name_ar, name_en, price, currency, delivery, eta_hours} + vat + payment",
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "type": "object"
        }
       }
      },
      "description": "نجاح — {\"ok\":true, \"data\":…}"
     },
     "400": {
      "description": "تحقق: حقل مفقود أو غير صالح (validation)"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية (read)"
     },
     "404": {
      "description": "الطلب غير موجود أو خارج نطاق المفتاح"
     },
     "409": {
      "description": "تعارض: الطلب مدفوع بالفعل أو غير مؤكد"
     },
     "429": {
      "description": "تجاوز 60 طلباً/دقيقة — راجع Retry-After"
     },
     "502": {
      "description": "خدمة الدفع غير متاحة — لم يُنشأ أي رابط"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "الخطط والأسعار (149 / 199 ر.س نهائية) والتسليم وطريقة الدفع",
    "tags": [
     "lahnak",
     "account"
    ],
    "x-emm-app": "lahnak",
    "x-scope": "read"
   },
   "servers": [
    {
     "description": "lahnak",
     "url": "https://lahnak.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "lahnak"
  },
  "/menu/api/v1/categories": {
   "get": {
    "description": "تصنيفات المنيو بترتيبها وعدد أصناف كل تصنيف. Menu categories in display order with item counts.",
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "التصنيفات / Categories",
    "tags": [
     "menu",
     "categories"
    ],
    "x-emm-app": "menu"
   },
   "post": {
    "description": "يضيف تصنيفاً في نهاية المنيو (الاسم العربي مطلوب؛ الإنجليزي في خطتي بلس وبرو). Appends a category.",
    "requestBody": {
     "content": {
      "application/json": {
       "example": {
        "name": "مشروبات ساخنة",
        "name_en": "Hot drinks"
       },
       "schema": {
        "properties": {
         "id": {
          "description": "معرّف التصنيف (من الاستجابة)",
          "type": "number"
         },
         "name": {
          "description": "الاسم العربي (1–60)",
          "example": "مشروبات ساخنة",
          "type": "string"
         },
         "name_en": {
          "description": "الاسم الإنجليزي (بلس وبرو)",
          "type": "string"
         }
        },
        "required": [
         "name"
        ],
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "id": 1,
          "items_count": 4,
          "name": "مشروبات",
          "name_en": "Drinks",
          "position": 0
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "201": {
      "description": "أُنشئ / created"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "409": {
      "description": "تعارض / conflict (quota_exceeded, slug_taken, not_submitted, plan_required)"
     },
     "422": {
      "description": "تحقق / validation error"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "إضافة تصنيف / Add category",
    "tags": [
     "menu",
     "categories"
    ],
    "x-emm-app": "menu"
   },
   "servers": [
    {
     "description": "menu",
     "url": "https://menu.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "menu"
  },
  "/menu/api/v1/categories/{id}": {
   "delete": {
    "description": "يحذف التصنيف وأصنافه. Deletes the category and its items.",
    "parameters": [
     {
      "description": "معرّف رقمي",
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "data": {
           "deleted": true
          },
          "ok": true
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "409": {
      "description": "تعارض / conflict (quota_exceeded, slug_taken, not_submitted, plan_required)"
     },
     "422": {
      "description": "تحقق / validation error"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "حذف تصنيف / Delete category",
    "tags": [
     "menu",
     "categories"
    ],
    "x-emm-app": "menu"
   },
   "patch": {
    "description": "يعدّل الاسم العربي والإنجليزي. Updates the Arabic/English names.",
    "parameters": [
     {
      "description": "معرّف رقمي",
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "example": {
        "name": "مشروبات",
        "name_en": "Drinks"
       },
       "schema": {
        "properties": {
         "id": {
          "description": "معرّف التصنيف (من الاستجابة)",
          "type": "number"
         },
         "name": {
          "description": "الاسم العربي (1–60)",
          "example": "مشروبات ساخنة",
          "type": "string"
         },
         "name_en": {
          "description": "الاسم الإنجليزي (بلس وبرو)",
          "type": "string"
         }
        },
        "required": [
         "name"
        ],
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "id": 1,
          "items_count": 4,
          "name": "مشروبات",
          "name_en": "Drinks",
          "position": 0
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "409": {
      "description": "تعارض / conflict (quota_exceeded, slug_taken, not_submitted, plan_required)"
     },
     "422": {
      "description": "تحقق / validation error"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "تعديل تصنيف / Update category",
    "tags": [
     "menu",
     "categories"
    ],
    "x-emm-app": "menu"
   },
   "servers": [
    {
     "description": "menu",
     "url": "https://menu.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "menu"
  },
  "/menu/api/v1/categories/{id}/move": {
   "post": {
    "description": "dir = up | down — يحرك التصنيف خطوة. Moves a category one step.",
    "parameters": [
     {
      "description": "معرّف رقمي",
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "example": {
        "dir": "up"
       },
       "schema": {
        "properties": {
         "dir": {
          "description": "up | down",
          "enum": [
           "up",
           "down"
          ],
          "example": "up",
          "type": "string"
         }
        },
        "required": [
         "dir"
        ],
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "id": 1,
          "items_count": 4,
          "name": "مشروبات",
          "name_en": "Drinks",
          "position": 0
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "201": {
      "description": "أُنشئ / created"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "409": {
      "description": "تعارض / conflict (quota_exceeded, slug_taken, not_submitted, plan_required)"
     },
     "422": {
      "description": "تحقق / validation error"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "تحريك تصنيف / Move category",
    "tags": [
     "menu",
     "categories"
    ],
    "x-emm-app": "menu"
   },
   "servers": [
    {
     "description": "menu",
     "url": "https://menu.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "menu"
  },
  "/menu/api/v1/items": {
   "get": {
    "description": "أصناف المنيو مع فلتر category_id وavailable والبحث q. Items with category/availability filters and search.",
    "parameters": [
     {
      "description": "فلتر التصنيف",
      "in": "query",
      "name": "category_id",
      "schema": {
       "type": "integer"
      }
     },
     {
      "description": "فلتر التوفر",
      "in": "query",
      "name": "available",
      "schema": {
       "type": "boolean"
      }
     },
     {
      "description": "بحث (العميل / الجوال / المرجع)",
      "in": "query",
      "name": "q",
      "schema": {
       "type": "string"
      }
     },
     {
      "description": "عدد النتائج (1–200، افتراضي 50)",
      "in": "query",
      "name": "limit",
      "schema": {
       "default": 50,
       "maximum": 200,
       "minimum": 1,
       "type": "integer"
      }
     },
     {
      "description": "تخطي النتائج",
      "in": "query",
      "name": "offset",
      "schema": {
       "default": 0,
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "الأصناف / Items",
    "tags": [
     "menu",
     "items"
    ],
    "x-emm-app": "menu"
   },
   "post": {
    "description": "يضيف صنفاً (ضمن حد الخطة) — السعر نص بالريال. Appends an item within the plan quota (409 quota_exceeded).",
    "requestBody": {
     "content": {
      "application/json": {
       "example": {
        "category_id": 1,
        "description": "حليب مبخّر وإسبريسو",
        "name": "لاتيه",
        "price": "14.00"
       },
       "schema": {
        "properties": {
         "available": {
          "description": "متوفر على المنيو العام (افتراضياً true)",
          "type": "boolean"
         },
         "category_id": {
          "description": "معرّف التصنيف",
          "example": "1",
          "type": "number"
         },
         "description": {
          "description": "وصف قصير (حتى 200)",
          "type": "string"
         },
         "id": {
          "description": "معرّف الصنف (من الاستجابة)",
          "type": "number"
         },
         "name": {
          "description": "الاسم العربي (1–80)",
          "example": "لاتيه",
          "type": "string"
         },
         "name_en": {
          "description": "الاسم الإنجليزي (بلس وبرو)",
          "type": "string"
         },
         "price": {
          "description": "السعر بالريال نص بمنزلتين",
          "example": "14.00",
          "type": "string"
         }
        },
        "required": [
         "category_id",
         "name",
         "price"
        ],
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "available": true,
          "category_id": 1,
          "category_name": "مشروبات",
          "currency": "SAR",
          "description": "",
          "id": 7,
          "image_url": "",
          "name": "لاتيه",
          "name_en": "Latte",
          "position": 0,
          "price": "14.00"
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "201": {
      "description": "أُنشئ / created"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "409": {
      "description": "تعارض / conflict (quota_exceeded, slug_taken, not_submitted, plan_required)"
     },
     "422": {
      "description": "تحقق / validation error"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "إضافة صنف / Add item",
    "tags": [
     "menu",
     "items"
    ],
    "x-emm-app": "menu"
   },
   "servers": [
    {
     "description": "menu",
     "url": "https://menu.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "menu"
  },
  "/menu/api/v1/items/{id}": {
   "delete": {
    "description": "يحذف الصنف (الطلبات السابقة تبقى). Deletes the item; past orders stay.",
    "parameters": [
     {
      "description": "معرّف رقمي",
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "data": {
           "deleted": true
          },
          "ok": true
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "409": {
      "description": "تعارض / conflict (quota_exceeded, slug_taken, not_submitted, plan_required)"
     },
     "422": {
      "description": "تحقق / validation error"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "حذف صنف / Delete item",
    "tags": [
     "menu",
     "items"
    ],
    "x-emm-app": "menu"
   },
   "get": {
    "description": "صنف واحد. One item.",
    "parameters": [
     {
      "description": "معرّف رقمي",
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "available": true,
          "category_id": 1,
          "category_name": "مشروبات",
          "currency": "SAR",
          "description": "",
          "id": 7,
          "image_url": "",
          "name": "لاتيه",
          "name_en": "Latte",
          "position": 0,
          "price": "14.00"
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "صنف / Item",
    "tags": [
     "menu",
     "items"
    ],
    "x-emm-app": "menu"
   },
   "patch": {
    "description": "تعديل جزئي للاسم والوصف والسعر والتصنيف والتوفر. Partial update of name, description, price, category and availability.",
    "parameters": [
     {
      "description": "معرّف رقمي",
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "example": {
        "available": false,
        "category_id": 0,
        "name": "",
        "price": "15.00"
       },
       "schema": {
        "properties": {
         "available": {
          "description": "متوفر على المنيو العام (افتراضياً true)",
          "type": "boolean"
         },
         "category_id": {
          "description": "معرّف التصنيف",
          "example": "1",
          "type": "number"
         },
         "description": {
          "description": "وصف قصير (حتى 200)",
          "type": "string"
         },
         "id": {
          "description": "معرّف الصنف (من الاستجابة)",
          "type": "number"
         },
         "name": {
          "description": "الاسم العربي (1–80)",
          "example": "لاتيه",
          "type": "string"
         },
         "name_en": {
          "description": "الاسم الإنجليزي (بلس وبرو)",
          "type": "string"
         },
         "price": {
          "description": "السعر بالريال نص بمنزلتين",
          "example": "14.00",
          "type": "string"
         }
        },
        "required": [
         "category_id",
         "name",
         "price"
        ],
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "available": true,
          "category_id": 1,
          "category_name": "مشروبات",
          "currency": "SAR",
          "description": "",
          "id": 7,
          "image_url": "",
          "name": "لاتيه",
          "name_en": "Latte",
          "position": 0,
          "price": "14.00"
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "409": {
      "description": "تعارض / conflict (quota_exceeded, slug_taken, not_submitted, plan_required)"
     },
     "422": {
      "description": "تحقق / validation error"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "تعديل صنف / Update item",
    "tags": [
     "menu",
     "items"
    ],
    "x-emm-app": "menu"
   },
   "servers": [
    {
     "description": "menu",
     "url": "https://menu.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "menu"
  },
  "/menu/api/v1/items/{id}/availability": {
   "post": {
    "description": "available: true|false — يُظهر/يخفي الصنف من المنيو العام فوراً. Shows/hides the item on the public menu immediately.",
    "parameters": [
     {
      "description": "معرّف رقمي",
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "example": {
        "available": false
       },
       "schema": {
        "properties": {
         "available": {
          "description": "true = متوفر، false = مخفي",
          "example": "false",
          "type": "boolean"
         }
        },
        "required": [
         "available"
        ],
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "available": true,
          "category_id": 1,
          "category_name": "مشروبات",
          "currency": "SAR",
          "description": "",
          "id": 7,
          "image_url": "",
          "name": "لاتيه",
          "name_en": "Latte",
          "position": 0,
          "price": "14.00"
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "201": {
      "description": "أُنشئ / created"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "409": {
      "description": "تعارض / conflict (quota_exceeded, slug_taken, not_submitted, plan_required)"
     },
     "422": {
      "description": "تحقق / validation error"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "توفر الصنف / Set availability",
    "tags": [
     "menu",
     "items"
    ],
    "x-emm-app": "menu"
   },
   "servers": [
    {
     "description": "menu",
     "url": "https://menu.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "menu"
  },
  "/menu/api/v1/me": {
   "get": {
    "description": "يتحقق من المفتاح ويعيد المستخدم والمطعم والخطة الحالية وحدود الأصناف والطلبات. Checks a key; returns user, restaurant, current plan and quotas.",
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "plan": {
           "annual": "450.00",
           "currency": "SAR",
           "features": {
            "api_mcp": true,
            "emm_badge": false,
            "english": true,
            "logo": true,
            "online_pay": true
           },
           "id": "plus",
           "limits": {
            "items": 0,
            "online_orders_per_month": 500
           },
           "name": "بلس",
           "period": "month",
           "price": "45.00"
          },
          "quotas": {
           "items": {
            "limit": 0,
            "used": 24
           },
           "online_orders": {
            "limit": 500,
            "month": "2026-12",
            "used": 12
           }
          },
          "restaurant": {
           "id": 3,
           "name": "مطعم الرياض",
           "online_pay": true,
           "public_url": "https://menu.emm.sa/m/riyadh-rest",
           "slug": "riyadh-rest"
          },
          "service": "menu",
          "user": {
           "email": "owner@example.com"
          }
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "الهوية والخطة والحدود / Identity, plan, quotas",
    "tags": [
     "menu",
     "me"
    ],
    "x-emm-app": "menu"
   },
   "servers": [
    {
     "description": "menu",
     "url": "https://menu.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "menu"
  },
  "/menu/api/v1/orders": {
   "get": {
    "description": "طلباتك مع فلاتر status وtype وfrom/to (YYYY-MM-DD) وq، والصفحات. Orders with status/type/date/search filters and pagination.",
    "parameters": [
     {
      "description": "فلتر الحالة",
      "in": "query",
      "name": "status",
      "schema": {
       "enum": [
        "new",
        "paid",
        "preparing",
        "ready",
        "delivered",
        "cancelled",
        "refunded"
       ],
       "type": "string"
      }
     },
     {
      "description": "فلتر النوع",
      "in": "query",
      "name": "type",
      "schema": {
       "enum": [
        "dinein",
        "pickup",
        "delivery"
       ],
       "type": "string"
      }
     },
     {
      "description": "من YYYY-MM-DD",
      "in": "query",
      "name": "from",
      "schema": {
       "format": "date",
       "type": "string"
      }
     },
     {
      "description": "إلى YYYY-MM-DD",
      "in": "query",
      "name": "to",
      "schema": {
       "format": "date",
       "type": "string"
      }
     },
     {
      "description": "بحث (العميل / الجوال / المرجع)",
      "in": "query",
      "name": "q",
      "schema": {
       "type": "string"
      }
     },
     {
      "description": "عدد النتائج (1–200، افتراضي 50)",
      "in": "query",
      "name": "limit",
      "schema": {
       "default": 50,
       "maximum": 200,
       "minimum": 1,
       "type": "integer"
      }
     },
     {
      "description": "تخطي النتائج",
      "in": "query",
      "name": "offset",
      "schema": {
       "default": 0,
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "الطلبات / Orders",
    "tags": [
     "menu",
     "orders"
    ],
    "x-emm-app": "menu"
   },
   "servers": [
    {
     "description": "menu",
     "url": "https://menu.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "menu"
  },
  "/menu/api/v1/orders/settlement.csv": {
   "get": {
    "description": "نفس تقرير اللوحة: الإجمالي والرسوم التقديرية والصافي لكل طلب مدفوع. Settlement report (gross, estimated fees, net).",
    "parameters": [
     {
      "description": "من YYYY-MM-DD",
      "in": "query",
      "name": "from",
      "schema": {
       "format": "date",
       "type": "string"
      }
     },
     {
      "description": "إلى YYYY-MM-DD",
      "in": "query",
      "name": "to",
      "schema": {
       "format": "date",
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "text/csv": {
        "example": "تقرير تسوية طلبات المنيو…\nرقم الطلب,المرجع,تاريخ الدفع,…",
        "schema": {
         "type": "string"
        }
       }
      },
      "description": "CSV / text/csv (BOM، عربي)"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "تقرير التسوية / Settlement CSV",
    "tags": [
     "menu",
     "orders"
    ],
    "x-emm-app": "menu"
   },
   "servers": [
    {
     "description": "menu",
     "url": "https://menu.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "menu"
  },
  "/menu/api/v1/orders/{id}": {
   "get": {
    "description": "طلب واحد بأصنافه وحالته والانتقالات المسموحة. One order with items, status and allowed next statuses.",
    "parameters": [
     {
      "description": "معرّف رقمي",
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "created_at": "2026-12-03T10:15:00+03:00",
          "currency": "SAR",
          "customer": {
           "name": "أحمد",
           "phone": "0500000001"
          },
          "id": 9,
          "items": [
           {
            "line_total": "14.00",
            "name": "لاتيه",
            "price": "14.00",
            "qty": 1
           }
          ],
          "next_statuses": [
           "preparing",
           "cancelled"
          ],
          "number": 12,
          "paid_at": "2026-12-03T10:16:02+03:00",
          "reference": "menu-ord-3-12",
          "refund_requested": "",
          "status": "paid",
          "status_ar": "مدفوع",
          "subtotal": "26.50",
          "table": "5",
          "total": "26.50",
          "type": "dinein",
          "type_ar": "داخل المطعم"
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "طلب / Order",
    "tags": [
     "menu",
     "orders"
    ],
    "x-emm-app": "menu"
   },
   "servers": [
    {
     "description": "menu",
     "url": "https://menu.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "menu"
  },
  "/menu/api/v1/orders/{id}/refund": {
   "post": {
    "description": "يسجّل طلب استرجاع لطلب مدفوع — التنفيذ يدوي من StreamPay. Records a refund request (manual execution).",
    "parameters": [
     {
      "description": "معرّف رقمي",
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "example": {
        "reason": "طلب خاطئ من العميل"
       },
       "schema": {
        "properties": {
         "reason": {
          "description": "سبب الاسترجاع (حتى 300)",
          "example": "طلب خاطئ من العميل",
          "type": "string"
         }
        },
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "created_at": "2026-12-03T10:15:00+03:00",
          "currency": "SAR",
          "customer": {
           "name": "أحمد",
           "phone": "0500000001"
          },
          "id": 9,
          "items": [
           {
            "line_total": "14.00",
            "name": "لاتيه",
            "price": "14.00",
            "qty": 1
           }
          ],
          "next_statuses": [
           "preparing",
           "cancelled"
          ],
          "number": 12,
          "paid_at": "2026-12-03T10:16:02+03:00",
          "reference": "menu-ord-3-12",
          "refund_requested": "",
          "status": "paid",
          "status_ar": "مدفوع",
          "subtotal": "26.50",
          "table": "5",
          "total": "26.50",
          "type": "dinein",
          "type_ar": "داخل المطعم"
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "201": {
      "description": "أُنشئ / created"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "409": {
      "description": "تعارض / conflict (quota_exceeded, slug_taken, not_submitted, plan_required)"
     },
     "422": {
      "description": "تحقق / validation error"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "طلب استرجاع / Refund request",
    "tags": [
     "menu",
     "orders"
    ],
    "x-emm-app": "menu"
   },
   "servers": [
    {
     "description": "menu",
     "url": "https://menu.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "menu"
  },
  "/menu/api/v1/orders/{id}/transition": {
   "post": {
    "description": "to: paid→preparing→ready→delivered (أو cancelled) — الانتقالات غير المسموحة 409. Moves an order through the state machine (409 bad_transition).",
    "parameters": [
     {
      "description": "معرّف رقمي",
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "example": {
        "to": "preparing"
       },
       "schema": {
        "properties": {
         "to": {
          "description": "الحالة الجديدة",
          "enum": [
           "paid",
           "preparing",
           "ready",
           "delivered",
           "cancelled"
          ],
          "example": "preparing",
          "type": "string"
         }
        },
        "required": [
         "to"
        ],
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "created_at": "2026-12-03T10:15:00+03:00",
          "currency": "SAR",
          "customer": {
           "name": "أحمد",
           "phone": "0500000001"
          },
          "id": 9,
          "items": [
           {
            "line_total": "14.00",
            "name": "لاتيه",
            "price": "14.00",
            "qty": 1
           }
          ],
          "next_statuses": [
           "preparing",
           "cancelled"
          ],
          "number": 12,
          "paid_at": "2026-12-03T10:16:02+03:00",
          "reference": "menu-ord-3-12",
          "refund_requested": "",
          "status": "paid",
          "status_ar": "مدفوع",
          "subtotal": "26.50",
          "table": "5",
          "total": "26.50",
          "type": "dinein",
          "type_ar": "داخل المطعم"
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "201": {
      "description": "أُنشئ / created"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "409": {
      "description": "تعارض / conflict (quota_exceeded, slug_taken, not_submitted, plan_required)"
     },
     "422": {
      "description": "تحقق / validation error"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "تغيير حالة / Transition",
    "tags": [
     "menu",
     "orders"
    ],
    "x-emm-app": "menu"
   },
   "servers": [
    {
     "description": "menu",
     "url": "https://menu.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "menu"
  },
  "/menu/api/v1/plan": {
   "get": {
    "description": "الخطة الحالية مع الاستهلاك وكل الخطط بأسعارها وحدودها (ر.س/شهر). Current plan with usage plus every plan (SAR/month).",
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "الخطة الحالية وكل الخطط / Current plan and catalogue",
    "tags": [
     "menu",
     "plan"
    ],
    "x-emm-app": "menu"
   },
   "servers": [
    {
     "description": "menu",
     "url": "https://menu.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "menu"
  },
  "/menu/api/v1/public-menu/{slug}": {
   "get": {
    "description": "ما يراه العميل في /m/{slug}: التصنيفات والأصناف المتوفرة وأسعارها. What customers see on /m/{slug}.",
    "parameters": [
     {
      "description": "رابط المنيو",
      "in": "path",
      "name": "slug",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "ask_table": true,
          "categories": [
           {
            "id": 1,
            "items": [
             {
              "id": 7,
              "name": "لاتيه",
              "price": "14.00"
             }
            ],
            "name": "مشروبات"
           }
          ],
          "currency": "SAR",
          "english": false,
          "name": "مطعم الرياض",
          "online_pay": true,
          "public_url": "https://menu.emm.sa/m/riyadh-rest",
          "slug": "riyadh-rest"
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "المنيو العام / Public menu",
    "tags": [
     "menu",
     "public-menu"
    ],
    "x-emm-app": "menu"
   },
   "servers": [
    {
     "description": "menu",
     "url": "https://menu.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "menu"
  },
  "/menu/api/v1/settings": {
   "get": {
    "description": "إعدادات المطعم: الاسم والهاتف والرابط وطلب رقم الطاولة والإنجليزية والدفع أونلاين. Restaurant settings.",
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "ask_table": true,
          "english": false,
          "name": "مطعم الرياض",
          "name_en": "",
          "online_pay": true,
          "online_pay_allowed": true,
          "phone": "0551234567",
          "public_url": "https://menu.emm.sa/m/riyadh-rest",
          "slug": "riyadh-rest"
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "الإعدادات / Settings",
    "tags": [
     "menu",
     "settings"
    ],
    "x-emm-app": "menu"
   },
   "put": {
    "description": "نفس تحقق صفحة الإعدادات؛ online_pay يتطلب خطتي بلس/برو (409 plan_required). Same validation as the settings page.",
    "requestBody": {
     "content": {
      "application/json": {
       "example": {
        "ask_table": true,
        "english": false,
        "name": "مطعم الرياض",
        "online_pay": true,
        "phone": "0551234567",
        "slug": "riyadh-rest"
       },
       "schema": {
        "properties": {
         "ask_table": {
          "description": "اطلب رقم الطاولة",
          "type": "boolean"
         },
         "english": {
          "description": "تفعيل الإنجليزية (بلس وبرو)",
          "type": "boolean"
         },
         "name": {
          "description": "اسم المطعم (2–60)",
          "example": "مطعم الرياض",
          "type": "string"
         },
         "name_en": {
          "description": "الاسم الإنجليزي (بلس وبرو)",
          "type": "string"
         },
         "online_pay": {
          "description": "قبول الدفع أونلاين (بلس وبرو فقط)",
          "type": "boolean"
         },
         "phone": {
          "description": "جوال واتساب للطلبات 05XXXXXXXX",
          "example": "0551234567",
          "type": "string"
         },
         "slug": {
          "description": "الرابط المختصر a-z0-9- (3–40)",
          "example": "riyadh-rest",
          "type": "string"
         }
        },
        "required": [
         "name"
        ],
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "ask_table": true,
          "english": false,
          "name": "مطعم الرياض",
          "name_en": "",
          "online_pay": true,
          "online_pay_allowed": true,
          "phone": "0551234567",
          "public_url": "https://menu.emm.sa/m/riyadh-rest",
          "slug": "riyadh-rest"
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "409": {
      "description": "تعارض / conflict (quota_exceeded, slug_taken, not_submitted, plan_required)"
     },
     "422": {
      "description": "تحقق / validation error"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "حفظ الإعدادات / Save settings",
    "tags": [
     "menu",
     "settings"
    ],
    "x-emm-app": "menu"
   },
   "servers": [
    {
     "description": "menu",
     "url": "https://menu.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "menu"
  },
  "/pdf/api/v1/esign/{id}/apply": {
   "post": {
    "description": "يضع التوقيع على الصفحة ويعيد المهمة مكتملة مع download_url وverify_url لسجل إثبات التوقيع.",
    "operationId": "pdf_post__api_v1_esign_id_apply",
    "parameters": [
     {
      "description": "رقم المهمة",
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "description": "",
       "type": "string"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "properties": {
         "name": {
          "description": "",
          "type": "string"
         },
         "page": {
          "description": "",
          "example": "1",
          "type": "integer"
         },
         "signature": {
          "description": "",
          "example": "data:image/png;base64,iVBORw0KGgo=",
          "type": "string"
         },
         "w": {
          "description": "",
          "example": "120",
          "type": "number"
         },
         "x": {
          "description": "",
          "example": "400",
          "type": "number"
         },
         "y": {
          "description": "",
          "example": "700",
          "type": "number"
         }
        },
        "required": [
         "page",
         "signature",
         "x",
         "y",
         "w"
        ],
        "type": "object"
       }
      },
      "multipart/form-data": {
       "schema": {
        "properties": {
         "name": {
          "description": "",
          "type": "string"
         },
         "page": {
          "description": "",
          "type": "integer"
         },
         "signature": {
          "description": "",
          "type": "string"
         },
         "w": {
          "description": "",
          "type": "number"
         },
         "x": {
          "description": "",
          "type": "number"
         },
         "y": {
          "description": "",
          "type": "number"
         }
        },
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "content": {
          "application/json": {
           "schema": {
            "properties": {
             "data": {
              "properties": {
               "apply_url": {
                "description": "",
                "type": "string"
               },
               "created_at": {
                "description": "",
                "format": "date-time",
                "type": "string"
               },
               "download_url": {
                "description": "",
                "example": "https://pdf.emm.sa/api/v1/jobs/k3Jd8QzLmPq2Rv/download",
                "type": "string"
               },
               "error": {
                "description": "",
                "type": "string"
               },
               "expires_at": {
                "description": "",
                "format": "date-time",
                "type": "string"
               },
               "id": {
                "description": "",
                "example": "k3Jd8QzLmPq2Rv",
                "type": "string"
               },
               "output_name": {
                "description": "",
                "example": "merged.pdf",
                "type": "string"
               },
               "pages_in": {
                "description": "",
                "type": "integer"
               },
               "pages_out": {
                "description": "",
                "type": "integer"
               },
               "preview_url_pattern": {
                "description": "",
                "type": "string"
               },
               "previews": {
                "description": "",
                "type": "integer"
               },
               "size_bytes": {
                "description": "",
                "type": "integer"
               },
               "status": {
                "description": "",
                "enum": [
                 "draft",
                 "done",
                 "expired"
                ],
                "example": "done",
                "type": "string"
               },
               "tool": {
                "description": "",
                "example": "merge",
                "type": "string"
               },
               "verify_url": {
                "description": "",
                "type": "string"
               }
              },
              "type": "object"
             },
             "ok": {
              "description": "",
              "type": "boolean"
             }
            },
            "required": [
             "ok",
             "data"
            ],
            "type": "object"
           }
          }
         },
         "description": "OK"
        }
       }
      },
      "description": "OK"
     },
     "400": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "error": {
           "properties": {
            "code": {
             "description": "",
             "example": "validation",
             "type": "string"
            },
            "message": {
             "description": "",
             "example": "نص عربي",
             "type": "string"
            }
           },
           "type": "object"
          },
          "ok": {
           "description": "",
           "example": "false",
           "type": "boolean"
          }
         },
         "required": [
          "ok",
          "error"
         ],
         "type": "object"
        }
       }
      },
      "description": "خطأ"
     },
     "401": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "error": {
           "properties": {
            "code": {
             "description": "",
             "example": "unauthorized",
             "type": "string"
            },
            "message": {
             "description": "",
             "example": "نص عربي",
             "type": "string"
            }
           },
           "type": "object"
          },
          "ok": {
           "description": "",
           "example": "false",
           "type": "boolean"
          }
         },
         "required": [
          "ok",
          "error"
         ],
         "type": "object"
        }
       }
      },
      "description": "خطأ"
     },
     "403": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "error": {
           "properties": {
            "code": {
             "description": "",
             "example": "forbidden",
             "type": "string"
            },
            "message": {
             "description": "",
             "example": "نص عربي",
             "type": "string"
            }
           },
           "type": "object"
          },
          "ok": {
           "description": "",
           "example": "false",
           "type": "boolean"
          }
         },
         "required": [
          "ok",
          "error"
         ],
         "type": "object"
        }
       }
      },
      "description": "خطأ"
     },
     "404": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "error": {
           "properties": {
            "code": {
             "description": "",
             "example": "not_found",
             "type": "string"
            },
            "message": {
             "description": "",
             "example": "نص عربي",
             "type": "string"
            }
           },
           "type": "object"
          },
          "ok": {
           "description": "",
           "example": "false",
           "type": "boolean"
          }
         },
         "required": [
          "ok",
          "error"
         ],
         "type": "object"
        }
       }
      },
      "description": "خطأ"
     },
     "409": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "error": {
           "properties": {
            "code": {
             "description": "",
             "example": "not_ready",
             "type": "string"
            },
            "message": {
             "description": "",
             "example": "نص عربي",
             "type": "string"
            }
           },
           "type": "object"
          },
          "ok": {
           "description": "",
           "example": "false",
           "type": "boolean"
          }
         },
         "required": [
          "ok",
          "error"
         ],
         "type": "object"
        }
       }
      },
      "description": "خطأ"
     },
     "429": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "error": {
           "properties": {
            "code": {
             "description": "",
             "example": "rate_limited",
             "type": "string"
            },
            "message": {
             "description": "",
             "example": "نص عربي",
             "type": "string"
            }
           },
           "type": "object"
          },
          "ok": {
           "description": "",
           "example": "false",
           "type": "boolean"
          }
         },
         "required": [
          "ok",
          "error"
         ],
         "type": "object"
        }
       }
      },
      "description": "خطأ"
     },
     "500": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "error": {
           "properties": {
            "code": {
             "description": "",
             "example": "internal_error",
             "type": "string"
            },
            "message": {
             "description": "",
             "example": "نص عربي",
             "type": "string"
            }
           },
           "type": "object"
          },
          "ok": {
           "description": "",
           "example": "false",
           "type": "boolean"
          }
         },
         "required": [
          "ok",
          "error"
         ],
         "type": "object"
        }
       }
      },
      "description": "خطأ"
     }
    },
    "security": [
     {
      "bearer": []
     },
     {
      "apiKey": []
     }
    ],
    "summary": "",
    "tags": [
     "pdf",
     "esign"
    ],
    "x-emm-app": "pdf"
   },
   "servers": [
    {
     "description": "pdf",
     "url": "https://pdf.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "pdf"
  },
  "/pdf/api/v1/esign/{id}/preview/{page}": {
   "get": {
    "description": "صورة PNG لصفحة المسودة (1-based) لتحديد موضع التوقيع.",
    "operationId": "pdf_get__api_v1_esign_id_preview_page",
    "parameters": [
     {
      "description": "رقم المهمة",
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "description": "",
       "type": "string"
      }
     },
     {
      "description": "رقم الصفحة 1-based",
      "in": "path",
      "name": "page",
      "required": true,
      "schema": {
       "description": "",
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "format": "binary",
         "type": "string"
        }
       }
      },
      "description": "OK"
     },
     "400": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "error": {
           "properties": {
            "code": {
             "description": "",
             "example": "validation",
             "type": "string"
            },
            "message": {
             "description": "",
             "example": "نص عربي",
             "type": "string"
            }
           },
           "type": "object"
          },
          "ok": {
           "description": "",
           "example": "false",
           "type": "boolean"
          }
         },
         "required": [
          "ok",
          "error"
         ],
         "type": "object"
        }
       }
      },
      "description": "خطأ"
     },
     "401": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "error": {
           "properties": {
            "code": {
             "description": "",
             "example": "unauthorized",
             "type": "string"
            },
            "message": {
             "description": "",
             "example": "نص عربي",
             "type": "string"
            }
           },
           "type": "object"
          },
          "ok": {
           "description": "",
           "example": "false",
           "type": "boolean"
          }
         },
         "required": [
          "ok",
          "error"
         ],
         "type": "object"
        }
       }
      },
      "description": "خطأ"
     },
     "403": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "error": {
           "properties": {
            "code": {
             "description": "",
             "example": "forbidden",
             "type": "string"
            },
            "message": {
             "description": "",
             "example": "نص عربي",
             "type": "string"
            }
           },
           "type": "object"
          },
          "ok": {
           "description": "",
           "example": "false",
           "type": "boolean"
          }
         },
         "required": [
          "ok",
          "error"
         ],
         "type": "object"
        }
       }
      },
      "description": "خطأ"
     },
     "404": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "error": {
           "properties": {
            "code": {
             "description": "",
             "example": "not_found",
             "type": "string"
            },
            "message": {
             "description": "",
             "example": "نص عربي",
             "type": "string"
            }
           },
           "type": "object"
          },
          "ok": {
           "description": "",
           "example": "false",
           "type": "boolean"
          }
         },
         "required": [
          "ok",
          "error"
         ],
         "type": "object"
        }
       }
      },
      "description": "خطأ"
     },
     "429": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "error": {
           "properties": {
            "code": {
             "description": "",
             "example": "rate_limited",
             "type": "string"
            },
            "message": {
             "description": "",
             "example": "نص عربي",
             "type": "string"
            }
           },
           "type": "object"
          },
          "ok": {
           "description": "",
           "example": "false",
           "type": "boolean"
          }
         },
         "required": [
          "ok",
          "error"
         ],
         "type": "object"
        }
       }
      },
      "description": "خطأ"
     },
     "500": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "error": {
           "properties": {
            "code": {
             "description": "",
             "example": "internal_error",
             "type": "string"
            },
            "message": {
             "description": "",
             "example": "نص عربي",
             "type": "string"
            }
           },
           "type": "object"
          },
          "ok": {
           "description": "",
           "example": "false",
           "type": "boolean"
          }
         },
         "required": [
          "ok",
          "error"
         ],
         "type": "object"
        }
       }
      },
      "description": "خطأ"
     }
    },
    "security": [
     {
      "bearer": []
     },
     {
      "apiKey": []
     }
    ],
    "summary": "معاينة صفحة للتوقيع",
    "tags": [
     "pdf",
     "esign"
    ],
    "x-emm-app": "pdf"
   },
   "servers": [
    {
     "description": "pdf",
     "url": "https://pdf.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "pdf"
  },
  "/pdf/api/v1/jobs": {
   "get": {
    "description": "قائمة مهام الحساب (?limit=50\u0026offset=0) مع الحالة ورابط التحميل ووقت الانتهاء.",
    "operationId": "pdf_get__api_v1_jobs",
    "parameters": [
     {
      "description": "عدد النتائج 1-200 (افتراضي 200)",
      "in": "query",
      "name": "limit",
      "required": false,
      "schema": {
       "description": "",
       "example": "50",
       "type": "integer"
      }
     },
     {
      "description": "إزاحة الترحيل",
      "in": "query",
      "name": "offset",
      "required": false,
      "schema": {
       "description": "",
       "example": "0",
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "content": {
          "application/json": {
           "schema": {
            "properties": {
             "data": {
              "properties": {
               "items": {
                "items": {
                 "properties": {
                  "apply_url": {
                   "description": "",
                   "type": "string"
                  },
                  "created_at": {
                   "description": "",
                   "format": "date-time",
                   "type": "string"
                  },
                  "download_url": {
                   "description": "",
                   "example": "https://pdf.emm.sa/api/v1/jobs/k3Jd8QzLmPq2Rv/download",
                   "type": "string"
                  },
                  "error": {
                   "description": "",
                   "type": "string"
                  },
                  "expires_at": {
                   "description": "",
                   "format": "date-time",
                   "type": "string"
                  },
                  "id": {
                   "description": "",
                   "example": "k3Jd8QzLmPq2Rv",
                   "type": "string"
                  },
                  "output_name": {
                   "description": "",
                   "example": "merged.pdf",
                   "type": "string"
                  },
                  "pages_in": {
                   "description": "",
                   "type": "integer"
                  },
                  "pages_out": {
                   "description": "",
                   "type": "integer"
                  },
                  "preview_url_pattern": {
                   "description": "",
                   "type": "string"
                  },
                  "previews": {
                   "description": "",
                   "type": "integer"
                  },
                  "size_bytes": {
                   "description": "",
                   "type": "integer"
                  },
                  "status": {
                   "description": "",
                   "enum": [
                    "draft",
                    "done",
                    "expired"
                   ],
                   "example": "done",
                   "type": "string"
                  },
                  "tool": {
                   "description": "",
                   "example": "merge",
                   "type": "string"
                  },
                  "verify_url": {
                   "description": "",
                   "type": "string"
                  }
                 },
                 "type": "object"
                },
                "type": "array"
               },
               "limit": {
                "description": "",
                "example": "50",
                "type": "integer"
               },
               "offset": {
                "description": "",
                "example": "0",
                "type": "integer"
               },
               "total": {
                "description": "",
                "type": "integer"
               }
              },
              "required": [
               "items",
               "total"
              ],
              "type": "object"
             },
             "ok": {
              "description": "",
              "type": "boolean"
             }
            },
            "required": [
             "ok",
             "data"
            ],
            "type": "object"
           }
          }
         },
         "description": "OK"
        }
       }
      },
      "description": "OK"
     },
     "400": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "error": {
           "properties": {
            "code": {
             "description": "",
             "example": "validation",
             "type": "string"
            },
            "message": {
             "description": "",
             "example": "نص عربي",
             "type": "string"
            }
           },
           "type": "object"
          },
          "ok": {
           "description": "",
           "example": "false",
           "type": "boolean"
          }
         },
         "required": [
          "ok",
          "error"
         ],
         "type": "object"
        }
       }
      },
      "description": "خطأ"
     },
     "401": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "error": {
           "properties": {
            "code": {
             "description": "",
             "example": "unauthorized",
             "type": "string"
            },
            "message": {
             "description": "",
             "example": "نص عربي",
             "type": "string"
            }
           },
           "type": "object"
          },
          "ok": {
           "description": "",
           "example": "false",
           "type": "boolean"
          }
         },
         "required": [
          "ok",
          "error"
         ],
         "type": "object"
        }
       }
      },
      "description": "خطأ"
     },
     "403": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "error": {
           "properties": {
            "code": {
             "description": "",
             "example": "forbidden",
             "type": "string"
            },
            "message": {
             "description": "",
             "example": "نص عربي",
             "type": "string"
            }
           },
           "type": "object"
          },
          "ok": {
           "description": "",
           "example": "false",
           "type": "boolean"
          }
         },
         "required": [
          "ok",
          "error"
         ],
         "type": "object"
        }
       }
      },
      "description": "خطأ"
     },
     "429": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "error": {
           "properties": {
            "code": {
             "description": "",
             "example": "rate_limited",
             "type": "string"
            },
            "message": {
             "description": "",
             "example": "نص عربي",
             "type": "string"
            }
           },
           "type": "object"
          },
          "ok": {
           "description": "",
           "example": "false",
           "type": "boolean"
          }
         },
         "required": [
          "ok",
          "error"
         ],
         "type": "object"
        }
       }
      },
      "description": "خطأ"
     },
     "500": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "error": {
           "properties": {
            "code": {
             "description": "",
             "example": "internal_error",
             "type": "string"
            },
            "message": {
             "description": "",
             "example": "نص عربي",
             "type": "string"
            }
           },
           "type": "object"
          },
          "ok": {
           "description": "",
           "example": "false",
           "type": "boolean"
          }
         },
         "required": [
          "ok",
          "error"
         ],
         "type": "object"
        }
       }
      },
      "description": "خطأ"
     }
    },
    "security": [
     {
      "bearer": []
     },
     {
      "apiKey": []
     }
    ],
    "summary": "مهامي",
    "tags": [
     "pdf",
     "jobs"
    ],
    "x-emm-app": "pdf"
   },
   "servers": [
    {
     "description": "pdf",
     "url": "https://pdf.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "pdf"
  },
  "/pdf/api/v1/jobs/{id}": {
   "get": {
    "description": "حالة المهمة (draft | done | expired) ورابط التحميل.",
    "operationId": "pdf_get__api_v1_jobs_id",
    "parameters": [
     {
      "description": "رقم المهمة",
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "description": "",
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "content": {
          "application/json": {
           "schema": {
            "properties": {
             "data": {
              "properties": {
               "apply_url": {
                "description": "",
                "type": "string"
               },
               "created_at": {
                "description": "",
                "format": "date-time",
                "type": "string"
               },
               "download_url": {
                "description": "",
                "example": "https://pdf.emm.sa/api/v1/jobs/k3Jd8QzLmPq2Rv/download",
                "type": "string"
               },
               "error": {
                "description": "",
                "type": "string"
               },
               "expires_at": {
                "description": "",
                "format": "date-time",
                "type": "string"
               },
               "id": {
                "description": "",
                "example": "k3Jd8QzLmPq2Rv",
                "type": "string"
               },
               "output_name": {
                "description": "",
                "example": "merged.pdf",
                "type": "string"
               },
               "pages_in": {
                "description": "",
                "type": "integer"
               },
               "pages_out": {
                "description": "",
                "type": "integer"
               },
               "preview_url_pattern": {
                "description": "",
                "type": "string"
               },
               "previews": {
                "description": "",
                "type": "integer"
               },
               "size_bytes": {
                "description": "",
                "type": "integer"
               },
               "status": {
                "description": "",
                "enum": [
                 "draft",
                 "done",
                 "expired"
                ],
                "example": "done",
                "type": "string"
               },
               "tool": {
                "description": "",
                "example": "merge",
                "type": "string"
               },
               "verify_url": {
                "description": "",
                "type": "string"
               }
              },
              "type": "object"
             },
             "ok": {
              "description": "",
              "type": "boolean"
             }
            },
            "required": [
             "ok",
             "data"
            ],
            "type": "object"
           }
          }
         },
         "description": "OK"
        }
       }
      },
      "description": "OK"
     },
     "400": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "error": {
           "properties": {
            "code": {
             "description": "",
             "example": "validation",
             "type": "string"
            },
            "message": {
             "description": "",
             "example": "نص عربي",
             "type": "string"
            }
           },
           "type": "object"
          },
          "ok": {
           "description": "",
           "example": "false",
           "type": "boolean"
          }
         },
         "required": [
          "ok",
          "error"
         ],
         "type": "object"
        }
       }
      },
      "description": "خطأ"
     },
     "401": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "error": {
           "properties": {
            "code": {
             "description": "",
             "example": "unauthorized",
             "type": "string"
            },
            "message": {
             "description": "",
             "example": "نص عربي",
             "type": "string"
            }
           },
           "type": "object"
          },
          "ok": {
           "description": "",
           "example": "false",
           "type": "boolean"
          }
         },
         "required": [
          "ok",
          "error"
         ],
         "type": "object"
        }
       }
      },
      "description": "خطأ"
     },
     "403": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "error": {
           "properties": {
            "code": {
             "description": "",
             "example": "forbidden",
             "type": "string"
            },
            "message": {
             "description": "",
             "example": "نص عربي",
             "type": "string"
            }
           },
           "type": "object"
          },
          "ok": {
           "description": "",
           "example": "false",
           "type": "boolean"
          }
         },
         "required": [
          "ok",
          "error"
         ],
         "type": "object"
        }
       }
      },
      "description": "خطأ"
     },
     "404": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "error": {
           "properties": {
            "code": {
             "description": "",
             "example": "not_found",
             "type": "string"
            },
            "message": {
             "description": "",
             "example": "نص عربي",
             "type": "string"
            }
           },
           "type": "object"
          },
          "ok": {
           "description": "",
           "example": "false",
           "type": "boolean"
          }
         },
         "required": [
          "ok",
          "error"
         ],
         "type": "object"
        }
       }
      },
      "description": "خطأ"
     },
     "429": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "error": {
           "properties": {
            "code": {
             "description": "",
             "example": "rate_limited",
             "type": "string"
            },
            "message": {
             "description": "",
             "example": "نص عربي",
             "type": "string"
            }
           },
           "type": "object"
          },
          "ok": {
           "description": "",
           "example": "false",
           "type": "boolean"
          }
         },
         "required": [
          "ok",
          "error"
         ],
         "type": "object"
        }
       }
      },
      "description": "خطأ"
     },
     "500": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "error": {
           "properties": {
            "code": {
             "description": "",
             "example": "internal_error",
             "type": "string"
            },
            "message": {
             "description": "",
             "example": "نص عربي",
             "type": "string"
            }
           },
           "type": "object"
          },
          "ok": {
           "description": "",
           "example": "false",
           "type": "boolean"
          }
         },
         "required": [
          "ok",
          "error"
         ],
         "type": "object"
        }
       }
      },
      "description": "خطأ"
     }
    },
    "security": [
     {
      "bearer": []
     },
     {
      "apiKey": []
     }
    ],
    "summary": "مهمة واحدة",
    "tags": [
     "pdf",
     "jobs"
    ],
    "x-emm-app": "pdf"
   },
   "servers": [
    {
     "description": "pdf",
     "url": "https://pdf.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "pdf"
  },
  "/pdf/api/v1/jobs/{id}/download": {
   "get": {
    "description": "الملف الثنائي (application/octet-stream). التحميل يبدأ ساعة الاحتفاظ: يُحذف بعد 60 دقيقة (24 ساعة كحد أقصى إن لم يُحمّل).",
    "operationId": "pdf_get__api_v1_jobs_id_download",
    "parameters": [
     {
      "description": "رقم المهمة",
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "description": "",
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "format": "binary",
         "type": "string"
        }
       }
      },
      "description": "OK"
     },
     "400": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "error": {
           "properties": {
            "code": {
             "description": "",
             "example": "validation",
             "type": "string"
            },
            "message": {
             "description": "",
             "example": "نص عربي",
             "type": "string"
            }
           },
           "type": "object"
          },
          "ok": {
           "description": "",
           "example": "false",
           "type": "boolean"
          }
         },
         "required": [
          "ok",
          "error"
         ],
         "type": "object"
        }
       }
      },
      "description": "خطأ"
     },
     "401": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "error": {
           "properties": {
            "code": {
             "description": "",
             "example": "unauthorized",
             "type": "string"
            },
            "message": {
             "description": "",
             "example": "نص عربي",
             "type": "string"
            }
           },
           "type": "object"
          },
          "ok": {
           "description": "",
           "example": "false",
           "type": "boolean"
          }
         },
         "required": [
          "ok",
          "error"
         ],
         "type": "object"
        }
       }
      },
      "description": "خطأ"
     },
     "403": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "error": {
           "properties": {
            "code": {
             "description": "",
             "example": "forbidden",
             "type": "string"
            },
            "message": {
             "description": "",
             "example": "نص عربي",
             "type": "string"
            }
           },
           "type": "object"
          },
          "ok": {
           "description": "",
           "example": "false",
           "type": "boolean"
          }
         },
         "required": [
          "ok",
          "error"
         ],
         "type": "object"
        }
       }
      },
      "description": "خطأ"
     },
     "404": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "error": {
           "properties": {
            "code": {
             "description": "",
             "example": "not_found",
             "type": "string"
            },
            "message": {
             "description": "",
             "example": "نص عربي",
             "type": "string"
            }
           },
           "type": "object"
          },
          "ok": {
           "description": "",
           "example": "false",
           "type": "boolean"
          }
         },
         "required": [
          "ok",
          "error"
         ],
         "type": "object"
        }
       }
      },
      "description": "خطأ"
     },
     "409": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "error": {
           "properties": {
            "code": {
             "description": "",
             "example": "not_ready",
             "type": "string"
            },
            "message": {
             "description": "",
             "example": "نص عربي",
             "type": "string"
            }
           },
           "type": "object"
          },
          "ok": {
           "description": "",
           "example": "false",
           "type": "boolean"
          }
         },
         "required": [
          "ok",
          "error"
         ],
         "type": "object"
        }
       }
      },
      "description": "خطأ"
     },
     "410": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "error": {
           "properties": {
            "code": {
             "description": "",
             "example": "expired",
             "type": "string"
            },
            "message": {
             "description": "",
             "example": "نص عربي",
             "type": "string"
            }
           },
           "type": "object"
          },
          "ok": {
           "description": "",
           "example": "false",
           "type": "boolean"
          }
         },
         "required": [
          "ok",
          "error"
         ],
         "type": "object"
        }
       }
      },
      "description": "خطأ"
     },
     "429": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "error": {
           "properties": {
            "code": {
             "description": "",
             "example": "rate_limited",
             "type": "string"
            },
            "message": {
             "description": "",
             "example": "نص عربي",
             "type": "string"
            }
           },
           "type": "object"
          },
          "ok": {
           "description": "",
           "example": "false",
           "type": "boolean"
          }
         },
         "required": [
          "ok",
          "error"
         ],
         "type": "object"
        }
       }
      },
      "description": "خطأ"
     },
     "500": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "error": {
           "properties": {
            "code": {
             "description": "",
             "example": "internal_error",
             "type": "string"
            },
            "message": {
             "description": "",
             "example": "نص عربي",
             "type": "string"
            }
           },
           "type": "object"
          },
          "ok": {
           "description": "",
           "example": "false",
           "type": "boolean"
          }
         },
         "required": [
          "ok",
          "error"
         ],
         "type": "object"
        }
       }
      },
      "description": "خطأ"
     }
    },
    "security": [
     {
      "bearer": []
     },
     {
      "apiKey": []
     }
    ],
    "summary": "تحميل النتيجة",
    "tags": [
     "pdf",
     "jobs"
    ],
    "x-emm-app": "pdf"
   },
   "servers": [
    {
     "description": "pdf",
     "url": "https://pdf.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "pdf"
  },
  "/pdf/api/v1/me": {
   "get": {
    "description": "يعيد المستخدم والخطة الحالية والحدود (الأسعار نص بالريال، رقمين عشريين) والاستخدام اليومي. استخدمه لاختبار مفتاحك.",
    "operationId": "pdf_get__api_v1_me",
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "content": {
          "application/json": {
           "schema": {
            "properties": {
             "data": {
              "properties": {
               "ocr_available": {
                "description": "",
                "type": "boolean"
               },
               "plan": {
                "properties": {
                 "currency": {
                  "description": "",
                  "example": "SAR",
                  "type": "string"
                 },
                 "features": {
                  "items": {
                   "description": "",
                   "type": "string"
                  },
                  "type": "array"
                 },
                 "id": {
                  "description": "",
                  "enum": [
                   "free",
                   "pro",
                   "team"
                  ],
                  "type": "string"
                 },
                 "interval": {
                  "description": "",
                  "example": "month",
                  "type": "string"
                 },
                 "limits": {
                  "type": "object"
                 },
                 "name": {
                  "description": "",
                  "type": "string"
                 },
                 "price": {
                  "description": "",
                  "example": "19.00",
                  "type": "string"
                 }
                },
                "type": "object"
               },
               "quotas": {
                "properties": {
                 "daily_tasks": {
                  "description": "",
                  "type": "integer"
                 },
                 "max_files_per_task": {
                  "description": "",
                  "type": "integer"
                 },
                 "max_pages_per_pdf": {
                  "description": "",
                  "type": "integer"
                 },
                 "max_upload_bytes": {
                  "description": "",
                  "type": "integer"
                 },
                 "retention_minutes": {
                  "description": "",
                  "example": "60",
                  "type": "integer"
                 },
                 "tasks_used_today": {
                  "description": "",
                  "type": "integer"
                 }
                },
                "type": "object"
               },
               "user": {
                "properties": {
                 "email": {
                  "description": "",
                  "example": "user@example.sa",
                  "format": "email",
                  "type": "string"
                 },
                 "id": {
                  "description": "",
                  "example": "1",
                  "type": "integer"
                 }
                },
                "type": "object"
               }
              },
              "type": "object"
             },
             "ok": {
              "description": "",
              "type": "boolean"
             }
            },
            "required": [
             "ok",
             "data"
            ],
            "type": "object"
           }
          }
         },
         "description": "OK"
        }
       }
      },
      "description": "OK"
     },
     "400": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "error": {
           "properties": {
            "code": {
             "description": "",
             "example": "validation",
             "type": "string"
            },
            "message": {
             "description": "",
             "example": "نص عربي",
             "type": "string"
            }
           },
           "type": "object"
          },
          "ok": {
           "description": "",
           "example": "false",
           "type": "boolean"
          }
         },
         "required": [
          "ok",
          "error"
         ],
         "type": "object"
        }
       }
      },
      "description": "خطأ"
     },
     "401": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "error": {
           "properties": {
            "code": {
             "description": "",
             "example": "unauthorized",
             "type": "string"
            },
            "message": {
             "description": "",
             "example": "نص عربي",
             "type": "string"
            }
           },
           "type": "object"
          },
          "ok": {
           "description": "",
           "example": "false",
           "type": "boolean"
          }
         },
         "required": [
          "ok",
          "error"
         ],
         "type": "object"
        }
       }
      },
      "description": "خطأ"
     },
     "403": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "error": {
           "properties": {
            "code": {
             "description": "",
             "example": "forbidden",
             "type": "string"
            },
            "message": {
             "description": "",
             "example": "نص عربي",
             "type": "string"
            }
           },
           "type": "object"
          },
          "ok": {
           "description": "",
           "example": "false",
           "type": "boolean"
          }
         },
         "required": [
          "ok",
          "error"
         ],
         "type": "object"
        }
       }
      },
      "description": "خطأ"
     },
     "429": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "error": {
           "properties": {
            "code": {
             "description": "",
             "example": "rate_limited",
             "type": "string"
            },
            "message": {
             "description": "",
             "example": "نص عربي",
             "type": "string"
            }
           },
           "type": "object"
          },
          "ok": {
           "description": "",
           "example": "false",
           "type": "boolean"
          }
         },
         "required": [
          "ok",
          "error"
         ],
         "type": "object"
        }
       }
      },
      "description": "خطأ"
     },
     "500": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "error": {
           "properties": {
            "code": {
             "description": "",
             "example": "internal_error",
             "type": "string"
            },
            "message": {
             "description": "",
             "example": "نص عربي",
             "type": "string"
            }
           },
           "type": "object"
          },
          "ok": {
           "description": "",
           "example": "false",
           "type": "boolean"
          }
         },
         "required": [
          "ok",
          "error"
         ],
         "type": "object"
        }
       }
      },
      "description": "خطأ"
     }
    },
    "security": [
     {
      "bearer": []
     },
     {
      "apiKey": []
     }
    ],
    "summary": "الحساب والخطة والحدود",
    "tags": [
     "pdf",
     "account"
    ],
    "x-emm-app": "pdf"
   },
   "servers": [
    {
     "description": "pdf",
     "url": "https://pdf.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "pdf"
  },
  "/pdf/api/v1/plan": {
   "get": {
    "description": "الخطة الحالية وكل الخطط (SAR/شهر، نهائية بلا ضريبة) ورابط الدفع.",
    "operationId": "pdf_get__api_v1_plan",
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "content": {
          "application/json": {
           "schema": {
            "properties": {
             "data": {
              "properties": {
               "currency": {
                "description": "",
                "example": "SAR",
                "type": "string"
               },
               "current": {
                "properties": {
                 "currency": {
                  "description": "",
                  "example": "SAR",
                  "type": "string"
                 },
                 "features": {
                  "items": {
                   "description": "",
                   "type": "string"
                  },
                  "type": "array"
                 },
                 "id": {
                  "description": "",
                  "enum": [
                   "free",
                   "pro",
                   "team"
                  ],
                  "type": "string"
                 },
                 "interval": {
                  "description": "",
                  "example": "month",
                  "type": "string"
                 },
                 "limits": {
                  "type": "object"
                 },
                 "name": {
                  "description": "",
                  "type": "string"
                 },
                 "price": {
                  "description": "",
                  "example": "19.00",
                  "type": "string"
                 }
                },
                "type": "object"
               },
               "pay_at": {
                "description": "",
                "type": "string"
               },
               "plans": {
                "items": {
                 "properties": {
                  "currency": {
                   "description": "",
                   "example": "SAR",
                   "type": "string"
                  },
                  "features": {
                   "items": {
                    "description": "",
                    "type": "string"
                   },
                   "type": "array"
                  },
                  "id": {
                   "description": "",
                   "enum": [
                    "free",
                    "pro",
                    "team"
                   ],
                   "type": "string"
                  },
                  "interval": {
                   "description": "",
                   "example": "month",
                   "type": "string"
                  },
                  "limits": {
                   "type": "object"
                  },
                  "name": {
                   "description": "",
                   "type": "string"
                  },
                  "price": {
                   "description": "",
                   "example": "19.00",
                   "type": "string"
                  }
                 },
                 "type": "object"
                },
                "type": "array"
               },
               "vat": {
                "description": "",
                "type": "string"
               }
              },
              "type": "object"
             },
             "ok": {
              "description": "",
              "type": "boolean"
             }
            },
            "required": [
             "ok",
             "data"
            ],
            "type": "object"
           }
          }
         },
         "description": "OK"
        }
       }
      },
      "description": "OK"
     },
     "400": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "error": {
           "properties": {
            "code": {
             "description": "",
             "example": "validation",
             "type": "string"
            },
            "message": {
             "description": "",
             "example": "نص عربي",
             "type": "string"
            }
           },
           "type": "object"
          },
          "ok": {
           "description": "",
           "example": "false",
           "type": "boolean"
          }
         },
         "required": [
          "ok",
          "error"
         ],
         "type": "object"
        }
       }
      },
      "description": "خطأ"
     },
     "401": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "error": {
           "properties": {
            "code": {
             "description": "",
             "example": "unauthorized",
             "type": "string"
            },
            "message": {
             "description": "",
             "example": "نص عربي",
             "type": "string"
            }
           },
           "type": "object"
          },
          "ok": {
           "description": "",
           "example": "false",
           "type": "boolean"
          }
         },
         "required": [
          "ok",
          "error"
         ],
         "type": "object"
        }
       }
      },
      "description": "خطأ"
     },
     "403": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "error": {
           "properties": {
            "code": {
             "description": "",
             "example": "forbidden",
             "type": "string"
            },
            "message": {
             "description": "",
             "example": "نص عربي",
             "type": "string"
            }
           },
           "type": "object"
          },
          "ok": {
           "description": "",
           "example": "false",
           "type": "boolean"
          }
         },
         "required": [
          "ok",
          "error"
         ],
         "type": "object"
        }
       }
      },
      "description": "خطأ"
     },
     "429": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "error": {
           "properties": {
            "code": {
             "description": "",
             "example": "rate_limited",
             "type": "string"
            },
            "message": {
             "description": "",
             "example": "نص عربي",
             "type": "string"
            }
           },
           "type": "object"
          },
          "ok": {
           "description": "",
           "example": "false",
           "type": "boolean"
          }
         },
         "required": [
          "ok",
          "error"
         ],
         "type": "object"
        }
       }
      },
      "description": "خطأ"
     },
     "500": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "error": {
           "properties": {
            "code": {
             "description": "",
             "example": "internal_error",
             "type": "string"
            },
            "message": {
             "description": "",
             "example": "نص عربي",
             "type": "string"
            }
           },
           "type": "object"
          },
          "ok": {
           "description": "",
           "example": "false",
           "type": "boolean"
          }
         },
         "required": [
          "ok",
          "error"
         ],
         "type": "object"
        }
       }
      },
      "description": "خطأ"
     }
    },
    "security": [
     {
      "bearer": []
     },
     {
      "apiKey": []
     }
    ],
    "summary": "الخطط والأسعار",
    "tags": [
     "pdf",
     "account"
    ],
    "x-emm-app": "pdf"
   },
   "servers": [
    {
     "description": "pdf",
     "url": "https://pdf.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "pdf"
  },
  "/pdf/api/v1/tools": {
   "get": {
    "description": "12 أداة مع حقول كل أداة وحدود خطتك (الحجم، الصفحات، عدد الملفات).",
    "operationId": "pdf_get__api_v1_tools",
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "content": {
          "application/json": {
           "schema": {
            "properties": {
             "data": {
              "properties": {
               "items": {
                "items": {
                 "properties": {
                  "accept": {
                   "description": "",
                   "example": "application/pdf",
                   "type": "string"
                  },
                  "available": {
                   "description": "",
                   "type": "boolean"
                  },
                  "description": {
                   "description": "",
                   "type": "string"
                  },
                  "endpoint": {
                   "description": "",
                   "type": "string"
                  },
                  "fields": {
                   "items": {
                    "properties": {
                     "label": {
                      "description": "",
                      "type": "string"
                     },
                     "name": {
                      "description": "",
                      "type": "string"
                     },
                     "required": {
                      "description": "",
                      "type": "boolean"
                     },
                     "type": {
                      "description": "",
                      "type": "string"
                     }
                    },
                    "type": "object"
                   },
                   "type": "array"
                  },
                  "id": {
                   "description": "",
                   "example": "merge",
                   "type": "string"
                  },
                  "multiple_files": {
                   "description": "",
                   "type": "boolean"
                  },
                  "name": {
                   "description": "",
                   "type": "string"
                  },
                  "output": {
                   "description": "",
                   "example": "pdf",
                   "type": "string"
                  }
                 },
                 "type": "object"
                },
                "type": "array"
               },
               "limits": {
                "type": "object"
               },
               "total": {
                "description": "",
                "example": "12",
                "type": "integer"
               }
              },
              "type": "object"
             },
             "ok": {
              "description": "",
              "type": "boolean"
             }
            },
            "required": [
             "ok",
             "data"
            ],
            "type": "object"
           }
          }
         },
         "description": "OK"
        }
       }
      },
      "description": "OK"
     },
     "400": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "error": {
           "properties": {
            "code": {
             "description": "",
             "example": "validation",
             "type": "string"
            },
            "message": {
             "description": "",
             "example": "نص عربي",
             "type": "string"
            }
           },
           "type": "object"
          },
          "ok": {
           "description": "",
           "example": "false",
           "type": "boolean"
          }
         },
         "required": [
          "ok",
          "error"
         ],
         "type": "object"
        }
       }
      },
      "description": "خطأ"
     },
     "401": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "error": {
           "properties": {
            "code": {
             "description": "",
             "example": "unauthorized",
             "type": "string"
            },
            "message": {
             "description": "",
             "example": "نص عربي",
             "type": "string"
            }
           },
           "type": "object"
          },
          "ok": {
           "description": "",
           "example": "false",
           "type": "boolean"
          }
         },
         "required": [
          "ok",
          "error"
         ],
         "type": "object"
        }
       }
      },
      "description": "خطأ"
     },
     "403": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "error": {
           "properties": {
            "code": {
             "description": "",
             "example": "forbidden",
             "type": "string"
            },
            "message": {
             "description": "",
             "example": "نص عربي",
             "type": "string"
            }
           },
           "type": "object"
          },
          "ok": {
           "description": "",
           "example": "false",
           "type": "boolean"
          }
         },
         "required": [
          "ok",
          "error"
         ],
         "type": "object"
        }
       }
      },
      "description": "خطأ"
     },
     "429": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "error": {
           "properties": {
            "code": {
             "description": "",
             "example": "rate_limited",
             "type": "string"
            },
            "message": {
             "description": "",
             "example": "نص عربي",
             "type": "string"
            }
           },
           "type": "object"
          },
          "ok": {
           "description": "",
           "example": "false",
           "type": "boolean"
          }
         },
         "required": [
          "ok",
          "error"
         ],
         "type": "object"
        }
       }
      },
      "description": "خطأ"
     },
     "500": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "error": {
           "properties": {
            "code": {
             "description": "",
             "example": "internal_error",
             "type": "string"
            },
            "message": {
             "description": "",
             "example": "نص عربي",
             "type": "string"
            }
           },
           "type": "object"
          },
          "ok": {
           "description": "",
           "example": "false",
           "type": "boolean"
          }
         },
         "required": [
          "ok",
          "error"
         ],
         "type": "object"
        }
       }
      },
      "description": "خطأ"
     }
    },
    "security": [
     {
      "bearer": []
     },
     {
      "apiKey": []
     }
    ],
    "summary": "كتالوج الأدوات",
    "tags": [
     "pdf",
     "tools"
    ],
    "x-emm-app": "pdf"
   },
   "servers": [
    {
     "description": "pdf",
     "url": "https://pdf.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "pdf"
  },
  "/pdf/api/v1/tools/{tool}": {
   "get": {
    "description": "تعريف الأداة وحقولها.",
    "operationId": "pdf_get__api_v1_tools_tool",
    "parameters": [
     {
      "description": "معرّف الأداة: merge | split | compress | toimages | fromimages | rotate | numbers | watermark | protect | unlock | ocr | esign",
      "in": "path",
      "name": "tool",
      "required": true,
      "schema": {
       "description": "",
       "enum": [
        "merge",
        "split",
        "compress",
        "toimages",
        "fromimages",
        "rotate",
        "numbers",
        "watermark",
        "protect",
        "unlock",
        "ocr",
        "esign"
       ],
       "example": "merge",
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "content": {
          "application/json": {
           "schema": {
            "properties": {
             "data": {
              "properties": {
               "accept": {
                "description": "",
                "example": "application/pdf",
                "type": "string"
               },
               "available": {
                "description": "",
                "type": "boolean"
               },
               "description": {
                "description": "",
                "type": "string"
               },
               "endpoint": {
                "description": "",
                "type": "string"
               },
               "fields": {
                "items": {
                 "properties": {
                  "label": {
                   "description": "",
                   "type": "string"
                  },
                  "name": {
                   "description": "",
                   "type": "string"
                  },
                  "required": {
                   "description": "",
                   "type": "boolean"
                  },
                  "type": {
                   "description": "",
                   "type": "string"
                  }
                 },
                 "type": "object"
                },
                "type": "array"
               },
               "id": {
                "description": "",
                "example": "merge",
                "type": "string"
               },
               "multiple_files": {
                "description": "",
                "type": "boolean"
               },
               "name": {
                "description": "",
                "type": "string"
               },
               "output": {
                "description": "",
                "example": "pdf",
                "type": "string"
               }
              },
              "type": "object"
             },
             "ok": {
              "description": "",
              "type": "boolean"
             }
            },
            "required": [
             "ok",
             "data"
            ],
            "type": "object"
           }
          }
         },
         "description": "OK"
        }
       }
      },
      "description": "OK"
     },
     "400": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "error": {
           "properties": {
            "code": {
             "description": "",
             "example": "validation",
             "type": "string"
            },
            "message": {
             "description": "",
             "example": "نص عربي",
             "type": "string"
            }
           },
           "type": "object"
          },
          "ok": {
           "description": "",
           "example": "false",
           "type": "boolean"
          }
         },
         "required": [
          "ok",
          "error"
         ],
         "type": "object"
        }
       }
      },
      "description": "خطأ"
     },
     "401": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "error": {
           "properties": {
            "code": {
             "description": "",
             "example": "unauthorized",
             "type": "string"
            },
            "message": {
             "description": "",
             "example": "نص عربي",
             "type": "string"
            }
           },
           "type": "object"
          },
          "ok": {
           "description": "",
           "example": "false",
           "type": "boolean"
          }
         },
         "required": [
          "ok",
          "error"
         ],
         "type": "object"
        }
       }
      },
      "description": "خطأ"
     },
     "403": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "error": {
           "properties": {
            "code": {
             "description": "",
             "example": "forbidden",
             "type": "string"
            },
            "message": {
             "description": "",
             "example": "نص عربي",
             "type": "string"
            }
           },
           "type": "object"
          },
          "ok": {
           "description": "",
           "example": "false",
           "type": "boolean"
          }
         },
         "required": [
          "ok",
          "error"
         ],
         "type": "object"
        }
       }
      },
      "description": "خطأ"
     },
     "404": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "error": {
           "properties": {
            "code": {
             "description": "",
             "example": "not_found",
             "type": "string"
            },
            "message": {
             "description": "",
             "example": "نص عربي",
             "type": "string"
            }
           },
           "type": "object"
          },
          "ok": {
           "description": "",
           "example": "false",
           "type": "boolean"
          }
         },
         "required": [
          "ok",
          "error"
         ],
         "type": "object"
        }
       }
      },
      "description": "خطأ"
     },
     "429": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "error": {
           "properties": {
            "code": {
             "description": "",
             "example": "rate_limited",
             "type": "string"
            },
            "message": {
             "description": "",
             "example": "نص عربي",
             "type": "string"
            }
           },
           "type": "object"
          },
          "ok": {
           "description": "",
           "example": "false",
           "type": "boolean"
          }
         },
         "required": [
          "ok",
          "error"
         ],
         "type": "object"
        }
       }
      },
      "description": "خطأ"
     },
     "500": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "error": {
           "properties": {
            "code": {
             "description": "",
             "example": "internal_error",
             "type": "string"
            },
            "message": {
             "description": "",
             "example": "نص عربي",
             "type": "string"
            }
           },
           "type": "object"
          },
          "ok": {
           "description": "",
           "example": "false",
           "type": "boolean"
          }
         },
         "required": [
          "ok",
          "error"
         ],
         "type": "object"
        }
       }
      },
      "description": "خطأ"
     }
    },
    "security": [
     {
      "bearer": []
     },
     {
      "apiKey": []
     }
    ],
    "summary": "أداة واحدة",
    "tags": [
     "pdf",
     "tools"
    ],
    "x-emm-app": "pdf"
   },
   "post": {
    "description": "يعالج الملفات ويعيد 202 مع المهمة (status=done وdownload_url، أو draft للأداة esign مع preview_url_pattern وapply_url). يخصم من حد المهام اليومي.",
    "operationId": "pdf_post__api_v1_tools_tool",
    "parameters": [
     {
      "description": "معرّف الأداة: merge | split | compress | toimages | fromimages | rotate | numbers | watermark | protect | unlock | ocr | esign",
      "in": "path",
      "name": "tool",
      "required": true,
      "schema": {
       "description": "",
       "enum": [
        "merge",
        "split",
        "compress",
        "toimages",
        "fromimages",
        "rotate",
        "numbers",
        "watermark",
        "protect",
        "unlock",
        "ocr",
        "esign"
       ],
       "example": "merge",
       "type": "string"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "properties": {
         "file": {
          "description": "",
          "format": "byte",
          "type": "string"
         },
         "files": {
          "items": {
           "properties": {
            "content_base64": {
             "description": "",
             "format": "byte",
             "type": "string"
            },
            "name": {
             "description": "",
             "example": "a.pdf",
             "type": "string"
            }
           },
           "type": "object"
          },
          "type": "array"
         }
        },
        "type": "object"
       }
      },
      "multipart/form-data": {
       "schema": {
        "properties": {
         "file": {
          "format": "binary",
          "type": "string"
         },
         "files": {
          "items": {
           "format": "binary",
           "type": "string"
          },
          "type": "array"
         }
        },
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "content": {
          "application/json": {
           "schema": {
            "properties": {
             "data": {
              "properties": {
               "apply_url": {
                "description": "",
                "type": "string"
               },
               "created_at": {
                "description": "",
                "format": "date-time",
                "type": "string"
               },
               "download_url": {
                "description": "",
                "example": "https://pdf.emm.sa/api/v1/jobs/k3Jd8QzLmPq2Rv/download",
                "type": "string"
               },
               "error": {
                "description": "",
                "type": "string"
               },
               "expires_at": {
                "description": "",
                "format": "date-time",
                "type": "string"
               },
               "id": {
                "description": "",
                "example": "k3Jd8QzLmPq2Rv",
                "type": "string"
               },
               "output_name": {
                "description": "",
                "example": "merged.pdf",
                "type": "string"
               },
               "pages_in": {
                "description": "",
                "type": "integer"
               },
               "pages_out": {
                "description": "",
                "type": "integer"
               },
               "preview_url_pattern": {
                "description": "",
                "type": "string"
               },
               "previews": {
                "description": "",
                "type": "integer"
               },
               "size_bytes": {
                "description": "",
                "type": "integer"
               },
               "status": {
                "description": "",
                "enum": [
                 "draft",
                 "done",
                 "expired"
                ],
                "example": "done",
                "type": "string"
               },
               "tool": {
                "description": "",
                "example": "merge",
                "type": "string"
               },
               "verify_url": {
                "description": "",
                "type": "string"
               }
              },
              "type": "object"
             },
             "ok": {
              "description": "",
              "type": "boolean"
             }
            },
            "required": [
             "ok",
             "data"
            ],
            "type": "object"
           }
          }
         },
         "description": "OK"
        }
       }
      },
      "description": "OK"
     },
     "202": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "data": {
           "properties": {
            "apply_url": {
             "description": "",
             "type": "string"
            },
            "created_at": {
             "description": "",
             "format": "date-time",
             "type": "string"
            },
            "download_url": {
             "description": "",
             "example": "https://pdf.emm.sa/api/v1/jobs/k3Jd8QzLmPq2Rv/download",
             "type": "string"
            },
            "error": {
             "description": "",
             "type": "string"
            },
            "expires_at": {
             "description": "",
             "format": "date-time",
             "type": "string"
            },
            "id": {
             "description": "",
             "example": "k3Jd8QzLmPq2Rv",
             "type": "string"
            },
            "output_name": {
             "description": "",
             "example": "merged.pdf",
             "type": "string"
            },
            "pages_in": {
             "description": "",
             "type": "integer"
            },
            "pages_out": {
             "description": "",
             "type": "integer"
            },
            "preview_url_pattern": {
             "description": "",
             "type": "string"
            },
            "previews": {
             "description": "",
             "type": "integer"
            },
            "size_bytes": {
             "description": "",
             "type": "integer"
            },
            "status": {
             "description": "",
             "enum": [
              "draft",
              "done",
              "expired"
             ],
             "example": "done",
             "type": "string"
            },
            "tool": {
             "description": "",
             "example": "merge",
             "type": "string"
            },
            "verify_url": {
             "description": "",
             "type": "string"
            }
           },
           "type": "object"
          },
          "ok": {
           "description": "",
           "type": "boolean"
          }
         },
         "required": [
          "ok",
          "data"
         ],
         "type": "object"
        }
       }
      },
      "description": "Accepted — المهمة"
     },
     "400": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "error": {
           "properties": {
            "code": {
             "description": "",
             "example": "validation",
             "type": "string"
            },
            "message": {
             "description": "",
             "example": "نص عربي",
             "type": "string"
            }
           },
           "type": "object"
          },
          "ok": {
           "description": "",
           "example": "false",
           "type": "boolean"
          }
         },
         "required": [
          "ok",
          "error"
         ],
         "type": "object"
        }
       }
      },
      "description": "خطأ"
     },
     "401": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "error": {
           "properties": {
            "code": {
             "description": "",
             "example": "unauthorized",
             "type": "string"
            },
            "message": {
             "description": "",
             "example": "نص عربي",
             "type": "string"
            }
           },
           "type": "object"
          },
          "ok": {
           "description": "",
           "example": "false",
           "type": "boolean"
          }
         },
         "required": [
          "ok",
          "error"
         ],
         "type": "object"
        }
       }
      },
      "description": "خطأ"
     },
     "403": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "error": {
           "properties": {
            "code": {
             "description": "",
             "example": "forbidden",
             "type": "string"
            },
            "message": {
             "description": "",
             "example": "نص عربي",
             "type": "string"
            }
           },
           "type": "object"
          },
          "ok": {
           "description": "",
           "example": "false",
           "type": "boolean"
          }
         },
         "required": [
          "ok",
          "error"
         ],
         "type": "object"
        }
       }
      },
      "description": "خطأ"
     },
     "404": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "error": {
           "properties": {
            "code": {
             "description": "",
             "example": "not_found",
             "type": "string"
            },
            "message": {
             "description": "",
             "example": "نص عربي",
             "type": "string"
            }
           },
           "type": "object"
          },
          "ok": {
           "description": "",
           "example": "false",
           "type": "boolean"
          }
         },
         "required": [
          "ok",
          "error"
         ],
         "type": "object"
        }
       }
      },
      "description": "خطأ"
     },
     "409": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "error": {
           "properties": {
            "code": {
             "description": "",
             "example": "quota",
             "type": "string"
            },
            "message": {
             "description": "",
             "example": "نص عربي",
             "type": "string"
            }
           },
           "type": "object"
          },
          "ok": {
           "description": "",
           "example": "false",
           "type": "boolean"
          }
         },
         "required": [
          "ok",
          "error"
         ],
         "type": "object"
        }
       }
      },
      "description": "خطأ"
     },
     "410": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "error": {
           "properties": {
            "code": {
             "description": "",
             "example": "expired",
             "type": "string"
            },
            "message": {
             "description": "",
             "example": "نص عربي",
             "type": "string"
            }
           },
           "type": "object"
          },
          "ok": {
           "description": "",
           "example": "false",
           "type": "boolean"
          }
         },
         "required": [
          "ok",
          "error"
         ],
         "type": "object"
        }
       }
      },
      "description": "خطأ"
     },
     "413": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "error": {
           "properties": {
            "code": {
             "description": "",
             "example": "upload",
             "type": "string"
            },
            "message": {
             "description": "",
             "example": "نص عربي",
             "type": "string"
            }
           },
           "type": "object"
          },
          "ok": {
           "description": "",
           "example": "false",
           "type": "boolean"
          }
         },
         "required": [
          "ok",
          "error"
         ],
         "type": "object"
        }
       }
      },
      "description": "خطأ"
     },
     "429": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "error": {
           "properties": {
            "code": {
             "description": "",
             "example": "rate_limited",
             "type": "string"
            },
            "message": {
             "description": "",
             "example": "نص عربي",
             "type": "string"
            }
           },
           "type": "object"
          },
          "ok": {
           "description": "",
           "example": "false",
           "type": "boolean"
          }
         },
         "required": [
          "ok",
          "error"
         ],
         "type": "object"
        }
       }
      },
      "description": "خطأ"
     },
     "500": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "error": {
           "properties": {
            "code": {
             "description": "",
             "example": "internal_error",
             "type": "string"
            },
            "message": {
             "description": "",
             "example": "نص عربي",
             "type": "string"
            }
           },
           "type": "object"
          },
          "ok": {
           "description": "",
           "example": "false",
           "type": "boolean"
          }
         },
         "required": [
          "ok",
          "error"
         ],
         "type": "object"
        }
       }
      },
      "description": "خطأ"
     },
     "503": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "error": {
           "properties": {
            "code": {
             "description": "",
             "example": "ocr_unavailable",
             "type": "string"
            },
            "message": {
             "description": "",
             "example": "نص عربي",
             "type": "string"
            }
           },
           "type": "object"
          },
          "ok": {
           "description": "",
           "example": "false",
           "type": "boolean"
          }
         },
         "required": [
          "ok",
          "error"
         ],
         "type": "object"
        }
       }
      },
      "description": "خطأ"
     }
    },
    "security": [
     {
      "bearer": []
     },
     {
      "apiKey": []
     }
    ],
    "summary": "تشغيل أداة",
    "tags": [
     "pdf",
     "tools"
    ],
    "x-emm-app": "pdf"
   },
   "servers": [
    {
     "description": "pdf",
     "url": "https://pdf.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "pdf"
  },
  "/qr/codes": {
   "get": {
    "operationId": "qr_get_codes",
    "parameters": [
     {
      "in": "query",
      "name": "limit",
      "required": false,
      "schema": {
       "description": "عدد النتائج 1-200 (افتراضي 50)",
       "example": 50,
       "type": "integer"
      }
     },
     {
      "in": "query",
      "name": "offset",
      "required": false,
      "schema": {
       "description": "إزاحة الترحيل",
       "example": 0,
       "type": "integer"
      }
     },
     {
      "in": "query",
      "name": "kind",
      "required": false,
      "schema": {
       "description": "dynamic أو static",
       "enum": [
        "dynamic",
        "static"
       ],
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "data": {
           "description": "رمز QR (نفس مخرجات /api/v1/codes/{id})",
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "type": "object"
        }
       }
      },
      "description": "نجاح — {\"ok\":true,\"data\":…}"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية (read)"
     },
     "429": {
      "description": "تجاوز 60 طلباً/دقيقة — راجع Retry-After"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "قائمة الرموز (ترحيل)",
    "tags": [
     "qr",
     "codes"
    ],
    "x-emm-app": "qr",
    "x-scope": "read"
   },
   "post": {
    "operationId": "qr_post_codes",
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "additionalProperties": true,
        "properties": {
         "clear_password": {
          "description": "إزالة كلمة المرور",
          "type": "boolean"
         },
         "destination": {
          "description": "الوجهة باختصار (رابط/نص/رقم/بريد/SSID) — الحقل الرئيسي للنوع",
          "example": "https://menu.example.sa",
          "type": "string"
         },
         "dynamic": {
          "description": "بديل لـ kind: true = ديناميكي",
          "example": true,
          "type": "boolean"
         },
         "expires_on": {
          "description": "تاريخ انتهاء YYYY-MM-DD (خطط مدفوعة)",
          "example": "2030-12-31",
          "type": "string"
         },
         "fields": {
          "description": "حقول النوع كاملة (مثال: url, text, phone, message, ssid, lat, lng) تتجاوز destination",
          "type": "object"
         },
         "kind": {
          "description": "dynamic (افتراضي) أو static",
          "enum": [
           "dynamic",
           "static"
          ],
          "example": "dynamic",
          "type": "string"
         },
         "name": {
          "description": "اسم تعريفي (≤60)",
          "example": "منيو المطعم",
          "type": "string"
         },
         "password": {
          "description": "كلمة مرور للمسح (خطط مدفوعة، ≥4 أحرف)",
          "example": "1234",
          "type": "string"
         },
         "paused": {
          "description": "إيقاف/استئناف التوجيه",
          "type": "boolean"
         },
         "style": {
          "description": "تخصيص الشكل: shape, eye, fg, bg, gradient, fg2, ec, quiet, size, caption",
          "type": "object"
         },
         "type": {
          "description": "نوع الرمز",
          "enum": [
           "url",
           "text",
           "vcard",
           "wifi",
           "phone",
           "email",
           "whatsapp",
           "location",
           "event"
          ],
          "example": "url",
          "type": "string"
         }
        },
        "required": [
         "type"
        ],
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "201": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "data": {
           "description": "رمز QR (نفس مخرجات /api/v1/codes/{id})",
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "type": "object"
        }
       }
      },
      "description": "نجاح — {\"ok\":true,\"data\":…}"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية (write)"
     },
     "429": {
      "description": "تجاوز 60 طلباً/دقيقة — راجع Retry-After"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "إنشاء رمز (نفس تحقق المحرر)",
    "tags": [
     "qr",
     "codes"
    ],
    "x-emm-app": "qr",
    "x-scope": "write"
   },
   "servers": [
    {
     "description": "qr",
     "url": "https://qr.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "qr"
  },
  "/qr/codes/import": {
   "post": {
    "operationId": "qr_post_codes_import",
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "additionalProperties": true,
        "properties": {
         "items": {
          "description": "قائمة {name,url,kind}",
          "example": [
           {
            "name": "فرع الرياض",
            "url": "https://example.sa"
           }
          ],
          "items": {
           "type": "object"
          },
          "type": "array"
         },
         "kind": {
          "description": "dynamic (افتراضي) أو static لكل الصفوف",
          "enum": [
           "dynamic",
           "static"
          ],
          "type": "string"
         }
        },
        "required": [
         "items"
        ],
        "type": "object"
       }
      },
      "multipart/form-data": {
       "schema": {
        "properties": {
         "file": {
          "format": "binary",
          "type": "string"
         }
        },
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "data": {
           "description": "رمز QR (نفس مخرجات /api/v1/codes/{id})",
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "type": "object"
        }
       }
      },
      "description": "نجاح — {\"ok\":true,\"data\":…}"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية (write)"
     },
     "429": {
      "description": "تجاوز 60 طلباً/دقيقة — راجع Retry-After"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "استيراد مجمع: {items:[{name,url,kind}]} أو ملف CSV multipart في الحقل file (name,url[,kind]) — حتى 500 صف",
    "tags": [
     "qr",
     "codes"
    ],
    "x-emm-app": "qr",
    "x-scope": "write"
   },
   "servers": [
    {
     "description": "qr",
     "url": "https://qr.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "qr"
  },
  "/qr/codes/{id}": {
   "delete": {
    "operationId": "qr_delete_codes_id",
    "parameters": [
     {
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "data": {
           "description": "رمز QR (نفس مخرجات /api/v1/codes/{id})",
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "type": "object"
        }
       }
      },
      "description": "نجاح — {\"ok\":true,\"data\":…}"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية (write)"
     },
     "429": {
      "description": "تجاوز 60 طلباً/دقيقة — راجع Retry-After"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "حذف الرمز نهائياً",
    "tags": [
     "qr",
     "codes"
    ],
    "x-emm-app": "qr",
    "x-scope": "write"
   },
   "get": {
    "operationId": "qr_get_codes_id",
    "parameters": [
     {
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "data": {
           "description": "رمز QR (نفس مخرجات /api/v1/codes/{id})",
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "type": "object"
        }
       }
      },
      "description": "نجاح — {\"ok\":true,\"data\":…}"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية (read)"
     },
     "429": {
      "description": "تجاوز 60 طلباً/دقيقة — راجع Retry-After"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "رمز واحد",
    "tags": [
     "qr",
     "codes"
    ],
    "x-emm-app": "qr",
    "x-scope": "read"
   },
   "patch": {
    "operationId": "qr_patch_codes_id",
    "parameters": [
     {
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "additionalProperties": true,
        "properties": {
         "clear_password": {
          "description": "إزالة كلمة المرور",
          "type": "boolean"
         },
         "destination": {
          "description": "الوجهة باختصار (رابط/نص/رقم/بريد/SSID) — الحقل الرئيسي للنوع",
          "example": "https://menu.example.sa",
          "type": "string"
         },
         "dynamic": {
          "description": "بديل لـ kind: true = ديناميكي",
          "example": true,
          "type": "boolean"
         },
         "expires_on": {
          "description": "تاريخ انتهاء YYYY-MM-DD (خطط مدفوعة)",
          "example": "2030-12-31",
          "type": "string"
         },
         "fields": {
          "description": "حقول النوع كاملة (مثال: url, text, phone, message, ssid, lat, lng) تتجاوز destination",
          "type": "object"
         },
         "kind": {
          "description": "dynamic (افتراضي) أو static",
          "enum": [
           "dynamic",
           "static"
          ],
          "example": "dynamic",
          "type": "string"
         },
         "name": {
          "description": "اسم تعريفي (≤60)",
          "example": "منيو المطعم",
          "type": "string"
         },
         "password": {
          "description": "كلمة مرور للمسح (خطط مدفوعة، ≥4 أحرف)",
          "example": "1234",
          "type": "string"
         },
         "paused": {
          "description": "إيقاف/استئناف التوجيه",
          "type": "boolean"
         },
         "style": {
          "description": "تخصيص الشكل: shape, eye, fg, bg, gradient, fg2, ec, quiet, size, caption",
          "type": "object"
         },
         "type": {
          "description": "نوع الرمز",
          "enum": [
           "url",
           "text",
           "vcard",
           "wifi",
           "phone",
           "email",
           "whatsapp",
           "location",
           "event"
          ],
          "example": "url",
          "type": "string"
         }
        },
        "required": [],
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "data": {
           "description": "رمز QR (نفس مخرجات /api/v1/codes/{id})",
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "type": "object"
        }
       }
      },
      "description": "نجاح — {\"ok\":true,\"data\":…}"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية (write)"
     },
     "429": {
      "description": "تجاوز 60 طلباً/دقيقة — راجع Retry-After"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "تعديل وجهة/حقول/اسم/شكل/حماية (PUT مقبول أيضاً) — الحقول الغائبة تبقى كما هي",
    "tags": [
     "qr",
     "codes"
    ],
    "x-emm-app": "qr",
    "x-scope": "write"
   },
   "put": {
    "operationId": "qr_patch_codes_id",
    "parameters": [
     {
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "additionalProperties": true,
        "properties": {
         "clear_password": {
          "description": "إزالة كلمة المرور",
          "type": "boolean"
         },
         "destination": {
          "description": "الوجهة باختصار (رابط/نص/رقم/بريد/SSID) — الحقل الرئيسي للنوع",
          "example": "https://menu.example.sa",
          "type": "string"
         },
         "dynamic": {
          "description": "بديل لـ kind: true = ديناميكي",
          "example": true,
          "type": "boolean"
         },
         "expires_on": {
          "description": "تاريخ انتهاء YYYY-MM-DD (خطط مدفوعة)",
          "example": "2030-12-31",
          "type": "string"
         },
         "fields": {
          "description": "حقول النوع كاملة (مثال: url, text, phone, message, ssid, lat, lng) تتجاوز destination",
          "type": "object"
         },
         "kind": {
          "description": "dynamic (افتراضي) أو static",
          "enum": [
           "dynamic",
           "static"
          ],
          "example": "dynamic",
          "type": "string"
         },
         "name": {
          "description": "اسم تعريفي (≤60)",
          "example": "منيو المطعم",
          "type": "string"
         },
         "password": {
          "description": "كلمة مرور للمسح (خطط مدفوعة، ≥4 أحرف)",
          "example": "1234",
          "type": "string"
         },
         "paused": {
          "description": "إيقاف/استئناف التوجيه",
          "type": "boolean"
         },
         "style": {
          "description": "تخصيص الشكل: shape, eye, fg, bg, gradient, fg2, ec, quiet, size, caption",
          "type": "object"
         },
         "type": {
          "description": "نوع الرمز",
          "enum": [
           "url",
           "text",
           "vcard",
           "wifi",
           "phone",
           "email",
           "whatsapp",
           "location",
           "event"
          ],
          "example": "url",
          "type": "string"
         }
        },
        "required": [],
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "data": {
           "description": "رمز QR (نفس مخرجات /api/v1/codes/{id})",
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "type": "object"
        }
       }
      },
      "description": "نجاح — {\"ok\":true,\"data\":…}"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية (write)"
     },
     "429": {
      "description": "تجاوز 60 طلباً/دقيقة — راجع Retry-After"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "تعديل وجهة/حقول/اسم/شكل/حماية (PUT مقبول أيضاً) — الحقول الغائبة تبقى كما هي",
    "tags": [
     "qr",
     "codes"
    ],
    "x-emm-app": "qr",
    "x-scope": "write"
   },
   "servers": [
    {
     "description": "qr",
     "url": "https://qr.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "qr"
  },
  "/qr/codes/{id}/pause": {
   "post": {
    "operationId": "qr_post_codes_id_pause",
    "parameters": [
     {
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "additionalProperties": true,
        "properties": {
         "paused": {
          "description": "true إيقاف، false استئناف",
          "example": true,
          "type": "boolean"
         }
        },
        "required": [
         "paused"
        ],
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "data": {
           "description": "رمز QR (نفس مخرجات /api/v1/codes/{id})",
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "type": "object"
        }
       }
      },
      "description": "نجاح — {\"ok\":true,\"data\":…}"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية (write)"
     },
     "429": {
      "description": "تجاوز 60 طلباً/دقيقة — راجع Retry-After"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "إيقاف أو استئناف التوجيه",
    "tags": [
     "qr",
     "codes"
    ],
    "x-emm-app": "qr",
    "x-scope": "write"
   },
   "servers": [
    {
     "description": "qr",
     "url": "https://qr.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "qr"
  },
  "/qr/codes/{id}/qr.png": {
   "get": {
    "operationId": "qr_get_codes_id_qr.png",
    "parameters": [
     {
      "in": "query",
      "name": "size",
      "required": false,
      "schema": {
       "description": "حجم الصورة بالبكسل",
       "example": 1024,
       "type": "integer"
      }
     },
     {
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "image/png": {
        "schema": {
         "format": "binary",
         "type": "string"
        }
       }
      },
      "description": "image/png"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "صورة PNG للرمز (ثنائية، خارج المغلّف) — ?size=256..2048",
    "tags": [
     "qr",
     "codes"
    ],
    "x-emm-app": "qr",
    "x-scope": "read"
   },
   "servers": [
    {
     "description": "qr",
     "url": "https://qr.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "qr"
  },
  "/qr/codes/{id}/scans": {
   "get": {
    "operationId": "qr_get_codes_id_scans",
    "parameters": [
     {
      "in": "query",
      "name": "limit",
      "required": false,
      "schema": {
       "description": "عدد النتائج 1-200 (افتراضي 50)",
       "example": 50,
       "type": "integer"
      }
     },
     {
      "in": "query",
      "name": "offset",
      "required": false,
      "schema": {
       "description": "إزاحة الترحيل",
       "example": 0,
       "type": "integer"
      }
     },
     {
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "data": {
           "description": "رمز QR (نفس مخرجات /api/v1/codes/{id})",
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "type": "object"
        }
       }
      },
      "description": "نجاح — {\"ok\":true,\"data\":…}"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية (read)"
     },
     "429": {
      "description": "تجاوز 60 طلباً/دقيقة — راجع Retry-After"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "سجل المسحات (ترحيل): ts, day, country, device",
    "tags": [
     "qr",
     "codes"
    ],
    "x-emm-app": "qr",
    "x-scope": "read"
   },
   "servers": [
    {
     "description": "qr",
     "url": "https://qr.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "qr"
  },
  "/qr/codes/{id}/scans/summary": {
   "get": {
    "operationId": "qr_get_codes_id_scans_summary",
    "parameters": [
     {
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "data": {
           "description": "رمز QR (نفس مخرجات /api/v1/codes/{id})",
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "type": "object"
        }
       }
      },
      "description": "نجاح — {\"ok\":true,\"data\":…}"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية (read)"
     },
     "429": {
      "description": "تجاوز 60 طلباً/دقيقة — راجع Retry-After"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "ملخص المسحات: اليوم، الشهر، الإجمالي، 14 يوماً، الأجهزة",
    "tags": [
     "qr",
     "codes"
    ],
    "x-emm-app": "qr",
    "x-scope": "read"
   },
   "servers": [
    {
     "description": "qr",
     "url": "https://qr.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "qr"
  },
  "/qr/me": {
   "get": {
    "operationId": "qr_get_me",
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "data": {
           "description": "رمز QR (نفس مخرجات /api/v1/codes/{id})",
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "type": "object"
        }
       }
      },
      "description": "نجاح — {\"ok\":true,\"data\":…}"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية (read)"
     },
     "429": {
      "description": "تجاوز 60 طلباً/دقيقة — راجع Retry-After"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "المستخدم والخطة والحصص — اختبار مفتاحك",
    "tags": [
     "qr",
     "codes"
    ],
    "x-emm-app": "qr",
    "x-scope": "read"
   },
   "servers": [
    {
     "description": "qr",
     "url": "https://qr.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "qr"
  },
  "/qr/plan": {
   "get": {
    "operationId": "qr_get_plan",
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "data": {
           "description": "رمز QR (نفس مخرجات /api/v1/codes/{id})",
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "type": "object"
        }
       }
      },
      "description": "نجاح — {\"ok\":true,\"data\":…}"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح أو ملغى"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية (read)"
     },
     "429": {
      "description": "تجاوز 60 طلباً/دقيقة — راجع Retry-After"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "كل الخطط والحدود والخطة الحالية",
    "tags": [
     "qr",
     "codes"
    ],
    "x-emm-app": "qr",
    "x-scope": "read"
   },
   "servers": [
    {
     "description": "qr",
     "url": "https://qr.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "qr"
  },
  "/staff/api/v1/days/status": {
   "get": {
    "description": "حالة كل موظف لكل يوم في نطاق (≤ 62 يوماً): present|late|absent|off|leave|pending|na. Per-employee per-day status.",
    "parameters": [
     {
      "description": "بداية النطاق YYYY-MM-DD",
      "in": "query",
      "name": "from",
      "schema": {
       "format": "date",
       "type": "string"
      }
     },
     {
      "description": "نهاية النطاق YYYY-MM-DD (شاملة)",
      "in": "query",
      "name": "to",
      "schema": {
       "format": "date",
       "type": "string"
      }
     },
     {
      "description": "فلتر/معرّف الموظف",
      "in": "query",
      "name": "employee_id",
      "schema": {
       "type": "integer"
      }
     },
     {
      "description": "عدد النتائج (1–200، افتراضي 50)",
      "in": "query",
      "name": "limit",
      "schema": {
       "default": 50,
       "maximum": 200,
       "minimum": 1,
       "type": "integer"
      }
     },
     {
      "description": "تخطي النتائج",
      "in": "query",
      "name": "offset",
      "schema": {
       "default": 0,
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "حالة اليوم لنطاق / Day status (range)",
    "tags": [
     "staff",
     "days"
    ],
    "x-emm-app": "staff"
   },
   "servers": [
    {
     "description": "staff",
     "url": "https://staff.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "staff"
  },
  "/staff/api/v1/days/{emp}/{day}/mark": {
   "post": {
    "description": "يسجّل حالة يدوية (leave|absent|present|off) لموظف ويوم مع ملاحظة. Sets a manual day status.",
    "parameters": [
     {
      "description": "معرّف الموظف",
      "in": "path",
      "name": "emp",
      "required": true,
      "schema": {
       "type": "integer"
      }
     },
     {
      "description": "اليوم YYYY-MM-DD",
      "in": "path",
      "name": "day",
      "required": true,
      "schema": {
       "format": "date",
       "type": "string"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "example": {
        "note": "إجازة سنوية",
        "status": "leave"
       },
       "schema": {
        "properties": {
         "note": {
          "description": "ملاحظة",
          "type": "string"
         },
         "status": {
          "description": "leave | absent | present | off",
          "enum": [
           "leave",
           "absent",
           "present",
           "off"
          ],
          "example": "leave",
          "type": "string"
         }
        },
        "required": [
         "status"
        ],
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "data": {
           "deleted": true
          },
          "ok": true
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "201": {
      "description": "أُنشئ / created"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "409": {
      "description": "تعارض / conflict (slot_taken, quota_exceeded, deposit_pending)"
     },
     "422": {
      "description": "تحقق / validation error"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "قيام اليوم / Mark a day",
    "tags": [
     "staff",
     "days"
    ],
    "x-emm-app": "staff"
   },
   "servers": [
    {
     "description": "staff",
     "url": "https://staff.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "staff"
  },
  "/staff/api/v1/devices": {
   "get": {
    "description": "الأجهزة مع حالتها (online|offline) وآخر مزامنة وآخر سجل. Devices with status, last poll and last record.",
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "أجهزة البصمة / Devices",
    "tags": [
     "staff",
     "devices"
    ],
    "x-emm-app": "staff"
   },
   "servers": [
    {
     "description": "staff",
     "url": "https://staff.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "staff"
  },
  "/staff/api/v1/devices/{id}": {
   "get": {
    "description": "جهاز واحد بحالته وأخطائه الأخيرة. One device.",
    "parameters": [
     {
      "description": "معرّف رقمي",
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "id": 1,
          "ip": "192.168.1.50",
          "last_ok": "2026-12-02T20:40:00+03:00",
          "last_poll": "2026-12-02T20:40:00+03:00",
          "last_record_at": "2026-12-02T17:02:11+03:00",
          "name": "جهاز بصمة 1",
          "platform": "ZK609",
          "port": 4370,
          "status": "online"
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "جهاز / Device",
    "tags": [
     "staff",
     "devices"
    ],
    "x-emm-app": "staff"
   },
   "servers": [
    {
     "description": "staff",
     "url": "https://staff.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "staff"
  },
  "/staff/api/v1/employees": {
   "get": {
    "description": "قائمة الموظفين (فلتر active=1|0 و q للبحث بالاسم/الرمز/الرقم الوظيفي). Lists employees.",
    "parameters": [
     {
      "description": "عدد النتائج (1–200، افتراضي 50)",
      "in": "query",
      "name": "limit",
      "schema": {
       "default": 50,
       "maximum": 200,
       "minimum": 1,
       "type": "integer"
      }
     },
     {
      "description": "تخطي النتائج",
      "in": "query",
      "name": "offset",
      "schema": {
       "default": 0,
       "type": "integer"
      }
     },
     {
      "description": "1 = النشطون فقط، 0 = الموقوفون",
      "in": "query",
      "name": "active",
      "schema": {
       "type": "integer"
      }
     },
     {
      "description": "بحث بالاسم أو الرمز أو الرقم الوظيفي",
      "in": "query",
      "name": "q",
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "الموظفون / Employees",
    "tags": [
     "staff",
     "employees"
    ],
    "x-emm-app": "staff"
   },
   "post": {
    "description": "يضيف موظفاً ضمن حد الخطة (409 quota_exceeded) ويصدر رقماً سرياً يُعاد مرة واحدة. Adds an employee within the plan quota; the PIN is returned once.",
    "requestBody": {
     "content": {
      "application/json": {
       "example": {
        "allowances": 200,
        "basic_salary": 3000,
        "emp_ref": "10xxxxxxx1",
        "hire_date": "2026-01-01",
        "job_title": "باريستا",
        "name": "أحمد سالم",
        "zk_user_id": "1001"
       },
       "schema": {
        "properties": {
         "active": {
          "description": "مفعّل (الافتراضي true)",
          "type": "boolean"
         },
         "allowances": {
          "description": "البدلات بالريال",
          "example": "200",
          "type": "number"
         },
         "basic_salary": {
          "description": "الراتب الأساسي بالريال",
          "example": "3000",
          "type": "number"
         },
         "emp_ref": {
          "description": "رقم الهوية/الإقامة أو الرقم الوظيفي",
          "example": "10xxxxxxx1",
          "type": "string"
         },
         "hire_date": {
          "description": "تاريخ التعيين YYYY-MM-DD",
          "example": "2026-01-01",
          "type": "string"
         },
         "job_title": {
          "description": "المسمى الوظيفي",
          "example": "باريستا",
          "type": "string"
         },
         "name": {
          "description": "الاسم (حرفان على الأقل)",
          "example": "أحمد سالم",
          "type": "string"
         },
         "zk_user_id": {
          "description": "رقم المستخدم على جهاز البصمة",
          "example": "1001",
          "type": "string"
         }
        },
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "employee": {
           "active": true,
           "allowances": "200.00",
           "basic_salary": "3000.00",
           "code": "A1B2C3",
           "emp_ref": "10xxxxxxx1",
           "hire_date": "2026-01-01",
           "id": 1,
           "job_title": "باريستا",
           "kiosk_url": "https://staff.emm.sa/in/A1B2C3",
           "name": "أحمد سالم",
           "zk_user_id": "1001"
          },
          "note": "الرقم السري يُعرض مرة واحدة",
          "pin": "4821"
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "201": {
      "description": "أُنشئ / created"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "409": {
      "description": "تعارض / conflict (slot_taken, quota_exceeded, deposit_pending)"
     },
     "422": {
      "description": "تحقق / validation error"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "إضافة موظف / Add employee",
    "tags": [
     "staff",
     "employees"
    ],
    "x-emm-app": "staff"
   },
   "servers": [
    {
     "description": "staff",
     "url": "https://staff.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "staff"
  },
  "/staff/api/v1/employees/import": {
   "post": {
    "description": "multipart/form-data بحقل csv (الأعمدة عربية أو إنجليزية كقالب /app/employees/import.csv). يُعاد added/skipped/failed/errors. Multipart CSV import.",
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "added": 3,
          "errors": [],
          "failed": 0,
          "skipped": 1
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "201": {
      "description": "أُنشئ / created"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "409": {
      "description": "تعارض / conflict (slot_taken, quota_exceeded, deposit_pending)"
     },
     "422": {
      "description": "تحقق / validation error"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "استيراد موظفين من CSV / Import employees (CSV)",
    "tags": [
     "staff",
     "employees"
    ],
    "x-emm-app": "staff"
   },
   "servers": [
    {
     "description": "staff",
     "url": "https://staff.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "staff"
  },
  "/staff/api/v1/employees/{id}": {
   "delete": {
    "description": "يحذف الموظف وبصماته وقيام أيامه. Deletes the employee with punches and day marks.",
    "parameters": [
     {
      "description": "معرّف رقمي",
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "data": {
           "deleted": true
          },
          "ok": true
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "409": {
      "description": "تعارض / conflict (slot_taken, quota_exceeded, deposit_pending)"
     },
     "422": {
      "description": "تحقق / validation error"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "حذف موظف / Delete employee",
    "tags": [
     "staff",
     "employees"
    ],
    "x-emm-app": "staff"
   },
   "get": {
    "description": "بيانات موظف واحد مع ملخص الفترة الحالية. One employee with the current-period summary.",
    "parameters": [
     {
      "description": "معرّف رقمي",
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "active": true,
          "allowances": "200.00",
          "basic_salary": "3000.00",
          "code": "A1B2C3",
          "emp_ref": "10xxxxxxx1",
          "hire_date": "2026-01-01",
          "id": 1,
          "job_title": "باريستا",
          "kiosk_url": "https://staff.emm.sa/in/A1B2C3",
          "name": "أحمد سالم",
          "zk_user_id": "1001"
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "موظف / Employee",
    "tags": [
     "staff",
     "employees"
    ],
    "x-emm-app": "staff"
   },
   "patch": {
    "description": "تعديل الاسم، المسمى، الرقم الوظيفي، الراتب، البدلات، رقم جهاز البصمة، تاريخ التعيين، التفعيل. Partial update.",
    "parameters": [
     {
      "description": "معرّف رقمي",
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "example": {
        "allowances": 200,
        "basic_salary": 3000,
        "emp_ref": "10xxxxxxx1",
        "hire_date": "2026-01-01",
        "job_title": "باريستا",
        "name": "أحمد سالم",
        "zk_user_id": "1001"
       },
       "schema": {
        "properties": {
         "active": {
          "description": "مفعّل (الافتراضي true)",
          "type": "boolean"
         },
         "allowances": {
          "description": "البدلات بالريال",
          "example": "200",
          "type": "number"
         },
         "basic_salary": {
          "description": "الراتب الأساسي بالريال",
          "example": "3000",
          "type": "number"
         },
         "emp_ref": {
          "description": "رقم الهوية/الإقامة أو الرقم الوظيفي",
          "example": "10xxxxxxx1",
          "type": "string"
         },
         "hire_date": {
          "description": "تاريخ التعيين YYYY-MM-DD",
          "example": "2026-01-01",
          "type": "string"
         },
         "job_title": {
          "description": "المسمى الوظيفي",
          "example": "باريستا",
          "type": "string"
         },
         "name": {
          "description": "الاسم (حرفان على الأقل)",
          "example": "أحمد سالم",
          "type": "string"
         },
         "zk_user_id": {
          "description": "رقم المستخدم على جهاز البصمة",
          "example": "1001",
          "type": "string"
         }
        },
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "active": true,
          "allowances": "200.00",
          "basic_salary": "3000.00",
          "code": "A1B2C3",
          "emp_ref": "10xxxxxxx1",
          "hire_date": "2026-01-01",
          "id": 1,
          "job_title": "باريستا",
          "kiosk_url": "https://staff.emm.sa/in/A1B2C3",
          "name": "أحمد سالم",
          "zk_user_id": "1001"
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "409": {
      "description": "تعارض / conflict (slot_taken, quota_exceeded, deposit_pending)"
     },
     "422": {
      "description": "تحقق / validation error"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "تعديل موظف / Update employee",
    "tags": [
     "staff",
     "employees"
    ],
    "x-emm-app": "staff"
   },
   "servers": [
    {
     "description": "staff",
     "url": "https://staff.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "staff"
  },
  "/staff/api/v1/employees/{id}/pin-reset": {
   "post": {
    "description": "يصدر رقماً جديداً لصفحة التسجيل الذاتي ويُعاد مرة واحدة. Issues a new self check-in PIN (returned once).",
    "parameters": [
     {
      "description": "معرّف رقمي",
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "employee_id": 1,
          "kiosk_url": "https://staff.emm.sa/in/A1B2C3",
          "note": "الرقم السري يُعرض مرة واحدة",
          "pin": "4821"
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "201": {
      "description": "أُنشئ / created"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "409": {
      "description": "تعارض / conflict (slot_taken, quota_exceeded, deposit_pending)"
     },
     "422": {
      "description": "تحقق / validation error"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "رقم سري جديد / Reset kiosk PIN",
    "tags": [
     "staff",
     "employees"
    ],
    "x-emm-app": "staff"
   },
   "servers": [
    {
     "description": "staff",
     "url": "https://staff.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "staff"
  },
  "/staff/api/v1/me": {
   "get": {
    "description": "يتحقق من المفتاح ويعيد المستخدم والخطة الحالية وحدود الموظفين والأجهزة. Checks a key; returns user, plan and quotas.",
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "plan": {
           "currency": "SAR",
           "features": [
            "حتى 10 موظفين",
            "جهاز بصمة ZKTeco واحد",
            "تسجيل حضور يدوي وصفحة تسجيل ذاتي برقم سري",
            "حالة اليوم (حاضر · متأخر · غائب · راحة)",
            "العربية الكاملة للجوال"
           ],
           "id": "starter",
           "limits": {
            "devices": 1,
            "employees": 10,
            "salary_periods": false
           },
           "name": "ابدأ",
           "period": "month",
           "price": "0.00"
          },
          "quotas": {
           "devices": {
            "limit": 1,
            "used": 1
           },
           "employees": {
            "limit": 10,
            "used": 3
           }
          },
          "service": "staff",
          "user": {
           "email": "user@example.com"
          }
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "الهوية والخطة والحدود / Identity, plan, quotas",
    "tags": [
     "staff",
     "me"
    ],
    "x-emm-app": "staff"
   },
   "servers": [
    {
     "description": "staff",
     "url": "https://staff.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "staff"
  },
  "/staff/api/v1/notifications": {
   "get": {
    "description": "تفضيلات محفوظة (الإرسال غير مفعّل بعد). Saved preferences (delivery not enabled yet).",
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "absent_alert": true,
          "delivery_enabled": false,
          "device_offline": true,
          "email": "",
          "period_ready": true,
          "phone": ""
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "تفضيلات الإشعارات / Notification preferences",
    "tags": [
     "staff",
     "notifications"
    ],
    "x-emm-app": "staff"
   },
   "put": {
    "description": "يحفظ ما يريد العميل إشعاره به عند تفعيل الإرسال. Saves what the customer wants to be notified about once delivery is enabled.",
    "requestBody": {
     "content": {
      "application/json": {
       "example": {
        "absent_alert": true,
        "delivery_enabled": false,
        "device_offline": true,
        "email": "",
        "period_ready": true,
        "phone": ""
       },
       "schema": {
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "absent_alert": true,
          "delivery_enabled": false,
          "device_offline": true,
          "email": "",
          "period_ready": true,
          "phone": ""
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "409": {
      "description": "تعارض / conflict (slot_taken, quota_exceeded, deposit_pending)"
     },
     "422": {
      "description": "تحقق / validation error"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "حفظ تفضيلات الإشعارات / Save notification preferences",
    "tags": [
     "staff",
     "notifications"
    ],
    "x-emm-app": "staff"
   },
   "servers": [
    {
     "description": "staff",
     "url": "https://staff.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "staff"
  },
  "/staff/api/v1/periods": {
   "get": {
    "description": "آخر 12 فترة (الأحدث أولاً) مع مفتاح الفترة وحالة الإغلاق. Latest periods with key and closed flag.",
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "فترات الرواتب / Salary periods",
    "tags": [
     "staff",
     "periods"
    ],
    "x-emm-app": "staff"
   },
   "servers": [
    {
     "description": "staff",
     "url": "https://staff.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "staff"
  },
  "/staff/api/v1/plan": {
   "get": {
    "description": "الخطة الحالية مع الاستهلاك وكل الخطط بأسعارها وحدودها. Current plan with usage plus every plan (SAR/month).",
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "الخطة الحالية وكل الخطط / Current plan and catalogue",
    "tags": [
     "staff",
     "plan"
    ],
    "x-emm-app": "staff"
   },
   "servers": [
    {
     "description": "staff",
     "url": "https://staff.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "staff"
  },
  "/staff/api/v1/punches": {
   "get": {
    "description": "بصمات في نطاق تاريخي (≤ 92 يوماً) مع فلتر employee_id. Punches in a date range with optional employee filter.",
    "parameters": [
     {
      "description": "بداية النطاق YYYY-MM-DD",
      "in": "query",
      "name": "from",
      "schema": {
       "format": "date",
       "type": "string"
      }
     },
     {
      "description": "نهاية النطاق YYYY-MM-DD (شاملة)",
      "in": "query",
      "name": "to",
      "schema": {
       "format": "date",
       "type": "string"
      }
     },
     {
      "description": "فلتر/معرّف الموظف",
      "in": "query",
      "name": "employee_id",
      "schema": {
       "type": "integer"
      }
     },
     {
      "description": "عدد النتائج (1–200، افتراضي 50)",
      "in": "query",
      "name": "limit",
      "schema": {
       "default": 50,
       "maximum": 200,
       "minimum": 1,
       "type": "integer"
      }
     },
     {
      "description": "تخطي النتائج",
      "in": "query",
      "name": "offset",
      "schema": {
       "default": 0,
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "البصمات / Punches",
    "tags": [
     "staff",
     "punches"
    ],
    "x-emm-app": "staff"
   },
   "post": {
    "description": "يسجّل حضوراً/انصرافاً لموظف (نفس التحقق من الشاشة). Records a manual in/out punch (idempotent on same employee+time+direction).",
    "requestBody": {
     "content": {
      "application/json": {
       "example": {
        "at": "2026-12-02T09:05",
        "direction": "in",
        "employee_id": 1
       },
       "schema": {
        "properties": {
         "at": {
          "description": "الوقت بتوقيت الرياض 2026-12-02T09:05 أو 2026-12-02 09:05",
          "example": "2026-12-02T09:05",
          "type": "string"
         },
         "direction": {
          "description": "in | out",
          "enum": [
           "in",
           "out"
          ],
          "example": "in",
          "type": "string"
         },
         "employee_id": {
          "description": "معرّف الموظف",
          "example": "1",
          "type": "number"
         }
        },
        "required": [
         "employee_id",
         "at",
         "direction"
        ],
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "at": "2026-12-02T09:05:00+03:00",
          "created": true,
          "direction": "in",
          "employee_id": 1,
          "employee_name": "أحمد سالم",
          "id": 10,
          "source": "manual"
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "201": {
      "description": "أُنشئ / created"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "409": {
      "description": "تعارض / conflict (slot_taken, quota_exceeded, deposit_pending)"
     },
     "422": {
      "description": "تحقق / validation error"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "بصمة يدوية / Manual punch",
    "tags": [
     "staff",
     "punches"
    ],
    "x-emm-app": "staff"
   },
   "servers": [
    {
     "description": "staff",
     "url": "https://staff.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "staff"
  },
  "/staff/api/v1/punches/{id}": {
   "delete": {
    "description": "يحذف بصمة يدوية. Deletes a punch.",
    "parameters": [
     {
      "description": "معرّف رقمي",
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "data": {
           "deleted": true
          },
          "ok": true
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "409": {
      "description": "تعارض / conflict (slot_taken, quota_exceeded, deposit_pending)"
     },
     "422": {
      "description": "تحقق / validation error"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "حذف بصمة / Delete punch",
    "tags": [
     "staff",
     "punches"
    ],
    "x-emm-app": "staff"
   },
   "servers": [
    {
     "description": "staff",
     "url": "https://staff.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "staff"
  },
  "/staff/api/v1/reports/period": {
   "get": {
    "description": "كشف الرواتب لفترة (period=YYYY-MM-DD مفتاح الفترة؛ الافتراضي الحالية). يحتاج خطة تدعم الرواتب (403 plan_limit). Payroll rows + totals.",
    "parameters": [
     {
      "description": "مفتاح الفترة YYYY-MM-DD (يوم بداية الفترة؛ من /periods)",
      "in": "query",
      "name": "period",
      "schema": {
       "format": "date",
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "كشف فترة (JSON) / Period report (JSON)",
    "tags": [
     "staff",
     "reports"
    ],
    "x-emm-app": "staff"
   },
   "servers": [
    {
     "description": "staff",
     "url": "https://staff.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "staff"
  },
  "/staff/api/v1/reports/period.csv": {
   "get": {
    "description": "كشف رواتب CSV بأعمدة مرجعية شبيهة بقيود التأمينات موسومة «مرجعي» — ليس قيداً رسمياً. Payroll CSV with GOSI-like reference columns.",
    "parameters": [
     {
      "description": "مفتاح الفترة YYYY-MM-DD (يوم بداية الفترة؛ من /periods)",
      "in": "query",
      "name": "period",
      "schema": {
       "format": "date",
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "properties": {
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "كشف فترة (CSV مرجعي) / Period report (reference CSV)",
    "tags": [
     "staff",
     "reports"
    ],
    "x-emm-app": "staff"
   },
   "servers": [
    {
     "description": "staff",
     "url": "https://staff.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "staff"
  },
  "/staff/api/v1/settings": {
   "get": {
    "description": "أسبوع العمل، الدوام، الساعات اليومية، يوم بداية الفترة، السماح بالتأخير، قواسم الخصم. Workweek, shift, daily hours, period start day, grace, deduction rules.",
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "absent_ded_divisor": 30,
          "currency": "SAR",
          "daily_hours": 8,
          "late_ded_per_min": "0.00",
          "late_grace_min": 15,
          "name": "شركة النور",
          "period_start_day": 26,
          "shift_end": "17:00",
          "shift_start": "09:00",
          "timezone": "Asia/Riyadh",
          "workweek": [
           true,
           true,
           true,
           true,
           true,
           false,
           false
          ]
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "قواعد الحضور والرواتب / Attendance \u0026 payroll rules",
    "tags": [
     "staff",
     "settings"
    ],
    "x-emm-app": "staff"
   },
   "put": {
    "description": "تحديث جزئي: name, workweek[7] (0=الأحد), shift_start, shift_end (HH:MM), daily_hours, period_start_day (1–31), late_grace_min, absent_ded_divisor, late_ded_per_min. Partial update.",
    "requestBody": {
     "content": {
      "application/json": {
       "example": {
        "absent_ded_divisor": 30,
        "daily_hours": 8,
        "late_grace_min": 15,
        "name": "شركة النور",
        "period_start_day": 26,
        "shift_end": "17:00",
        "shift_start": "09:00",
        "workweek": [
         true,
         true,
         true,
         true,
         true,
         false,
         false
        ]
       },
       "schema": {
        "properties": {
         "absent_ded_divisor": {
          "description": "خصم يوم الغياب = الراتب ÷ هذا القاسم",
          "example": "30",
          "type": "number"
         },
         "daily_hours": {
          "description": "الساعات اليومية (\u003e0، ≤24)",
          "example": "8",
          "type": "number"
         },
         "late_ded_per_min": {
          "description": "خصم التأخير لكل دقيقة بالريال (0 = تقرير فقط)",
          "example": "0",
          "type": "number"
         },
         "late_grace_min": {
          "description": "سماح التأخير بالدقائق (≥0)",
          "example": "15",
          "type": "number"
         },
         "name": {
          "description": "اسم المنشأة",
          "example": "شركة النور",
          "type": "string"
         },
         "period_start_day": {
          "description": "يوم بداية فترة الراتب 1–31",
          "example": "26",
          "type": "number"
         },
         "shift_end": {
          "description": "نهاية الدوام HH:MM",
          "example": "17:00",
          "type": "string"
         },
         "shift_start": {
          "description": "بداية الدوام HH:MM",
          "example": "09:00",
          "type": "string"
         },
         "workweek": {
          "description": "7 قيم، 0=الأحد … 6=السبت (يوم واحد على الأقل)",
          "items": {
           "type": "string"
          },
          "type": "array"
         }
        },
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "example": {
         "data": {
          "absent_ded_divisor": 30,
          "currency": "SAR",
          "daily_hours": 8,
          "late_ded_per_min": "0.00",
          "late_grace_min": 15,
          "name": "شركة النور",
          "period_start_day": 26,
          "shift_end": "17:00",
          "shift_start": "09:00",
          "timezone": "Asia/Riyadh",
          "workweek": [
           true,
           true,
           true,
           true,
           true,
           false,
           false
          ]
         },
         "ok": true
        },
        "schema": {
         "properties": {
          "data": {
           "type": "object"
          },
          "ok": {
           "type": "boolean"
          }
         },
         "required": [
          "ok"
         ],
         "type": "object"
        }
       }
      },
      "description": "نجاح / success"
     },
     "401": {
      "description": "مفتاح مفقود أو غير صالح / missing or invalid key"
     },
     "403": {
      "description": "المفتاح بلا صلاحية / missing scope"
     },
     "409": {
      "description": "تعارض / conflict (slot_taken, quota_exceeded, deposit_pending)"
     },
     "422": {
      "description": "تحقق / validation error"
     },
     "429": {
      "description": "تجاوز الحد / rate limited (Retry-After)"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "تحديث القواعد / Update rules",
    "tags": [
     "staff",
     "settings"
    ],
    "x-emm-app": "staff"
   },
   "servers": [
    {
     "description": "staff",
     "url": "https://staff.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "staff"
  },
  "/zatca/businesses": {
   "post": {
    "description": "Create a business + profile and run the readiness check — إنشاء منشأة مع الفحص. Requires scope: write.",
    "requestBody": {
     "content": {
      "application/json": {
       "example": {
        "annual_revenue": 250000,
        "invoice_tool": "sheets",
        "name": "متجر الشمال",
        "vat_number": "310123456700003",
        "vat_registered": true
       },
       "schema": {
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "$ref": "#/components/schemas/zatca_Envelope",
      "description": "OK"
     },
     "201": {
      "$ref": "#/components/schemas/zatca_Envelope",
      "description": "Created"
     },
     "401": {
      "description": "مفتاح API مفقود أو غير صالح أو ملغى — missing/invalid/revoked key"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية — missing scope"
     },
     "429": {
      "description": "الحد 60 طلباً/دقيقة لكل مفتاح — Retry-After header"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "Create a business + profile and run the readiness check",
    "tags": [
     "zatca"
    ],
    "x-emm-app": "zatca"
   },
   "servers": [
    {
     "description": "zatca",
     "url": "https://zatca.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "zatca"
  },
  "/zatca/businesses/{id}": {
   "delete": {
    "description": "Delete a business — حذف منشأة. Requires scope: write.",
    "parameters": [
     {
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "$ref": "#/components/schemas/zatca_Envelope",
      "description": "OK"
     },
     "401": {
      "description": "مفتاح API مفقود أو غير صالح أو ملغى — missing/invalid/revoked key"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية — missing scope"
     },
     "429": {
      "description": "الحد 60 طلباً/دقيقة لكل مفتاح — Retry-After header"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "Delete a business",
    "tags": [
     "zatca"
    ],
    "x-emm-app": "zatca"
   },
   "get": {
    "description": "One business with its latest result and gaps — منشأة واحدة مع النتيجة والفجوات. Requires scope: read.",
    "parameters": [
     {
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "$ref": "#/components/schemas/zatca_Envelope",
      "description": "OK"
     },
     "401": {
      "description": "مفتاح API مفقود أو غير صالح أو ملغى — missing/invalid/revoked key"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية — missing scope"
     },
     "429": {
      "description": "الحد 60 طلباً/دقيقة لكل مفتاح — Retry-After header"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "One business with its latest result and gaps",
    "tags": [
     "zatca"
    ],
    "x-emm-app": "zatca"
   },
   "patch": {
    "description": "Update profile/identity and re-run the check — تحديث الملف وإعادة الفحص. Requires scope: write.",
    "parameters": [
     {
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "example": {
        "annual_revenue": 400000,
        "invoice_tool": "erp"
       },
       "schema": {
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "$ref": "#/components/schemas/zatca_Envelope",
      "description": "OK"
     },
     "401": {
      "description": "مفتاح API مفقود أو غير صالح أو ملغى — missing/invalid/revoked key"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية — missing scope"
     },
     "429": {
      "description": "الحد 60 طلباً/دقيقة لكل مفتاح — Retry-After header"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "Update profile/identity and re-run the check",
    "tags": [
     "zatca"
    ],
    "x-emm-app": "zatca"
   },
   "servers": [
    {
     "description": "zatca",
     "url": "https://zatca.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "zatca"
  },
  "/zatca/businesses?limit=50\u0026offset=0": {
   "get": {
    "description": "List saved businesses (paginated) — قائمة المنشآت المحفوظة. Requires scope: read.",
    "responses": {
     "200": {
      "$ref": "#/components/schemas/zatca_Envelope",
      "description": "OK"
     },
     "401": {
      "description": "مفتاح API مفقود أو غير صالح أو ملغى — missing/invalid/revoked key"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية — missing scope"
     },
     "429": {
      "description": "الحد 60 طلباً/دقيقة لكل مفتاح — Retry-After header"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "List saved businesses (paginated)",
    "tags": [
     "zatca"
    ],
    "x-emm-app": "zatca"
   },
   "servers": [
    {
     "description": "zatca",
     "url": "https://zatca.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "zatca"
  },
  "/zatca/kits": {
   "post": {
    "description": "Buy a kit for a business → checkout_url (https) or paid kit when the plan includes kits — شراء حزمة لمنشأة. Requires scope: write.",
    "requestBody": {
     "content": {
      "application/json": {
       "example": {
        "business_id": 3
       },
       "schema": {
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "$ref": "#/components/schemas/zatca_Envelope",
      "description": "OK"
     },
     "401": {
      "description": "مفتاح API مفقود أو غير صالح أو ملغى — missing/invalid/revoked key"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية — missing scope"
     },
     "429": {
      "description": "الحد 60 طلباً/دقيقة لكل مفتاح — Retry-After header"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "Buy a kit for a business → checkout_url (https) or paid kit when the plan includes kits",
    "tags": [
     "zatca"
    ],
    "x-emm-app": "zatca"
   },
   "servers": [
    {
     "description": "zatca",
     "url": "https://zatca.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "zatca"
  },
  "/zatca/kits/{id}": {
   "get": {
    "description": "One kit — حزمة واحدة. Requires scope: read.",
    "parameters": [
     {
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "$ref": "#/components/schemas/zatca_Envelope",
      "description": "OK"
     },
     "401": {
      "description": "مفتاح API مفقود أو غير صالح أو ملغى — missing/invalid/revoked key"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية — missing scope"
     },
     "429": {
      "description": "الحد 60 طلباً/دقيقة لكل مفتاح — Retry-After header"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "One kit",
    "tags": [
     "zatca"
    ],
    "x-emm-app": "zatca"
   },
   "servers": [
    {
     "description": "zatca",
     "url": "https://zatca.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "zatca"
  },
  "/zatca/kits/{id}/download": {
   "get": {
    "description": "Kit ZIP (paid only) — binary, outside the envelope — تحميل الحزمة ZIP (مدفوعة فقط). Requires scope: read.",
    "parameters": [
     {
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "$ref": "#/components/schemas/zatca_Envelope",
      "description": "OK"
     },
     "401": {
      "description": "مفتاح API مفقود أو غير صالح أو ملغى — missing/invalid/revoked key"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية — missing scope"
     },
     "429": {
      "description": "الحد 60 طلباً/دقيقة لكل مفتاح — Retry-After header"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "Kit ZIP (paid only) — binary, outside the envelope",
    "tags": [
     "zatca"
    ],
    "x-emm-app": "zatca"
   },
   "servers": [
    {
     "description": "zatca",
     "url": "https://zatca.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "zatca"
  },
  "/zatca/kits?limit=50\u0026offset=0": {
   "get": {
    "description": "List kits (paid/pending) with download state — قائمة الحزم. Requires scope: read.",
    "responses": {
     "200": {
      "$ref": "#/components/schemas/zatca_Envelope",
      "description": "OK"
     },
     "401": {
      "description": "مفتاح API مفقود أو غير صالح أو ملغى — missing/invalid/revoked key"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية — missing scope"
     },
     "429": {
      "description": "الحد 60 طلباً/دقيقة لكل مفتاح — Retry-After header"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "List kits (paid/pending) with download state",
    "tags": [
     "zatca"
    ],
    "x-emm-app": "zatca"
   },
   "servers": [
    {
     "description": "zatca",
     "url": "https://zatca.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "zatca"
  },
  "/zatca/me": {
   "get": {
    "description": "Current user, plan and limits — المستخدم الحالي وخطته وحدوده. Requires scope: read.",
    "responses": {
     "200": {
      "$ref": "#/components/schemas/zatca_Envelope",
      "description": "OK"
     },
     "401": {
      "description": "مفتاح API مفقود أو غير صالح أو ملغى — missing/invalid/revoked key"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية — missing scope"
     },
     "429": {
      "description": "الحد 60 طلباً/دقيقة لكل مفتاح — Retry-After header"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "Current user, plan and limits",
    "tags": [
     "zatca"
    ],
    "x-emm-app": "zatca"
   },
   "servers": [
    {
     "description": "zatca",
     "url": "https://zatca.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "zatca"
  },
  "/zatca/phase-lookup": {
   "post": {
    "description": "Profile → phase, wave, deadline, gap list, citations — ملف المنشأة → المرحلة والموجة والموعد والفجوات. Requires scope: read.",
    "requestBody": {
     "content": {
      "application/json": {
       "example": {
        "annual_revenue": 250000,
        "invoice_tool": "accounting",
        "vat_registered": true
       },
       "schema": {
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "$ref": "#/components/schemas/zatca_Envelope",
      "description": "OK"
     },
     "401": {
      "description": "مفتاح API مفقود أو غير صالح أو ملغى — missing/invalid/revoked key"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية — missing scope"
     },
     "429": {
      "description": "الحد 60 طلباً/دقيقة لكل مفتاح — Retry-After header"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "Profile → phase, wave, deadline, gap list, citations",
    "tags": [
     "zatca"
    ],
    "x-emm-app": "zatca"
   },
   "servers": [
    {
     "description": "zatca",
     "url": "https://zatca.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "zatca"
  },
  "/zatca/plan": {
   "get": {
    "description": "Plans, prices (SAR strings), free-tier limits — الخطط والأسعار (ريال نصي) وحدود المجاني. Requires scope: read.",
    "responses": {
     "200": {
      "$ref": "#/components/schemas/zatca_Envelope",
      "description": "OK"
     },
     "401": {
      "description": "مفتاح API مفقود أو غير صالح أو ملغى — missing/invalid/revoked key"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية — missing scope"
     },
     "429": {
      "description": "الحد 60 طلباً/دقيقة لكل مفتاح — Retry-After header"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "Plans, prices (SAR strings), free-tier limits",
    "tags": [
     "zatca"
    ],
    "x-emm-app": "zatca"
   },
   "servers": [
    {
     "description": "zatca",
     "url": "https://zatca.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "zatca"
  },
  "/zatca/required-fields?phase=2\u0026kind=simplified": {
   "get": {
    "description": "Mandatory invoice fields per phase and kind — حقول الفاتورة الإلزامية لكل مرحلة ونوع. Requires scope: read.",
    "responses": {
     "200": {
      "$ref": "#/components/schemas/zatca_Envelope",
      "description": "OK"
     },
     "401": {
      "description": "مفتاح API مفقود أو غير صالح أو ملغى — missing/invalid/revoked key"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية — missing scope"
     },
     "429": {
      "description": "الحد 60 طلباً/دقيقة لكل مفتاح — Retry-After header"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "Mandatory invoice fields per phase and kind",
    "tags": [
     "zatca"
    ],
    "x-emm-app": "zatca"
   },
   "servers": [
    {
     "description": "zatca",
     "url": "https://zatca.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "zatca"
  },
  "/zatca/validate": {
   "post": {
    "description": "Validate an invoice: invoice (JSON object) | xml | qr | text — مدقق الفواتير: كائن JSON أو XML أو QR أو نص. Requires scope: read.",
    "requestBody": {
     "content": {
      "application/json": {
       "example": {
        "invoice": {
         "kind": "simplified",
         "qr": "…",
         "seller_vat": "310123456700003",
         "taxable_amount": "100",
         "total_with_vat": "115",
         "vat_amount": "15",
         "vat_rate": "15"
        }
       },
       "schema": {
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "$ref": "#/components/schemas/zatca_Envelope",
      "description": "OK"
     },
     "401": {
      "description": "مفتاح API مفقود أو غير صالح أو ملغى — missing/invalid/revoked key"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية — missing scope"
     },
     "429": {
      "description": "الحد 60 طلباً/دقيقة لكل مفتاح — Retry-After header"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "Validate an invoice: invoice (JSON object) | xml | qr | text",
    "tags": [
     "zatca"
    ],
    "x-emm-app": "zatca"
   },
   "servers": [
    {
     "description": "zatca",
     "url": "https://zatca.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "zatca"
  },
  "/zatca/validations?limit=50\u0026offset=0": {
   "get": {
    "description": "Validation history (paginated) — سجل الفحوص (مع ترقيم). Requires scope: read.",
    "responses": {
     "200": {
      "$ref": "#/components/schemas/zatca_Envelope",
      "description": "OK"
     },
     "401": {
      "description": "مفتاح API مفقود أو غير صالح أو ملغى — missing/invalid/revoked key"
     },
     "403": {
      "description": "المفتاح لا يملك الصلاحية — missing scope"
     },
     "429": {
      "description": "الحد 60 طلباً/دقيقة لكل مفتاح — Retry-After header"
     }
    },
    "security": [
     {
      "bearerAuth": []
     }
    ],
    "summary": "Validation history (paginated)",
    "tags": [
     "zatca"
    ],
    "x-emm-app": "zatca"
   },
   "servers": [
    {
     "description": "zatca",
     "url": "https://zatca.emm.sa/api/v1"
    }
   ],
   "x-emm-app": "zatca"
  }
 },
 "servers": [
  {
   "description": "hub (directory, introspection)",
   "url": "https://api.emm.sa"
  }
 ],
 "tags": [
  {
   "description": "فاتورة — invoice.emm.sa",
   "name": "invoice"
  },
  {
   "description": "موعد — booking.emm.sa",
   "name": "booking"
  },
  {
   "description": "حضور — staff.emm.sa",
   "name": "staff"
  },
  {
   "description": "نماذج — form.emm.sa",
   "name": "form"
  },
  {
   "description": "مينيو — menu.emm.sa",
   "name": "menu"
  },
  {
   "description": "فعاليات — event.emm.sa",
   "name": "event"
  },
  {
   "description": "رمز — qr.emm.sa",
   "name": "qr"
  },
  {
   "description": "بي دي إف — pdf.emm.sa",
   "name": "pdf"
  },
  {
   "description": "سيرة — cv.emm.sa",
   "name": "cv"
  },
  {
   "description": "عقود — contracts.emm.sa",
   "name": "contracts"
  },
  {
   "description": "لَحنك — lahnak.emm.sa",
   "name": "lahnak"
  },
  {
   "description": "عون — aun.emm.sa",
   "name": "aun"
  },
  {
   "description": "موثوق — zatca.emm.sa",
   "name": "zatca"
  }
 ],
 "x-emm-apps": [
  {
   "docs_url": "https://invoice.emm.sa/api/docs",
   "host": "invoice.emm.sa",
   "mcp_url": "https://invoice.emm.sa/mcp",
   "name_ar": "فاتورة",
   "name_en": "Invoice",
   "openapi_url": "https://invoice.emm.sa/api/openapi.json",
   "path_count": 12,
   "slug": "invoice",
   "status": "live",
   "status_ar": "متاح"
  },
  {
   "docs_url": "https://booking.emm.sa/api/docs",
   "host": "booking.emm.sa",
   "mcp_url": "https://booking.emm.sa/mcp",
   "name_ar": "موعد",
   "name_en": "Booking",
   "openapi_url": "https://booking.emm.sa/api/openapi.json",
   "path_count": 13,
   "slug": "booking",
   "status": "live",
   "status_ar": "متاح"
  },
  {
   "docs_url": "https://staff.emm.sa/api/docs",
   "host": "staff.emm.sa",
   "mcp_url": "https://staff.emm.sa/mcp",
   "name_ar": "حضور",
   "name_en": "Staff",
   "openapi_url": "https://staff.emm.sa/api/openapi.json",
   "path_count": 17,
   "slug": "staff",
   "status": "live",
   "status_ar": "متاح"
  },
  {
   "docs_url": "https://form.emm.sa/api/docs",
   "host": "form.emm.sa",
   "mcp_url": "https://form.emm.sa/mcp",
   "name_ar": "نماذج",
   "name_en": "Forms",
   "openapi_url": "https://form.emm.sa/api/openapi.json",
   "path_count": 17,
   "slug": "form",
   "status": "live",
   "status_ar": "متاح"
  },
  {
   "docs_url": "https://menu.emm.sa/api/docs",
   "host": "menu.emm.sa",
   "mcp_url": "https://menu.emm.sa/mcp",
   "name_ar": "مينيو",
   "name_en": "Menu",
   "openapi_url": "https://menu.emm.sa/api/openapi.json",
   "path_count": 15,
   "slug": "menu",
   "status": "live",
   "status_ar": "متاح"
  },
  {
   "docs_url": "https://event.emm.sa/api/docs",
   "host": "event.emm.sa",
   "mcp_url": "https://event.emm.sa/mcp",
   "name_ar": "فعاليات",
   "name_en": "Events",
   "openapi_url": "https://event.emm.sa/api/openapi.json",
   "path_count": 14,
   "slug": "event",
   "status": "live",
   "status_ar": "متاح"
  },
  {
   "docs_url": "https://qr.emm.sa/api/docs",
   "host": "qr.emm.sa",
   "mcp_url": "https://qr.emm.sa/mcp",
   "name_ar": "رمز",
   "name_en": "QR",
   "openapi_url": "https://qr.emm.sa/api/openapi.json",
   "path_count": 9,
   "slug": "qr",
   "status": "live",
   "status_ar": "متاح"
  },
  {
   "docs_url": "https://pdf.emm.sa/api/docs",
   "host": "pdf.emm.sa",
   "mcp_url": "https://pdf.emm.sa/mcp",
   "name_ar": "بي دي إف",
   "name_en": "PDF",
   "openapi_url": "https://pdf.emm.sa/api/openapi.json",
   "path_count": 9,
   "slug": "pdf",
   "status": "live",
   "status_ar": "متاح"
  },
  {
   "docs_url": "https://cv.emm.sa/api/docs",
   "host": "cv.emm.sa",
   "mcp_url": "https://cv.emm.sa/mcp",
   "name_ar": "سيرة",
   "name_en": "CV",
   "openapi_url": "https://cv.emm.sa/api/openapi.json",
   "path_count": 12,
   "slug": "cv",
   "status": "live",
   "status_ar": "متاح"
  },
  {
   "docs_url": "https://contracts.emm.sa/api/docs",
   "host": "contracts.emm.sa",
   "mcp_url": "https://contracts.emm.sa/mcp",
   "name_ar": "عقود",
   "name_en": "Contracts",
   "openapi_url": "https://contracts.emm.sa/api/openapi.json",
   "path_count": 12,
   "slug": "contracts",
   "status": "live",
   "status_ar": "متاح"
  },
  {
   "docs_url": "https://lahnak.emm.sa/api/docs",
   "host": "lahnak.emm.sa",
   "mcp_url": "https://lahnak.emm.sa/mcp",
   "name_ar": "لَحنك",
   "name_en": "Lahnak",
   "openapi_url": "https://lahnak.emm.sa/api/openapi.json",
   "path_count": 7,
   "slug": "lahnak",
   "status": "live",
   "status_ar": "متاح"
  },
  {
   "docs_url": "https://aun.emm.sa/api/docs",
   "host": "aun.emm.sa",
   "mcp_url": "https://aun.emm.sa/mcp",
   "name_ar": "عون",
   "name_en": "Aun",
   "openapi_url": "https://aun.emm.sa/api/openapi.json",
   "path_count": 9,
   "slug": "aun",
   "status": "live",
   "status_ar": "متاح"
  },
  {
   "docs_url": "https://pay.emm.sa/api/docs",
   "host": "pay.emm.sa",
   "mcp_url": "https://pay.emm.sa/mcp",
   "name_ar": "إم باي",
   "name_en": "emm-pay",
   "openapi_url": "https://pay.emm.sa/api/openapi.json",
   "path_count": 0,
   "slug": "pay",
   "status": "coming_soon",
   "status_ar": "قريباً"
  },
  {
   "docs_url": "https://zatca.emm.sa/api/docs",
   "host": "zatca.emm.sa",
   "mcp_url": "https://zatca.emm.sa/mcp",
   "name_ar": "موثوق",
   "name_en": "Muwathiq",
   "openapi_url": "https://zatca.emm.sa/api/openapi.json",
   "path_count": 13,
   "slug": "zatca",
   "status": "live",
   "status_ar": "متاح"
  }
 ],
 "x-emm-generated-at": "2026-12-04T22:53:32Z"
}
