Skip to main content

Create Invoice

Create a new invoice for a customer with line items.

POSThttps://api.zenpayz.com/merchant/api/v1/invoices
Bearer · API key

Request

Headers

HeaderDescription
Authorization
REQUIRED
Bearer {api_key}
X-Signature
REQUIRED
HMAC-SHA256 signature
X-Timestamp
REQUIRED
ISO 8601 timestamp
X-Secret-Salt
REQUIRED
Secret salt for HMAC validation
Content-Type
REQUIRED
application/json

Body Parameters

ParameterTypeDescription
customerId
REQUIRED
stringCustomer ID
customerEmail
REQUIRED
stringCustomer email address
customerName
OPTIONAL
stringCustomer display name (1-255 characters)
currency
OPTIONAL
stringCurrency code (default: USD)
issueDate
REQUIRED
stringInvoice issue date (ISO 8601)
dueDate
REQUIRED
stringPayment due date (ISO 8601)
taxRate
OPTIONAL
numberTax rate percentage (minimum 0, default: 0)
discountAmount
OPTIONAL
numberDiscount amount (minimum 0, default: 0)
notes
OPTIONAL
stringNotes displayed on the invoice
terms
OPTIONAL
stringPayment terms and conditions
lineItems
REQUIRED
arrayArray of line items (minimum 1)
metadata
OPTIONAL
objectCustom key-value pairs

Response

Success (201 Created)

{
"success": true,
"data": {
"invoiceId": "inv_a1b2c3d4e5f6g7h8",
"invoiceNumber": "INV-2024-0001",
"customerId": "cust_a1b2c3d4e5f6g7h8",
"customerEmail": "john@example.com",
"customerName": "John Doe",
"currency": "USD",
"status": "DRAFT",
"issueDate": "2024-01-15T00:00:00.000Z",
"dueDate": "2024-02-15T00:00:00.000Z",
"subtotal": 250.00,
"taxRate": 10,
"taxAmount": 25.00,
"discountAmount": 0,
"totalAmount": 275.00,
"amountPaid": 0,
"amountDue": 275.00,
"notes": "Thank you for your business",
"terms": "Net 30",
"lineItems": [
{
"id": "li_001",
"productId": "prod_a1b2c3d4e5f6g7h8",
"description": "Pro Plan - Monthly",
"quantity": 5,
"unitPrice": 50.00,
"taxRate": 0,
"amount": 250.00,
"sortOrder": 0
}
],
"metadata": {},
"createdAt": "2024-01-15T10:30:00.000Z",
"updatedAt": "2024-01-15T10:30:00.000Z"
},
"message": "Invoice created successfully",
"error": null,
"meta": {
"request_id": "req_xxxxx",
"timestamp": "2024-01-15T10:30:00.000Z",
"processing_time_ms": 65,
"api_version": "v1",
"endpoint": "POST /invoices",
"user_type": "merchant"
}
}

Error Responses

CodeHTTPMessage
VALIDATION_ERROR400Invalid request parameters
UNAUTHORIZED401Invalid API key
CUSTOMER_NOT_FOUND404Customer does not exist

Examples

curl -X POST https://api.zenpayz.com/merchant/api/v1/invoices \
-H "Authorization: Bearer zp_test_xxxxx" \
-H "X-Timestamp: 2024-01-15T10:30:00.000Z" \
-H "X-Signature: a1b2c3d4e5f6..." \
-H "X-Secret-Salt: your_secret_salt" \
-H "Content-Type: application/json" \
-d '{
"customerId": "cust_a1b2c3d4e5f6g7h8",
"customerEmail": "john@example.com",
"customerName": "John Doe",
"currency": "USD",
"issueDate": "2024-01-15T00:00:00.000Z",
"dueDate": "2024-02-15T00:00:00.000Z",
"taxRate": 10,
"notes": "Thank you for your business",
"terms": "Net 30",
"lineItems": [
{
"productId": "prod_a1b2c3d4e5f6g7h8",
"description": "Pro Plan - Monthly",
"quantity": 5,
"unitPrice": 50.00
}
]
}'