Skip to content

Latest commit

 

History

History
939 lines (770 loc) · 27.7 KB

comprehensive_api_docs.md

File metadata and controls

939 lines (770 loc) · 27.7 KB

🌐 Xtraction Comprehensive API Documentation

Welcome to the comprehensive API documentation for Xtraction, an AI-powered document processing, OCR extraction, and insight platform.

This unified document is designed to guide frontend developers through seamless integration with the Xtraction API.


🛠️ API Fundamentals

1. Base URL

  • Local Development: http://localhost:8080
  • Context Path: All REST endpoints are prefixed with /api/v1 unless specified otherwise.

2. Global Response Envelope

Every response from the REST API is wrapped in a standard JSON envelope (ApiResponse<T>).

{
  "success": true,
  "statusCode": 200,
  "message": "Resource retrieved successfully",
  "data": { },
  "timestamp": "2026-07-07T15:20:00.000Z",
  "path": "/api/v1/user/profile",
  "traceId": "tr_f0932a...",
  "errorCode": null,
  "errors": null
}

Envelope Field Specification:

Field Type Description
success Boolean true for 2xx codes, false otherwise.
statusCode Integer HTTP Status Code (e.g. 200, 201, 400).
message String A human-readable description of the operation result.
data Object / Array / Null The payload return (corresponds to T).
timestamp String ISO 8601 UTC timestamp of response generation.
path String Request URI path.
traceId String Correlating ID for server-side debugging logs.
errorCode String Custom application error code (e.g., ACCOUNT_LOCKED).
errors Array List of validation errors for 400 Bad Request.

3. Global Validation Error Structure

When payload fields fail constraint validation, the API returns 400 Bad Request with validation metadata:

{
  "success": false,
  "statusCode": 400,
  "message": "Validation failed",
  "data": null,
  "errors": [
    {
      "field": "email",
      "rejectedValue": "invalid-email-address",
      "message": "Must be a valid email address format"
    }
  ],
  "timestamp": "2026-07-07T15:21:00.000Z"
}

4. Pagination Envelope (PagedResponse<T>)

Endpoints that return lists are paginated and use the following format within the data envelope field:

{
  "content": [],
  "page": 0,
  "size": 20,
  "totalElements": 45,
  "totalPages": 3,
  "first": true,
  "last": false
}

🔐 Authentication & Security

1. Token Mechanics

  • Access Tokens (JWT): Passed in request headers. Short-lived (1 hour).
    • Header structure: Authorization: Bearer <accessToken>
  • Refresh Tokens: Set as a rolling HttpOnly, Secure (production only), SameSite=Strict cookie named refreshToken. Handled automatically by the browser.

2. Lockout counter

Accounts are locked out for 5 days after 4 consecutive failed login attempts. Locking details are persisted in Redis.


🚀 Endpoint Guide

Module 1: Authentication & Identity

Signup / Registration

  • URL: /api/v1/auth/signup
  • Method: POST
  • Authentication Required: No
  • Request Body (SignupRequestDto):
    {
      "firstName": "Jane",
      "lastName": "Doe",
      "email": "janedoe@example.com",
      "password": "SecureP@ssw0rd1!",
      "confirmPassword": "SecureP@ssw0rd1!",
      "acceptTerms": true,
      "subscribeToMarketing": false,
      "profession": "Developer",
      "organization": "Brints",
      "country": "Nigeria"
    }
  • Response (201 Created): Returns registered user profile without tokens (email verification required).

Login

  • URL: /api/v1/auth/login
  • Method: POST
  • Request Body (LoginRequestDto):
    {
      "email": "janedoe@example.com",
      "password": "SecureP@ssw0rd1!"
    }
  • Response (200 OK): Sets refreshToken cookie and returns accessToken:
    {
      "success": true,
      "statusCode": 200,
      "message": "User logged in successfully",
      "data": {
        "userId": "usr_9b1deb4d-3b7d-4bad-9bdd-2b0d7b3d4f82",
        "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
        "tokenType": "Bearer",
        "accessExpiresIn": 3600000
      }
    }

