AI Gateway API Documentation (14.0.12)

Download OpenAPI specification:

Overview

Purpose

The AI Gateway API provides document processing capabilities for partner lending applications. It accepts document uploads, processes them through AI-powered analysis, and returns structured data extracted from documents.


Key Features

  • Batch document processing with concurrent handling
  • Document type mapping: Bank Statement, Payslip, Electric Utility Bills, Tax Forms, Employment Certificates, etc.
  • OCR data extraction with computed financial metrics
  • Fraud detection and quality assessment scoring
  • Asynchronous callback notifications
  • Comprehensive error handling and validation

Supported Document Types

The API processes multiple document categories with customizable extraction schemas. Extracted fields can be extended beyond the standard set through fine-tuning to meet specific partner requirements.

Document Type Classification Extracted Data
BANK_STATEMENT PRIMARY Account details, transactions, balances, inferred income
PAYSLIP PRIMARY Employment details, salary breakdown, deductions
BIR_FORM_2303 PRIMARY Tax information and compliance data
CERTIFICATE_OF_EMPLOYMENT PRIMARY Employment status and company information
ELECTRICITY_BILL SUPPORTING Address, payment history
TELCO_BILL SUPPORTING Contact information, billing details
WATER_BILL SUPPORTING Address verification data

Base URLs

Endpoint URLs are shared with partners individually.

Contact Boost Capital to receive environment-specific endpoint URLs and IP addresses for network configuration.

IP Addresses

The API operates from dedicated IP ranges:

  • Ingress IP: Load balancer address for incoming API requests
  • Egress IPs: Cloud Function addresses for outgoing callbacks

Specific IP addresses are provided during integration setup for firewall whitelisting.


Authentication & Security

The security measures described below represent the baseline configuration. These are not limited and can be extended, modified, or customized individually with partners based on specific security requirements and compliance obligations.

Partners have complete flexibility to choose which authentication and encryption methods to implement.


Mutual TLS

Mutual TLS (mTLS) provides bidirectional authentication for API domains. This setup ensures both the server and client verify each other's identity before any data is exchanged.

Requirements

For successful connection and client authentication:

  • Client Certificate: client.cert file
  • Client Private Key: client.key file

These cryptographic materials are securely shared by Boost Capital. The mTLS policy is configured to reject connections from clients that do not present a valid, trusted certificate.

Implementation

  1. Obtain client.cert and client.key files from Boost Capital via secure channel
  2. Configure HTTPS client to present client certificate during TLS handshake
  3. Server validates client certificate against trusted certificate authority
  4. Secure encrypted communication channel established

Payload Encryption

End-to-end encryption of all API request and response payloads provides an additional layer of data security.

Encryption Specifications

  • Algorithm: AES-256-CBC with PKCS#7 padding
  • Key/IV Management: Encryption keys and Initialization Vectors (IVs) are securely shared by Boost Capital
  • Format: Base64-encoded encrypted JSON payload
  • Content-Type: text/plain (when encryption is enabled)

Implementation Steps

Request Encryption:

  1. Obtain the shared secret key and IV from Boost Capital via secure channel
  2. Construct JSON request payload
  3. Encrypt the JSON payload using AES-256-CBC with the provided key and IV
  4. Base64-encode the encrypted data
  5. Send the base64-encoded string as HTTP POST body with Content-Type: text/plain header

Response Decryption:

  1. Receive response body as base64-encoded string
  2. Base64-decode the response
  3. Decrypt using AES-256-CBC with the same key and IV
  4. Parse the decrypted JSON payload

Important: The request and response examples in this documentation display decrypted JSON for readability. In actual implementation with encryption enabled, payloads must be encrypted and base64-encoded as described above.


OAuth 2.0

The API supports OAuth 2.0 authentication via Google Cloud Identity-Aware Proxy (IAP). This standard ensures only trusted service accounts can obtain access tokens required for API requests.

Requirements

Boost Capital will securely share:

  • Service Account JSON file (e.g., service-account.json)
  • IAP Audience (OAuth 2.0 Client ID)

Implementation Steps

  1. Obtain Credentials: Receive service account JSON and IAP Audience from Boost Capital
  2. Generate ID Token: Use the service account credentials and IAP Audience to obtain a Google-signed ID token
  3. Authenticate Requests: Include the ID token in the Authorization header of every API request:
    Authorization: Bearer {idToken}
    

Token Management

  • ID tokens have limited validity periods and must be refreshed periodically
  • Implement token caching and automatic refresh logic
  • Handle 401 Unauthorized responses by obtaining a new token

Rate Limiting

Sliding-window rate limiting is applied per tenant. The following limits are enforced:

Endpoint Limit
POST /ai-gateway/batch-upload 200 requests/min
POST /ai-gateway/status 300 requests/min
GET /ai-gateway/s3/listObjects 100 requests/min

File Processing Limits

Constraint Value
Max file size 50 MB
Max pages per document 50
Max resolution per page 40 megapixels
Max total resolution per batch 400 megapixels
Allowed content types PDF, PNG, JPEG, TIFF, HEIC, HEIF
Max concurrent documents per batch 6 (default), configurable 1–20

When a rate limit is exceeded, the API responds with HTTP 429 and the following headers:

  • Retry-After: seconds until the next request window opens
  • X-RateLimit-Limit: configured request ceiling per window
  • X-RateLimit-Remaining: requests remaining in the current window
  • X-RateLimit-Reset: seconds until the current window resets

Recommended retry guidance: respect the Retry-After header; use exponential backoff (1s → 2s → 4s); maximum 3 retries.


Error Handling

Standard Error Format (500)

{ "detail": "Error message describing what went wrong" }

Validation Error Format (422)

Validation errors follow the Pydantic error format:

