Create Invoice
Creates an invoice for one or more order items. The same eligibility checks as the admin Invoice screen apply (the order must not be closed, marked fraud, or paid through PayPal Standard). Each item's requested quantity is validated against its still-invoiceable quantity, qty_to_invoice (rejected per-SKU with a message carrying the requested vs available quantity) before the invoice is created.
Endpoint
| Endpoint | Method |
|---|---|
/api/admin/orders/{orderId}/invoices | POST |
Request body
| Field | Type | Required | Notes |
|---|---|---|---|
items | array of { orderItemId, quantity } | yes | At least one entry with quantity > 0. |
Errors
| HTTP | Lang key | Message |
|---|---|---|
| 422 | bagistoapi::app.admin.order.actions.invoice.closed | Closed orders cannot be invoiced. |
| 422 | bagistoapi::app.admin.order.actions.invoice.fraud | Fraud orders cannot be invoiced. |
| 422 | bagistoapi::app.admin.order.actions.invoice.paypal-standard-blocked | Invoices cannot be created for orders paid through PayPal Standard. |
| 422 | bagistoapi::app.admin.order.actions.invoice.nothing-to-invoice | There is nothing to invoice on this order. |
| 422 | bagistoapi::app.admin.order.actions.invoice.no-permission | You do not have permission to create invoices. |
| 422 | bagistoapi::app.admin.order.actions.invoice.items-required | At least one item with a positive quantity is required. |
| 422 | bagistoapi::app.admin.order.actions.invoice.qty-exceeds | Requested quantity (:requested) exceeds available quantity (:available) for SKU :sku. |
| 422 | bagistoapi::app.admin.order.actions.invoice.failed | Could not create the invoice. |
Sample 422 response
json
{
"type": "/errors/422",
"title": "Bad Request",
"status": 422,
"detail": "Requested quantity (5) exceeds available quantity (3) for SKU WS-12-S."
}