Email Verification (OTP)

  • URL: /api/v1/auth/verify-email
  • Method: POST
  • Request Body:
    {
      "email": "janedoe@example.com",
      "token": "verification-otp-or-token"
    }
  • Response (200 OK): Returns verification success message.

Resend Verification Email

  • URL: /api/v1/auth/resend-verification-email
  • Method: POST
  • Request Body: { "email": "janedoe@example.com" }
  • Response (200 OK): Standard response to prevent email enumeration.

Refresh Access Token

  • URL: /api/v1/auth/refresh-token
  • Method: POST
  • Request cookies: Cookie refreshToken must be present.
  • Response (200 OK): Returns new accessToken and sets rotated refreshToken cookie.

Logout (Current Session)

  • URL: /api/v1/auth/logout
  • Method: POST
  • Headers: Authorization: Bearer <accessToken>
  • Response (204 No Content): Clears client refresh cookie.

Logout (All Devices)

  • URL: /api/v1/auth/logout-all
  • Method: POST
  • Headers: Authorization: Bearer <accessToken>
  • Response (204 No Content): Revokes all refresh tokens linked to account.

Password Generator Helper

  • URL: /api/v1/auth/generate-password
  • Method: POST
  • Request Body: { "passwordLength": "16", "excludedChars": "@#$" }
  • Response (200 OK): { "generatedPassword": "..." }

Module 2: User Profile & Settings

All endpoints below require Authorization: Bearer <accessToken> in headers.

Get Authenticated User Profile

  • URL: /api/v1/user/profile
  • Method: GET
  • Response (200 OK): Enriched profile details (creation date, status, verification status, profile picture CDN URL).

Forgot Password

  • URL: /api/v1/user/forgot-password
  • Method: POST
  • Rate Limit: Max 5 requests / hour.
  • Request Body: { "email": "janedoe@example.com" }

Reset Password with Token

  • URL: /api/v1/user/reset-password
  • Method: POST
  • Rate Limit: Max 10 attempts / hour.
  • Request Body:
    {
      "email": "janedoe@example.com",
      "token": "reset_token_abc...",
      "newPassword": "NewSecurePassword99!",
      "confirmNewPassword": "NewSecurePassword99!"
    }

Change Password (Session Authenticated)

  • URL: /api/v1/user/change-password
  • Method: POST
  • Request Body:
    {
      "oldPassword": "SecureP@ssw0rd1!",
      "newPassword": "BrandNewPassword123*",
      "confirmNewPassword": "BrandNewPassword123*"
    }

Update Profile metadata

  • URL: /api/v1/user/profile/{userId}
  • Method: PUT
  • Request Body (ProfileUpdateRequestDto):
    {
      "firstName": "Janet",
      "lastName": "Doe",
      "country": "Canada",
      "profession": "Senior Developer",
      "organization": "Brints Corp"
    }

Upload Profile Picture

  • URL: /api/v1/user/profile/{userId}/upload
  • Method: POST
  • Content-Type: multipart/form-data
  • Body: File payload in key file.
  • Response (200 OK): Returns the CDN storage URL of the uploaded image.

Delete Profile Picture

  • URL: /api/v1/user/profile/{userId}/delete
  • Method: DELETE

Delete Account Immediately

  • URL: /api/v1/user/profile/{userId}
  • Method: DELETE
  • Response (200 OK): Returns text confirmation "User profile deleted successfully".

Module 3: Document & Collection Management

Upload Documents

  • URL: /api/v1/documents/upload
  • Method: POST
  • Content-Type: multipart/form-data
  • Rate Limit: 10 requests / minute.
  • Form Data Parameters:
    • files (MultipartFile[], Required): The documents to upload.
    • collectionName (String, Optional): The target collection to upload files into. Creates a new collection if name is new.
    • enableEncryption (Boolean, Default: false): Flags files to be encrypted at rest in storage.
  • Response (202 Accepted - Async Pipeline initiation):
    {
      "statusCode": 202,
      "status": "success",
      "message": "Upload initiated. Subscribe to WebSocket progress topic.",
      "collectionId": "col_b8d348a0-2f3b-48cf-99bf-8cd64f201083",
      "totalFiles": 2,
      "wsSubscriptionTopic": "/user/queue/extraction-progress"
    }

