Documents API

Generate, manage, and download trade documents, invoices, and export certificates.

POST/api/v1/documents/generate

Generate export documents such as commercial invoices, packing lists, and certificates of origin.

Request Body

{
  "type": "commercial_invoice",
  "shipmentId": "shp_123456789",
  "data": {
    "invoiceNumber": "INV-2024-001",
    "invoiceDate": "2024-12-01",
    "seller": {
      "name": "Export Company Ltd",
      "address": "123 Export St",
      "country": "US"
    },
    "buyer": {
      "name": "Import Corp",
      "address": "456 Import Ave",
      "country": "CN"
    },
    "items": [
      {
        "description": "Mobile Phones",
        "hsCode": "8517",
        "quantity": 100,
        "unitPrice": 500,
        "total": 50000
      }
    ],
    "currency": "USD",
    "paymentTerms": "Net 30"
  }
}

Response

{
  "success": true,
  "data": {
    "documentId": "doc_987654321",
    "type": "commercial_invoice",
    "status": "generated",
    "downloadUrl": "https://api.heydeo.ai/v1/documents/doc_987654321/download",
    "expiresAt": "2024-12-08T00:00:00Z",
    "format": "pdf",
    "size": 245760
  }
}
GET/api/v1/documents/:id

Retrieve document metadata and status.

Path Parameters

ParameterTypeDescription
idstringUnique document identifier

Response

{
  "success": true,
  "data": {
    "documentId": "doc_987654321",
    "type": "commercial_invoice",
    "status": "generated",
    "shipmentId": "shp_123456789",
    "createdAt": "2024-12-01T10:30:00Z",
    "downloadUrl": "https://api.heydeo.ai/v1/documents/doc_987654321/download",
    "expiresAt": "2024-12-08T00:00:00Z",
    "format": "pdf",
    "size": 245760
  }
}
GET/api/v1/documents/:id/download

Download the generated document file (PDF).

Path Parameters

ParameterTypeDescription
idstringUnique document identifier

Response

Returns the PDF file with appropriate headers:

Content-Type: application/pdf
Content-Disposition: attachment; filename="commercial_invoice_INV-2024-001.pdf"

[Binary PDF data]

Supported Document Types

TypeDescription
commercial_invoiceCommercial invoice for customs clearance
packing_listDetailed packing list of goods
certificate_of_originCertificate of origin document
bill_of_ladingBill of lading for shipment
proforma_invoiceProforma invoice for quotation