Skip to content

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

EndpointMethod
/api/admin/orders/{orderId}/invoicesPOST

Request body

FieldTypeRequiredNotes
itemsarray of { orderItemId, quantity }yesAt least one entry with quantity > 0.

Errors

HTTPLang keyMessage
422bagistoapi::app.admin.order.actions.invoice.closedClosed orders cannot be invoiced.
422bagistoapi::app.admin.order.actions.invoice.fraudFraud orders cannot be invoiced.
422bagistoapi::app.admin.order.actions.invoice.paypal-standard-blockedInvoices cannot be created for orders paid through PayPal Standard.
422bagistoapi::app.admin.order.actions.invoice.nothing-to-invoiceThere is nothing to invoice on this order.
422bagistoapi::app.admin.order.actions.invoice.no-permissionYou do not have permission to create invoices.
422bagistoapi::app.admin.order.actions.invoice.items-requiredAt least one item with a positive quantity is required.
422bagistoapi::app.admin.order.actions.invoice.qty-exceedsRequested quantity (:requested) exceeds available quantity (:available) for SKU :sku.
422bagistoapi::app.admin.order.actions.invoice.failedCould 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."
}

Released under the MIT License.