Send Admin API request
The Send Admin API request action sends a mutation to the Shopify GraphQL Admin API. By doing so, you can do almost any action the API allows using Flow.
On this page
Fields
The Send Admin API request action contains the following fields.
Field | Description |
---|---|
Mutation | Required. The Shopify GraphQL Admin mutation that you want to call. A mutation is an API that takes action or updates data. |
Mutation inputs | Required. The data (in JSON) that you need to send as part of your mutation request. Each mutation requires a different set of data, which is documented in the link provided for each mutation. To construct the necessary JSON, you can use Liquid or a Run code action. |
Triggers
The Send Admin API request action can be used in any workflow, with any trigger, as long as the workflow provides the data necessary to construct the mutation inputs.
Examples
Example 1: Update the template used for a product
In this example, we'll use the Send Admin API request action to call the productUpdate
mutation to update the template used for a product.
The id
field is required and must be a valid product GID. Here, we set it with the {{product.id}}
Liquid variable. This assumes that your workflow has a trigger that provides a product object.
The templateSuffix
is the name of the template that you want to apply to the product. For example, if you want to apply the pre-order
template, you would set the templateSuffix to pre-order
.
Example 2: Update a customer's tax exemption status
In this example, we'll use the Send Admin API request action to call the customerUpdate
mutation to update a customer's tax exemption status.
The id
field is required and must be a valid customer GID. Here, we set it with the {{order.customer.id}}
Liquid variable. This assumes that your workflow has a trigger that provides an order object.
The taxExempt
field is a boolean that indicates whether the customer is tax exempt. In this example, we set it to true
.
Example 3: Update a customer's locale
In this example, we'll use the Send Admin API request action to call the customerUpdate
mutation to update a customer's locale.
The id
field is required and must be a valid customer GID. Here, we set it with the {{customer.id}}
Liquid variable. This assumes that your workflow has a trigger that provides a customer object.
The locale
field is a string that represents the customer's locale. In this example, we set it to en
.
Liquid tips
Flow supports a json
liquid filter that can be useful in constructing the input. The following examples all use the customerUpdate
mutation and assume that your workflow has a trigger that provides a customer object.
Working with strings
The following example updates the note on a customer:
The json
filter escapes the string to ensure proper JSON. This results in the following JSON after the workflow runs:
Working with arrays
Array example
The json
filter transforms a liquid array into a JSON array. The following example outputs a JSON array when provided with a liquid array:
This results in the following JSON after the workflow runs:
For loop example
The following example uses a loop to output the elements of an array, separated by commas:
This results in the following JSON when the workflow runs:
Map example
The map filter can be used to get an array of a specific property from an array of objects. In the following example, an array of city
properties is extracted from an array of customer addresses:
This results in the following JSON after the workflow runs:
Limitations
The Send Admin API request action has the following limitations:
- The action doesn't support GraphQL queries, only mutations.
- The action doesn't support asynchronous mutations or mutations that return a
Job
type. - The action doesn't support mutations that do not implement the Node interface.
- The action doesn't support mutations that are specific to certain apps, which include subscriptions and discount mutations.
- The following mutations are currently unsupported:
checkoutBrandingUpsert
,draftOrderCalculate
,fileAcknowledgeUpdateFailed
,fileCreate
,fileUpdate
,priceListFixedPricesAdd
,priceListFixedPricesUpdate
,productAppendImages
,productCreateMedia
,productImageUpdate
,productUpdateMedia
,publishablePublish
,publishablePublishToCurrentChannel
,publishableUnpublish
,publishableUnpublishToCurrentChannel
,subscriptionBillingCycleEditDelete
,subscriptionBillingCycleEditsDelete
,subscriptionBillingCycleScheduleEdit
,subscriptionBillingCycleSkip
,subscriptionBillingCycleUnskip
,subscriptionContractProductChange
. - The action will display a list of
Mutations
andMutation inputs
from a single Shopify API version, which is currently2024-01
. - When the API version is upgraded and contains a breaking change, it can cause this action to fail if you rely upon that field.