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 will display a list of Mutations and Mutation inputs from Shopify Admin API version 2024-04.
  • When the Admin API version is upgraded, this action can fail if relying on a field with a breaking change.
  • The action doesn't support GraphQL queries, only mutations.
  • The action doesn't support mutations that have been deprecated.
  • The action doesn't support some mutations that are specific to certain apps, including some subscription, marketing activity, and discount 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.

Templates

Add free (discounted 100%) item to new orders

This template adds a free, discounted item to new orders if the item is in stock. It checks inventory, applies a 100% discount, and updates the order without notifying the customer. This automation would be useful to (1) enhance customer satisfaction by including a surprise free item in their order, (2) promote new or less-known products by adding them as free samples in orders, or (3) to streamline promotions by automating the inclusion and discounting of free items. View template

Allow ordering for companies created by company account requests

Assign an ordering permission when a company is created by a company account request. View template

Change product template when variants are out of stock or back in stock

Update a product template based on the inventory for the product's variants. The workflow allows you to switch between templates for in stock (the store's default template), out of stock, and when one or more variants are out of stock. View template

Fulfill any digital items in an order

Fulfills any items that have no physical delivery required, such as digital items, or that match a list of SKUs. Runs once for each fulfillment location (the 'fulfillment order') for a new order. View template

Can’t find the answers you’re looking for? We’re here to help.