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.
- Local Development:
http://localhost:8080 - Context Path: All REST endpoints are prefixed with
/api/v1unless specified otherwise.
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
}| 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. |
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"
}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
}- Access Tokens (JWT): Passed in request headers. Short-lived (1 hour).
- Header structure:
Authorization: Bearer <accessToken>
- Header structure:
- Refresh Tokens: Set as a rolling
HttpOnly,Secure(production only),SameSite=Strictcookie namedrefreshToken. Handled automatically by the browser.
Accounts are locked out for 5 days after 4 consecutive failed login attempts. Locking details are persisted in Redis.
- 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).
- URL:
/api/v1/auth/login - Method:
POST - Request Body (
LoginRequestDto):{ "email": "janedoe@example.com", "password": "SecureP@ssw0rd1!" } - Response (
200 OK): SetsrefreshTokencookie and returnsaccessToken:{ "success": true, "statusCode": 200, "message": "User logged in successfully", "data": { "userId": "usr_9b1deb4d-3b7d-4bad-9bdd-2b0d7b3d4f82", "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...", "tokenType": "Bearer", "accessExpiresIn": 3600000 } }
- 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.
- URL:
/api/v1/auth/resend-verification-email - Method:
POST - Request Body:
{ "email": "janedoe@example.com" } - Response (
200 OK): Standard response to prevent email enumeration.
- URL:
/api/v1/auth/refresh-token - Method:
POST - Request cookies: Cookie
refreshTokenmust be present. - Response (
200 OK): Returns newaccessTokenand sets rotatedrefreshTokencookie.
- URL:
/api/v1/auth/logout - Method:
POST - Headers:
Authorization: Bearer <accessToken> - Response (
204 No Content): Clears client refresh cookie.
- URL:
/api/v1/auth/logout-all - Method:
POST - Headers:
Authorization: Bearer <accessToken> - Response (
204 No Content): Revokes all refresh tokens linked to account.
- URL:
/api/v1/auth/generate-password - Method:
POST - Request Body:
{ "passwordLength": "16", "excludedChars": "@#$" } - Response (
200 OK):{ "generatedPassword": "..." }
All endpoints below require Authorization: Bearer <accessToken> in headers.
- URL:
/api/v1/user/profile - Method:
GET - Response (
200 OK): Enriched profile details (creation date, status, verification status, profile picture CDN URL).
- URL:
/api/v1/user/forgot-password - Method:
POST - Rate Limit: Max 5 requests / hour.
- Request Body:
{ "email": "janedoe@example.com" }
- 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!" }
- URL:
/api/v1/user/change-password - Method:
POST - Request Body:
{ "oldPassword": "SecureP@ssw0rd1!", "newPassword": "BrandNewPassword123*", "confirmNewPassword": "BrandNewPassword123*" }
- URL:
/api/v1/user/profile/{userId} - Method:
PUT - Request Body (
ProfileUpdateRequestDto):{ "firstName": "Janet", "lastName": "Doe", "country": "Canada", "profession": "Senior Developer", "organization": "Brints Corp" }
- 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.
- URL:
/api/v1/user/profile/{userId}/delete - Method:
DELETE
- URL:
/api/v1/user/profile/{userId} - Method:
DELETE - Response (
200 OK): Returns text confirmation"User profile deleted successfully".
- 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" }
- URL:
/api/v1/documents/my-collections - Method:
GET - Response (
200 OK): Returns summary of user collections.
- 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.
- URL:
/api/v1/documents/collection/{collectionId}/document/{documentId} - Method:
GET
- URL:
/api/v1/documents/collection/{collectionId} - Method:
DELETE
- URL:
/api/v1/documents/collection/{collectionId}/document/{documentId} - Method:
DELETE
- URL:
/api/v1/documents/clear-all - Method:
DELETE
- URL:
/api/v1/documents/move - Method:
POST - Request Body (
MoveDocumentRequest):{ "sourceCollectionId": "col_123...", "targetCollectionId": "col_456...", "documentId": "doc_789..." }
- URL:
/api/v1/documents/collection/{collectionId} - Method:
PUT - Request Body:
{ "name": "New Collection Name" }
- URL:
/api/v1/documents/collection/{collectionId}/document/{documentId} - Method:
PUT - Request Body:
{ "displayName": "new_invoice.pdf" }
- 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).
- 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.
- URL:
/api/v1/collections/{collectionId}/document/results - Method:
GET - Response (
200 OK): List of OCR text contents for all completed documents in the collection.
- URL:
/api/v1/collections/{collectionId}/document/{documentId}/ocr-data - Method:
GET - Response (
200 OK): Returns original OCR text, page count, and edit history.
- URL:
/api/v1/collections/{collectionId}/document/{documentId}/content - Method:
PUT - Request Body (
UpdateOcrContentRequest):{ "editedContent": "This is corrected invoice text...", "contentFormat": "MARKDOWN or HTML" }
- 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.
- 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.
- URL:
/api/v1/ai/classify/{documentId} - Method:
POST - Response (
200 OK): Returns classified document category, key attributes, confidence score, and language indicators.
- 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.
- URL:
/api/v1/search/documents/content - Method:
GET - Query Params:
query(Required),page(Default: 0),size(Default: 10)
- URL:
/api/v1/search/documents - Method:
GET - Query Params:
query,page,size,sortBy,sortDirection
- URL:
/api/v1/credits/packs - Method:
GET - Query Params:
currency(Optional, defaults to"USD") - Response (
200 OK): Lists packs (price, credit volume, active status).
- URL:
/api/v1/credits/balance - Method:
GET
- 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.
- 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 }
- URL:
/api/v1/credits/transactions - Method:
GET - Query Params:
page,size(paginated)
- 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.
- URL:
/api/v1/subscriptions/me - Method:
GET - Response (
200 OK): returns plan tier, quotas (ocr limits, document limits, storage limits), reset dates.
- URL:
/api/v1/subscriptions/trial/{planId} - Method:
POST - Response (
200 OK): Success message.
- URL:
/api/v1/paypal/plans - Method:
GET
- 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.
- URL:
/api/v1/paypal/orders/{orderId}/capture - Method:
POST
- URL:
/api/v1/paypal/orders/{orderId} - Method:
GET
- URL:
/api/v1/paypal/refund - Method:
POST - Request Body:
{ "captureId": "...", "amount": "9.99", "currency": "USD" }
- URL:
/api/v1/paypal/payments/history - Method:
GET
- URL:
/api/v1/paypal/subscriptions - Method:
POST - Request Body (
CreateSubscriptionRequest):{ "planId": "plan_uuid" } - Response (
201 Created): Returns PayPal checkout link.
- 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)
- URL:
/api/v1/paypal/webhook - Method:
POST - Headers Required: PayPal authentication headers (Transmission ID, signature, etc.).
- 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.
- URL:
/api/v1/paystack/transaction/verify/{reference} - Method:
GET
- URL:
/api/v1/paystack/transaction/history - Method:
GET
- URL:
/api/v1/paystack/subscription - Method:
POST - Request Body:
{ "plan": "PLN_code", "authorization": "AUTH_code" }
- URL:
/api/v1/paystack/subscription/{subscriptionCode}/enable - URL:
/api/v1/paystack/subscription/{subscriptionCode}/disable - Method:
POST - Query Params:
emailToken(Required)
- URL:
/api/v1/paystack/webhook - Method:
POST - Headers Required:
x-paystack-signature
- URL:
/api/v1/receipts - Method:
GET - Query Params:
page,size
- URL:
/api/v1/receipts/{receiptNumber} - Method:
GET
- URL:
/api/v1/receipts/{receiptNumber}/download - Method:
GET - Response (
200 OK): Returns the absolute file URL.
- URL:
/api/v1/receipts/{receiptNumber} - Method:
DELETE
- URL:
/api/v1/receipts - Method:
DELETE - Query Params:
receiptNumbers(Comma-separated list of identifiers)
- URL:
/api/v1/promo_codes/validate/{code} - Method:
GET
- URL:
/api/v1/promo_codes/apply - Method:
POST - Request Body (
ApplyPromoCodeRequest):{ "code": "PROMO10", "amount": 100.00 }
- URL:
/api/v1/promo_codes/available - Method:
GET
- URL:
/api/v1/currency/convert - Method:
GET - Query Params:
amountInCents,from,to
- URL:
/api/v1/currency/rates - Method:
GET
- URL:
/api/v1/notifications/device - Method:
POST - Request Body (
RegisterDeviceRequest):{ "token": "firebase-device-token", "deviceType": "ios" // OR "android" }
- URL:
/api/v1/notifications/device/{tokenId} - Method:
DELETE
- URL:
/api/v1/notifications/devices - Method:
GET
- URL:
/api/v1/notifications - Method:
GET - Query Params:
page,size
- URL:
/api/v1/notifications/unread - Method:
GET
- URL:
/api/v1/notifications/{id}/read - Method:
PATCH
- URL:
/api/v1/notifications/read-all - Method:
PATCH
- URL:
/api/v1/notifications/{id} - Method:
DELETE
- URL:
/api/v1/notifications/preferences - Method:
GET
- URL:
/api/v1/notifications/preferences - Method:
PUT - Request Body (
UpdatePreferencesRequest):{ "emailEnabled": true, "pushEnabled": false, "smsEnabled": false, "marketingEnabled": true }
- 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 } }
For asynchronous operations (uploading large files, OCR page extractions, AI classification), Xtraction streams live updates via WebSockets (SockJS + STOMP protocol).
Standard WebSockets do not support sending custom authentication headers in browsers. Xtraction solves this using a one-time ticket exchange:
- 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" }
- URL:
- Connect Handshake: Connect to the SockJS endpoint
http://localhost:8080/ws/extraction-progress. Include thetickettoken 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.
Once the connection is active, subscribe to your user-specific private queue:
- Destination:
/user/queue/extraction-progress
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
}
}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.
These endpoints are strictly protected and require a user session with role ADMIN, SUPER_ADMIN, or MODERATOR.
- URL:
/api/v1/admin/users - Method:
GET - Query Filters:
page,size,sortBy,sortOrder,search,role,isActive,isVerified,country,subscriptionPlan.
- URL:
/api/v1/admin/{userId} - Method:
GET - Response: Aggregates metadata, usage quotas, credit balances, trial status, and Redis lockout status flags.
- URL:
/api/v1/admin/users/{userId}/activate - URL:
/api/v1/admin/users/{userId}/deactivate - Method:
PUT - Request Body:
{ "reason": "Reason details" }
- URL:
/api/v1/admin/users/{userId}/unlock - Method:
PUT - Description: Clears locked-out state flags in Redis database.
- URL:
/api/v1/admin/users/{userId}/force-verify - Method:
PUT
- URL:
/api/v1/admin/users/{userId}/reset-password - Method:
POST
- URL:
/api/v1/admin/change-role - Method:
PUT - Request Body:
{ "userId": "...", "role": "ADMIN" }
- URL:
/api/v1/admin/users/{userId}/soft-delete - Method:
DELETE - Role Requirement:
SUPER_ADMINonly.
- URL:
/api/v1/admin/users/{userId}/impersonate - Method:
POST - Role Requirement:
SUPER_ADMINonly. Generates a standard JWT token for the target user. Audit-logged atWARNlevel. - Request Body:
{ "reason": "Reason details" }
- URL:
/api/v1/admin/users/{userId}/subscription - Method:
PUT - Role Requirement:
SUPER_ADMINonly. - Request Body:
{ "plan": "PRO_MONTHLY", "billingIntervalUnit": "MONTH", "billingIntervalValue": 1, "autoRenew": true, "source": "ADMIN_OVERRIDE" }
- URL:
/api/v1/admin/users/{userId}/quotas/reset - Method:
POST
- URL:
/api/v1/admin/subscriptions/plans - Method:
POST
- URL:
/api/v1/admin/subscriptions/plans/{planId} - Method:
PUT - Role Requirement:
SUPER_ADMINonly.
- URL:
/api/v1/admin/subscriptions/plans/{planId}/status - Method:
PATCH - Role Requirement:
SUPER_ADMINonly. - Query Params:
isActive(Boolean) - Request Body:
{ "reason": "..." }
- URL:
/api/v1/admin/subscriptions/plans/{planId}/subscribers - Method:
GET - Query Params:
page,size
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
- 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
- URL:
/api/v1/admin/storage/migrate - Method:
POST - Role Requirement:
SUPER_ADMINonly. - Description: Recalculates storage footprint sizing parameters for all existing profiles.