Legal Rail
Legal Rail
Section titled “Legal Rail”Legal document management, templates, and contract documentation.
Overview
Section titled “Overview”The Legal Rail provides endpoints for managing legal documents, contract templates, version control, and document signing workflows.
Base URL
Section titled “Base URL”/api/v1/legalEndpoints
Section titled “Endpoints”Create Template
Section titled “Create Template”POST /api/v1/legal/templatesCreate a legal document template.
Request Body:
{ "name": "Murabaha Financing Agreement", "type": "CONTRACT", "category": "FINANCING", "jurisdiction": "SAU_SAMA", "language": "ar", "content": "{{template_content}}", "variables": [ { "name": "customerName", "type": "string", "required": true }, { "name": "financingAmount", "type": "currency", "required": true }, { "name": "profitRate", "type": "percentage", "required": true } ], "shariahApproved": true, "fatwaReference": "fatwa_123"}Response:
{ "data": { "templateId": "tpl_abc123", "version": "1.0.0", "status": "DRAFT", "createdAt": "2025-01-15T10:00:00Z" }}Generate Document
Section titled “Generate Document”POST /api/v1/legal/documents/generateGenerate a document from template.
Request Body:
{ "templateId": "tpl_abc123", "variables": { "customerName": "Ahmad Abdullah", "financingAmount": "500000.00", "financingCurrency": "SAR", "profitRate": "5.5", "tenor": 60 }, "outputFormat": "PDF"}Response:
{ "data": { "documentId": "doc_xyz789", "templateId": "tpl_abc123", "status": "GENERATED", "downloadUrl": "https://...", "expiresAt": "2025-01-16T10:00:00Z" }}Get Document
Section titled “Get Document”GET /api/v1/legal/documents/:documentIdRetrieve document details.
List Documents
Section titled “List Documents”GET /api/v1/legal/documentsQuery Parameters:
| Parameter | Type | Description |
|---|---|---|
type | string | Document type |
status | string | Document status |
contractId | string | Related contract |
Request Signature
Section titled “Request Signature”POST /api/v1/legal/documents/:documentId/signaturesRequest document signature.
Request Body:
{ "signers": [ { "name": "Ahmad Abdullah", "email": "ahmad@example.com", "role": "CUSTOMER", "order": 1 }, { "name": "Bank Representative", "email": "legal@bank.com", "role": "INSTITUTION", "order": 2 } ], "expiresAt": "2025-02-01", "reminderDays": [3, 7]}Upload Document
Section titled “Upload Document”POST /api/v1/legal/documents/uploadUpload an external document.
Request Body (multipart/form-data):
file: document.pdftype: SUPPORTINGcategory: KYCdescription: Customer ID documentCreate Version
Section titled “Create Version”POST /api/v1/legal/templates/:templateId/versionsCreate a new template version.
Request Body:
{ "content": "{{updated_template_content}}", "changeNotes": "Updated profit calculation clause", "requiresApproval": true}Compare Versions
Section titled “Compare Versions”GET /api/v1/legal/templates/:templateId/compareCompare two template versions.
Query Parameters:
| Parameter | Type | Description |
|---|---|---|
version1 | string | First version |
version2 | string | Second version |
Document Types
Section titled “Document Types”| Type | Description |
|---|---|
| CONTRACT | Legal contract |
| AGREEMENT | Agreement/MOU |
| DISCLOSURE | Disclosure document |
| SCHEDULE | Contract schedule |
| AMENDMENT | Contract amendment |
| SUPPORTING | Supporting document |
Document Status
Section titled “Document Status”| Status | Description |
|---|---|
| DRAFT | In draft |
| GENERATED | Generated from template |
| PENDING_SIGNATURE | Awaiting signatures |
| PARTIALLY_SIGNED | Some signatures collected |
| FULLY_SIGNED | All signatures collected |
| EXECUTED | Legally executed |
| ARCHIVED | Archived |
Events
Section titled “Events”| Event | Description |
|---|---|
legal.document.generated | Document generated |
legal.document.signed | Document signed |
legal.document.executed | Document executed |
legal.template.approved | Template approved |
See Also
Section titled “See Also”- Contracts Rail - Contract management
- Governance Rail - Shariah governance