6.1 API Design Principles
Standards:
- RESTful design with resource-based URLs
- JSON request/response bodies
- HTTP status codes per RFC 7231
- OAuth 2.0 Bearer token authentication
- URL path versioning (/v1, /v2)
- Consistent error response envelope
- HATEOAS links for related resources (optional)
Base URL: https://api.egflow.com/v1
Response Envelope (All Responses):
{
"success": true|false,
"data": { },
"metadata": {
"timestamp": "ISO8601",
"requestId": "uuid",
"apiVersion": "1.0"
},
"errors": null|[]
}6.2 Complete API Endpoint Catalog
6.2.1 Batch Management APIs
| Method | Endpoint | Description | Auth Role | Rate Limit |
|---|---|---|---|---|
| POST | /v1/organizations/{orgId}/batches | Upload batch XML | Batch Operator | 10/hour |
| POST | /v1/organizations/{orgId}/batches/{batchId}/start | Start processing | Batch Operator | 30/hour |
| GET | /v1/organizations/{orgId}/batches/{batchId} | Get batch status | Read-Only | 100/min |
| GET | /v1/organizations/{orgId}/batches | List batches (with filters) | Read-Only | 100/min |
| GET | /v1/organizations/{orgId}/batches/{batchId}/items | List invoice items | Read-Only | 100/min |
| GET | /v1/organizations/{orgId}/batches/{batchId}/items/{itemId} | Get item details | Read-Only | 100/min |
| PUT | /v1/organizations/{orgId}/batches/{batchId} | Update batch metadata | Batch Operator | 30/hour |
6.2.2 Organization APIs
| Method | Endpoint | Description | Auth Role | Rate Limit |
|---|---|---|---|---|
| GET | /v1/organizations/{orgId} | Get organization details | Read-Only | 100/min |
| PUT | /v1/organizations/{orgId} | Update organization config | Org Admin | 10/hour |
6.2.3 Template APIs
| Method | Endpoint | Description | Auth Role | Rate Limit |
|---|---|---|---|---|
| GET | /v1/organizations/{orgId}/templates | List templates (filter: category, status) | Read-Only | 100/min |
| GET | /v1/organizations/{orgId}/templates/{templateId} | Get template details | Read-Only | 100/min |
| GET | /v1/organizations/{orgId}/template-categories | List template categories | Read-Only | 100/min |
6.2.4 Schema Management APIs
| Method | Endpoint | Description | Auth Role | Rate Limit |
|---|---|---|---|---|
| GET | /v1/organizations/{orgId}/schemas | List supported vendor formats | Read-Only | 100/min |
| POST | /v1/organizations/{orgId}/schemas/validate | Pre-validate XML | Batch Operator | 20/hour |
6.2.5 Invoice APIs
| Method | Endpoint | Description | Auth Role | Rate Limit |
|---|---|---|---|---|
| GET | /v1/organizations/{orgId}/invoices/{invoiceId}/pdf | Download PDF | Read-Only | 1000/hour |
| GET | /v1/organizations/{orgId}/invoices/{invoiceId}/html | Download HTML | Read-Only | 1000/hour |
6.2.6 System APIs
| Method | Endpoint | Description | Auth Role | Rate Limit |
|---|---|---|---|---|
| GET | /v1/health | Health check | None | Unlimited |
| GET | /v1/version | API version info | None | Unlimited |
6.3 Detailed API Specifications
6.3.1 POST /organizations/{orgId}/batches (Batch Upload)
Purpose: Upload batch invoice XML file for processing
Request Headers:
Authorization: Bearer {jwt-token}
Content-Type: multipart/form-data
Request Body:
file: [XML file binary]
metadata: {
"batchName": "Invoice_November_2025",
"priority": "normal"
}
Success Response (201 Created):
{
"success": true,
"data": {
"batchId": "550e8400-e29b-41d4-a716-446655440000",
"organizationId": "123e4567-e89b-12d3-a456-426614174000",
"status": "uploaded",
"uploadedAt": "2025-11-21T10:30:00Z",
"fileInfo": {
"fileName": "invoices_nov.xml",
"fileSize": 15728640,
"checksum": "sha256:a3d5e7f9...",
"detectedFormat": "GASEL"
},
"blobPath": "acme-batches-2025/11/21/550e8400.../source.xml"
}
}
Error Responses:
// 400 Bad Request - Invalid XML { "success": false, "errors": [{ "code": "INVALID_XML", "message": "XML file is not well-formed", "field": "file", "details": { "line": 142, "column": 23, "error": "Unexpected end tag: </Invoice>", "suggestion": "Check that all opening tags have matching closing tags", "documentationUrl": "https://docs.egflow.com/errors/INVALID_XML" } }] } // 413 Payload Too Large { "success": false, "errors": [{ "code": "FILE_TOO_LARGE", "message": "File exceeds 100MB limit", "details": { "fileSize": 105906176, "limit": 104857600, "suggestion": "Split large batches into multiple files" } }] } // 415 Unsupported Media Type { "success": false, "errors": [{ "code": "UNSUPPORTED_FORMAT", "message": "Cannot detect vendor format", "details": { "detectedNamespace": "http://unknown.com/schema", "supportedFormats": ["GASEL", "XELLENT", "ZYNERGY"], "suggestion": "Ensure XML uses one of the supported vendor formats", "documentationUrl": "https://docs.egflow.com/vendor-formats" } }] } // 429 Too Many Requests { "success": false, "errors": [{ "code": "RATE_LIMIT_EXCEEDED", "message": "Too many batch uploads", "details": { "limit": 10, "window": "1 hour", "retryAfter": "2025-11-21T11:30:00Z" } }] }
Response Headers:
X-RateLimit-Limit: 10
X-RateLimit-Remaining: 5
X-RateLimit-Reset: 1700226000
Location: /v1/organizations/{orgId}/batches/{batchId}
6.3.2 POST /organizations/{orgId}/batches/{batchId}/start
Purpose: Start asynchronous processing of uploaded batch
Request:
{
"validationMode": "strict"
}
Success Response (202 Accepted):
{
"success": true,
"data": {
"batchId": "550e8400-e29b-41d4-a716-446655440000",
"status": "queued",
"queuedAt": "2025-11-21T10:35:00Z",
"estimatedProcessingTime": "15-30 minutes",
"queuePosition": 2
}
}
Error Responses:
// 409 Conflict - Already Processing { "success": false, "errors": [{ "code": "CONFLICT", "message": "Batch is already processing", "details": { "currentStatus": "processing", "startedAt": "2025-11-21T10:00:00Z", "estimatedCompletionAt": "2025-11-21T11:30:00Z" } }] } // 503 Service Unavailable - Queue Full { "success": false, "errors": [{ "code": "SERVICE_UNAVAILABLE", "message": "System at capacity, retry later", "details": { "queueDepth": 10500, "estimatedWaitTime": "30-60 minutes", "retryAfter": "2025-11-21T11:00:00Z", "suggestion": "Consider scheduling batch for off-peak hours (22:00-06:00 CET)" } }] }
6.3.3 GET /organizations/{orgId}/batches/{batchId}
Purpose: Get current batch status and statistics
Success Response (200 OK):
{
"success": true,
"data": {
"batchId": "550e8400-e29b-41d4-a716-446655440000",
"organizationId": "123e4567-e89b-12d3-a456-426614174000",
"batchName": "Invoice_November_2025",
"status": "processing",
"priority": "normal",
"vendorInfo": {
"vendorCode": "GASEL",
"vendorName": "Telinet Energi / EDIEL",
"version": "1.0",
"detectedNamespace": "urn:ediel:se:electricity:invoice:1.0"
},
"statistics": {
"totalItems": 5000,
"parsedItems": 5000,
"queuedItems": 1800,
"processingItems": 200,
"completedItems": 3000,
"failedItems": 0,
"successRate": 100.0,
"itemsByStatus": {
"queued": 1800,
"rendering": 50,
"rendered": 100,
"delivering": 50,
"delivered": 2900,
"failed": 0
},
"deliveryChannelBreakdown": {
"email": 2500,
"postal": 500
}
},
"timestamps": {
"uploadedAt": "2025-11-21T10:30:00Z",
"queuedAt": "2025-11-21T10:35:00Z",
"startedAt": "2025-11-21T10:35:10Z",
"estimatedCompletionAt": "2025-11-21T11:05:00Z",
"completedAt": null
},
"fileInfo": {
"fileName": "invoices_nov.xml",
"fileSize": 15728640,
"format": "xml"
}
}
}
6.3.4 GET /organizations/{orgId}/batches
Purpose: List and search batches with filtering
Query Parameters:
from: ISO 8601 date (default: 90 days ago)to: ISO 8601 date (default: today)status: uploaded|queued|processing|completed|failedvendorCode: GASEL|XELLENT|ZYNERGYsearch: Batch name searchsortBy: uploadedAt|completedAt|batchNameorder: asc|desc (default: desc)page: integer (default: 1)pageSize: integer (default: 50, max: 500)
Success Response (200 OK):
{
"success": true,
"data": {
"batches": [
{
"batchId": "uuid",
"batchName": "Invoice_November_2025",
"status": "completed",
"vendorCode": "GASEL",
"statistics": {
"totalItems": 5000,
"successfulItems": 4950,
"failedItems": 50
},
"timestamps": {
"uploadedAt": "2025-11-21T10:30:00Z",
"completedAt": "2025-11-21T11:45:00Z"
}
}
],
"pagination": {
"currentPage": 1,
"pageSize": 50,
"totalBatches": 127,
"totalPages": 3,
"hasNextPage": true,
"hasPreviousPage": false
}
}
}
6.3.5 GET /organizations/{orgId}/batches/{batchId}/items
Purpose: List individual invoice items in batch
Query Parameters:
status: queued|processing|completed|failedpage: integer (default: 1)pageSize: integer (default: 50, max: 500)
Success Response (200 OK):
{
"success": true,
"data": {
"items": [
{
"itemId": "uuid",
"batchId": "uuid",
"invoiceNumber": "2025-11-001",
"customerReference": "020624-2380",
"customerName": "Medeni Schröder",
"totalAmount": 749.28,
"currency": "SEK",
"status": "delivered",
"deliveryChannel": "email",
"processedAt": "2025-11-21T10:45:00Z",
"deliveredAt": "2025-11-21T10:46:15Z"
}
],
"pagination": {
"currentPage": 1,
"pageSize": 50,
"totalItems": 5000,
"totalPages": 100
}
}
}
6.3.6 GET /organizations/{orgId}/batches/{batchId}/items/{itemId}
Purpose: Get detailed invoice item information
Success Response (200 OK):
{
"success": true,
"data": {
"itemId": "uuid",
"batchId": "uuid",
"organizationId": "uuid",
"invoiceNumber": "2025-11-001",
"invoiceDate": "2025-11-06",
"dueDate": "2025-11-20",
"currency": "SEK",
"customerInfo": {
"customerId": "020624-2380",
"fullName": "Medeni Schröder",
"email": "muntaser.af@zavann.net",
"phone": "09193538799"
},
"invoiceDetails": {
"subTotal": 599.42,
"taxAmount": 149.86,
"totalAmount": 749.28
},
"status": "delivered",
"deliveryChannel": "email",
"deliveryStatus": {
"attemptedAt": "2025-11-21T10:46:00Z",
"deliveredAt": "2025-11-21T10:46:15Z",
"providerMessageId": "sendgrid-msg-12345"
},
"processingTimeline": [
{"status": "queued", "timestamp": "2025-11-21T10:35:00Z"},
{"status": "rendering", "timestamp": "2025-11-21T10:44:00Z"},
{"status": "rendered", "timestamp": "2025-11-21T10:45:00Z"},
{"status": "delivering", "timestamp": "2025-11-21T10:46:00Z"},
{"status": "delivered", "timestamp": "2025-11-21T10:46:15Z"}
],
"sourceInfo": {
"vendorCode": "GASEL",
"originalInvoiceId": "2025-11-001"
},
"fileReferences": {
"pdfUrl": "/v1/organizations/{orgId}/invoices/{itemId}/pdf",
"htmlUrl": "/v1/organizations/{orgId}/invoices/{itemId}/html"
}
}
}
6.3.7 GET /organizations/{orgId}/schemas/validate
Purpose: Pre-validate XML before upload
Request:
{
"xmlContent": "<?xml version=\"1.0\"?>\n<InvoiceBatch>...</InvoiceBatch>",
"vendorCode": "GASEL"
}
Success Response (200 OK):
{
"success": true,
"data": {
"valid": true,
"vendorCode": "GASEL",
"version": "1.0",
"invoiceCount": 10,
"batchId": "BATCH2025110600001",
"validationDetails": {
"schemaValid": true,
"structureValid": true,
"requiredFieldsPresent": true
},
"warnings": [
{
"field": "CustomerParty[0]/Contact/ElectronicMail",
"message": "Email format should be validated",
"severity": "warning",
"line": 45
}
],
"errors": []
}
}