orderCreate
Requires access scope. Also: This mutation is only accessible to apps authenticated using offline tokens.
Creates an order with attributes such as customer information, line items, and shipping and billing addresses.
Use the mutation to programmatically generate orders in scenarios where
orders aren't created through the standard checkout process, such as when importing orders from an external
system or creating orders for wholesale customers.
The mutation doesn't support applying multiple discounts, such as discounts on line items.
Automatic discounts won't be applied unless you replicate the logic of those discounts in your custom
implementation. You can apply a discount code,
but only one discount code can be set for each order.
If you're using the mutation with a
trial or
development store, then you can create a
maximum of five new orders per minute.
After you create an order, you can make subsequent edits to the order using one of the following mutations:
: Used for simple updates to an order, such as changing the order's note, tags, or customer information.
: Used when you need to make significant updates to an order, such as adding or removing line items, changing quantities, or modifying discounts. The
mutation initiates an order editing session, allowing you to make multiple changes before finalizing them. Learn more about using the
mutation to edit existing orders.
Learn how to build apps that integrate with order management and fulfillment processes.
Arguments
- Anchor to optionsoptions•
The strategies for updating inventory and whether to send shipping and order confirmations to customers.
- Anchor to orderorder•Order
Create requiredOrder Input! The attributes of the new order.
Anchor to OrderCreatePayload returnsOrderCreatePayload returns
- Anchor to orderorder•
The order that was created.
- Anchor to userErrorsuser•
Errors [OrderCreate non-nullUser Error!]! The list of errors that occurred from executing the mutation.
- Create a comprehensive order
- Create an order and send email confirmations
- Create an order using a product variant ID
- Create an order with a fixed amount off discount
- Create an order with a percentage discount
- Create an order with fulfillment details
- Create an order with tax lines
- Create an order without sending email confirmations
- orderCreate reference
Examples
mutation orderCreate($order: OrderCreateOrderInput!, $options: OrderCreateOptionsInput) {
orderCreate(order: $order, options: $options) {
userErrors {
field
message
}
order {
id
totalTaxSet {
shopMoney {
amount
currencyCode
}
}
lineItems(first: 5) {
nodes {
variant {
id
}
id
title
quantity
taxLines {
title
rate
priceSet {
shopMoney {
amount
currencyCode
}
}
}
}
}
}
}
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "mutation orderCreate($order: OrderCreateOrderInput!, $options: OrderCreateOptionsInput) { orderCreate(order: $order, options: $options) { userErrors { field message } order { id totalTaxSet { shopMoney { amount currencyCode } } lineItems(first: 5) { nodes { variant { id } id title quantity taxLines { title rate priceSet { shopMoney { amount currencyCode } } } } } } } }",
"variables": {
"order": {
"currency": "EUR",
"lineItems": [
{
"title": "Big Brown Bear Boots",
"priceSet": {
"shopMoney": {
"amount": 74.99,
"currencyCode": "EUR"
}
},
"quantity": 3,
"taxLines": [
{
"priceSet": {
"shopMoney": {
"amount": 13.5,
"currencyCode": "EUR"
}
},
"rate": 0.06,
"title": "State tax"
}
]
}
],
"transactions": [
{
"kind": "SALE",
"status": "SUCCESS",
"amountSet": {
"shopMoney": {
"amount": 238.47,
"currencyCode": "EUR"
}
}
}
]
}
}
}'
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation orderCreate($order: OrderCreateOrderInput!, $options: OrderCreateOptionsInput) {
orderCreate(order: $order, options: $options) {
userErrors {
field
message
}
order {
id
totalTaxSet {
shopMoney {
amount
currencyCode
}
}
lineItems(first: 5) {
nodes {
variant {
id
}
id
title
quantity
taxLines {
title
rate
priceSet {
shopMoney {
amount
currencyCode
}
}
}
}
}
}
}
}`,
{
variables: {
"order": {
"currency": "EUR",
"lineItems": [
{
"title": "Big Brown Bear Boots",
"priceSet": {
"shopMoney": {
"amount": 74.99,
"currencyCode": "EUR"
}
},
"quantity": 3,
"taxLines": [
{
"priceSet": {
"shopMoney": {
"amount": 13.5,
"currencyCode": "EUR"
}
},
"rate": 0.06,
"title": "State tax"
}
]
}
],
"transactions": [
{
"kind": "SALE",
"status": "SUCCESS",
"amountSet": {
"shopMoney": {
"amount": 238.47,
"currencyCode": "EUR"
}
}
}
]
}
},
},
);
const data = await response.json();
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `mutation orderCreate($order: OrderCreateOrderInput!, $options: OrderCreateOptionsInput) {
orderCreate(order: $order, options: $options) {
userErrors {
field
message
}
order {
id
totalTaxSet {
shopMoney {
amount
currencyCode
}
}
lineItems(first: 5) {
nodes {
variant {
id
}
id
title
quantity
taxLines {
title
rate
priceSet {
shopMoney {
amount
currencyCode
}
}
}
}
}
}
}
}`,
"variables": {
"order": {
"currency": "EUR",
"lineItems": [
{
"title": "Big Brown Bear Boots",
"priceSet": {
"shopMoney": {
"amount": 74.99,
"currencyCode": "EUR"
}
},
"quantity": 3,
"taxLines": [
{
"priceSet": {
"shopMoney": {
"amount": 13.5,
"currencyCode": "EUR"
}
},
"rate": 0.06,
"title": "State tax"
}
]
}
],
"transactions": [
{
"kind": "SALE",
"status": "SUCCESS",
"amountSet": {
"shopMoney": {
"amount": 238.47,
"currencyCode": "EUR"
}
}
}
]
}
},
},
});
session = ShopifyAPI::Auth::Session.new(
shop: "your-development-store.myshopify.com",
access_token: access_token
)
client = ShopifyAPI::Clients::Graphql::Admin.new(
session: session
)
query = <<~QUERY
mutation orderCreate($order: OrderCreateOrderInput!, $options: OrderCreateOptionsInput) {
orderCreate(order: $order, options: $options) {
userErrors {
field
message
}
order {
id
totalTaxSet {
shopMoney {
amount
currencyCode
}
}
lineItems(first: 5) {
nodes {
variant {
id
}
id
title
quantity
taxLines {
title
rate
priceSet {
shopMoney {
amount
currencyCode
}
}
}
}
}
}
}
}
QUERY
variables = {
"order": {
"currency": "EUR",
"lineItems": [{"title"=>"Big Brown Bear Boots", "priceSet"=>{"shopMoney"=>{"amount"=>74.99, "currencyCode"=>"EUR"}}, "quantity"=>3, "taxLines"=>[{"priceSet"=>{"shopMoney"=>{"amount"=>13.5, "currencyCode"=>"EUR"}}, "rate"=>0.06, "title"=>"State tax"}]}],
"transactions": [{"kind"=>"SALE", "status"=>"SUCCESS", "amountSet"=>{"shopMoney"=>{"amount"=>238.47, "currencyCode"=>"EUR"}}}]
}
}
response = client.query(query: query, variables: variables)