Anchor to orderCreateorder
orderCreate
mutation
Requires access scope. Also: This mutation is only accessible to apps authenticated using [offline tokens](https://shopify.dev/docs/apps/build/authentication-authorization/access-tokens/offline-access-tokens.
Creates an order.
Anchor to Arguments
Arguments
- Anchor to optionsoptions•
Service options for the mutation.
- Anchor to orderorder•Order
Create requiredOrder Input! The input for the mutation.
Was this section helpful?
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.
Was this section helpful?
- Create a comprehensive order
- Create a pending order with an existing customer and new addresses via customer_id
- Create a simple order with only a product variant ID and no optional parameters
- Create a simple order without sending an order receipt or a fulfillment receipt
- Create a simple order, sending an order confirmation and a shipping confirmation to the customer
- Create an order
- Create an order and apply a fixed discount
- Create an order and apply a percentage discount
- Create an order with a fulfillment and send customer notification
- Creating an order with tax lines will split among taxable line items
- orderCreate reference
Examples
1const { admin } = await authenticate.admin(request);23const response = await admin.graphql(4 `#graphql5 mutation OrderCreate($order: OrderCreateOrderInput!, $options: OrderCreateOptionsInput) {6 orderCreate(order: $order, options: $options) {7 userErrors {8 field9 message10 }11 order {12 id13 totalTaxSet {14 shopMoney {15 amount16 currencyCode17 }18 }19 lineItems(first: 5) {20 nodes {21 variant {22 id23 }24 id25 title26 quantity27 taxLines {28 title29 rate30 priceSet {31 shopMoney {32 amount33 currencyCode34 }35 }36 }37 }38 }39 }40 }41 }`,42 {43 variables: {44 "order": {45 "currency": "EUR",46 "lineItems": [47 {48 "title": "Big Brown Bear Boots",49 "priceSet": {50 "shopMoney": {51 "amount": 74.99,52 "currencyCode": "EUR"53 }54 },55 "quantity": 3,56 "taxLines": [57 {58 "priceSet": {59 "shopMoney": {60 "amount": 13.5,61 "currencyCode": "EUR"62 }63 },64 "rate": 0.06,65 "title": "State tax"66 }67 ]68 }69 ],70 "transactions": [71 {72 "kind": "SALE",73 "status": "SUCCESS",74 "amountSet": {75 "shopMoney": {76 "amount": 238.47,77 "currencyCode": "EUR"78 }79 }80 }81 ]82 }83 },84 },85);8687const data = await response.json();88
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)
Input variables
JSON1{2 "order": {3 "currency": "EUR",4 "lineItems": [5 {6 "title": "Big Brown Bear Boots",7 "priceSet": {8 "shopMoney": {9 "amount": 74.99,10 "currencyCode": "EUR"11 }12 },13 "quantity": 3,14 "taxLines": [15 {16 "priceSet": {17 "shopMoney": {18 "amount": 13.5,19 "currencyCode": "EUR"20 }21 },22 "rate": 0.06,23 "title": "State tax"24 }25 ]26 }27 ],28 "transactions": [29 {30 "kind": "SALE",31 "status": "SUCCESS",32 "amountSet": {33 "shopMoney": {34 "amount": 238.47,35 "currencyCode": "EUR"36 }37 }38 }39 ]40 }41}
Response
JSON1{2 "orderCreate": {3 "userErrors": [],4 "order": {5 "id": "gid://shopify/Order/1073459972",6 "totalTaxSet": {7 "shopMoney": {8 "amount": "13.5",9 "currencyCode": "EUR"10 }11 },12 "lineItems": {13 "nodes": [14 {15 "variant": null,16 "id": "gid://shopify/LineItem/1071823182",17 "title": "Big Brown Bear Boots",18 "quantity": 3,19 "taxLines": [20 {21 "title": "State tax",22 "rate": 0.06,23 "priceSet": {24 "shopMoney": {25 "amount": "13.5",26 "currencyCode": "EUR"27 }28 }29 }30 ]31 }32 ]33 }34 }35 }36}