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
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
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
JSON{
"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",
Response
JSON{
"orderCreate": {
"userErrors": [],
"order": {
"id": "gid://shopify/Order/1073459972",
"totalTaxSet": {
"shopMoney": {
"amount": "13.5",
"currencyCode": "EUR"
}
},
"lineItems": {
"nodes": [
{
"variant": null,
"id": "gid://shopify/LineItem/1071823182",
"title": "Big Brown Bear Boots",
"quantity": 3,
"taxLines": [
{
"title": "State tax",
"rate": 0.06,
"priceSet": {
"shopMoney": {
"amount": "13.5",