{
 "openapi": "3.0.3",
 "info": {
  "title": "Lawia API",
  "version": "1",
  "description": "اقرأ بيانات لوايا وحدّثها من أنظمتك. كل طلب يعمل باسم صاحب المفتاح: يسري عليه دوره والقضايا التي يراها ونطاقات المفتاح. أما حساب الخدمة فيعمل باسم المكتب، بنطاقاته، ولا يرى أبدًا قضية عليها حاجز أخلاقي ولا قضية مشاركة مع أشخاص محددين فقط.",
  "x-documentation": "https://lawia.io/developers/"
 },
 "servers": [
  {
   "url": "https://lawia.io/api/v1"
  }
 ],
 "security": [
  {
   "key": []
  },
  {
   "oauth": []
  }
 ],
 "components": {
  "securitySchemes": {
   "key": {
    "type": "http",
    "scheme": "bearer",
    "description": "مفتاح API من الإعدادات، الواجهة البرمجية والـ Webhooks."
   },
   "oauth": {
    "type": "oauth2",
    "description": "معرّف عميل ورمز سري من الإعدادات، الواجهة البرمجية والـ Webhooks، يُستبدل بهما رمز دخول صالح لمدة ساعة.",
    "flows": {
     "clientCredentials": {
      "tokenUrl": "https://lawia.io/api/v1/oauth/token",
      "scopes": {
       "contacts:read": "الموكلون وجهات الاتصال: قراءة",
       "cases:read": "القضايا ومستنداتها: قراءة",
       "time:read": "الوقت والمصروفات: قراءة",
       "billing:read": "الفواتير والمدفوعات: قراءة",
       "tasks:read": "المهام: قراءة",
       "reports:read": "موجزات التقارير لـ Power BI وExcel: قراءة",
       "audit:read": "سجل التدقيق: قراءة",
       "contacts:write": "الموكلون وجهات الاتصال: قراءة وكتابة",
       "cases:write": "القضايا ومستنداتها: قراءة وكتابة",
       "time:write": "الوقت والمصروفات: قراءة وكتابة",
       "billing:write": "الفواتير والمدفوعات: قراءة وكتابة"
      }
     }
    }
   }
  },
  "schemas": {
   "member": {
    "type": "object",
    "properties": {
     "id": {
      "type": "integer"
     },
     "name": {
      "type": "string"
     },
     "title": {
      "type": "string"
     },
     "email": {
      "type": "string"
     },
     "role": {
      "type": "string"
     }
    }
   },
   "contact": {
    "type": "object",
    "properties": {
     "id": {
      "type": "integer"
     },
     "kind": {
      "type": "string"
     },
     "name": {
      "type": "string"
     },
     "first_name": {
      "type": "string"
     },
     "last_name": {
      "type": "string"
     },
     "email": {
      "type": "string"
     },
     "phone": {
      "type": "string"
     },
     "preferred_language": {
      "type": "string"
     },
     "archived": {
      "type": "boolean"
     },
     "created_at": {
      "type": "string",
      "format": "date-time"
     },
     "updated_at": {
      "type": "string",
      "format": "date-time"
     },
     "url": {
      "type": "string"
     }
    }
   },
   "template": {
    "type": "object",
    "properties": {
     "id": {
      "type": "integer"
     },
     "name": {
      "type": "string"
     },
     "practice_area": {
      "type": "object",
      "nullable": true
     }
    }
   },
   "case": {
    "type": "object",
    "properties": {
     "id": {
      "type": "integer"
     },
     "number": {
      "type": "string"
     },
     "title": {
      "type": "string"
     },
     "other_title": {
      "type": "string"
     },
     "status": {
      "type": "string"
     },
     "client": {
      "type": "object",
      "nullable": true
     },
     "practice_area": {
      "type": "object",
      "nullable": true
     },
     "stage": {
      "type": "string"
     },
     "template": {
      "type": "integer"
     },
     "responsible": {
      "type": "object",
      "nullable": true
     },
     "originating": {
      "type": "object",
      "nullable": true
     },
     "opened_on": {
      "type": "string",
      "format": "date"
     },
     "closed_on": {
      "type": "string",
      "format": "date"
     },
     "court_case_number": {
      "type": "string"
     },
     "client_reference": {
      "type": "string"
     },
     "description": {
      "type": "string"
     },
     "other_description": {
      "type": "string"
     },
     "tags": {
      "type": "array",
      "items": {
       "type": "string"
      }
     },
     "created_at": {
      "type": "string",
      "format": "date-time"
     },
     "updated_at": {
      "type": "string",
      "format": "date-time"
     },
     "url": {
      "type": "string"
     }
    }
   },
   "time_entry": {
    "type": "object",
    "properties": {
     "id": {
      "type": "integer"
     },
     "case": {
      "type": "object",
      "nullable": true
     },
     "person": {
      "type": "object",
      "nullable": true
     },
     "worked_on": {
      "type": "string",
      "format": "date"
     },
     "minutes": {
      "type": "integer"
     },
     "billable_minutes": {
      "type": "integer"
     },
     "billable": {
      "type": "boolean"
     },
     "approval": {
      "type": "string"
     },
     "activity": {
      "type": "string"
     },
     "narrative": {
      "type": "string"
     },
     "amount": {
      "type": "string",
      "description": "A decimal amount, such as 1500.00"
     },
     "currency": {
      "type": "string"
     },
     "status": {
      "type": "string"
     },
     "invoice": {
      "type": "integer"
     },
     "created_at": {
      "type": "string",
      "format": "date-time"
     },
     "updated_at": {
      "type": "string",
      "format": "date-time"
     }
    }
   },
   "expense": {
    "type": "object",
    "properties": {
     "id": {
      "type": "integer"
     },
     "case": {
      "type": "object",
      "nullable": true
     },
     "person": {
      "type": "object",
      "nullable": true
     },
     "incurred_on": {
      "type": "string",
      "format": "date"
     },
     "description": {
      "type": "string"
     },
     "kind": {
      "type": "string"
     },
     "category": {
      "type": "string"
     },
     "quantity": {
      "type": "string"
     },
     "unit_price": {
      "type": "string",
      "description": "A decimal amount, such as 1500.00"
     },
     "amount": {
      "type": "string",
      "description": "A decimal amount, such as 1500.00"
     },
     "currency": {
      "type": "string"
     },
     "billable": {
      "type": "boolean"
     },
     "status": {
      "type": "string"
     },
     "invoice": {
      "type": "integer"
     },
     "created_at": {
      "type": "string",
      "format": "date-time"
     }
    }
   },
   "invoice": {
    "type": "object",
    "properties": {
     "id": {
      "type": "integer"
     },
     "number": {
      "type": "string"
     },
     "status": {
      "type": "string"
     },
     "client": {
      "type": "object",
      "nullable": true
     },
     "case": {
      "type": "object",
      "nullable": true
     },
     "issued_on": {
      "type": "string",
      "format": "date"
     },
     "due_on": {
      "type": "string",
      "format": "date"
     },
     "currency": {
      "type": "string"
     },
     "fees": {
      "type": "string",
      "description": "A decimal amount, such as 1500.00"
     },
     "expenses": {
      "type": "string",
      "description": "A decimal amount, such as 1500.00"
     },
     "adjustment": {
      "type": "string",
      "description": "A decimal amount, such as 1500.00"
     },
     "tax": {
      "type": "string",
      "description": "A decimal amount, such as 1500.00"
     },
     "total": {
      "type": "string",
      "description": "A decimal amount, such as 1500.00"
     },
     "paid": {
      "type": "string",
      "description": "A decimal amount, such as 1500.00"
     },
     "written_off": {
      "type": "string",
      "description": "A decimal amount, such as 1500.00"
     },
     "balance": {
      "type": "string",
      "description": "A decimal amount, such as 1500.00"
     },
     "exchange_rate": {
      "type": "string"
     },
     "created_at": {
      "type": "string",
      "format": "date-time"
     },
     "updated_at": {
      "type": "string",
      "format": "date-time"
     },
     "url": {
      "type": "string"
     }
    }
   },
   "payment": {
    "type": "object",
    "properties": {
     "id": {
      "type": "integer"
     },
     "client": {
      "type": "object",
      "nullable": true
     },
     "method": {
      "type": "string"
     },
     "amount": {
      "type": "string",
      "description": "A decimal amount, such as 1500.00"
     },
     "currency": {
      "type": "string"
     },
     "received_on": {
      "type": "string",
      "format": "date"
     },
     "reference": {
      "type": "string"
     },
     "fees": {
      "type": "string",
      "description": "A decimal amount, such as 1500.00"
     },
     "invoices": {
      "type": "array",
      "items": {
       "type": "object"
      }
     },
     "unapplied": {
      "type": "string",
      "description": "A decimal amount, such as 1500.00"
     },
     "created_at": {
      "type": "string",
      "format": "date-time"
     }
    }
   },
   "task": {
    "type": "object",
    "properties": {
     "id": {
      "type": "integer"
     },
     "title": {
      "type": "string"
     },
     "case": {
      "type": "object",
      "nullable": true
     },
     "assignee": {
      "type": "object",
      "nullable": true
     },
     "due_on": {
      "type": "string",
      "format": "date"
     },
     "priority": {
      "type": "string"
     },
     "progress": {
      "type": "string"
     },
     "private": {
      "type": "boolean"
     },
     "done": {
      "type": "boolean"
     },
     "done_at": {
      "type": "string",
      "format": "date-time"
     },
     "done_by": {
      "type": "object",
      "nullable": true
     },
     "created_at": {
      "type": "string",
      "format": "date-time"
     },
     "updated_at": {
      "type": "string",
      "format": "date-time"
     },
     "url": {
      "type": "string"
     }
    }
   },
   "document": {
    "type": "object",
    "properties": {
     "id": {
      "type": "integer"
     },
     "title": {
      "type": "string"
     },
     "case": {
      "type": "object",
      "nullable": true
     },
     "folder": {
      "type": "string"
     },
     "version": {
      "type": "integer"
     },
     "created_at": {
      "type": "string",
      "format": "date-time"
     },
     "url": {
      "type": "string"
     }
    }
   },
   "me": {
    "type": "object",
    "properties": {
     "key": {
      "type": "object"
     },
     "acts_as": {
      "type": "object",
      "nullable": true
     },
     "service_account": {
      "type": "boolean"
     },
     "firm": {
      "type": "object"
     },
     "areas": {
      "type": "object"
     }
    }
   },
   "token": {
    "type": "object",
    "properties": {
     "access_token": {
      "type": "string"
     },
     "token_type": {
      "type": "string",
      "enum": [
       "Bearer"
      ]
     },
     "expires_in": {
      "type": "integer",
      "example": 3600
     },
     "scope": {
      "type": "string"
     }
    }
   },
   "token_error": {
    "type": "object",
    "properties": {
     "error": {
      "type": "string"
     },
     "error_description": {
      "type": "string"
     }
    }
   },
   "row": {
    "type": "object",
    "properties": {
     "id": {
      "type": "integer"
     }
    }
   },
   "audit_event": {
    "type": "object",
    "properties": {
     "id": {
      "type": "integer"
     },
     "time": {
      "type": "string",
      "format": "date-time"
     },
     "action": {
      "type": "string"
     },
     "action_label": {
      "type": "string"
     },
     "by": {
      "type": "object",
      "nullable": true,
      "properties": {
       "type": {
        "type": "string",
        "enum": [
         "person",
         "service_account"
        ]
       },
       "id": {
        "type": "integer",
        "nullable": true
       },
       "name": {
        "type": "string"
       },
       "email": {
        "type": "string",
        "nullable": true
       }
      }
     },
     "api_key": {
      "type": "string",
      "nullable": true
     },
     "ip_address": {
      "type": "string",
      "nullable": true
     },
     "record": {
      "type": "object",
      "nullable": true,
      "properties": {
       "type": {
        "type": "string"
       },
       "id": {
        "type": "string"
       },
       "name": {
        "type": "string"
       }
      }
     },
     "case": {
      "type": "integer",
      "nullable": true
     },
     "details": {
      "type": "object"
     }
    }
   },
   "hearing": {
    "type": "object",
    "properties": {
     "id": {
      "type": "integer"
     },
     "type": {
      "type": "string"
     },
     "title": {
      "type": "string"
     },
     "case": {
      "type": "object",
      "nullable": true
     },
     "starts_at": {
      "type": "string",
      "format": "date-time"
     },
     "ends_at": {
      "type": "string",
      "format": "date-time"
     },
     "all_day": {
      "type": "boolean"
     },
     "court": {
      "type": "string"
     },
     "courthouse": {
      "type": "string"
     },
     "circuit": {
      "type": "string"
     },
     "room": {
      "type": "string"
     },
     "location": {
      "type": "string"
     },
     "decision": {
      "type": "object",
      "nullable": true,
      "properties": {
       "kind": {
        "type": "string"
       },
       "summary": {
        "type": "string"
       },
       "reason": {
        "type": "string"
       },
       "next_date": {
        "type": "string",
        "format": "date"
       },
       "memo_until": {
        "type": "string",
        "format": "date"
       },
       "outcome": {
        "type": "string"
       },
       "finality": {
        "type": "string"
       },
       "text": {
        "type": "string"
       },
       "recorded_by": {
        "type": "string"
       },
       "recorded_at": {
        "type": "string",
        "format": "date-time"
       }
      }
     },
     "created_at": {
      "type": "string",
      "format": "date-time"
     },
     "updated_at": {
      "type": "string",
      "format": "date-time"
     },
     "url": {
      "type": "string"
     }
    }
   },
   "deadline": {
    "type": "object",
    "properties": {
     "id": {
      "type": "integer"
     },
     "kind": {
      "type": "string"
     },
     "title": {
      "type": "string"
     },
     "case": {
      "type": "object",
      "nullable": true
     },
     "due_on": {
      "type": "string",
      "format": "date"
     },
     "court": {
      "type": "string"
     },
     "rule": {
      "type": "string"
     },
     "responsible": {
      "type": "object",
      "nullable": true
     },
     "verified": {
      "type": "boolean"
     },
     "done": {
      "type": "boolean"
     },
     "done_at": {
      "type": "string",
      "format": "date-time"
     },
     "created_at": {
      "type": "string",
      "format": "date-time"
     },
     "updated_at": {
      "type": "string",
      "format": "date-time"
     },
     "url": {
      "type": "string"
     }
    }
   },
   "hearing_change": {
    "type": "object",
    "properties": {
     "change": {
      "type": "string",
      "enum": [
       "added",
       "moved",
       "result"
      ]
     },
     "hearing": {
      "$ref": "#/components/schemas/hearing"
     },
     "deadline": {
      "$ref": "#/components/schemas/deadline"
     }
    }
   },
   "error": {
    "type": "object",
    "properties": {
     "error": {
      "type": "object",
      "properties": {
       "code": {
        "type": "string"
       },
       "message": {
        "type": "string"
       },
       "fields": {
        "type": "object"
       }
      }
     }
    }
   }
  }
 },
 "paths": {
  "/oauth/token": {
   "post": {
    "operationId": "post_oauth_token",
    "summary": "استبدل بمعرّف عميل OAuth ورمزه السري رمز دخول.",
    "tags": [
     "المفتاح"
    ],
    "security": [],
    "description": "أرسل معرّف العميل والرمز السري في ترويسة Basic Authorization، أو في النموذج باسم client_id وclient_secret. ورمز الدخول صالح لمدة ساعة وله صلاحيات العميل.",
    "requestBody": {
     "required": true,
     "content": {
      "application/x-www-form-urlencoded": {
       "schema": {
        "type": "object",
        "required": [
         "grant_type"
        ],
        "properties": {
         "grant_type": {
          "type": "string",
          "enum": [
           "client_credentials"
          ]
         },
         "client_id": {
          "type": "string"
         },
         "client_secret": {
          "type": "string"
         }
        }
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/token"
        }
       }
      }
     },
     "400": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/token_error"
        }
       }
      }
     },
     "401": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/token_error"
        }
       }
      }
     },
     "429": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/token_error"
        }
       }
      }
     }
    }
   }
  },
  "/me": {
   "get": {
    "operationId": "get_me",
    "summary": "المفتاح: باسم من يعمل، ونطاقاته، وموعد انتهاء صلاحيته.",
    "tags": [
     "المفتاح"
    ],
    "parameters": [],
    "responses": {
     "401": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/error"
        }
       }
      }
     },
     "403": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/error"
        }
       }
      }
     },
     "429": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/error"
        }
       }
      }
     },
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "data": {
           "$ref": "#/components/schemas/me"
          }
         }
        }
       }
      }
     }
    }
   }
  },
  "/people": {
   "get": {
    "operationId": "get_people",
    "summary": "العاملون الحاليون في المكتب، لتحديد المحامي المسؤول.",
    "tags": [
     "المفتاح"
    ],
    "parameters": [
     {
      "name": "page",
      "in": "query",
      "schema": {
       "type": "integer"
      },
      "description": "رقم الصفحة، بدءاً من 1."
     },
     {
      "name": "page_size",
      "in": "query",
      "schema": {
       "type": "integer"
      },
      "description": "عدد السجلات في الصفحة: 100 ما لم يُحدَّد، و500 على الأكثر."
     }
    ],
    "responses": {
     "401": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/error"
        }
       }
      }
     },
     "403": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/error"
        }
       }
      }
     },
     "429": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/error"
        }
       }
      }
     },
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "data": {
           "type": "array",
           "items": {
            "$ref": "#/components/schemas/member"
           }
          },
          "page": {
           "type": "integer"
          },
          "page_size": {
           "type": "integer"
          },
          "total": {
           "type": "integer"
          },
          "next": {
           "type": "string",
           "nullable": true
          },
          "previous": {
           "type": "string",
           "nullable": true
          }
         }
        }
       }
      }
     }
    }
   }
  },
  "/contacts": {
   "get": {
    "operationId": "get_contacts",
    "summary": "الموكلون وجهات الاتصال.",
    "tags": [
     "الموكلون وجهات الاتصال"
    ],
    "parameters": [
     {
      "name": "page",
      "in": "query",
      "schema": {
       "type": "integer"
      },
      "description": "رقم الصفحة، بدءاً من 1."
     },
     {
      "name": "page_size",
      "in": "query",
      "schema": {
       "type": "integer"
      },
      "description": "عدد السجلات في الصفحة: 100 ما لم يُحدَّد، و500 على الأكثر."
     },
     {
      "name": "changed_since",
      "in": "query",
      "schema": {
       "type": "string"
      },
      "description": "السجلات التي تغيّرت (أو سُجِّلت، في المدفوعات والمصروفات) في هذا الوقت أو بعده فقط، بتاريخ أو وقت بصيغة ISO 8601، مثل 2026-11-01T08:00:00Z."
     },
     {
      "name": "q",
      "in": "query",
      "schema": {
       "type": "string"
      },
      "description": "التي يحتوي اسمها أو رقمها أو عنوانها على هذا النص فقط."
     },
     {
      "name": "kind",
      "in": "query",
      "schema": {
       "type": "string"
      },
      "description": "person (شخص) أو organization (جهة)."
     }
    ],
    "responses": {
     "401": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/error"
        }
       }
      }
     },
     "403": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/error"
        }
       }
      }
     },
     "429": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/error"
        }
       }
      }
     },
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "data": {
           "type": "array",
           "items": {
            "$ref": "#/components/schemas/contact"
           }
          },
          "page": {
           "type": "integer"
          },
          "page_size": {
           "type": "integer"
          },
          "total": {
           "type": "integer"
          },
          "next": {
           "type": "string",
           "nullable": true
          },
          "previous": {
           "type": "string",
           "nullable": true
          }
         }
        }
       }
      }
     }
    },
    "description": "يتطلب النطاق contacts:read."
   },
   "post": {
    "operationId": "post_contacts",
    "summary": "إضافة موكل أو جهة اتصال.",
    "tags": [
     "الموكلون وجهات الاتصال"
    ],
    "parameters": [],
    "responses": {
     "401": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/error"
        }
       }
      }
     },
     "403": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/error"
        }
       }
      }
     },
     "429": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/error"
        }
       }
      }
     },
     "201": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "data": {
           "$ref": "#/components/schemas/contact"
          }
         }
        }
       }
      }
     },
     "400": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/error"
        }
       }
      }
     }
    },
    "description": "يتطلب النطاق contacts:write.",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [],
        "properties": {
         "kind": {
          "type": "string",
          "description": "person (شخص، وهو الافتراضي) أو organization (جهة)."
         },
         "first_name": {
          "type": "string",
          "description": "الاسم الأول للشخص؛ ويلزم للشخص اسم أول أو اسم عائلة."
         },
         "last_name": {
          "type": "string",
          "description": "اسم العائلة للشخص."
         },
         "name": {
          "type": "string",
          "description": "اسم الجهة."
         },
         "email": {
          "type": "string",
          "description": "بريده الإلكتروني."
         },
         "phone": {
          "type": "string",
          "description": "هاتفه."
         },
         "preferred_language": {
          "type": "string",
          "description": "ar (الافتراضي) أو en."
         },
         "notes": {
          "type": "string",
          "description": "ملاحظات."
         }
        }
       }
      }
     }
    }
   }
  },
  "/contacts/{id}": {
   "get": {
    "operationId": "get_contacts_id",
    "summary": "جهة اتصال واحدة.",
    "tags": [
     "الموكلون وجهات الاتصال"
    ],
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "schema": {
       "type": "integer"
      },
      "description": "معرّف السجل.",
      "required": true
     }
    ],
    "responses": {
     "401": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/error"
        }
       }
      }
     },
     "403": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/error"
        }
       }
      }
     },
     "429": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/error"
        }
       }
      }
     },
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "data": {
           "$ref": "#/components/schemas/contact"
          }
         }
        }
       }
      }
     },
     "404": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/error"
        }
       }
      }
     }
    },
    "description": "يتطلب النطاق contacts:read."
   }
  },
  "/case-templates": {
   "get": {
    "operationId": "get_case-templates",
    "summary": "قوالب القضايا في المكتب، لفتح القضايا منها.",
    "tags": [
     "القضايا ومستنداتها"
    ],
    "parameters": [
     {
      "name": "page",
      "in": "query",
      "schema": {
       "type": "integer"
      },
      "description": "رقم الصفحة، بدءاً من 1."
     },
     {
      "name": "page_size",
      "in": "query",
      "schema": {
       "type": "integer"
      },
      "description": "عدد السجلات في الصفحة: 100 ما لم يُحدَّد، و500 على الأكثر."
     }
    ],
    "responses": {
     "401": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/error"
        }
       }
      }
     },
     "403": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/error"
        }
       }
      }
     },
     "429": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/error"
        }
       }
      }
     },
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "data": {
           "type": "array",
           "items": {
            "$ref": "#/components/schemas/template"
           }
          },
          "page": {
           "type": "integer"
          },
          "page_size": {
           "type": "integer"
          },
          "total": {
           "type": "integer"
          },
          "next": {
           "type": "string",
           "nullable": true
          },
          "previous": {
           "type": "string",
           "nullable": true
          }
         }
        }
       }
      }
     }
    },
    "description": "يتطلب النطاق cases:read."
   }
  },
  "/cases": {
   "get": {
    "operationId": "get_cases",
    "summary": "القضايا التي يستطيع الشخص الذي يعمل المفتاح باسمه رؤيتها.",
    "tags": [
     "القضايا ومستنداتها"
    ],
    "parameters": [
     {
      "name": "page",
      "in": "query",
      "schema": {
       "type": "integer"
      },
      "description": "رقم الصفحة، بدءاً من 1."
     },
     {
      "name": "page_size",
      "in": "query",
      "schema": {
       "type": "integer"
      },
      "description": "عدد السجلات في الصفحة: 100 ما لم يُحدَّد، و500 على الأكثر."
     },
     {
      "name": "changed_since",
      "in": "query",
      "schema": {
       "type": "string"
      },
      "description": "السجلات التي تغيّرت (أو سُجِّلت، في المدفوعات والمصروفات) في هذا الوقت أو بعده فقط، بتاريخ أو وقت بصيغة ISO 8601، مثل 2026-11-01T08:00:00Z."
     },
     {
      "name": "status",
      "in": "query",
      "schema": {
       "type": "string"
      },
      "description": "التي لها هذه الحالة فقط."
     },
     {
      "name": "client",
      "in": "query",
      "schema": {
       "type": "integer"
      },
      "description": "الخاصة بهذا الموكل فقط."
     },
     {
      "name": "q",
      "in": "query",
      "schema": {
       "type": "string"
      },
      "description": "التي يحتوي اسمها أو رقمها أو عنوانها على هذا النص فقط."
     }
    ],
    "responses": {
     "401": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/error"
        }
       }
      }
     },
     "403": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/error"
        }
       }
      }
     },
     "429": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/error"
        }
       }
      }
     },
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "data": {
           "type": "array",
           "items": {
            "$ref": "#/components/schemas/case"
           }
          },
          "page": {
           "type": "integer"
          },
          "page_size": {
           "type": "integer"
          },
          "total": {
           "type": "integer"
          },
          "next": {
           "type": "string",
           "nullable": true
          },
          "previous": {
           "type": "string",
           "nullable": true
          }
         }
        }
       }
      }
     }
    },
    "description": "يتطلب النطاق cases:read."
   },
   "post": {
    "operationId": "post_cases",
    "summary": "فتح قضية من قالب أو من مجال ممارسة. تبقى معلّقة حتى يُبَتّ في فحص التعارض الخاص بها في Lawia.",
    "tags": [
     "القضايا ومستنداتها"
    ],
    "parameters": [],
    "responses": {
     "401": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/error"
        }
       }
      }
     },
     "403": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/error"
        }
       }
      }
     },
     "429": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/error"
        }
       }
      }
     },
     "201": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "data": {
           "$ref": "#/components/schemas/case"
          }
         }
        }
       }
      }
     },
     "400": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/error"
        }
       }
      }
     }
    },
    "description": "يتطلب النطاق cases:write.",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "client",
         "title"
        ],
        "properties": {
         "client": {
          "type": "integer",
          "description": "معرّف الموكل."
         },
         "title": {
          "type": "string",
          "description": "عنوان القضية."
         },
         "template": {
          "type": "integer",
          "description": "معرّف قالب القضية: بمجال ممارسته ومراحله ومهامه ومجلداته."
         },
         "practice_area": {
          "type": "integer",
          "description": "معرّف مجال الممارسة، عند عدم وجود قالب."
         },
         "responsible": {
          "type": "integer",
          "description": "معرّف المحامي المسؤول؛ صاحب المفتاح إن لم يُحدَّد. وعلى حساب الخدمة أن يحدده."
         },
         "originating": {
          "type": "integer",
          "description": "معرّف المحامي الذي جلب القضية."
         },
         "description": {
          "type": "string",
          "description": "وصف."
         },
         "court_case_number": {
          "type": "string",
          "description": "رقم الدعوى لدى المحكمة."
         }
        }
       }
      }
     }
    }
   }
  },
  "/cases/{id}": {
   "get": {
    "operationId": "get_cases_id",
    "summary": "قضية واحدة.",
    "tags": [
     "القضايا ومستنداتها"
    ],
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "schema": {
       "type": "integer"
      },
      "description": "معرّف السجل.",
      "required": true
     }
    ],
    "responses": {
     "401": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/error"
        }
       }
      }
     },
     "403": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/error"
        }
       }
      }
     },
     "429": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/error"
        }
       }
      }
     },
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "data": {
           "$ref": "#/components/schemas/case"
          }
         }
        }
       }
      }
     },
     "404": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/error"
        }
       }
      }
     }
    },
    "description": "يتطلب النطاق cases:read."
   }
  },
  "/time-entries": {
   "get": {
    "operationId": "get_time-entries",
    "summary": "قيود الوقت: قيود الشخص الذي يعمل المفتاح باسمه، وقيود الجميع إن كان يملك رؤيتها.",
    "tags": [
     "الوقت والمصروفات"
    ],
    "parameters": [
     {
      "name": "page",
      "in": "query",
      "schema": {
       "type": "integer"
      },
      "description": "رقم الصفحة، بدءاً من 1."
     },
     {
      "name": "page_size",
      "in": "query",
      "schema": {
       "type": "integer"
      },
      "description": "عدد السجلات في الصفحة: 100 ما لم يُحدَّد، و500 على الأكثر."
     },
     {
      "name": "changed_since",
      "in": "query",
      "schema": {
       "type": "string"
      },
      "description": "السجلات التي تغيّرت (أو سُجِّلت، في المدفوعات والمصروفات) في هذا الوقت أو بعده فقط، بتاريخ أو وقت بصيغة ISO 8601، مثل 2026-11-01T08:00:00Z."
     },
     {
      "name": "from",
      "in": "query",
      "schema": {
       "type": "string"
      },
      "description": "من هذا التاريخ، مثل 2026-11-01."
     },
     {
      "name": "to",
      "in": "query",
      "schema": {
       "type": "string"
      },
      "description": "حتى هذا التاريخ وشاملاً له."
     },
     {
      "name": "case",
      "in": "query",
      "schema": {
       "type": "integer"
      },
      "description": "الخاصة بهذه القضية فقط."
     },
     {
      "name": "person",
      "in": "query",
      "schema": {
       "type": "integer"
      },
      "description": "الخاصة بهذا الشخص فقط."
     },
     {
      "name": "status",
      "in": "query",
      "schema": {
       "type": "string"
      },
      "description": "التي لها هذه الحالة فقط."
     }
    ],
    "responses": {
     "401": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/error"
        }
       }
      }
     },
     "403": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/error"
        }
       }
      }
     },
     "429": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/error"
        }
       }
      }
     },
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "data": {
           "type": "array",
           "items": {
            "$ref": "#/components/schemas/time_entry"
           }
          },
          "page": {
           "type": "integer"
          },
          "page_size": {
           "type": "integer"
          },
          "total": {
           "type": "integer"
          },
          "next": {
           "type": "string",
           "nullable": true
          },
          "previous": {
           "type": "string",
           "nullable": true
          }
         }
        }
       }
      }
     }
    },
    "description": "يتطلب النطاق time:read."
   },
   "post": {
    "operationId": "post_time-entries",
    "summary": "تسجيل وقت للشخص الذي يعمل المفتاح باسمه، بسعر ساعته.",
    "tags": [
     "الوقت والمصروفات"
    ],
    "parameters": [],
    "responses": {
     "401": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/error"
        }
       }
      }
     },
     "403": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/error"
        }
       }
      }
     },
     "429": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/error"
        }
       }
      }
     },
     "201": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "data": {
           "$ref": "#/components/schemas/time_entry"
          }
         }
        }
       }
      }
     },
     "400": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/error"
        }
       }
      }
     }
    },
    "description": "يتطلب النطاق time:write.",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "narrative"
        ],
        "properties": {
         "person": {
          "type": "integer",
          "description": "صاحب الوقت، لحساب الخدمة، وعليه أن يحدده."
         },
         "case": {
          "type": "integer",
          "description": "معرّف القضية: قضية مفتوحة يستطيع رؤيتها."
         },
         "worked_on": {
          "type": "string",
          "description": "اليوم، وهو اليوم الحالي ما لم يُحدَّد."
         },
         "minutes": {
          "type": "integer",
          "description": "الوقت بالدقائق."
         },
         "hours": {
          "type": "number",
          "description": "أو الوقت بالساعات، مثل 1.5."
         },
         "narrative": {
          "type": "string",
          "description": "ما تم إنجازه."
         },
         "billable": {
          "type": "boolean",
          "description": "true ما لم يُحدَّد."
         },
         "activity": {
          "type": "string",
          "description": "النشاط، مثل الصياغة."
         }
        }
       }
      }
     }
    }
   }
  },
  "/expenses": {
   "get": {
    "operationId": "get_expenses",
    "summary": "المصروفات، بنفس قواعد الوقت.",
    "tags": [
     "الوقت والمصروفات"
    ],
    "parameters": [
     {
      "name": "page",
      "in": "query",
      "schema": {
       "type": "integer"
      },
      "description": "رقم الصفحة، بدءاً من 1."
     },
     {
      "name": "page_size",
      "in": "query",
      "schema": {
       "type": "integer"
      },
      "description": "عدد السجلات في الصفحة: 100 ما لم يُحدَّد، و500 على الأكثر."
     },
     {
      "name": "changed_since",
      "in": "query",
      "schema": {
       "type": "string"
      },
      "description": "السجلات التي تغيّرت (أو سُجِّلت، في المدفوعات والمصروفات) في هذا الوقت أو بعده فقط، بتاريخ أو وقت بصيغة ISO 8601، مثل 2026-11-01T08:00:00Z."
     },
     {
      "name": "from",
      "in": "query",
      "schema": {
       "type": "string"
      },
      "description": "من هذا التاريخ، مثل 2026-11-01."
     },
     {
      "name": "to",
      "in": "query",
      "schema": {
       "type": "string"
      },
      "description": "حتى هذا التاريخ وشاملاً له."
     },
     {
      "name": "case",
      "in": "query",
      "schema": {
       "type": "integer"
      },
      "description": "الخاصة بهذه القضية فقط."
     }
    ],
    "responses": {
     "401": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/error"
        }
       }
      }
     },
     "403": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/error"
        }
       }
      }
     },
     "429": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/error"
        }
       }
      }
     },
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "data": {
           "type": "array",
           "items": {
            "$ref": "#/components/schemas/expense"
           }
          },
          "page": {
           "type": "integer"
          },
          "page_size": {
           "type": "integer"
          },
          "total": {
           "type": "integer"
          },
          "next": {
           "type": "string",
           "nullable": true
          },
          "previous": {
           "type": "string",
           "nullable": true
          }
         }
        }
       }
      }
     }
    },
    "description": "يتطلب النطاق time:read."
   }
  },
  "/invoices": {
   "get": {
    "operationId": "get_invoices",
    "summary": "الفواتير الصادرة للقضايا التي يستطيع الشخص الذي يعمل المفتاح باسمه رؤيتها.",
    "tags": [
     "الفواتير والمدفوعات"
    ],
    "parameters": [
     {
      "name": "page",
      "in": "query",
      "schema": {
       "type": "integer"
      },
      "description": "رقم الصفحة، بدءاً من 1."
     },
     {
      "name": "page_size",
      "in": "query",
      "schema": {
       "type": "integer"
      },
      "description": "عدد السجلات في الصفحة: 100 ما لم يُحدَّد، و500 على الأكثر."
     },
     {
      "name": "changed_since",
      "in": "query",
      "schema": {
       "type": "string"
      },
      "description": "السجلات التي تغيّرت (أو سُجِّلت، في المدفوعات والمصروفات) في هذا الوقت أو بعده فقط، بتاريخ أو وقت بصيغة ISO 8601، مثل 2026-11-01T08:00:00Z."
     },
     {
      "name": "from",
      "in": "query",
      "schema": {
       "type": "string"
      },
      "description": "من هذا التاريخ، مثل 2026-11-01."
     },
     {
      "name": "to",
      "in": "query",
      "schema": {
       "type": "string"
      },
      "description": "حتى هذا التاريخ وشاملاً له."
     },
     {
      "name": "case",
      "in": "query",
      "schema": {
       "type": "integer"
      },
      "description": "الخاصة بهذه القضية فقط."
     },
     {
      "name": "client",
      "in": "query",
      "schema": {
       "type": "integer"
      },
      "description": "الخاصة بهذا الموكل فقط."
     },
     {
      "name": "status",
      "in": "query",
      "schema": {
       "type": "string"
      },
      "description": "التي لها هذه الحالة فقط."
     }
    ],
    "responses": {
     "401": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/error"
        }
       }
      }
     },
     "403": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/error"
        }
       }
      }
     },
     "429": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/error"
        }
       }
      }
     },
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "data": {
           "type": "array",
           "items": {
            "$ref": "#/components/schemas/invoice"
           }
          },
          "page": {
           "type": "integer"
          },
          "page_size": {
           "type": "integer"
          },
          "total": {
           "type": "integer"
          },
          "next": {
           "type": "string",
           "nullable": true
          },
          "previous": {
           "type": "string",
           "nullable": true
          }
         }
        }
       }
      }
     }
    },
    "description": "يتطلب النطاق billing:read."
   }
  },
  "/invoices/{id}": {
   "get": {
    "operationId": "get_invoices_id",
    "summary": "فاتورة واحدة.",
    "tags": [
     "الفواتير والمدفوعات"
    ],
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "schema": {
       "type": "integer"
      },
      "description": "معرّف السجل.",
      "required": true
     }
    ],
    "responses": {
     "401": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/error"
        }
       }
      }
     },
     "403": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/error"
        }
       }
      }
     },
     "429": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/error"
        }
       }
      }
     },
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "data": {
           "$ref": "#/components/schemas/invoice"
          }
         }
        }
       }
      }
     },
     "404": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/error"
        }
       }
      }
     }
    },
    "description": "يتطلب النطاق billing:read."
   }
  },
  "/payments": {
   "get": {
    "operationId": "get_payments",
    "summary": "المدفوعات المستلمة.",
    "tags": [
     "الفواتير والمدفوعات"
    ],
    "parameters": [
     {
      "name": "page",
      "in": "query",
      "schema": {
       "type": "integer"
      },
      "description": "رقم الصفحة، بدءاً من 1."
     },
     {
      "name": "page_size",
      "in": "query",
      "schema": {
       "type": "integer"
      },
      "description": "عدد السجلات في الصفحة: 100 ما لم يُحدَّد، و500 على الأكثر."
     },
     {
      "name": "changed_since",
      "in": "query",
      "schema": {
       "type": "string"
      },
      "description": "السجلات التي تغيّرت (أو سُجِّلت، في المدفوعات والمصروفات) في هذا الوقت أو بعده فقط، بتاريخ أو وقت بصيغة ISO 8601، مثل 2026-11-01T08:00:00Z."
     },
     {
      "name": "from",
      "in": "query",
      "schema": {
       "type": "string"
      },
      "description": "من هذا التاريخ، مثل 2026-11-01."
     },
     {
      "name": "to",
      "in": "query",
      "schema": {
       "type": "string"
      },
      "description": "حتى هذا التاريخ وشاملاً له."
     },
     {
      "name": "client",
      "in": "query",
      "schema": {
       "type": "integer"
      },
      "description": "الخاصة بهذا الموكل فقط."
     }
    ],
    "responses": {
     "401": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/error"
        }
       }
      }
     },
     "403": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/error"
        }
       }
      }
     },
     "429": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/error"
        }
       }
      }
     },
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "data": {
           "type": "array",
           "items": {
            "$ref": "#/components/schemas/payment"
           }
          },
          "page": {
           "type": "integer"
          },
          "page_size": {
           "type": "integer"
          },
          "total": {
           "type": "integer"
          },
          "next": {
           "type": "string",
           "nullable": true
          },
          "previous": {
           "type": "string",
           "nullable": true
          }
         }
        }
       }
      }
     }
    },
    "description": "يتطلب النطاق billing:read."
   },
   "post": {
    "operationId": "post_payments",
    "summary": "تسجيل دفعة على فاتورة صادرة، ويصل الموكلَ إيصال.",
    "tags": [
     "الفواتير والمدفوعات"
    ],
    "parameters": [],
    "responses": {
     "401": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/error"
        }
       }
      }
     },
     "403": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/error"
        }
       }
      }
     },
     "429": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/error"
        }
       }
      }
     },
     "201": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "data": {
           "$ref": "#/components/schemas/payment"
          }
         }
        }
       }
      }
     },
     "400": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/error"
        }
       }
      }
     }
    },
    "description": "يتطلب النطاق billing:write.",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "invoice",
         "amount"
        ],
        "properties": {
         "invoice": {
          "type": "integer",
          "description": "معرّف الفاتورة."
         },
         "amount": {
          "type": "string",
          "description": "المبلغ بعملة الفاتورة، مثل 1500.00."
         },
         "method": {
          "type": "string",
          "description": "transfer (تحويل، وهو الافتراضي) أو cash (نقداً) أو card (بطاقة) أو wallet (محفظة) أو check (شيك)."
         },
         "received_on": {
          "type": "string",
          "description": "يوم استلامها، وهو اليوم الحالي ما لم يُحدَّد."
         },
         "reference": {
          "type": "string",
          "description": "مرجع البنك أو الإيصال."
         }
        }
       }
      }
     }
    }
   }
  },
  "/tasks": {
   "get": {
    "operationId": "get_tasks",
    "summary": "المهام التي يستطيع الشخص الذي يعمل المفتاح باسمه رؤيتها.",
    "tags": [
     "المهام"
    ],
    "parameters": [
     {
      "name": "page",
      "in": "query",
      "schema": {
       "type": "integer"
      },
      "description": "رقم الصفحة، بدءاً من 1."
     },
     {
      "name": "page_size",
      "in": "query",
      "schema": {
       "type": "integer"
      },
      "description": "عدد السجلات في الصفحة: 100 ما لم يُحدَّد، و500 على الأكثر."
     },
     {
      "name": "changed_since",
      "in": "query",
      "schema": {
       "type": "string"
      },
      "description": "السجلات التي تغيّرت (أو سُجِّلت، في المدفوعات والمصروفات) في هذا الوقت أو بعده فقط، بتاريخ أو وقت بصيغة ISO 8601، مثل 2026-11-01T08:00:00Z."
     },
     {
      "name": "case",
      "in": "query",
      "schema": {
       "type": "integer"
      },
      "description": "الخاصة بهذه القضية فقط."
     },
     {
      "name": "assignee",
      "in": "query",
      "schema": {
       "type": "integer"
      },
      "description": "المسندة إلى هذا الشخص فقط."
     },
     {
      "name": "done",
      "in": "query",
      "schema": {
       "type": "boolean"
      },
      "description": "true للمهام المنجزة فقط، وfalse للمفتوحة فقط."
     }
    ],
    "responses": {
     "401": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/error"
        }
       }
      }
     },
     "403": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/error"
        }
       }
      }
     },
     "429": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/error"
        }
       }
      }
     },
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "data": {
           "type": "array",
           "items": {
            "$ref": "#/components/schemas/task"
           }
          },
          "page": {
           "type": "integer"
          },
          "page_size": {
           "type": "integer"
          },
          "total": {
           "type": "integer"
          },
          "next": {
           "type": "string",
           "nullable": true
          },
          "previous": {
           "type": "string",
           "nullable": true
          }
         }
        }
       }
      }
     }
    },
    "description": "يتطلب النطاق tasks:read."
   }
  },
  "/feeds/{dataset}": {
   "get": {
    "operationId": "get_feeds_dataset",
    "summary": "مجموعة بيانات تقارير لـ Power BI وExcel: الوقت أو الفواتير أو المدفوعات أو القضايا أو العملاء المحتملون، بكل الأعمدة.",
    "tags": [
     "موجزات التقارير لـ Power BI وExcel"
    ],
    "parameters": [
     {
      "name": "dataset",
      "in": "path",
      "schema": {
       "type": "string",
       "enum": [
        "time",
        "invoices",
        "payments",
        "cases",
        "leads"
       ]
      },
      "description": "مجموعة البيانات.",
      "required": true
     },
     {
      "name": "page",
      "in": "query",
      "schema": {
       "type": "integer"
      },
      "description": "رقم الصفحة، بدءاً من 1."
     },
     {
      "name": "page_size",
      "in": "query",
      "schema": {
       "type": "integer"
      },
      "description": "عدد السجلات في الصفحة: 100 ما لم يُحدَّد، و500 على الأكثر."
     },
     {
      "name": "from",
      "in": "query",
      "schema": {
       "type": "string"
      },
      "description": "من هذا التاريخ، مثل 2026-11-01."
     },
     {
      "name": "to",
      "in": "query",
      "schema": {
       "type": "string"
      },
      "description": "حتى هذا التاريخ وشاملاً له."
     },
     {
      "name": "format",
      "in": "query",
      "schema": {
       "type": "string"
      },
      "description": "csv لملف CSV بكل السجلات (حتى 100,000) بدلاً من صفحات JSON."
     }
    ],
    "responses": {
     "401": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/error"
        }
       }
      }
     },
     "403": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/error"
        }
       }
      }
     },
     "429": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/error"
        }
       }
      }
     },
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "data": {
           "type": "array",
           "items": {
            "$ref": "#/components/schemas/row"
           }
          },
          "page": {
           "type": "integer"
          },
          "page_size": {
           "type": "integer"
          },
          "total": {
           "type": "integer"
          },
          "next": {
           "type": "string",
           "nullable": true
          },
          "previous": {
           "type": "string",
           "nullable": true
          }
         }
        }
       }
      }
     },
     "404": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/error"
        }
       }
      }
     }
    },
    "description": "يتطلب النطاق reports:read."
   }
  },
  "/audit-events": {
   "get": {
    "operationId": "get_audit-events",
    "summary": "سجل التدقيق الخاص بالمكتب، من الأقدم إلى الأحدث، لنظام SIEM: ما تعرضه صفحة سجل التدقيق لصاحب المفتاح. ويحصل حساب الخدمة على كل الإدخالات إلا ما يخص القضايا التي لا يراها.",
    "tags": [
     "سجل التدقيق"
    ],
    "parameters": [
     {
      "name": "page",
      "in": "query",
      "schema": {
       "type": "integer"
      },
      "description": "رقم الصفحة، بدءاً من 1."
     },
     {
      "name": "page_size",
      "in": "query",
      "schema": {
       "type": "integer"
      },
      "description": "عدد السجلات في الصفحة: 100 ما لم يُحدَّد، و500 على الأكثر."
     },
     {
      "name": "after",
      "in": "query",
      "schema": {
       "type": "integer"
      },
      "description": "الإدخالات التالية لهذا الإدخال فقط، بمعرّفه: المؤشر الذي تعطيه كل صفحة، ويحتفظ به الموصّل لطلبه التالي."
     },
     {
      "name": "since",
      "in": "query",
      "schema": {
       "type": "string"
      },
      "description": "الإدخالات المسجلة في هذا الوقت أو بعده فقط، بتاريخ أو وقت بصيغة ISO 8601، مثل 2026-11-01T08:00:00Z."
     }
    ],
    "responses": {
     "401": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/error"
        }
       }
      }
     },
     "403": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/error"
        }
       }
      }
     },
     "429": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/error"
        }
       }
      }
     },
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "data": {
           "type": "array",
           "items": {
            "$ref": "#/components/schemas/audit_event"
           }
          },
          "page": {
           "type": "integer"
          },
          "page_size": {
           "type": "integer"
          },
          "total": {
           "type": "integer"
          },
          "next": {
           "type": "string",
           "nullable": true
          },
          "previous": {
           "type": "string",
           "nullable": true
          },
          "cursor": {
           "type": "integer",
           "nullable": true
          },
          "has_more": {
           "type": "boolean"
          }
         }
        }
       }
      }
     }
    },
    "description": "يتطلب النطاق audit:read."
   }
  }
 },
 "x-webhooks": {
  "case.opened": {
   "post": {
    "operationId": "webhook_case_opened",
    "summary": "فتح قضية",
    "description": "يتطلب النطاق cases:read.",
    "parameters": [
     {
      "name": "Lawia-Event",
      "in": "header",
      "required": true,
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "Lawia-Delivery",
      "in": "header",
      "required": true,
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "Lawia-Signature",
      "in": "header",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "id": {
          "type": "string"
         },
         "type": {
          "type": "string",
          "enum": [
           "case.opened"
          ]
         },
         "created_at": {
          "type": "string",
          "format": "date-time"
         },
         "firm": {
          "type": "object"
         },
         "data": {
          "$ref": "#/components/schemas/case"
         }
        }
       }
      }
     }
    },
    "responses": {
     "2XX": {
      "description": "OK"
     }
    }
   }
  },
  "case.closed": {
   "post": {
    "operationId": "webhook_case_closed",
    "summary": "إغلاق قضية",
    "description": "يتطلب النطاق cases:read.",
    "parameters": [
     {
      "name": "Lawia-Event",
      "in": "header",
      "required": true,
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "Lawia-Delivery",
      "in": "header",
      "required": true,
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "Lawia-Signature",
      "in": "header",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "id": {
          "type": "string"
         },
         "type": {
          "type": "string",
          "enum": [
           "case.closed"
          ]
         },
         "created_at": {
          "type": "string",
          "format": "date-time"
         },
         "firm": {
          "type": "object"
         },
         "data": {
          "$ref": "#/components/schemas/case"
         }
        }
       }
      }
     }
    },
    "responses": {
     "2XX": {
      "description": "OK"
     }
    }
   }
  },
  "contact.created": {
   "post": {
    "operationId": "webhook_contact_created",
    "summary": "إضافة موكل أو جهة اتصال",
    "description": "يتطلب النطاق contacts:read.",
    "parameters": [
     {
      "name": "Lawia-Event",
      "in": "header",
      "required": true,
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "Lawia-Delivery",
      "in": "header",
      "required": true,
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "Lawia-Signature",
      "in": "header",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "id": {
          "type": "string"
         },
         "type": {
          "type": "string",
          "enum": [
           "contact.created"
          ]
         },
         "created_at": {
          "type": "string",
          "format": "date-time"
         },
         "firm": {
          "type": "object"
         },
         "data": {
          "$ref": "#/components/schemas/contact"
         }
        }
       }
      }
     }
    },
    "responses": {
     "2XX": {
      "description": "OK"
     }
    }
   }
  },
  "invoice.issued": {
   "post": {
    "operationId": "webhook_invoice_issued",
    "summary": "إصدار فاتورة",
    "description": "يتطلب النطاق billing:read.",
    "parameters": [
     {
      "name": "Lawia-Event",
      "in": "header",
      "required": true,
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "Lawia-Delivery",
      "in": "header",
      "required": true,
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "Lawia-Signature",
      "in": "header",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "id": {
          "type": "string"
         },
         "type": {
          "type": "string",
          "enum": [
           "invoice.issued"
          ]
         },
         "created_at": {
          "type": "string",
          "format": "date-time"
         },
         "firm": {
          "type": "object"
         },
         "data": {
          "$ref": "#/components/schemas/invoice"
         }
        }
       }
      }
     }
    },
    "responses": {
     "2XX": {
      "description": "OK"
     }
    }
   }
  },
  "invoice.paid": {
   "post": {
    "operationId": "webhook_invoice_paid",
    "summary": "سداد فاتورة بالكامل",
    "description": "يتطلب النطاق billing:read.",
    "parameters": [
     {
      "name": "Lawia-Event",
      "in": "header",
      "required": true,
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "Lawia-Delivery",
      "in": "header",
      "required": true,
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "Lawia-Signature",
      "in": "header",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "id": {
          "type": "string"
         },
         "type": {
          "type": "string",
          "enum": [
           "invoice.paid"
          ]
         },
         "created_at": {
          "type": "string",
          "format": "date-time"
         },
         "firm": {
          "type": "object"
         },
         "data": {
          "$ref": "#/components/schemas/invoice"
         }
        }
       }
      }
     }
    },
    "responses": {
     "2XX": {
      "description": "OK"
     }
    }
   }
  },
  "payment.received": {
   "post": {
    "operationId": "webhook_payment_received",
    "summary": "تسجيل دفعة",
    "description": "يتطلب النطاق billing:read.",
    "parameters": [
     {
      "name": "Lawia-Event",
      "in": "header",
      "required": true,
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "Lawia-Delivery",
      "in": "header",
      "required": true,
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "Lawia-Signature",
      "in": "header",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "id": {
          "type": "string"
         },
         "type": {
          "type": "string",
          "enum": [
           "payment.received"
          ]
         },
         "created_at": {
          "type": "string",
          "format": "date-time"
         },
         "firm": {
          "type": "object"
         },
         "data": {
          "$ref": "#/components/schemas/payment"
         }
        }
       }
      }
     }
    },
    "responses": {
     "2XX": {
      "description": "OK"
     }
    }
   }
  },
  "time.created": {
   "post": {
    "operationId": "webhook_time_created",
    "summary": "تسجيل وقت",
    "description": "يتطلب النطاق time:read.",
    "parameters": [
     {
      "name": "Lawia-Event",
      "in": "header",
      "required": true,
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "Lawia-Delivery",
      "in": "header",
      "required": true,
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "Lawia-Signature",
      "in": "header",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "id": {
          "type": "string"
         },
         "type": {
          "type": "string",
          "enum": [
           "time.created"
          ]
         },
         "created_at": {
          "type": "string",
          "format": "date-time"
         },
         "firm": {
          "type": "object"
         },
         "data": {
          "$ref": "#/components/schemas/time_entry"
         }
        }
       }
      }
     }
    },
    "responses": {
     "2XX": {
      "description": "OK"
     }
    }
   }
  },
  "task.done": {
   "post": {
    "operationId": "webhook_task_done",
    "summary": "إنجاز مهمة",
    "description": "يتطلب النطاق tasks:read.",
    "parameters": [
     {
      "name": "Lawia-Event",
      "in": "header",
      "required": true,
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "Lawia-Delivery",
      "in": "header",
      "required": true,
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "Lawia-Signature",
      "in": "header",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "id": {
          "type": "string"
         },
         "type": {
          "type": "string",
          "enum": [
           "task.done"
          ]
         },
         "created_at": {
          "type": "string",
          "format": "date-time"
         },
         "firm": {
          "type": "object"
         },
         "data": {
          "$ref": "#/components/schemas/task"
         }
        }
       }
      }
     }
    },
    "responses": {
     "2XX": {
      "description": "OK"
     }
    }
   }
  },
  "document.added": {
   "post": {
    "operationId": "webhook_document_added",
    "summary": "إضافة مستند إلى قضية",
    "description": "يتطلب النطاق cases:read.",
    "parameters": [
     {
      "name": "Lawia-Event",
      "in": "header",
      "required": true,
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "Lawia-Delivery",
      "in": "header",
      "required": true,
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "Lawia-Signature",
      "in": "header",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "id": {
          "type": "string"
         },
         "type": {
          "type": "string",
          "enum": [
           "document.added"
          ]
         },
         "created_at": {
          "type": "string",
          "format": "date-time"
         },
         "firm": {
          "type": "object"
         },
         "data": {
          "$ref": "#/components/schemas/document"
         }
        }
       }
      }
     }
    },
    "responses": {
     "2XX": {
      "description": "OK"
     }
    }
   }
  },
  "hearing.changed": {
   "post": {
    "operationId": "webhook_hearing_changed",
    "summary": "إضافة جلسة أو مهلة أو تغيير موعدها أو تسجيل نتيجتها",
    "description": "يتطلب النطاق cases:read.",
    "parameters": [
     {
      "name": "Lawia-Event",
      "in": "header",
      "required": true,
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "Lawia-Delivery",
      "in": "header",
      "required": true,
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "Lawia-Signature",
      "in": "header",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "id": {
          "type": "string"
         },
         "type": {
          "type": "string",
          "enum": [
           "hearing.changed"
          ]
         },
         "created_at": {
          "type": "string",
          "format": "date-time"
         },
         "firm": {
          "type": "object"
         },
         "data": {
          "$ref": "#/components/schemas/hearing_change"
         }
        }
       }
      }
     }
    },
    "responses": {
     "2XX": {
      "description": "OK"
     }
    }
   }
  }
 }
}