output-sdk
    Preparing search index...

    Function sendPostRequestAndAwaitWebhook

    • Send an POST HTTP request to a URL, optionally with a payload, then wait for a webhook response.

      The "Content-Type" is inferred from the payload type and can be overridden via the headers argument.

      If the body is not a type natively accepted by the Fetch API, it is serialized to a string: JSON.stringify() for objects, or String() for primitives.

      When a body is sent, the payload is wrapped together with the workflowId and sent as:

      Parameters

      • params: { headers?: Record<string, string>; payload?: object; url: string }

        Parameters object

        • Optionalheaders?: Record<string, string>

          Headers for the request

        • Optionalpayload?: object

          Request payload

        • url: string

          Request URL

      Returns Promise<unknown>

      Resolves with the payload received by the webhook

      const finalPayload = {
      workflowId,
      payload
      }

      After dispatching the request, the workflow pauses and waits for a POST to /workflow/:id/feedback (where :id is the workflowId). When the API receives that request, its body is delivered back to the workflow and execution resumes.

      const response = await sendPostRequestAndAwaitWebhook( {
      url: 'https://example.com/integration',
      payload: {
      }
      } );

      assert( response, 'the value sent back via the api' );
      • Only callable from within a workflow function; do not use in steps or evaluators.
      • Steps and evaluators are activity-based and are not designed to be paused.
      • If used within steps or evaluators, a compilation error will be raised.
      • Uses a Temporal Activity to dispatch the HTTP request, working around the runtime limitation for workflows.
      • Uses a Temporal Trigger to pause the workflow.
      • Uses a Temporal Signal to resume the workflow when the API responds.