EnvoyX Docs
Invoices

Invoices

Invoices

The Invoices API lets you upload PDF invoices, track their processing status, view extracted data, and manage invoice lifecycle.

Endpoints

MethodPathDescription
POST/api/v1/invoices/uploadUpload an invoice (PDF, max 10MB)
GET/api/v1/invoicesList invoices with pagination and filtering
GET/api/v1/invoices/{id}Get invoice detail with extracted data
DELETE/api/v1/invoices/{id}Delete an invoice
PATCH/api/v1/invoices/{id}/statusUpdate invoice status

All endpoints require the X-API-Key header.

Upload Invoice

Upload a PDF file for AI-powered extraction.

curl -X POST https://staging-api.tryenvoyx.com/api/v1/invoices/upload \
  -H "X-API-Key: YOUR_API_KEY" \
  -F "file=@invoice.pdf"

Constraints:

  • File type: PDF only
  • Max file size: 10MB

Response:

{
  "success": true,
  "status": 201,
  "code": "INVOICE_UPLOADED",
  "message": "Invoice uploaded successfully",
  "data": {
    "id": "clx1234567890",
    "file_name": "invoice.pdf",
    "file_size": 245678,
    "status": "PENDING",
    "uploaded_at": "2024-02-10T12:00:00Z"
  }
}

After upload, the invoice enters the processing pipeline automatically. Use webhooks or WebSockets to get notified when processing completes.

List Invoices

Retrieve a paginated list of invoices with optional status filtering.

curl -X GET "https://staging-api.tryenvoyx.com/api/v1/invoices?page=1&page_size=20&status_filter=PROCESSED" \
  -H "X-API-Key: YOUR_API_KEY"

Query Parameters:

ParameterTypeDefaultDescription
pageinteger1Page number
page_sizeinteger20Items per page
status_filterstringFilter by status (e.g., PROCESSED, FLAGGED, PENDING)

Response:

{
  "success": true,
  "status": 200,
  "code": "INVOICES_FETCHED",
  "message": "Invoices retrieved successfully",
  "data": {
    "invoices": [
      {
        "id": "clx1234567890",
        "file_name": "invoice.pdf",
        "status": "PROCESSED",
        "uploaded_at": "2024-02-10T12:00:00Z",
        "processed_at": "2024-02-10T12:00:18Z"
      }
    ],
    "total": 42,
    "page": 1,
    "page_size": 20
  }
}

Get Invoice Detail

Retrieve a single invoice with full extracted data.

curl -X GET https://staging-api.tryenvoyx.com/api/v1/invoices/{id} \
  -H "X-API-Key: YOUR_API_KEY"

Response:

{
  "success": true,
  "status": 200,
  "code": "INVOICE_FETCHED",
  "message": "Invoice retrieved successfully",
  "data": {
    "id": "clx1234567890",
    "file_name": "invoice.pdf",
    "file_size": 245678,
    "file_url": "https://storage.example.com/invoice.pdf?signed=...",
    "status": "PROCESSED",
    "uploaded_at": "2024-02-10T12:00:00Z",
    "processed_at": "2024-02-10T12:00:18Z",
    "extracted_data": {
      "claim_number": "CLM-2024-001",
      "insured_id": "INS-123456",
      "insurance_name": "Blue Cross Blue Shield",
      "patient_name": "John Doe",
      "invoice_number": "INV-2024-0042",
      "submission_date": "2024-02-08",
      "invoice_date": "2024-02-05",
      "insurance_value": 250.00,
      "max_coverage": 500.00,
      "out_of_pocket": 50.00,
      "provider_name": "Dr. Smith Medical Center",
      "service_category": "Medical Consultation",
      "validation_passed": true,
      "validation_flags": []
    }
  }
}

Extracted Data Fields