Get All Collections For User

  • URL: /api/v1/documents/my-collections
  • Method: GET
  • Response (200 OK): Returns summary of user collections.

Get Collection Details by ID

  • URL: /api/v1/documents/collection/{collectionId}
  • Method: GET
  • Response (200 OK): Returns list of file entries (metadata, upload status, size, OCR status) nested in the collection.

Get File Details from Collection

  • URL: /api/v1/documents/collection/{collectionId}/document/{documentId}
  • Method: GET

Delete Collection

  • URL: /api/v1/documents/collection/{collectionId}
  • Method: DELETE

Delete File from Collection

  • URL: /api/v1/documents/collection/{collectionId}/document/{documentId}
  • Method: DELETE

Clear All Collections (Factory Reset)

  • URL: /api/v1/documents/clear-all
  • Method: DELETE

Move Document to Another Collection

  • URL: /api/v1/documents/move
  • Method: POST
  • Request Body (MoveDocumentRequest):
    {
      "sourceCollectionId": "col_123...",
      "targetCollectionId": "col_456...",
      "documentId": "doc_789..."
    }

Rename Collection

  • URL: /api/v1/documents/collection/{collectionId}
  • Method: PUT
  • Request Body: { "name": "New Collection Name" }

Rename Document

  • URL: /api/v1/documents/collection/{collectionId}/document/{documentId}
  • Method: PUT
  • Request Body: { "displayName": "new_invoice.pdf" }

Module 4: OCR (Text Extraction)

Run OCR Extract Text on Document

  • URL: /api/v1/collections/{collectionId}/document/{documentId}/extract
  • Method: POST
  • Query Parameters:
    • startPage (Integer, Optional): Start page of extraction.
    • endPage (Integer, Optional): End page of extraction.
    • pages (List, Optional): Discrete list of pages (e.g. 1,3,5).

Upload & Extract All (Shortcut)

  • URL: /api/v1/collections/upload/extract-all
  • Method: POST
  • Content-Type: multipart/form-data
  • Form Data:
    • files (MultipartFile[])
    • startPage, endPage, pages (Optional filters)
  • Response (202 Accepted): Initiates extraction job. Track progress via WebSockets.

Get Collection OCR Results

  • URL: /api/v1/collections/{collectionId}/document/results
  • Method: GET
  • Response (200 OK): List of OCR text contents for all completed documents in the collection.

Get Document OCR Data

  • URL: /api/v1/collections/{collectionId}/document/{documentId}/ocr-data
  • Method: GET
  • Response (200 OK): Returns original OCR text, page count, and edit history.

Update/Edit OCR Extracted Content

  • URL: /api/v1/collections/{collectionId}/document/{documentId}/content
  • Method: PUT
  • Request Body (UpdateOcrContentRequest):
    {
      "editedContent": "This is corrected invoice text...",
      "contentFormat": "MARKDOWN or HTML"
    }

Download OCR Result as Docx File

  • URL: /api/v1/collections/{collectionId}/documents/{documentId}/download/docx
  • Method: GET
  • Query Parameters:
    • type (String, Default: "original"): Options are "original" or "edited".
  • Response: Streams binary word file (application/vnd.openxmlformats-officedocument.wordprocessingml.document) directly.

Module 5: AI Insights

Summarize Document Text

  • URL: /api/v1/ai/summarize
  • Method: POST
  • Request Body (SummarizeRequest):
    {
      "documentId": "doc_123...",
      "summaryType": "SHORT or DETAILED",
      "modelPreference": "openai or mistral"
    }
  • Response (200 OK): Returns AI summary text.

