← Back to docs

Sending E-Invoices

Sending E-Invoices

The send endpoint generates a fully compliant XRechnung invoice from structured JSON data and delivers it as an email with the XML invoice attached. The recipient gets a professional email with both a human-readable HTML body and the machine-readable XML attachment.

Endpoint

POST /v1/invoices/send

Authentication

Authorization: Bearer ps_live_...

Request Body

{
  "from": "billing@yourdomain.com",
  "to": "invoices@customer.de",
  "format": "xrechnung-ubl",
  "invoice": {
    "number": "2026-0089",
    "issue_date": "2026-03-18",
    "due_date": "2026-04-17",
    "currency": "EUR",
    "seller": {
      "name": "Your Company GmbH",
      "street": "Hauptstr. 42",
      "city": "Munich",
      "postal_code": "80331",
      "country": "DE",
      "tax_id": "DE987654321",
      "contact_name": "Billing Department",
      "contact_email": "billing@yourdomain.com",
      "contact_phone": "+49 89 1234567"
    },
    "buyer": {
      "name": "Customer AG",
      "street": "Berliner Str. 10",
      "city": "Berlin",
      "postal_code": "10115",
      "country": "DE",
      "leitweg_id": "991-12345-67"
    },
    "payment": {
      "means_code": "58",
      "iban": "DE89370400440532013000",
      "bic": "COBADEFFXXX",
      "terms": "Net 30 days"
    },
    "line_items": [
      {
        "description": "Software license Q1 2026",
        "quantity": 1,
        "unit": "C62",
        "unit_price": "2400.00",
        "tax_category": "S",
        "tax_rate": "19.00"
      },
      {
        "description": "Implementation support",
        "quantity": 8,
        "unit": "HUR",
        "unit_price": "150.00",
        "tax_category": "S",
        "tax_rate": "19.00"
      }
    ]
  }
}

Response

{
  "id": "inv_a1b2c3d4",
  "email_id": "em_x9y8z7w6",
  "status": "queued",
  "format": "xrechnung-ubl",
  "validation": {
    "valid": true,
    "errors": [],
    "warnings": []
  }
}

The API validates the invoice data before generating XML. If validation fails, the response returns a 400 with the validation errors — the email is not sent.

Delivery Tracking

Track delivery status through the standard Postscale email events:

  • email.queued — invoice email accepted for delivery
  • email.delivered — invoice email delivered to recipient's mail server
  • email.bounced — delivery failed (check bounce reason)

Use webhooks or poll GET /v1/emails/{email_id} for status updates.

Generated Email

The sent email includes:

  • Subject: Invoice {number} from {seller.name}
  • HTML body: clean, professional invoice summary with line items and totals
  • XML attachment: fully compliant XRechnung/CII invoice (e.g., invoice-2026-0089.xml)
  • DKIM signed: using your domain's configured DKIM keys

Unit Codes

Common UN/ECE Recommendation 20 unit codes:

CodeMeaning
C62Unit (piece)
HURHour
DAYDay
MONMonth
KGMKilogram
MTRMetre
LTRLitre

Error Handling

HTTP StatusMeaning
200Invoice generated and queued for delivery
400Validation failed (see errors array)
401Missing or invalid API key
403Sending domain not verified
429Rate limit exceeded