https://agp.eu.hcompany.ai, and every route lives under /api/v2.
1. Create a credential
In n8n, go to Credentials → Add Credential → Header Auth and set:| Field | Value |
|---|---|
| Name | Authorization |
| Value | Bearer hk-... |
2. Start a session
Add an HTTP Request node:| Setting | Value |
|---|---|
| Method | POST |
| URL | https://agp.eu.hcompany.ai/api/v2/sessions |
| Authentication | Header Auth (from step 1) |
| Body Content Type | JSON |
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:
3. Poll for completion
Add a second HTTP Request node in a loop:| Setting | Value |
|---|---|
| Method | GET |
| URL | https://agp.eu.hcompany.ai/api/v2/sessions/{{ $json.id }}/status |
| Authentication | Header Auth (from step 1) |
status field. The session is done when status is completed, failed, timed_out, or interrupted. Any other value (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.
4. Read the answer
The status endpoint tells you when the run is done, but it doesn’t carry the answer. Once the status iscompleted, add one more HTTP Request node to fetch the session and read latest_answer:
| Setting | Value |
|---|---|
| Method | GET |
| URL | https://agp.eu.hcompany.ai/api/v2/sessions/{{ $json.id }} |
| Authentication | Header Auth (from step 1) |
latest_answer field holds the agent’s final result.
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 and subscribe tosession.status_updated. n8n will then receive a POST whenever a session’s status changes, with session_id, status, and previous_status in the payload.
Deliveries are signed and sent at most once with no retries, so verify the signature (see Verifying deliveries) and keep a polling fallback for critical flows.
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.