Classify / Categorize Document

  • URL: /api/v1/ai/classify/{documentId}
  • Method: POST
  • Response (200 OK): Returns classified document category, key attributes, confidence score, and language indicators.

Module 6: Document Search (Elasticsearch)

Advanced Document Search

  • URL: /api/v1/search/documents
  • Method: POST
  • Request Body (SearchRequest):
    {
      "query": "invoice matching string",
      "page": 0,
      "size": 10,
      "sortBy": "createdAt",
      "sortDirection": "desc",
      "includeHighlights": true
    }
  • Response (200 OK): Returns matching list of documents with highlight snippets containing query matches.

Search Within Document Content

  • URL: /api/v1/search/documents/content
  • Method: GET
  • Query Params: query (Required), page (Default: 0), size (Default: 10)

Quick Document Search

  • URL: /api/v1/search/documents
  • Method: GET
  • Query Params: query, page, size, sortBy, sortDirection

Module 7: Credit & Balance System

Get Available Credit Packs

  • URL: /api/v1/credits/packs
  • Method: GET
  • Query Params: currency (Optional, defaults to "USD")
  • Response (200 OK): Lists packs (price, credit volume, active status).

Get Current User Credit Balance

  • URL: /api/v1/credits/balance
  • Method: GET

Initialize Credit Pack Purchase

  • URL: /api/v1/credits/purchase
  • Method: POST
  • Request Body (PurchaseCreditPackRequest):
    {
      "packId": "pack_uuid",
      "paymentGateway": "PAYSTACK or PAYPAL",
      "promoCode": "WELCOME10"
    }
  • Response (200 OK): Returns payment checkout initialization URLs.

Transfer Credits to Another User

  • URL: /api/v1/credits/transfer
  • Method: POST
  • Constraint: Senders must retain a minimum of 5 credits. Transfers for regular users are capped at 30 credits / month.
  • Request Body (TransferCreditsRequest):
    {
      "recipientEmail": "friend@example.com",
      "amount": 15
    }

Get Credit Transaction History

  • URL: /api/v1/credits/transactions
  • Method: GET
  • Query Params: page, size (paginated)

Calculate Credit Cost for Upload

  • URL: /api/v1/credits/calculate
  • Method: POST
  • Content-Type: multipart/form-data
  • Form Data: files (MultipartFile[])
  • Response (200 OK): Returns calculated pages, credits required, and if user has enough balance.

Module 8: Subscriptions & Plans

Get Current Active Subscription

  • URL: /api/v1/subscriptions/me
  • Method: GET
  • Response (200 OK): returns plan tier, quotas (ocr limits, document limits, storage limits), reset dates.

Activate Free Trial

  • URL: /api/v1/subscriptions/trial/{planId}
  • Method: POST
  • Response (200 OK): Success message.

Module 9: PayPal Payments & Subscriptions

Get PayPal Plans (Public)

  • URL: /api/v1/paypal/plans
  • Method: GET

Create PayPal Order (One-Time)

  • URL: /api/v1/paypal/orders
  • Method: POST
  • Request Body (CreateOrderRequest):
    {
      "packId": "pack_uuid",
      "currency": "USD"
    }
  • Response (201 Created): Returns order approval link to redirect user to PayPal.

Capture PayPal Order

  • URL: /api/v1/paypal/orders/{orderId}/capture
  • Method: POST

Get PayPal Order Details

  • URL: /api/v1/paypal/orders/{orderId}
  • Method: GET

Refund PayPal Payment

  • URL: /api/v1/paypal/refund
  • Method: POST
  • Request Body: { "captureId": "...", "amount": "9.99", "currency": "USD" }

Get PayPal Payment History

  • URL: /api/v1/paypal/payments/history
  • Method: GET

Create PayPal Subscription (Recurring)

  • URL: /api/v1/paypal/subscriptions
  • Method: POST
  • Request Body (CreateSubscriptionRequest):
    {
      "planId": "plan_uuid"
    }
  • Response (201 Created): Returns PayPal checkout link.

