Send HTTP request

The Send HTTP request action connects your workflow to a web server or URL and sends HTTP requests.

After Flow sends your HTTP request, it waits for a maximum of 30 seconds for an HTTP response code. If Flow hasn't received a response after 30 seconds, then it closes the connection to your app. Later, it retries the request.

Fields

The Send HTTP request action contains the following fields.

Fields used in the Send HTTP request action.
FieldDescription
HTTP methodThe method of HTTP request to send. The Send HTTP request action supports the following methods:
  • Get - Sends a request for information from the server.
  • Delete - Removes a resource from the server.
  • Head - Retrieves the HTTP response headers of the server.
  • Options - Retrieves the options and features that are supported by the server.
  • Patch - Partially updates a resource on the server.
  • Put - Updates a resource on the server.
  • Post - Creates or replaces a resource on the server.
URLThe URL of the server to which the HTTP request is sent.
HeadersThe key and value pair for the HTTP request. Multiple key-value pairs can be entered.
BodyThe content to be sent to the server.
On client error (4XX response)When receiving a response code indicating a client error, Flow will:
  • Retry - Retry for up to 24 hours until receiving a different response code or timing out.
  • Fail - Fail the workflow run.
  • Ignore - Ignore the error and continue the workflow run.
On server error (5XX or 429 response)When receiving a response code indicating a server error, Flow will:
  • Retry - Retry for up to 24 hours until receiving a different response code or timing out.
  • Fail - Fail the workflow run.
  • Ignore - Ignore the error and continue the workflow run.

Returned data

To access the returned data in steps that follow this action, use the variable named sendHttpRequest, which includes all the details of the HTTP response. Optionally, use a Run code action to parse the body of the response for use in subsequent workflow steps, such as in the example below.

If a Send HTTP request action is used multiple times in a single workflow, then a number is added to the variable name. For example, in a workflow that uses the Send HTTP request action twice, the first variable for returned data is sendHttpRequest and the second variable is sendHttpRequest1. This name cannot be customized.

Response codes

The following table describes how Flow processes the HTTP response code after it receives a response.

How Flow processes HTTP response codes.
HTTP response codeHow Flow processes the response code
2XX or 3XX SuccessFlow marks the HTTP request as a success and performs subsequent actions in the workflow.
4XX Errors,
5XX and 429 Errors
Depending on how the action is configured, Flow will:
  • Retry - Retry for up to 24 hours until receiving a different response code or timing out.
  • Fail - Fail the workflow run.
  • Ignore - Ignore the error and continue the workflow run.
Other response codeIf the response returns a code not described in this table or it times out when retrying actions, then Flow marks the HTTP request as failing, fails the workflow run, and doesn't take subsequent workflow actions.

Secrets

Secrets are used to securely store sensitive information for use in the Send HTTP request action, such as access tokens or passwords. Secrets are created and managed from the Flow > Settings page. A secret contains a handle, value, and description. Reference the secret as a Liquid variable (such as {{secrets.handle}}) or from the Add secret option when configuring the URL, Header value, or Body fields. Secret values are never visible in the Flow interface and are redacted from the workflow run logs.

Triggers

The Send HTTP request action can be used in any workflow.

Examples

Example 1: Send an HTTP request to an external service

In this example, use Flow to send an HTTP request to an external service.

Before you begin, configure a web service that receives HTTP requests and stores the data of those requests for testing, such as Request Catcher. Remember to use caution when sending sensitive data (such as passwords or API keys) to a third-party service.

Steps:

  1. Choose the Product status updated trigger, which allows you to test this workflow by changing the status on a product.
  2. Add a Send HTTP Request action to your workflow and connect it to the trigger. Then open the configuration panel by clicking the Send HTTP Request step.
    • In the HTTP Method field, enter POST.
    • In the URL field, enter the URL to test against, such as https://yourFlowTest.requestcatcher.com/test.
    • In the Headers section, enter a header with Key of Content-Type and Value of text/plain.
    • In the Body section, enter {{product.title}} and {{product.status}} to send the title and updated status of the product from the trigger.
  3. Activate the workflow.
  4. Test it by changing the status on a Product, such as from Draft to Active.
  5. Observe the results in the external testing service, such as https://yourFlowTest.requestcatcher.com/ in this example.

Example 2: Use Run code to parse an HTTP response

In this example, use Flow to send an HTTP request to an external service and a Run code action to parse the body of the HTTP response for use in subsequent workflow steps.

Before you begin, choose a web service that receives HTTP requests and returns data, such as Postman Echo. Remember to use caution when sending sensitive data (such as passwords or API keys) to a third-party service.

Steps:

  1. Choose the Product status updated trigger, which allows you to test this workflow by changing the status on a product.

  2. Add a Send HTTP Request action to your workflow and connect it to the trigger. Then open the configuration panel by clicking the Send HTTP Request step.

    • In the HTTP Method field, enter POST.

    • In the URL field, enter the URL to test against, such as https://postman-echo.com/post.

    • In the Headers section, enter a header with Key of Content-Type and Value of application/json.

    • In the Body section, enter the example JSON to return to the workflow, such as:

      {
          "productTitle": "{{product.title}}",
          "productStatus": "{{product.status}}"
      }
  3. Add a Run code action to your workflow and connect it to the Send HTTP request action. Then open the configuration panel by clicking the Run code step.

    • In the Define inputs field, include the body returned by the sendHTTPrequest object, such as:

      query{
        sendHttpRequest {
          body
        }
      }
    • In the Define outputs field, defined in the output schema, such as:

      type Output {
        productTitle: String!
        productStatus: String!
      }
    • In the Write code field, parse the response using the JSON.parse method and make sure that the data you return matches the shape and types defined in the output schema, such as:

      export default function main(input) {
        const body = JSON.parse(input.sendHttpRequest.body);
        console.log("body is", body);
        return {
          productTitle: body.data.productTitle,
          productStatus: body.data.productStatus
        }
      }
  4. Add a Log output action to your workflow and connect it to the Run code action. Then open the configuration panel by clicking the Run code step.

    • In the Output field, include the variables returned by the Run code step, such as:

      Title from HTTP response: {{runCode.productTitle}}
      Status from HTTP response: {{runCode.productStatus}}
  5. Activate the workflow.

  6. Test it by changing the status on a Product, such as from Draft to Active.

  7. Observe the resulting run from the Flow / Recent runs page and note the values in the Log output step match the values returned from the Send HTTP request output.

Templates

Notify your fulfillment provider about upcoming orders

Send an HTTP request to your fulfillment provider when orders are tagged "Warehouse" in Order Tagger. View template

Send new orders to Airtable

Send orders to Airtable when an order is created. View template

Send all existing and new products to Airtable

Every 10 minutes, find products that have not been sent to Airtable (by tag) and send them to Airtable. View template

Update products in batches from product data stored in Airtable

Update products in batches from product data that is stored in Airtable. View template

Notify customers of expiring gifts cards using SendGrid

Every day, get all gift cards that are expiring in 7 days and send emails to customers using SendGrid. View template

Send email using SendGrid when customers places an order for a custom item

Send a transactional email using SendGrid when a customer places an order for a custom item. View template

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