This document provides comprehensive API documentation for the Bitween integration middleware. All endpoints follow REST conventions and use JSON for request/response payloads.
http://localhost:5000/api
Bitween uses JWT (JSON Web Tokens) for authentication. Include the token in the Authorization header:
Authorization: Bearer <your-jwt-token>
POST /api/auth/login
Content-Type: application/json
{
"username": "admin",
"password": "password"
}Response:
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"expiration": "2025-06-04T18:30:00Z"
}Partners represent external systems that integrate with Bitween.
GET /api/partnersResponse:
{
"data": [
{
"id": 1,
"name": "External System A",
"description": "Our main ERP system",
"apiKey": "partner-api-key-123",
"isActive": true,
"createdOn": "2025-06-01T10:00:00Z"
}
],
"totalCount": 1,
"pageSize": 50,
"pageNumber": 1
}GET /api/partners/{id}Response:
{
"id": 1,
"name": "External System A",
"description": "Our main ERP system",
"apiKey": "partner-api-key-123",
"settings": {
"endpoint": "https://erp.company.com/api",
"timeout": 30000
},
"isActive": true,
"createdOn": "2025-06-01T10:00:00Z"
}POST /api/partners
Content-Type: application/json
{
"name": "New Partner",
"description": "Partner description",
"settings": {
"endpoint": "https://partner.com/api",
"apiKey": "partner-key"
}
}Response:
{
"id": 2,
"name": "New Partner",
"description": "Partner description",
"apiKey": "generated-api-key-456",
"settings": {
"endpoint": "https://partner.com/api",
"apiKey": "partner-key"
},
"isActive": true,
"createdOn": "2025-06-04T12:00:00Z"
}PUT /api/partners/{id}
Content-Type: application/json
{
"name": "Updated Partner Name",
"description": "Updated description",
"isActive": false
}DELETE /api/partners/{id}Documents define message types and their structure.
GET /api/documentsQuery Parameters:
pageNumber(int): Page number (default: 1)pageSize(int): Page size (default: 50)search(string): Search term
Response:
{
"data": [
{
"id": 1,
"name": "CustomerOrder",
"format": "JSON",
"promotedProperties": {
"customerId": "$.customer.id",
"orderTotal": "$.order.total",
"orderDate": "$.order.date"
},
"createdOn": "2025-06-01T10:00:00Z"
}
],
"totalCount": 1,
"pageSize": 50,
"pageNumber": 1
}GET /api/documents/{id}POST /api/documents
Content-Type: application/json
{
"name": "CustomerOrder",
"format": "JSON",
"description": "Customer order document type",
"promotedProperties": {
"customerId": "$.customer.id",
"orderTotal": "$.order.total",
"orderDate": "$.order.date",
"orderType": "$.order.type"
}
}Response:
{
"id": 1,
"name": "CustomerOrder",
"format": "JSON",
"description": "Customer order document type",
"promotedProperties": {
"customerId": "$.customer.id",
"orderTotal": "$.order.total",
"orderDate": "$.order.date",
"orderType": "$.order.type"
},
"createdOn": "2025-06-04T12:00:00Z"
}PUT /api/documents/{id}
Content-Type: application/json
{
"name": "Updated Document Name",
"description": "Updated description",
"promotedProperties": {
"customerId": "$.customer.id",
"orderTotal": "$.order.total"
}
}DELETE /api/documents/{id}Subscriptions define how messages should be processed.
GET /api/subscriptionsQuery Parameters:
partnerId(int): Filter by partnerdocumentId(int): Filter by documenttype(string): Filter by subscription type
Response:
{
"data": [
{
"id": 1,
"name": "Process Customer Orders",
"type": "Internal",
"documentId": 1,
"partnerId": 1,
"filterExpression": {
"customerId": { "operator": "exists" }
},
"validatorEndpoint": "http://localhost:7001",
"mapperEndpoint": "http://localhost:7002",
"handlerEndpoint": "http://localhost:7003",
"isActive": true,
"createdOn": "2025-06-01T10:00:00Z"
}
]
}GET /api/subscriptions/{id}POST /api/subscriptions
Content-Type: application/json
{
"name": "Process Customer Orders",
"type": "Internal",
"documentId": 1,
"partnerId": 1,
"filterExpression": {
"customerId": { "operator": "exists" },
"orderTotal": { "operator": "greaterThan", "value": 100 }
},
"validatorEndpoint": "http://localhost:7001",
"mapperEndpoint": "http://localhost:7002",
"handlerEndpoint": "http://localhost:7003",
"schedule": {
"type": "Recurring",
"intervalMinutes": 60
}
}Subscription Types:
ApiCall: Synchronous processingInternal: Asynchronous processingReceiving: Scheduled data retrievalAggregation: Batch processing
Filter Expression Operators:
exists: Property existsequals: Exact matchnotEquals: Not equalgreaterThan: Greater thanlessThan: Less thancontains: String containsstartsWith: String starts withendsWith: String ends within: Value in listnotIn: Value not in list
PUT /api/subscriptions/{id}
Content-Type: application/json
{
"name": "Updated Subscription",
"isActive": false,
"filterExpression": {
"orderType": { "operator": "equals", "value": "priority" }
}
}DELETE /api/subscriptions/{id}Xchanges represent individual message processing transactions.
GET /api/xchangesQuery Parameters:
pageNumber(int): Page numberpageSize(int): Page sizedocumentId(int): Filter by documentpartnerId(int): Filter by partnerstatus(string): Filter by statusfromDate(datetime): Filter from datetoDate(datetime): Filter to datereference(string): Filter by referencecorrelationId(string): Filter by correlation ID
Response:
{
"data": [
{
"id": 1,
"reference": "ORDER-001",
"correlationId": "corr-123",
"documentId": 1,
"partnerId": 1,
"status": "Processed",
"promotedProperties": {
"customerId": "CUST-123",
"orderTotal": "299.99",
"orderDate": "2025-06-04T10:30:00Z"
},
"inputFileId": "file-input-123",
"outputFileId": "file-output-456",
"responseFileId": "file-response-789",
"createdOn": "2025-06-04T10:30:00Z",
"processedOn": "2025-06-04T10:31:00Z"
}
],
"totalCount": 1,
"pageSize": 50,
"pageNumber": 1
}GET /api/xchanges/{id}POST /api/xchanges
Content-Type: application/json
{
"documentId": 1,
"reference": "ORDER-002",
"correlationId": "corr-456",
"data": {
"customer": {
"id": "CUST-456",
"name": "Jane Smith",
"email": "jane@example.com"
},
"order": {
"total": 149.99,
"date": "2025-06-04T14:30:00Z",
"type": "standard",
"items": [
{
"productId": "PROD-1",
"quantity": 1,
"unitPrice": 149.99
}
]
}
}
}Response:
{
"id": 2,
"reference": "ORDER-002",
"correlationId": "corr-456",
"documentId": 1,
"status": "Processing",
"promotedProperties": {
"customerId": "CUST-456",
"orderTotal": "149.99",
"orderDate": "2025-06-04T14:30:00Z"
},
"inputFileId": "file-input-789",
"createdOn": "2025-06-04T14:30:00Z"
}GET /api/xchanges/{id}/resultsResponse:
{
"data": [
{
"id": 1,
"xchangeId": 1,
"subscriptionId": 1,
"status": "Success",
"processingTime": 1250,
"outputFileId": "file-output-456",
"responseFileId": "file-response-789",
"errorMessage": null,
"createdOn": "2025-06-04T10:31:00Z"
}
]
}GET /api/xchanges/{id}/files/{fileType}File Types:
input: Original input fileoutput: Processed output fileresponse: Response file
Response:
{
"fileName": "order-001.json",
"contentType": "application/json",
"content": "{ \"customer\": { \"id\": \"CUST-123\" } }",
"size": 1024,
"createdOn": "2025-06-04T10:30:00Z"
}POST /api/xchanges/{id}/reprocessThis will reprocess the message through all matching subscriptions.
GET /api/searchQuery Parameters:
query(string): Search termdocumentId(int): Filter by documentpartnerId(int): Filter by partnerfromDate(datetime): Date range starttoDate(datetime): Date range endpageNumber(int): Page numberpageSize(int): Page size
Response:
{
"data": [
{
"id": 1,
"reference": "ORDER-001",
"documentName": "CustomerOrder",
"partnerName": "External System A",
"status": "Processed",
"promotedProperties": {
"customerId": "CUST-123",
"orderTotal": "299.99"
},
"createdOn": "2025-06-04T10:30:00Z"
}
],
"totalCount": 1,
"pageSize": 50,
"pageNumber": 1
}POST /api/search/advanced
Content-Type: application/json
{
"criteria": [
{
"field": "promotedProperties.customerId",
"operator": "equals",
"value": "CUST-123"
},
{
"field": "promotedProperties.orderTotal",
"operator": "greaterThan",
"value": "100"
}
],
"logicalOperator": "and",
"fromDate": "2025-06-01T00:00:00Z",
"toDate": "2025-06-04T23:59:59Z",
"pageNumber": 1,
"pageSize": 20
}GET /api/healthResponse:
{
"status": "Healthy",
"totalDuration": "00:00:00.0123456",
"entries": {
"database": {
"status": "Healthy",
"duration": "00:00:00.0050000"
},
"file_storage": {
"status": "Healthy",
"duration": "00:00:00.0020000"
}
}
}GET /api/health/dbGET /api/health/readyGET /api/health/liveGET /api/notificationsPOST /api/notifications
Content-Type: application/json
{
"xchangeId": 1,
"type": "ProcessingComplete",
"recipient": "admin@company.com",
"subject": "Order Processing Complete",
"message": "Order ORDER-001 has been processed successfully"
}GET /api/statistics/dashboardResponse:
{
"totalMessages": 1250,
"processedToday": 45,
"successRate": 98.5,
"averageProcessingTime": 850,
"activeSubscriptions": 12,
"recentActivity": [
{
"time": "2025-06-04T14:30:00Z",
"message": "Processed ORDER-002",
"status": "Success"
}
]
}GET /api/statistics/processingQuery Parameters:
fromDate(datetime): Date range starttoDate(datetime): Date range endgroupBy(string): Group by hour/day/month
All API endpoints return standard HTTP status codes and error responses:
200 OK: Successful request201 Created: Resource created successfully204 No Content: Successful request with no content
400 Bad Request: Invalid request data401 Unauthorized: Authentication required403 Forbidden: Insufficient permissions404 Not Found: Resource not found409 Conflict: Resource conflict422 Unprocessable Entity: Validation errors500 Internal Server Error: Server error
{
"error": {
"code": "VALIDATION_ERROR",
"message": "The request is invalid",
"details": [
{
"field": "name",
"message": "Name is required"
}
],
"traceId": "0HN7SRLF8R2QK:00000001"
}
}API endpoints are rate limited:
- Standard endpoints: 1000 requests per hour per API key
- File upload endpoints: 100 requests per hour per API key
- Search endpoints: 500 requests per hour per API key
Rate limit information is included in response headers:
X-RateLimit-Limit: 1000
X-RateLimit-Remaining: 999
X-RateLimit-Reset: 1622832000
The API is versioned using the URL path:
/api/v1/partners
/api/v2/partners
Current version: v1
Configure webhooks to receive notifications about processing events:
POST /api/webhooks
Content-Type: application/json
{
"name": "Order Processing Webhook",
"url": "https://your-system.com/webhooks/bitween",
"events": ["xchange.created", "xchange.processed", "xchange.failed"],
"secret": "your-webhook-secret"
}{
"id": "webhook-event-123",
"type": "xchange.processed",
"timestamp": "2025-06-04T14:30:00Z",
"data": {
"xchangeId": 1,
"reference": "ORDER-001",
"status": "Processed",
"processingTime": 1250
}
}This API reference provides comprehensive documentation for integrating with Bitween. For more examples and detailed integration guides, see the other documentation files.