Cancel / Suspend / Activate Subscription

  • URL: /api/v1/paypal/subscriptions/{subscriptionId}/cancel
  • URL: /api/v1/paypal/subscriptions/{subscriptionId}/suspend
  • URL: /api/v1/paypal/subscriptions/{subscriptionId}/activate
  • Method: POST
  • Query Params: reason (Optional)

PayPal Webhook Endpoint

  • URL: /api/v1/paypal/webhook
  • Method: POST
  • Headers Required: PayPal authentication headers (Transmission ID, signature, etc.).

Module 10: Paystack Payments & Subscriptions

Initialize Paystack Transaction

  • URL: /api/v1/paystack/transaction/initialize
  • Method: POST
  • Request Body (InitializeTransactionRequest):
    {
      "amount": 5000, // In minor unit (kobo/cents)
      "email": "user@example.com",
      "planCode": "PLN_...", // Optional
      "callbackUrl": "https://frontend.com/callback"
    }
  • Response (200 OK): Returns Paystack access code and redirect authorization URL.

Verify Paystack Transaction

  • URL: /api/v1/paystack/transaction/verify/{reference}
  • Method: GET

Get Paystack Payment History

  • URL: /api/v1/paystack/transaction/history
  • Method: GET

Create Paystack Subscription

  • URL: /api/v1/paystack/subscription
  • Method: POST
  • Request Body: { "plan": "PLN_code", "authorization": "AUTH_code" }

Enable / Disable Paystack Subscription

  • URL: /api/v1/paystack/subscription/{subscriptionCode}/enable
  • URL: /api/v1/paystack/subscription/{subscriptionCode}/disable
  • Method: POST
  • Query Params: emailToken (Required)

Paystack Webhook Receiver

  • URL: /api/v1/paystack/webhook
  • Method: POST
  • Headers Required: x-paystack-signature

Module 11: Receipts

Get Receipts

  • URL: /api/v1/receipts
  • Method: GET
  • Query Params: page, size

Get Receipt Details

  • URL: /api/v1/receipts/{receiptNumber}
  • Method: GET

Download Receipt (PDF CDN Link)

  • URL: /api/v1/receipts/{receiptNumber}/download
  • Method: GET
  • Response (200 OK): Returns the absolute file URL.

Delete Receipt

  • URL: /api/v1/receipts/{receiptNumber}
  • Method: DELETE

Bulk Delete Receipts

  • URL: /api/v1/receipts
  • Method: DELETE
  • Query Params: receiptNumbers (Comma-separated list of identifiers)

Module 12: Promo Codes

Validate Promo Code

  • URL: /api/v1/promo_codes/validate/{code}
  • Method: GET

Apply Promo Code

  • URL: /api/v1/promo_codes/apply
  • Method: POST
  • Request Body (ApplyPromoCodeRequest):
    {
      "code": "PROMO10",
      "amount": 100.00
    }

List Available Promos for User

  • URL: /api/v1/promo_codes/available
  • Method: GET

Module 13: Currency & Rates

Convert Currencies

  • URL: /api/v1/currency/convert
  • Method: GET
  • Query Params: amountInCents, from, to

Get Current Rates

  • URL: /api/v1/currency/rates
  • Method: GET

Module 14: Push Notifications & Preferences

Register Device Token

  • URL: /api/v1/notifications/device
  • Method: POST
  • Request Body (RegisterDeviceRequest):
    {
      "token": "firebase-device-token",
      "deviceType": "ios" // OR "android"
    }

Unregister Device Token

  • URL: /api/v1/notifications/device/{tokenId}
  • Method: DELETE

Get Registered Devices

  • URL: /api/v1/notifications/devices
  • Method: GET

Get Notifications list

  • URL: /api/v1/notifications
  • Method: GET
  • Query Params: page, size

Get Unread Notifications list

  • URL: /api/v1/notifications/unread
  • Method: GET

Mark Notification as Read

  • URL: /api/v1/notifications/{id}/read
  • Method: PATCH

Mark All Notifications as Read

  • URL: /api/v1/notifications/read-all
  • Method: PATCH

