Header step

Read a header from the webhook request that started a Glue job.

The Header step reads one header from the request that started the job and saves its value in a variable. It's made for Webhook jobs, where the sender often puts useful information in the headers rather than the body: Shopify, for example, sends the event name in X-Shopify-Topic.

Set it up

In the appdata fieldWhat it does
Header keyheaderThe header to read, like X-Shopify-Topic. Header names aren't case-sensitive.
Response variableresponse_variableSaves the header's value as a string.

If the request didn't have that header, the variable is an empty string ("").

Use it for headers from the sender, such as event names, IDs and signatures. It's not a way to read Smooth POS authentication headers, so don't build a job that relies on them.

Example: Branch on the Shopify topic

Trigger: Webhook. Point a Shopify webhook at your job's URL.

  1. Header: Read the topic header, Header key X-Shopify-Topic, Response variable topic.

  2. Script: Branch on the topic

    $.is_new_order = $.topic === "orders/create";
    $.order = JSON.parse($.default);
  3. If Condition: If the topic is orders/create, Condition $.is_new_order === true. Add the steps that handle a new order under THEN.

📘

Check the signature too

Anyone with your webhook URL can call it. To be sure a request really came from Shopify, check its signature with the Signature step's Shopify webhook preset before you act on it.

Tips

  • Test with a header. When you select Run in the job editor, your test may not carry the header. Give the variable a fallback in the script while you build, like $.topic = $.topic || "orders/create";, and remove it when you're done.
  • Headers are strings. Convert numbers with Number($.my_header).

← All Glue step guides


Did this page help you?