API Endpoints

API Endpoints

Complete reference for all available API endpoints, parameters, and response formats.

Overview

The Sapphire Legal AI API provides RESTful endpoints for managing cases, documents, users, and system configurations. All endpoints return JSON responses and use standard HTTP status codes.

Base URL

All API requests should be made to:

https://api.sapphirelegal.ai/api/v1

Rate limits

API requests are subject to rate limiting to ensure fair usage and system stability:

  • Authenticated users: 1000 requests per hour
  • API keys: 5000 requests per hour
  • Admin endpoints: 100 requests per hour

Core endpoints

Authentication

MethodEndpointDescription
POST/auth/loginUser login and JWT token generation
POST/auth/refreshRefresh expired JWT token
POST/auth/logoutInvalidate JWT token

Cases

MethodEndpointDescription
GET/casesList all cases (with pagination)
POST/casesCreate a new case
GET/cases/{id}Get case details by ID
PUT/cases/{id}Update case information
DELETE/cases/{id}Delete a case

Documents

MethodEndpointDescription
GET/cases/{case_id}/documentsList documents in a case
POST/cases/{case_id}/documentsUpload a new document
GET/documents/{id}Get document metadata
GET/documents/{id}/contentDownload document content
DELETE/documents/{id}Delete a document

Request examples

Creating a new case

POST /api/v1/cases
Authorization: Bearer <your_jwt_token>
Content-Type: application/json

{
  "title": "Smith v. Johnson",
  "case_number": "CV-2025-001",
  "case_type": "litigation",
  "jurisdiction": "federal",
  "client_name": "John Smith",
  "description": "Contract dispute regarding software licensing agreement",
  "status": "active",
  "priority": "high"
}

Uploading a document

POST /api/v1/cases/123/documents
Authorization: Bearer <your_jwt_token>
Content-Type: multipart/form-data

{
  "file": <file_data>,
  "title": "Complaint",
  "document_type": "pleading",
  "tags": ["complaint", "initial_filing"],
  "description": "Initial complaint filed with the court"
}

Searching cases

GET /api/v1/cases?search=contract&status=active&case_type=litigation&page=1&limit=20
Authorization: Bearer <your_jwt_token>
Content-Type: application/json

Response formats

Successful response

{
  "success": true,
  "data": {
    "id": "case_1234567890abcdef",
    "title": "Smith v. Johnson",
    "case_number": "CV-2025-001",
    "case_type": "litigation",
    "jurisdiction": "federal",
    "client_name": "John Smith",
    "description": "Contract dispute regarding software licensing agreement",
    "status": "active",
    "priority": "high",
    "created_at": "2025-01-20T10:30:00Z",
    "updated_at": "2025-01-20T10:30:00Z"
  },
  "meta": {
    "request_id": "req_1234567890abcdef",
    "timestamp": "2025-01-20T10:30:00Z"
  }
}

Error response

{
  "success": false,
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Validation failed",
    "details": [
      {
        "field": "title",
        "message": "Title is required"
      },
      {
        "field": "case_number",
        "message": "Case number must be unique"
      }
    ]
  },
  "meta": {
    "request_id": "req_1234567890abcdef",
    "timestamp": "2025-01-20T10:30:00Z"
  }
}

Paginated response

{
  "success": true,
  "data": [
    // Array of case objects
  ],
  "meta": {
    "pagination": {
      "page": 1,
      "limit": 20,
      "total": 150,
      "pages": 8
    },
    "request_id": "req_1234567890abcdef",
    "timestamp": "2025-01-20T10:30:00Z"
  }
}

Query parameters

Common parameters

ParameterTypeDescriptionExample
pageintegerPage number for pagination1
limitintegerNumber of items per page20
searchstringSearch query for text fieldscontract
sortstringSort fieldcreated_at
orderstringSort order (asc/desc)desc
Tip
Pro tip: Use the fields parameter to request only the data you need, improving performance and reducing bandwidth.

What's next