Delete Notification

  • URL: /api/v1/notifications/{id}
  • Method: DELETE

Get Notification Preferences

  • URL: /api/v1/notifications/preferences
  • Method: GET

Update Notification Preferences

  • URL: /api/v1/notifications/preferences
  • Method: PUT
  • Request Body (UpdatePreferencesRequest):
    {
      "emailEnabled": true,
      "pushEnabled": false,
      "smsEnabled": false,
      "marketingEnabled": true
    }

Module 15: Storage Allocation

Get Storage Information

  • URL: /api/v1/storage
  • Method: GET
  • Response (200 OK):
    {
      "success": true,
      "statusCode": 200,
      "message": "Storage information retrieved successfully",
      "data": {
        "userId": "usr_...",
        "storageUsed": 1048576, // In bytes
        "storageLimit": 10737418240, // In bytes (10GB)
        "percentageUsed": 0.01
      }
    }

🔌 WebSocket & Real-Time Progress Tracking

For asynchronous operations (uploading large files, OCR page extractions, AI classification), Xtraction streams live updates via WebSockets (SockJS + STOMP protocol).

1. The One-Time Ticket Handshake

Standard WebSockets do not support sending custom authentication headers in browsers. Xtraction solves this using a one-time ticket exchange:

  1. Request Ticket: Post to the ticket endpoint with your JWT bearer token in headers.
    • URL: /api/v1/ws/ticket
    • Method: POST
    • Headers: Authorization: Bearer <accessToken>
    • Response:
      {
        "ticket": "ticket_uuid_string",
        "wsUrl": "/ws/extraction-progress"
      }
  2. Connect Handshake: Connect to the SockJS endpoint http://localhost:8080/ws/extraction-progress. Include the ticket token in your STOMP connect headers:
    const socket = new SockJS('http://localhost:8080/ws/extraction-progress');
    const stompClient = Stomp.over(socket);
    stompClient.connect({ ticket: 'ticket_uuid_string' }, onConnect, onError);

Important

The ticket is single-use and expires in Redis after 30 seconds if not connected.

2. Subscribing to Progress Channel

Once the connection is active, subscribe to your user-specific private queue:

  • Destination: /user/queue/extraction-progress

3. Event Payload Structure (ExtractionProgressEvent)

Messages dispatched from the server are JSON strings structured as:

{
  "collectionId": "col_b8d3...",
  "documentId": "doc_e3d3...",
  "fileName": "invoice_99.pdf",
  "eventType": "EXTRACTION_PROGRESS",
  "progress": 65,
  "message": "Running Tesseract OCR on page 3",
  "timestamp": "2026-07-07T15:22:00.123Z",
  "metadata": {
    "totalPages": 5,
    "currentPage": 3
  }
}

Event Type Enums (ProgressEventType):

  • UPLOAD_STARTED: Document streaming initiated.
  • FILE_UPLOADING: Document actively streaming to cloud store.
  • FILE_UPLOADED: Upload completed.
  • FILE_UPLOAD_FAILED: Upload failed.
  • EXTRACTION_QUEUED: Document queued for background OCR/Tesseract execution.
  • EXTRACTION_STARTED: OCR process launched.
  • EXTRACTION_PROGRESS: Progress update containing parsed pages info.
  • EXTRACTION_COMPLETED: OCR finished.
  • EXTRACTION_FAILED: OCR processing failure.
  • PIPELINE_COMPLETED: Downstream NLP analysis and search indexing successfully finalized.

🛡️ Administrative Console APIs

These endpoints are strictly protected and require a user session with role ADMIN, SUPER_ADMIN, or MODERATOR.

1. User Management

Get All Users (Filtered & Paginated)

  • URL: /api/v1/admin/users
  • Method: GET
  • Query Filters: page, size, sortBy, sortOrder, search, role, isActive, isVerified, country, subscriptionPlan.

Enriched User Profile

  • URL: /api/v1/admin/{userId}
  • Method: GET
  • Response: Aggregates metadata, usage quotas, credit balances, trial status, and Redis lockout status flags.

