Glue Sub Jobs

A Sub Job is a Glue job that other jobs call with the Run Sub Job step. Use it when the same piece of work should run from several places, like one "Update stock" job that a webhook, a schedule and a system hook all share.

A Sub Job has no inbound webhook and no schedule. It only starts when another job's Run Sub Job step starts it — and that step only accepts a job whose type is Sub Job. Calling a Sub Job's webhook URL from outside returns 400 with {"err":"sub job cannot be triggered by webhook"}.

New to Glue? Start with Creating Glue integrations. For every field on the step that starts a Sub Job, see Run Sub Job.

Create a Sub Job

  1. Go to Glue › Jobs and select New Job, or open an existing job.
  2. Under Details, set Type to Sub Job.
  3. Give it a clear Name, like "Update stock".
  4. Add steps as usual. There is no trigger, hook or schedule to configure.
  5. Select Save changes.

You can switch a job's type to or from Sub Job. Switching away from Scheduled removes its schedule. Switching away from System Hook removes its hook. If that cleanup fails, the update returns 400 with failed to update job.

Through the API, create or update the job with "type": "sub job" (or "Sub Job"). It has no trigger and no schedule.

Pass data into a Sub Job

The parent job's Run Sub Job step has a Payload. That payload (Liquid works) always arrives in the Sub Job as default, as text, whether the parent ran it in Sync or Async.

In the Sub Job's first Script step, parse it the same way you would for a webhook:

var payload = JSON.parse($.default);
$.sku = payload.sku;
$.qty = payload.qty;

The Sub Job also has:

  • Its own saved job variables (from More actions › Variables)
  • {{ company.id }}, {{ company.timezone }} and {{ company.currency }}

The parent's variables are not passed down, and Private Data isn't injected either. If the Sub Job needs Private Data or other Smooth POS data, it fetches it itself with normal steps, like any other Glue job.

Return data to the parent (Sync only)

There is no separate "return" step. Whatever the Sub Job leaves in its variables when it finishes is what the parent can read.

When the parent runs the Sub Job in Sync and sets a Response variable (for example stock_run), that variable gets:

{
  job_id: /* the Sub Job's id */,
  status: "success" or "error",
  error: /* message when status is error */,
  variables: /* the Sub Job's full variable set when it finished */
}

Read a value the Sub Job saved, for example $.stock_run.variables.updated in a Script step, or {{ stock_run.variables.total }} in a Liquid field.

Use a Stop Job step when you want to end the Sub Job early:

  • Stop Job with Status Success ends the Sub Job with status: "success". The parent is not failed.
  • Stop Job with Status Error ends the Sub Job with status: "error" and puts the stop message in error.
🚧

Don't keep secrets in variables you don't need to return

Nothing in the Sub Job's variables is redacted when Sync hands them back. Anything secret the Sub Job stored in a variable comes back to the parent. Only keep what the parent needs to read.

Async does not return results. The parent's response variable only gets {status: "queued", job_id}. The Sub Job runs on its own after that.

The normal per-run variable size limit applies. An Async payload can be up to 1 MB.

Errors

SituationWhat happens
Sync, Continue on error offA Sub Job error fails the parent's Run Sub Job step. The message looks like run_job "Update stock": <error>.
Sync, Continue on error onThe parent carries on. The response variable has status: "error" and the message in error.
Sub Job stops with SuccessThe parent is never failed by that stop.
Sync runsAre not retried on their own.
Async, a normal step errorThe Sub Job is retried automatically. A final failure shows in Glue › Errors under the Sub Job.
Async, Stop Job with ErrorFinal. It is not retried, and it shows in Glue › Errors under the Sub Job.
Calling the Sub Job's webhook URL from outside400 {"err":"sub job cannot be triggered by webhook"}.
Run Sub Job targets a job that is not a Sub JobThe step fails with run_job: job "<name>" is not a Sub Job (Sync and Async).

Limits

  • A Sync Sub Job shares the parent's time limit (270 seconds).
  • Jobs can nest at most 5 levels deep, counting both Sync and Async. A Sub Job can call another Sub Job.
  • Run Sub Job only runs a job whose type is Sub Job. Pick one from the list, or use its id or exact name. Any other type fails with run_job: job "<name>" is not a Sub Job.
  • Schedule Later set to Another job can still queue any job type — that step is not limited to Sub Jobs.

Test and logs

When you select Run on the parent job in the editor:

  • A Sync Sub Job runs for real, inline inside that test.
  • An Async Sub Job is not queued. The console logs something like test run: would queue job "Update stock"; nothing queued.

You can also open a Sub Job and select Run on it directly. Its default is whatever you put in the test default variable, which is an empty string unless you set one.

In the editor's test console, a Sync Sub Job's step logs appear inline under its steps. In production there is no saved step-by-step console for either job.

An Async Sub Job gets its own task row under the Sub Job's name, with its payload. There is no link back to the parent job. A Sync Sub Job's error shows as the parent's error, unless Continue on error is on.

Example 1: Sync "Update stock" and read updated

Build a Sub Job named Update stock, then a parent webhook job that runs it and reads the count it returns.

The Sub Job: Update stock

Type: Sub Job.

  1. Script: Read the payload

    var payload = JSON.parse($.default);
    $.sku = payload.sku;
    $.qty = payload.qty;
  2. API Request (or whatever steps update stock for that SKU).

  3. Script: Set the result: $.updated = 1;
    Or use Stop Job with Status Success when there is nothing to update, and leave updated at 0.

Anything you leave on $ (like updated) is what the parent can read from variables after a Sync run.

The parent job

Type: Webhook.

  1. Script: Read the payload: $.stock_payload = $.default;

  2. Run Sub Job: Run the stock job

    • Job: Update stock
    • Mode: Sync
    • Payload: {{ stock_payload }}
    • Continue on error: on
    • Response variable: stock_run
  3. Script: Read the result

    if ($.stock_run.status !== "success") {
      console.error("Stock job failed:", $.stock_run.error);
    }
    $.updated = $.stock_run.variables.updated || 0;

Example 2: Hand work off with Async

When the parent does not need the Sub Job's variables back, use Async so the parent finishes quickly and the Sub Job runs on its own with its own time limit.

  1. Script: Build the payload

    $.rows_json = JSON.stringify(JSON.parse($.default).rows || []);
  2. Run Sub Job: Run the import job, Job Import products (a Sub Job), Mode Async, Payload {{ rows_json }}.

The parent's response variable only gets {status: "queued", job_id}. Check Glue › Errors under the Sub Job if something goes wrong later.

Tips

  • Prefer Sync when the parent needs a result. Only Sync fills variables on the response.
  • Prefer Async when the parent should finish fast. The Sub Job gets its own time limit and its own retries.
  • Parse default as text. Liquid in the parent's Payload still arrives as a string in the child.
  • Name the Sub Job clearly. The Run Sub Job step can look it up by exact name or by id — and the target must be type Sub Job.
  • Need to queue a webhook or scheduled job later? Use Schedule Later with Another job, not Run Sub Job.

← All Glue step guides · Creating Glue integrations · Run Sub Job


Did this page help you?