Subchapter 23.9
references/workflow-http-trigger.mdMarkdown8 KBView on GitHub
Use this when a Datadog App backend function needs to trigger a Datadog Workflow Automation workflow and poll the workflow instance result.
@datadog/action-catalog.@datadog/action-catalog/http/httphttps://app.datadoghq.com/actions/connections and copy its ID.https://api.datadoghq.com.apiTrigger.Before wiring an app to a workflow, inspect the workflow’s published shape. Direct curl calls to the Datadog API use API/application keys even though normal scaffolded local app development uses OAuth by default:
workflow_id="<WORKFLOW_ID>"
curl -sS --fail-with-body \
"https://api.datadoghq.com/api/v2/workflows/${workflow_id}" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \
-H "Accept: application/json" \
| jq "{
id: .data.id,
name: .data.attributes.name,
published: .data.attributes.published,
inputSchema: .data.attributes.spec.inputSchema,
outputSchema: .data.attributes.spec.outputSchema,
hasApiTrigger: any(.data.attributes.spec.triggers[]?; has(\"apiTrigger\"))
}"Use this output to confirm:
published is true.inputSchema.parameters contains the input names and types the app will send.outputSchema.parameters describes expected outputs.hasApiTrigger is true.Do not copy browser UI curl cookies, CSRF tokens, or _authentication_token values into app code. Those belong to browser session-authenticated UI calls, not Datadog Apps backend functions.
Inputs go under meta.payload; do not send the workflow inputs as the raw JSON body.
Replace YOUR_HTTP_CONNECTION_ID with the ID of an HTTP connection from your Datadog org (https://app.datadoghq.com/actions/connections).
import { request } from "@datadog/action-catalog/http/http";
const DATADOG_HTTP_CONNECTION_ID = "<YOUR_HTTP_CONNECTION_ID>";
const DATADOG_API_BASE_URL = "https://api.datadoghq.com";
const DEFAULT_POLL_TIMEOUT_MS = 120_000;
const INITIAL_POLL_DELAY_MS = 250;
const POLL_DELAY_MULTIPLIER = 1.05;
const jsonHeaders = [
{ key: "Accept", value: [
Treat statusKind === "SUCCEEDED" as success. Treat INSTANCE_ERROR, STEP_ERROR, CANCELED, and other non-running statuses as terminal failures, and return or log the full response body so the caller can inspect errorDetail, stepStateAssociations, and any partial outputs.
The polling loop mirrors App Builder’s async query polling pattern: it waits 250ms before the first poll, grows by multiplier 1.05, and applies random plus or minus 20% jitter to avoid synchronized polling. Waiting before the first poll also avoids transient INSTANCE_NOT_FOUND responses immediately after a successful trigger. The default 120s timeout follows App Builder’s default frontend timeout pattern.
If a polling request fails, surface the error or response body to the caller. Do not replace it with a generic polling failure because the workflow instance body often contains the useful errorDetail.
data.attributes.outputs may be present after a successful run, but the full response body is the source of truth.
input parameter "<name>" not in workflow input schema: update meta.payload keys to match attributes.spec.inputSchema.parameters.Expected trigger type TRIGGER_TYPE_API not found: add and publish an API trigger on the workflow.DD_API_KEY and DD_APP_KEY are exported, the app key has Actions API Access, and the app’s Datadog site matches the API host and connection. For local app execution, rerun npm run dev and complete OAuth authorization.outputSchema.