{
  "detail": [
    {
      "type": "error_type",
      "loc": ["body", "field_path"],
      "msg": "Human-readable error message",
      "ctx": {}
    }
  ]
}

Retry Strategy

  • Retry on 500 errors with exponential backoff: 1s, 2s, 4s
  • Do not retry on 422 validation errors
  • Maximum recommended retries: 3 attempts
  • Respect the Retry-After header on 429 responses

Idempotency

Use a unique submissionId for each application submission. Duplicate submissions with the same submissionId may be rejected or return the existing result.

Dead Letter Queue

For production integrations, implement a Dead Letter Queue (DLQ) or equivalent mechanism to hold unfulfilled requests temporarily when persistent 500 errors occur. This allows processing to resume once the API recovers, preventing data loss without re-ingesting original documents.

Endpoint Reference

API endpoints for document processing and verification. The request body structures and examples shown in this documentation are displayed in decrypted JSON format for readability and ease of implementation. However, when payload encryption is enabled (see Payload Encryption section above), the actual HTTP POST body for all endpoints must be the base64-encoded, AES-256-CBC encrypted plain text string with the Content-Type:text/plain header. The same applies to response bodies - they will be returned as base64-encoded encrypted strings that must be decoded and decrypted using the same key and IV. Partners who choose not to implement payload encryption can send and receive standard JSON payloads with Content-Type:application/json.

Batch Document Upload

Submit a batch of documents for AI-powered processing. This endpoint accepts multiple documents associated with a single application submission and processes them asynchronously.

Processing Flow

  1. Submit documents with pre-signed S3 URLs
  2. Receive immediate acknowledgment (200 OK) with applicationId, submissionId, and initial status
  3. API processes documents asynchronously
  4. Document Result callbacks are sent to callbacks.documentResult.url as each individual document completes processing
  5. Application Result callback is sent to callbacks.applicationResult.url once all documents in the submission are processed

Document Identification

  • documentId: Logical document unit identifier — multiple image files representing the same document (e.g., a multi-page bank statement scanned as separate images) share the same documentId
  • fileId: Physical file identifier — each individual file or image in the batch has a unique fileId

For example, a two-page bank statement scanned as two separate JPEG images would have two entries sharing the same documentId but with different fileId values.

Callback Architecture

The API uses a two-tier callback system:

  • Document Result (callbacks.documentResult): Delivers per-document OCR extraction, fraud checks, and quality assessment as soon as each document finishes processing. If five documents are submitted, five separate document result callbacks will be sent.
  • Application Result (callbacks.applicationResult): Delivered once after all documents in the submission are processed. Contains aggregated computed fields and cross-document consistency checks for the entire application.
Authorizations:
Noneoauth2
Request Body schema: application/json
required
required
object
required
object

Callback endpoints for asynchronous processing results

Responses

Callbacks

Request samples

Content type
application/json
Example
{
  • "payload": {
    },
  • "callbacks": {}
}

Response samples

Content type
application/json
{
  • "applicationId": "550e8400-e29b-41d4-a716-446655440000",
  • "submissionId": "650e8400-e29b-41d4-a716-446655440001",
  • "status": "ACCEPTED",
  • "timestamp": "2025-11-07T14:30:00.123Z"
}

Callback payload samples

Callback
Content type
application/json
Example
{
  • "applicationId": "string",
  • "submissionId": "string",
  • "documentId": "string",
  • "fileId": "string",
  • "documentCategory": "string",
  • "documentType": "BANK_STATEMENT",
  • "status": "COMPLETED",
  • "ocrResult": {
    }
}

Application Status Check

Check the processing status of a previously submitted application.

This endpoint provides the current state of document processing for a given application. For detailed processing results including OCR data, fraud scores, and quality metrics, rely on the callback notifications sent to your webhook endpoints.

Use Cases

  • Query processing status before callback delivery
  • Verify completion status for tracking purposes
  • Check processing time metrics
Authorizations:
Noneoauth2
Request Body schema: application/json
required
applicationId
required
string <uuid>

Application identifier from batch upload response

Responses

Request samples

Content type
application/json
{
  • "applicationId": "550e8400-e29b-41d4-a716-446655440000"
}

Response samples

Content type
application/json
{
  • "applicationId": "550e8400-e29b-41d4-a716-446655440000",
  • "submissionId": "650e8400-e29b-41d4-a716-446655440001",
  • "status": "PROCESSING",
  • "processingTimeMs": 15420,
  • "timestamp": "2025-11-07T14:35:00.123Z"
}

Health Check

Check the API service health status. Optionally accepts a test payload that will be echoed back for integration testing.

Authorizations:
Noneoauth2
Request Body schema: application/json
optional
testPayload
object

Optional test data to echo back

Responses

Request samples

Content type
application/json
{
  • "testPayload": {
    }
}

Response samples

Content type
application/json
{
  • "status": "healthy",
  • "service": "ai-gateway-api",
  • "version": "1.0.0",
  • "echo": {
    }
}

S3 Cross-Cloud Check

This endpoint allows checking access to and listing objects within a specified S3 bucket, with an option to use custom AWS credentials for cross-cloud access.

Authorizations:
Noneoauth2
query Parameters
prefix
string

Prefix to filter objects

max_keys
integer [ 1 .. 1000 ]
Default: 100

Maximum number of objects to return

bucket
required
string

Bucket name

header Parameters
X-AWS-Role-ARN
string

Custom AWS role ARN

X-AWS-Region
string

Custom AWS region (optional)

X-AWS-Audience
string

Custom AWS audience (optional)

Responses

Response samples

Content type
application/json
{
  • "bucket": "string",
  • "prefix": "string",
  • "count": 0,
  • "objects": [
    ]
}