Skip to main content

Create an order

About orders

An order is a customer's request to purchase one or more products and have them delivered via a specified method. With the Delivery Gateway backend integration, you can create orders, assign all the relevant information to them, and manage them throughout the order's lifecycle.

An order requires the following data:

  • A reference ID: an automatically generated ID assigned by your system.
  • When the order was created.
  • The total price of the order. You must specify both the net and gross values.
  • The items included in the order.

Create an order

Create and update orders with the upsertOrder mutation.

First, assign the order an ID and set the time of its creation:

  • Generate an ID and pass it to referenceId.
  • Pass the time in Y-m-d\TH:i:sP format to createdAt.
mutation {
upsertOrder(
input: {
referenceId: "123456",
createdAt: $date
}
)
}

Add the items to the order. If you have multiple items, include them as an array. Each item must have a name, a unit price, a quantity, and a total price.

  • The unit field sets the unit price. The net and gross subfields both require an amount and a currency and you also need to specify the VAT in the vat subfield.
  • The quantity field requires count which takes a float, and type which defines the measurement. In addition to the pre-defined values, you can set it to OTHER and specify ta custom type with the typeOther field.
  • The total, like the unit prices, requires both a net and a gross amount. The total price should be calculated as the unit price multiplied by the item quantity.
mutation (
$netPrice: # calculated net price of order
$grossPrice: # calculated gross price of order
){
upsertOrder(
input: {
referenceId: "123456",
createdAt: "2025-12-10\\CET16:17:52+01:00",
items: {
name: "HAL-9000"
unit: {
net: {
amount: 55000,
currency: HUF
},
vat: 27,
gross: {
amount: 69850,
currency: HUF
}
}
quantity: {
count: 1,
type: PIECE
}
total: {
net: {
amount: $netPrice
currency: HUF
},
gross: {
amount: $grossPrice
currency: HUF
}
}
isShipping: true,
isPayment: true,
isDiscount: false
},
}
)
}

The final total price of the order is set in the total field. This also requires a net and a gross subfields. You can calculate the total price by adding all unit price totals.

GraphQL mutation
mutation (
$netPrice: # calculated net price of order
$grossPrice: # calculated gross price of order
$totalnetPrice: # a calculated total net price of all items
$totalgrossPrice: # a calculated total gross price of all items
){
upsertOrder(
input: {
referenceId: "123456",
createdAt: "2025-12-10\\CET16:17:52+01:00",
total: {
net: {
amount: 55000,
currency: HUF
}
gross: {
amount: 69850,
currency: HUF
}
},
items: [{
name: "HAL-9000"
unit: {
net: {
amount: 55000,
currency: HUF
},
vat: 27,
gross: {
amount: 69850,
currency: HUF
}
}
quantity: {
count: 1,
type: PIECE
}
total: {
net: {
amount: $netPrice
currency: HUF
},
gross: {
amount: $grossPrice
currency: HUF
}
}
isShipping: true,
isPayment: true,
isDiscount: false
},
]
}
)
}