Create a credential
In n8n, go to Credentials → Add Credential → Header Auth and set:
Create the key at platform.hcompany.ai/settings/api-keys. It’s shown once, so copy it when you create it. A key is scoped to one organization.
Start a session
Add an HTTP Request node:
Body:
Request body
h/web-surfer-flash is a built-in agent that comes with its own browser environment, so you can run a task without setting anything else up. To run your own agent, pass its name instead, or send an inline agent object; see Create a session for the full body.The response returns the session id you’ll use to poll for results:Response
Poll for completion
Add a second HTTP Request node in a loop:
Check the
status field. The session is done when status is completed, failed, timed_out, or interrupted. Any other value (queued, pending, running, paused, idle, awaiting_tool_results) means it’s still going. Use an If node to branch on the status, and loop the “still running” branch back through a Wait node before hitting the status endpoint again. Two to five seconds is a good interval; back off to ten to fifteen for tasks that run several minutes.Status response
Import the full workflow
Rather than build the four nodes by hand, copy the JSON below and paste it into an n8n canvas (⋯ menu → Import from clipboard, or just paste onto an empty canvas). It wires up the create, wait, poll, and read steps as a loop: the Wait node pauses a few seconds, Poll Status checks the state, and the If node either reads the answer (once the status is terminal) or loops back to wait. After importing, open each HTTP Request node and select your own Header Auth credential from step 1. The credential ID baked into the export won’t match your instance, so n8n shows the nodes as needing a credential until you pick yours.n8n workflow JSON
n8n workflow JSON
Event-driven alternative
Instead of polling, use Webhooks to get a callback when a session changes status. Add a Webhook trigger node in n8n, copy its Production URL, then register that URL for your organization with the Create webhook API. Subscribe to the events you care about, likesession.completed and session.failed, or to session.status_updated for every transition (see the event catalog). n8n then receives a POST whenever a matching event fires, with session_id, status, and previous_status in the payload.
Deliveries are signed and retried with backoff, so the same event can arrive more than once. Verify the signature (see Verifying deliveries), skip event ids you’ve already processed, and treat the webhook as a trigger: fetch the session for the authoritative state.
The same pattern works with any tool that can make HTTP requests, such as Make, Zapier, Pipedream, or your own orchestrator.
Next steps
Create a session
The full session request body and options.
Session status
States, step count, and the polling pattern.
Webhooks
Signed callbacks on status changes, and how to verify them.
SDKs
The typed Python and TypeScript clients and the hai CLI.