Skip to content

Create Transaction

The API equivalent of the admin Sales → Transactions → Create ("Record Payment") action. Records a manual payment against an invoice and returns the created transaction, which then appears in the Transactions listing.

Partial payments are supported. Once the cumulative recorded payments for an invoice reach its grand total, the invoice is marked paid and the order advances to completed (when it already has a shipment) or processing.

Two ways to create a transaction

This endpoint records an arbitrary or partial payment you specify (invoice, method, amount). Alternatively, the Create Transaction checkbox on invoice creation captures the full invoice amount in one step using the order's payment method. Both result in a transaction that appears in the Transactions listing.

Endpoint

EndpointMethod
/api/admin/transactionsPOST

Request Body

FieldTypeRequiredDescription
invoiceIdintegerYesThe invoice to record the payment against.
paymentMethodstringYesPayment method code (e.g. cashondelivery, moneytransfer).
amountnumberYesAmount paid. Must be greater than 0 and cannot push the invoice's cumulative payments above its grand total.

Response fields

FieldTypeDescription
idIntegerThe created transaction row id.
transactionIdStringGenerated transaction reference.
invoiceIdIntegerThe invoice this payment was recorded against.
orderId / orderIncrementIdInteger / StringParent order id and human-facing number.
amount / formattedAmountNumber / StringRecorded amount, raw and formatted.
statusStringAlways paid for a recorded payment.
type / paymentMethodStringThe payment method code used.
paymentTitleStringHuman-readable payment method title.
dataObjectRecorded payment payload — { "paidAmount": <amount> }.
createdAt / updatedAtStringTimestamps.
orderObjectSlim order summary — id, incrementId, status, customerName, customerEmail, grandTotal, orderCurrencyCode.

Errors

StatusWhen
422invoiceId, paymentMethod, or amount is missing, or amount is not numeric.
400Unknown invoice, the invoice is already fully paid, amount ≤ 0, or the amount would exceed the invoice grand total.
401Missing or invalid admin token.
403Admin role lacks the required permission.

Creating a transaction while invoicing (the "Create Transaction" checkbox)

On the order detail page, the admin invoice form has a Create Transaction checkbox. Ticking it records the payment automatically at the moment the invoice is created — you don't call this endpoint at all.

The API equivalent is not a separate transaction call: it's a single flag on Create Invoice. Send can_create_transaction: true in the invoice-create body and the invoice's full amount is recorded as a transaction against the order's payment method in the same request:

bash
curl -X POST "https://your-domain.com/api/admin/orders/8/invoices" \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{
    "items": [ { "orderItemId": 42, "quantity": 1 } ],
    "can_create_transaction": true
  }'

The resulting transaction then appears in the Transactions listing, exactly like one created through this endpoint.

Which to use:

You want to…Use
Record the full invoice amount at invoice time (one step)Create Invoice with can_create_transaction: true
Record a partial payment, a later payment, or a specific amount/method against an existing invoiceThis endpoint (POST /api/admin/transactions)

Permission

sales.transactions.view

Released under the MIT License.