Anchor to section titled 'undefined'

orderInvoiceSend
mutation

Requires write_orders access scope. Also: The user must have access to orders and manage orders information.

Sends an email invoice for an order.


The email input fields for the order invoice. The bcc and from fields should be store or staff account emails.

Anchor to id
id
required

The order associated with the invoice.


Was this section helpful?

The order associated with the invoice email.

The list of errors that occurred from executing the mutation.


Was this section helpful?

Examples

Hide code
DescriptionCopy
mutation OrderInvoiceSend($orderId: ID!, $email: EmailInput) {
  orderInvoiceSend(id: $orderId, email: $email) {
    order {
      id
    }
    userErrors {
      message
    }
  }
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "mutation OrderInvoiceSend($orderId: ID!, $email: EmailInput) { orderInvoiceSend(id: $orderId, email: $email) { order { id } userErrors { message } } }",
 "variables": {
    "orderId": "gid://shopify/Order/17181286",
    "email": {
      "to": "test@example.net",
      "from": "Sales Modyl <salesmodel@example.com>",
      "subject": "Invoice #1001",
      "customMessage": "Thank you for your order"
    }
  }
}'
const { admin } = await authenticate.admin(request);

const response = await admin.graphql(
  `#graphql
  mutation OrderInvoiceSend($orderId: ID!, $email: EmailInput) {
    orderInvoiceSend(id: $orderId, email: $email) {
      order {
        id
      }
      userErrors {
        message
      }
    }
  }`,
  {
    variables: {
      "orderId": "gid://shopify/Order/17181286",
      "email": {
        "to": "test@example.net",
        "from": "Sales Modyl <salesmodel@example.com>",
        "subject": "Invoice #1001",
        "customMessage": "Thank you for your order"
      }
    },
  },
);

const data = await response.json();
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 OrderInvoiceSend($orderId: ID!, $email: EmailInput) {
    orderInvoiceSend(id: $orderId, email: $email) {
      order {
        id
      }
      userErrors {
        message
      }
    }
  }
QUERY

variables = {
  "orderId": "gid://shopify/Order/17181286",
  "email": {
    "to": "test@example.net",
    "from": "Sales Modyl <salesmodel@example.com>",
    "subject": "Invoice #1001",
    "customMessage": "Thank you for your order"
  }
}

response = client.query(query: query, variables: variables)
const client = new shopify.clients.Graphql({session});
const data = await client.query({
  data: {
    "query": `mutation OrderInvoiceSend($orderId: ID!, $email: EmailInput) {
      orderInvoiceSend(id: $orderId, email: $email) {
        order {
          id
        }
        userErrors {
          message
        }
      }
    }`,
    "variables": {
      "orderId": "gid://shopify/Order/17181286",
      "email": {
        "to": "test@example.net",
        "from": "Sales Modyl <salesmodel@example.com>",
        "subject": "Invoice #1001",
        "customMessage": "Thank you for your order"
      }
    },
  },
});
use Shopify\Clients\Graphql;

$client = new Graphql("your-development-store.myshopify.com", $accessToken);
$query = <<<QUERY
  mutation OrderInvoiceSend($orderId: ID!, $email: EmailInput) {
    orderInvoiceSend(id: $orderId, email: $email) {
      order {
        id
      }
      userErrors {
        message
      }
    }
  }
QUERY;

$variables = [
  "orderId" => "gid://shopify/Order/17181286",
  "email" => [
    "to" => "test@example.net",
    "from" => "Sales Modyl <salesmodel@example.com>",
    "subject" => "Invoice #1001",
    "customMessage" => "Thank you for your order",
  ],
];

$response = $client->query(["query" => $query, "variables" => $variables]);
Hide code
Input variables
Copy
{
  "orderId": "gid://shopify/Order/17181286",
  "email": {
    "to": "test@example.net",
    "from": "Sales Modyl <salesmodel@example.com>",
    "subject": "Invoice #1001",
    "customMessage": "Thank you for your order"
  }
}
Hide code
Response
JSON
{
  "orderInvoiceSend": {
    "order": {
      "id": "gid://shopify/Order/17181286"
    },
    "userErrors": []
  }
}