Client Portal API
The Client Portal API provides endpoints for client-facing features including matter management, document access, signature requests, and AI-powered intake processing.
Authentication
All Client Portal API endpoints require authentication via session cookies or API tokens.
// Session-based authentication (web interface)const response = await fetch('/api/client-portal/matters', { credentials: 'include'});
// Token-based authentication (mobile/API)const response = await fetch('/api/client-portal/matters', { headers: { 'Authorization': 'Bearer your-api-token' }});Matters Management
List Client Matters
Retrieve all matters associated with the authenticated client.
Response:
{ "success": true, "matters": [ { "id": "matter_123", "name": "Document Service - Smith vs Jones", "description": "Service of summons and complaint", "status": "in_progress", "created_at": "2024-01-15T10:30:00Z", "updated_at": "2024-01-16T14:22:00Z", "assigned_team": "process_servers", "estimated_completion": "2024-01-18T17:00:00Z" } ], "count": 1}Get Matter Details
Retrieve detailed information about a specific matter.
Parameters:
matter_id(string, required): Unique identifier for the matter
Response:
{ "success": true, "matter": { "id": "matter_123", "name": "Document Service - Smith vs Jones", "description": "Service of summons and complaint", "status": "in_progress", "matter_type": "document_service", "urgency": "high", "created_at": "2024-01-15T10:30:00Z", "updated_at": "2024-01-16T14:22:00Z", "assigned_team": "process_servers", "assigned_staff": [ { "id": "staff_456", "name": "John Process", "role": "process_server", "email": "john@example.com" } ], "timeline": { "estimated_start": "2024-01-16T09:00:00Z", "estimated_completion": "2024-01-18T17:00:00Z", "actual_start": "2024-01-16T09:15:00Z" }, "progress": { "current_step": "service_attempt", "completed_steps": ["intake", "document_review", "assignment"], "remaining_steps": ["service_completion", "proof_filing"] }, "documents_count": 3, "events_count": 7 }}Get Matter Events
Retrieve the activity timeline for a specific matter.
Query Parameters:
limit(integer, optional): Maximum number of events to return (default: 50)offset(integer, optional): Number of events to skip (default: 0)
Response:
{ "success": true, "events": [ { "id": "event_789", "matter_id": "matter_123", "type": "service_attempt", "description": "First service attempt at residence", "details": { "location": "123 Main St, Apt 2B", "time": "2024-01-16T14:30:00Z", "result": "no_answer", "notes": "No answer at door, left notice of attempt" }, "created_at": "2024-01-16T14:35:00Z", "created_by": { "name": "John Process", "role": "process_server" } } ], "count": 7, "has_more": false}Document Management
List Matter Documents
Retrieve documents associated with a specific matter.
Query Parameters:
type(string, optional): Filter by document typeaccess_type(string, optional): Filter by access level (view,download,edit)
Response:
{ "success": true, "documents": [ { "id": "doc_456", "filename": "summons_smith_v_jones.pdf", "type": "summons", "size": 245760, "access_type": "download", "granted_at": "2024-01-15T10:30:00Z", "created_at": "2024-01-15T10:30:00Z", "metadata": { "pages": 3, "signed": false, "requires_signature": false } } ], "count": 3}Download Document
Download a specific document (returns file stream).
Headers:
Content-Type: application/pdfContent-Disposition: attachment; filename="document.pdf"Upload Document
Upload a new document to a matter.
Request (multipart/form-data):
file: [file data]type: "evidence"description: "Photos of service location"Response:
{ "success": true, "document": { "id": "doc_789", "filename": "service_photos.jpg", "type": "evidence", "size": 1024000, "access_type": "view", "created_at": "2024-01-16T15:30:00Z" }}AI-Powered Intake
Start Intake Session
Process client intake with AI assistance and workflow routing.
Request:
{ "conversation": [ { "role": "user", "content": "I need to serve an eviction notice to my tenant", "timestamp": "2024-01-15T10:00:00Z" }, { "role": "assistant", "content": "I can help with eviction service. What type of notice needs to be served?", "timestamp": "2024-01-15T10:00:15Z" } ], "formData": { "client_name": "Jane Smith", "email": "jane@example.com", "phone": "+1-555-0123", "matter_type": "eviction", "urgency": "high", "property_address": "456 Oak Street, Unit 3", "tenant_name": "John Doe", "eviction_reason": "non_payment_rent" }, "documents": [], "matterType": "eviction", "urgency": "high", "summary": "Eviction notice service for non-payment of rent", "workflow": "expedited_eviction_service"}Response:
{ "success": true, "caseNumber": "EV-2024-0123", "analysis": { "matterType": "eviction", "urgency": "high", "confidence": 0.95, "extractedInfo": { "detectedKeywords": ["eviction", "tenant", "notice"], "timelineIndicators": ["immediately"], "addressMentioned": true, "documentTypes": ["notice"] } }, "workflowPlan": { "workflow": "expedited_eviction_service", "assignedTeam": "eviction_specialists", "estimatedDays": 1, "nextSteps": [ "Case file created and assigned case number EV-2024-0123", "Matter routed to eviction_specialists for review", "AI analysis summary generated for legal team", "Client notification email sent with tracking information" ], "automatedActions": [ "create_case_file", "assign_team", "generate_summary", "send_notifications" ] }, "aiSummary": "AI INTAKE ANALYSIS SUMMARY\n\nMatter Type: EVICTION\nUrgency Level: HIGH\nConfidence Score: 95%\n...", "ragInsights": { "similarCases": [ { "id": "case_789", "similarity": 0.89, "outcome": "successful_service", "timeline": 1 } ], "guidance": "Based on similar eviction cases, this typically requires 3-day notice service with personal service attempt followed by posting if necessary.", "contextualQuestions": [ { "question": "Do you have the 3-day notice prepared?", "type": "select", "options": ["Yes", "No", "Need assistance"], "required": true } ] }}Get AI Chat Guidance
Get AI-powered responses during intake conversation.
Request:
{ "message": "I need to serve an eviction notice", "conversation": [ { "role": "user", "content": "I need help with a legal matter", "timestamp": "2024-01-15T10:00:00Z" } ], "currentMatterType": "eviction"}Response:
{ "message": "I can help with eviction service. Based on similar cases in our knowledge base, eviction notices typically require specific service methods depending on your jurisdiction. What type of eviction notice do you need served?", "detectedMatterType": "eviction", "shouldShowForm": false, "suggestedFields": [], "ragInsights": { "similarCases": [ { "caseId": "EV-2024-0089", "similarity": 0.87, "outcome": "successful_service" } ], "guidance": "Based on 15 similar eviction cases, success rate is 94% with average 1.2 day service time.", "confidence": 0.87 }}Signature Management
List Signature Requests
Retrieve signature requests for the authenticated client.
Query Parameters:
status(string, optional): Filter by status (pending,signed,declined,expired)
Response:
{ "success": true, "signatureRequests": [ { "id": "sig_123", "session_title": "Service Agreement - Case EV-2024-0123", "document_name": "service_agreement.pdf", "status": "pending", "signer_name": "Jane Smith", "signer_email": "jane@example.com", "access_token": "abc123xyz", "expiry_date": "2024-01-22T23:59:59Z", "created_at": "2024-01-15T10:30:00Z", "viewed_at": null, "signed_at": null } ], "count": 1}Sign Document
Access and sign a document using the provided access token.
Request:
{ "signature_data": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...", "signed_at": "2024-01-16T14:30:00Z"}Response:
{ "success": true, "message": "Document signed successfully", "signed_document_id": "doc_signed_456"}Job Tracking
List Client Jobs
Retrieve service jobs associated with client matters.
Query Parameters:
status(string, optional): Filter by job statusmatter_id(string, optional): Filter by specific matter
Response:
{ "success": true, "jobs": [ { "id": "job_789", "matter_id": "matter_123", "status": "in_progress", "service_type": "personal_service", "service_address": "456 Oak Street, Unit 3", "recipient_name": "John Doe", "assigned_server": { "name": "Mike Server", "phone": "+1-555-0199" }, "attempts": [ { "attempt_number": 1, "date": "2024-01-16T14:30:00Z", "result": "no_answer", "notes": "No answer at door, will retry tomorrow" } ], "created_at": "2024-01-16T09:00:00Z", "estimated_completion": "2024-01-17T17:00:00Z" } ], "count": 1}Get Job Details
Retrieve detailed information about a specific service job.
Response:
{ "success": true, "job": { "id": "job_789", "matter_id": "matter_123", "status": "in_progress", "service_type": "personal_service", "service_address": "456 Oak Street, Unit 3", "recipient_name": "John Doe", "recipient_description": "Male, approximately 35 years old", "documents_to_serve": [ { "document_id": "doc_456", "document_name": "3-Day Notice to Quit", "document_type": "eviction_notice" } ], "assigned_server": { "id": "server_123", "name": "Mike Server", "license": "PS-12345", "phone": "+1-555-0199", "email": "mike@servers.com" }, "attempts": [ { "attempt_number": 1, "date": "2024-01-16T14:30:00Z", "result": "no_answer", "location": "Front door of unit 3", "notes": "No answer at door, lights on inside, will retry tomorrow morning", "photos": [ { "id": "photo_123", "description": "Front door of service address", "timestamp": "2024-01-16T14:32:00Z" } ] } ], "special_instructions": "Tenant works night shift, try service attempts before 2 PM", "created_at": "2024-01-16T09:00:00Z", "estimated_completion": "2024-01-17T17:00:00Z" }}Error Handling
All API endpoints follow consistent error response format:
{ "success": false, "error": "Detailed error message", "error_code": "INVALID_MATTER_ID", "details": { "field": "matter_id", "message": "Matter not found or access denied" }}Common Error Codes:
UNAUTHORIZED: Authentication required or invalidFORBIDDEN: Insufficient permissionsNOT_FOUND: Resource does not existINVALID_INPUT: Request validation failedRATE_LIMITED: Too many requestsINTERNAL_ERROR: Server-side error
Rate Limiting
API endpoints are rate limited to ensure fair usage:
- Standard endpoints: 100 requests per minute
- Upload endpoints: 10 requests per minute
- AI endpoints: 20 requests per minute
Rate limit headers are included in responses:
X-RateLimit-Limit: 100X-RateLimit-Remaining: 95X-RateLimit-Reset: 1642617600Pagination
List endpoints support pagination using cursor-based pagination:
Request:
GET /api/client-portal/matters?limit=10&cursor=eyJpZCI6Im1hdHRlcl8xMjMifQResponse:
{ "success": true, "matters": [...], "pagination": { "has_more": true, "next_cursor": "eyJpZCI6Im1hdHRlcl8xMzQifQ" }}