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.

Fields

The Send Admin API request action contains the following fields.

Fields used in the Send Admin API request action.
FieldDescription
MutationRequired. The Shopify GraphQL Admin mutation that you want to call. A mutation is an API that takes action or updates data.
Mutation inputsRequired. 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.

{
  "input": {
    "templateSuffix": "pre-order",
    "id": "{{product.id}}"
  }
}

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.

{
  "input": {
    "id": "{{order.customer.id}}",
    "taxExempt": 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.

{
  "input": {
    "id": "{{customer.id}}",
    "locale": "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:

{% assign revisedNote = customer.note | append: " Hello from Flow!" %}

{
  "input": {
    "id": "{{ customer.id }}",
    "note": {{ revisedNote | json }},
  }
}

The json filter escapes the string to ensure proper JSON. This results in the following JSON after the workflow runs:

{
  "input": {
    "id": "gid://shopify/Customer/1234",
    "note": "Had a \"great experience\" with their latest order. Hello from Flow!",
  }
}

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:

{% assign tags = "tag1,tag2,tag3" | split: "," %}

{
  "input": {
    "id": "{{ customer.id }}",
    "tags": {{ tags | json }}
  }
}

This results in the following JSON after the workflow runs:

{
  "input": {
    "id": "gid://shopify/Customer/1234",
    "tags": ["tag1","tag2","tag3"]
  }
}

For loop example

The following example uses a loop to output the elements of an array, separated by commas:

{% assign tags = "tag1,tag2,tag3" | split: "," %}

{
  "input": {
    "id": "{{ customer.id }}",
    "tags": [
      {% for tag in tags %}
        "{{ tag }}"{% unless forloop.last %},{% endunless %}
      {% endfor %}
    ]
  }
}

This results in the following JSON when the workflow runs:

{
  "input": {
    "id": "gid://shopify/Customer/1234",
    "tags": [
        "tag1",
        "tag2",
        "tag3"
    ]
  }
}

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:

{
  "input": {
    "id": "{{ customer.id }}",
    "tags": {{ customer.addresses | map: "city" | json }}
  }
}

This results in the following JSON after the workflow runs:

{
  "input": {
    "id": "gid://shopify/Customer/1234",
    "tags": ["Ottawa","Toronto"]
  }
}

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 and Mutation inputs from a single Shopify API version, which is currently 2024-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.
Can’t find the answers you’re looking for? We’re here to help.