Toggle User Status (Activate/Deactivate)

  • URL: /api/v1/admin/users/{userId}/activate
  • URL: /api/v1/admin/users/{userId}/deactivate
  • Method: PUT
  • Request Body: { "reason": "Reason details" }

Account Unlocks

  • URL: /api/v1/admin/users/{userId}/unlock
  • Method: PUT
  • Description: Clears locked-out state flags in Redis database.

Force Verify Email Address

  • URL: /api/v1/admin/users/{userId}/force-verify
  • Method: PUT

Trigger Password Reset Email

  • URL: /api/v1/admin/users/{userId}/reset-password
  • Method: POST

Change User Role

  • URL: /api/v1/admin/change-role
  • Method: PUT
  • Request Body: { "userId": "...", "role": "ADMIN" }

Soft Delete Account

  • URL: /api/v1/admin/users/{userId}/soft-delete
  • Method: DELETE
  • Role Requirement: SUPER_ADMIN only.

Impersonate User

  • URL: /api/v1/admin/users/{userId}/impersonate
  • Method: POST
  • Role Requirement: SUPER_ADMIN only. Generates a standard JWT token for the target user. Audit-logged at WARN level.
  • Request Body: { "reason": "Reason details" }

Adjust User Subscription Limits

  • URL: /api/v1/admin/users/{userId}/subscription
  • Method: PUT
  • Role Requirement: SUPER_ADMIN only.
  • Request Body:
    {
      "plan": "PRO_MONTHLY",
      "billingIntervalUnit": "MONTH",
      "billingIntervalValue": 1,
      "autoRenew": true,
      "source": "ADMIN_OVERRIDE"
    }

Reset User Quotas

  • URL: /api/v1/admin/users/{userId}/quotas/reset
  • Method: POST

2. Subscription Plan Management

Create Subscription Plan

  • URL: /api/v1/admin/subscriptions/plans
  • Method: POST

Update Plan Limits

  • URL: /api/v1/admin/subscriptions/plans/{planId}
  • Method: PUT
  • Role Requirement: SUPER_ADMIN only.

Toggle Plan Status (Activate/Deactivate)

  • URL: /api/v1/admin/subscriptions/plans/{planId}/status
  • Method: PATCH
  • Role Requirement: SUPER_ADMIN only.
  • Query Params: isActive (Boolean)
  • Request Body: { "reason": "..." }

List Plan Subscribers

  • URL: /api/v1/admin/subscriptions/plans/{planId}/subscribers
  • Method: GET
  • Query Params: page, size

3. Analytics & Statistics

These endpoints retrieve aggregated KPIs for system dashboard components:

  • Dashboard metrics summary: GET /api/v1/admin/dashboard/stats
  • User signups statistics: GET /api/v1/admin/users/stats
  • Subscriptions & revenue metrics: GET /api/v1/admin/subscriptions/stats
  • Credits circulation analytics: GET /api/v1/admin/credits/stats
  • Promo code usage analytics: GET /api/v1/admin/promo_codes/stats
  • Document & collection storage metrics: GET /api/v1/admin/documents/stats
  • Push notification statistics: GET /api/v1/admin/notifications/stats
  • Failed logins & security blocks stats: GET /api/v1/admin/security/stats
  • Payment gateways performance statistics: GET /api/v1/admin/payments/stats

4. Search Index Sync (Elasticsearch)

  • Sync All DB records: POST /api/v1/admin/elasticsearch/sync
  • Sync Users: POST /api/v1/admin/elasticsearch/sync/users
  • Sync Documents: POST /api/v1/admin/elasticsearch/sync/documents
  • Sync Payments: POST /api/v1/admin/elasticsearch/sync/payments

5. Storage Recalculation Migration

  • URL: /api/v1/admin/storage/migrate
  • Method: POST
  • Role Requirement: SUPER_ADMIN only.
  • Description: Recalculates storage footprint sizing parameters for all existing profiles.