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.
The mutation returns the created invoice's scalar fields plus the linked order object (the full order resource — see Get Order Detail for every order sub-field). The nested items connection and the order { addresses { edges { node } } } connection are not resolved on a mutation payload — fetch them with a follow-up adminInvoice(id:) query (or REST GET /api/admin/invoices/{id}) using the returned id / _id.
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
| Operation | Type |
|---|---|
createAdminInvoice | Mutation |
Input
| Field | Type | Description |
|---|---|---|
orderId | Int! | The order to invoice. |
items | [{ orderItemId, quantity }]! | One entry per order item, with the quantity to invoice. Each quantity must be ≤ that item's still-invoiceable qty_to_invoice. |
canCreateTransaction | Boolean | Optional, default false. The admin Create Transaction checkbox — when true, also records an order transaction for the invoice amount against the order's payment method. |
Response shape notes
- The mutation payload resolves the invoice's scalar fields + the
orderobject's scalar fields (it's the full order resource —_id,incrementId,status,statusLabel,channelName,customerEmail,customerFirstName,customerLastName, totals, … — see Get Order Detail for the complete list). It does not resolve theitemsconnection ororder { addresses }— those are available on theadminInvoice(id:)detail query (whereitems { edges { node } }andorder { addresses { edges { node } } }resolve fully). - There is no top-level
orderId— the order id isorder { _id }. idis the resource IRI (/api/admin/invoices/88);_idis the numeric id.
Errors
| Condition | Message |
|---|---|
Order is closed | Closed orders cannot be invoiced. |
Order is fraud | Fraud orders cannot be invoiced. |
| Order paid with PayPal Standard | Invoices cannot be created for orders paid through PayPal Standard. |
| Nothing to invoice | There is nothing to invoice on this order. |
| No permission | You do not have permission to create invoices. |
| Items missing | At least one item with a positive quantity is required. |
| Qty exceeds available | Requested quantity exceeds the available quantity for the given SKU (the message names the SKU and both quantities). |
| Save failed | Could not create the invoice. |

