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 — those orders are hard-blocked from invoicing). Each item's requested quantity is validated against its still-invoiceable quantity, qty_to_invoice, before the invoice is created.

After the mutation, fetch the full invoice via adminInvoice(id:) or the REST GET /api/admin/invoices/{id} endpoint to get the embedded items and totals.

Prerequisites

The example targets an order with invoiceable items. If your order has no items with qty_to_invoice > 0 (already fully invoiced / closed / fraud / paypal_standard payment method) the mutation returns "There is nothing to invoice on this order." — pick an order with outstanding qty to invoice.

Operation

OperationType
createAdminInvoiceMutation

Errors

ConditionLang keyMessage
Order is closedbagistoapi::app.admin.order.actions.invoice.closedClosed orders cannot be invoiced.
Order is fraudbagistoapi::app.admin.order.actions.invoice.fraudFraud orders cannot be invoiced.
Order paid with PayPal Standardbagistoapi::app.admin.order.actions.invoice.paypal-standard-blockedInvoices cannot be created for orders paid through PayPal Standard.
Nothing to invoicebagistoapi::app.admin.order.actions.invoice.nothing-to-invoiceThere is nothing to invoice on this order.
No permissionbagistoapi::app.admin.order.actions.invoice.no-permissionYou do not have permission to create invoices.
Items missingbagistoapi::app.admin.order.actions.invoice.items-requiredAt least one item with a positive quantity is required.
Qty exceeds availablebagistoapi::app.admin.order.actions.invoice.qty-exceedsRequested quantity (:requested) exceeds available quantity (:available) for SKU :sku.
Save failedbagistoapi::app.admin.order.actions.invoice.failedCould not create the invoice.

Released under the MIT License.