Skip to main content

Build the workflow

1

Create a credential

In n8n, go to Credentials → Add Credential → Header Auth:Create the key at platform.hcompany.ai/settings/api-keys.
2

Start a session

Each call in this workflow is an HTTP Request node with Authentication set to the Header Auth credential from step 1:For the US region, replace agp.eu.hcompany.ai with agp.hcompany.ai.Add the Start Session node with Body Content Type set to JSON:
Request body
h/web-surfer-flash is a pre-built agent with its own browser, so you have nothing else to set up. To run your own agent, pass its name or an inline agent object to Create a session. The response carries the session id:
Response
3

Poll for completion

Add a Wait node (2 to 5 seconds, or 10 to 15 for tasks that run several minutes), then the Poll Status node, then an If node on status:
Status response
4

Read the answer

The status endpoint doesn’t carry the answer. Once status is completed or idle, the Read Answer node fetches the session: its latest_answer holds the agent’s final result.

Import the full workflow

Paste this JSON onto an empty n8n canvas (or ⋯ menu → Import from clipboard) to get the nodes above, wired as a Wait, Poll Status, If loop. Then open each HTTP Request node and pick your own Header Auth credential: the placeholder credential ID won’t match your instance. Add a counter if you want a hard cap on polls.

Event-driven alternative

Instead of polling, get a webhook when a session changes status.
1

Add a Webhook trigger node in n8n

Copy its Production URL.
2

Register the URL

Call Create webhook with that URL. Subscribe to session.completed and session.failed, or to session.status_updated for every transition (see the event catalog).
3

Handle the delivery

Each delivery is a signed POST with session_id, status, and previous_status. The same event can arrive more than once: verify the signature, skip event IDs you’ve already processed, and fetch the session for the authoritative state.

Other automation tools

The same pattern works with Make, Zapier, Pipedream, or any tool that can make HTTP requests.