The "http" action

Mechanic's "http" action allows you to send request to third-party APIs. This means Mechanic can be used to translate Shopify data and deliver it to other services.


  • "method" – required, must be one of "get" , "post" , "put" , "patch" , "delete" 
  • "url" – required, must be a string starting with http:// or https:// 
  • "headers" – optional, may be a hash of header names and values
  • "body" – required for non-GET requests, must be a string except when paired with some specific Content-Type header values (see below)
  • "verify" – optional, may be set to false to disable SSL certificate verification
  • "error_on_5xx" – optional, may be set to true to have 5xx-class responses be considered action errors

Special cases for Content-Type

In these special cases, this action accepts a "body" option set to a hash or array:

  • If the Content-Type header is not specified, or is set to "application/json", a hash or array body value will be automatically serialized to JSON before transmission.
  • If the Content-Type header is set to "application/x-www-form-urlencoded" or "multipart/form-data", a hash or array body value will be automatically serialized before transmission.

System headers

Mechanic adds two headers to every request generated by the "http" action:

  • user-agent: Mechanic/ (+
  • accept-encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3

Response data

The result of this action is a hash containing the following keys:

  • "status" – the integer HTTP response code
  • "headers" – a hash of HTTP response headers, whose values are each the array of values found for that header
  • "body" – the HTTP response body, represented as either the parsed response JSON (i.e. a hash, array, string, number, boolean, or null, if the response was JSON; see "Special cases for Content-Type", above) or as a UTF8 string
  • "body_base64" – the HTTP response body, in its original encoding, represented as base64 (hint: use with the decode_base64 Liquid filter to access the original value)

To access this data in a follow-up task run, use lookups of the form {{ }}.

Using response data

Action runs are performed in an entirely separate stage from task runs (see An introduction to runs), which means that you cannot perform third-party API requests within a task run. However, you can have your task subscribe to "mechanic/actions/perform" – a task configured this way will be reinvoked after its "http" action is performed, and the event data for that invocation will contain data from the HTTP response.

To learn more about this strategy, see Responding to action results.

Error handling

By default, Mechanic will  only automatically retry errors that result from connection issues (e.g. network or DNS failures, etc). If a valid HTTP response is received, the run will be considered successful – even if a 5xx status code is received.

However, because 5xx responses should often be considered a retryable error, we support the "error_on_5xx" option. When set to true, this action will interpret any 5xx responses as a failure of the action itself, rather than considering the action successful just because an HTTP request was technically successfully performed.

To read more about how retries are handled for erroring actions, see An introduction to runs / Runs are retryable.

Basic authentication

To authenticate your request using the Authorization header, using the "Basic" authentication type, use something like this:

{% assign username = "guest" %}
{% assign password = "guest" %}
{% assign authorization_header = username | append: ":" | append: password | base64 | prepend: "Basic " %}

{% action "http" %}
    "method": "get",
    "url": "",
    "headers": {
      "Authorization": {{ authorization_header | json }}
{% endaction %}


This task sends the merchant's input to a third-party API that simply echoes it back. Great for testing. ;)




{% action "http" %}
    "method": "post",
    "url": "",
    "body": {{ | json }}
{% endaction %}
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.