Skip to content

Environment variables

Environment variables are used to save the configuration and secrets required for workflow execution, and are injected into the env parameter of main(env, ctx) at step execution time.

  • Key rules

    • Must match ^[A-Za-z_][A-Za-z0-9_]*$
    • Maximum length 128
    • Not allowed to repeat
  • Value rules

    • Must be a string
    • Maximum length 8192

The key names starting with MAIA_ are reserved by the platform, the system will automatically ignore them.

The platform will inject these variables (read-only) at execution time:

  • Execution identifierMAIA_RUN_IDMAIA_STEP_KEYMAIA_ATTEMPT_NO
  • Path informationMAIA_INPUT_PATHMAIA_OUTPUT_PATHMAIA_RUN_DIRMAIA_ATTEMPT_DIR
  • Workflow informationMAIA_WORKFLOW_IDMAIA_WORKFLOW_DEPS_HASH
export default {
async main(env, ctx) {
const apiBase = env.API_BASE;
const token = env.API_TOKEN;
const timeoutMs = env.TIMEOUT_MS ? parseInt(env.TIMEOUT_MS, 10) : 30_000;
const resp = await fetch(`${apiBase}/data`, {
headers: { Authorization: `Bearer ${token}` },
signal: AbortSignal.timeout(timeoutMs),
});
return { outputs: { data: await resp.json() } };
},
};