FieldTypeDescription
claim_numberstringInsurance claim number
insured_idstringInsured person's ID
insurance_namestringInsurance company name
patient_namestringPatient's full name
invoice_numberstringInvoice reference number
submission_datestringDate invoice was submitted
invoice_datestringDate on the invoice
insurance_valuenumberAmount covered by insurance
max_coveragenumberMaximum coverage amount
out_of_pocketnumberPatient's out-of-pocket cost
provider_namestringHealthcare provider name
service_categorystringType of medical service
validation_passedbooleanWhether all validation checks passed
validation_flagsarrayList of validation issues (empty if all passed)

Delete Invoice

Permanently delete an invoice and its extracted data.

curl -X DELETE https://staging-api.tryenvoyx.com/api/v1/invoices/{id} \
  -H "X-API-Key: YOUR_API_KEY"

Response:

{
  "success": true,
  "status": 200,
  "code": "INVOICE_DELETED",
  "message": "Invoice deleted successfully"
}

Deletion is permanent. The invoice file and all extracted data will be removed.

Update Invoice Status

Update the status of a processed invoice (e.g., approve, reject, or mark as paid).

curl -X PATCH https://staging-api.tryenvoyx.com/api/v1/invoices/{id}/status \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "status": "APPROVED"
  }'

Response:

{
  "success": true,
  "status": 200,
  "code": "STATUS_UPDATED",
  "message": "Invoice status updated successfully",
  "data": {
    "id": "clx1234567890",
    "status": "APPROVED",
    "updated_at": "2024-02-11T09:30:00Z"
  }
}

Status Lifecycle

Invoices follow this status progression:

PENDING → PROCESSING → PROCESSED → APPROVED → PAID
                     ↘ FLAGGED  → APPROVED → PAID
                     ↘ FAILED     REJECTED
StatusDescription
PENDINGUploaded, awaiting processing
PROCESSINGAI extraction in progress
PROCESSEDSuccessfully extracted and validated
FLAGGEDExtracted but validation issues detected
FAILEDExtraction or processing error
APPROVEDManually approved after review
REJECTEDManually rejected after review
PAIDMarked as paid

Valid Status Transitions

Not all transitions are allowed. The API enforces these rules:

FromAllowed To
PROCESSEDAPPROVED, REJECTED
FLAGGEDAPPROVED, REJECTED
APPROVEDPAID

System statuses (PENDING, PROCESSING, FAILED) are set automatically and cannot be changed via the API.

Code Examples

Upload and Poll

const apiKey = process.env.ENVOYX_API_KEY

// Upload
const formData = new FormData()
formData.append('file', fs.createReadStream('invoice.pdf'))

const uploadRes = await fetch('https://staging-api.tryenvoyx.com/api/v1/invoices/upload', {
  method: 'POST',
  headers: { 'X-API-Key': apiKey },
  body: formData,
})

const { data: invoice } = await uploadRes.json()
console.log('Uploaded:', invoice.id)

// Poll for completion
let status = 'PENDING'
while (status === 'PENDING' || status === 'PROCESSING') {
  await new Promise(r => setTimeout(r, 3000))

  const res = await fetch(`https://staging-api.tryenvoyx.com/api/v1/invoices/${invoice.id}`, {
    headers: { 'X-API-Key': apiKey },
  })

  const { data } = await res.json()
  status = data.status
  console.log('Status:', status)
}
import requests
import time
import os

api_key = os.getenv('ENVOYX_API_KEY')
headers = {'X-API-Key': api_key}

# Upload
with open('invoice.pdf', 'rb') as f:
    res = requests.post(
        'https://staging-api.tryenvoyx.com/api/v1/invoices/upload',
        headers=headers,
        files={'file': f}
    )

invoice = res.json()['data']
print(f"Uploaded: {invoice['id']}")

# Poll for completion
status = 'PENDING'
while status in ('PENDING', 'PROCESSING'):
    time.sleep(3)
    res = requests.get(
        f"https://staging-api.tryenvoyx.com/api/v1/invoices/{invoice['id']}",
        headers=headers
    )
    status = res.json()['data']['status']
    print(f"Status: {status}")

Next Steps

On this page