Skip to content

Quickstart

Run a working Connect with hlix server locally, send one request to a connected agent and verify one signed event in 10 minutes.

In 10 minutes your machine runs a Connect with hlix button, sends one request to a connected agent and verifies one signed event. You run a single-file sample server in Node.js or Python against Test mode, which is free and needs no tunnel.

  • Node.js 22 or Python 3.12 installed on your machine.
  • A free partner account. If you do not have one yet, sign up on the partner sign-up page or follow Create the partner account.
  • A standard hlix account with at least one custom agent (or create one inside the connect screen in step 5).
  1. Open Apps in the partner portal and select Create an app.

    The Apps page with no apps yet: a Create an app button at the top and the Create an app form below.The Apps page with no apps yet: a Create an app button at the top and the Create an app form below.
  2. Enter an App name, pick an App type and select Create app and get test keys.

    The Create an app form with the app name Northwind Market, the type Marketplace selected, and a return URL filled in. The button reads Create app and get test keys.The Create an app form with the app name Northwind Market, the type Marketplace selected, and a return URL filled in. The button reads Create app and get test keys.
  3. Copy the Client ID (hlix_test_...), Client secret (hsk_...) and Event secret (hes_...) from the dialog.

    The Keep these keys now window. It shows the Client ID, the Client secret and the Event secret, each with a Copy button, and a warning that the secrets are shown one time.The Keep these keys now window. It shows the Client ID, the Client secret and the Event secret, each with a Copy button, and a warning that the secrets are shown one time.
  4. Select I have saved them to open the app page.

Create a new folder for the sample server and add a .env file with the three values you copied:

PARTNER_CLIENT_ID=hlix_test_replace_with_yours
PARTNER_CLIENT_SECRET=hsk_replace_with_yours
PARTNER_EVENT_SECRET=hes_replace_with_yours
PARTNER_RETURN_URL=http://localhost:3000/hlix/callback
Variable Value
PARTNER_CLIENT_ID Your Test mode client ID (hlix_test_...).
PARTNER_CLIENT_SECRET Your Test mode client secret (hsk_...).
PARTNER_EVENT_SECRET Your Test mode event secret (hes_...).
PARTNER_RETURN_URL http://localhost:3000/hlix/callback — must match the return URL saved on the app.

This single-file server handles the whole flow: the Connect with hlix button, PKCE and state checks, the token exchange, listing connected agents, sending a test request and verifying signed events.

Node.js (server.ts with Express):

Install dependencies:

Terminal window
npm init -y
npm install express cookie-parser
npm install -D typescript tsx @types/express @types/cookie-parser @types/node

Save the following code as server.ts:

import { createHash, createHmac, randomBytes, timingSafeEqual } from 'node:crypto'
import cookieParser from 'cookie-parser'
import express from 'express'
const API_BASE = 'https://server.hlix.ai'
const CLIENT_ID = process.env.PARTNER_CLIENT_ID!
const CLIENT_SECRET = process.env.PARTNER_CLIENT_SECRET!
const EVENT_SECRET = process.env.PARTNER_EVENT_SECRET!
const RETURN_URL = process.env.PARTNER_RETURN_URL ?? 'http://localhost:3000/hlix/callback'
const TOLERANCE_SECONDS = 300
// In-memory stores for local testing. Use your database in production.
const attempts = new Map<string, string>()
const handledEvents = new Set<string>()
let currentTokens: { accessToken: string; refreshToken?: string } | null = null
function isFromHlix(rawBody: Buffer, timestamp: string | undefined, signature: string | undefined): boolean {
if (!timestamp || !signature) return false
const sentAt = Number(timestamp)
if (!Number.isFinite(sentAt)) return false
if (Math.abs(Date.now() / 1000 - sentAt) > TOLERANCE_SECONDS) return false
const signed = Buffer.concat([Buffer.from(`${timestamp}.`), rawBody])
const expected = Buffer.from('v1=' + createHmac('sha256', EVENT_SECRET).update(signed).digest('hex'))
const received = Buffer.from(signature)
return expected.length === received.length && timingSafeEqual(expected, received)
}
const app = express()
app.use(cookieParser())
// Register the raw-body event route BEFORE express.json() or express.urlencoded().
app.post('/hlix/events', express.raw({ type: 'application/json' }), (req, res) => {
const rawBody = req.body as Buffer
if (!isFromHlix(rawBody, req.header('hlix-timestamp'), req.header('hlix-signature'))) {
res.sendStatus(400)
return
}
let event: { id: string; type: string; data: Record<string, unknown> }
try {
event = JSON.parse(rawBody.toString('utf8'))
} catch {
res.sendStatus(400)
return
}
if (!handledEvents.has(event.id)) {
handledEvents.add(event.id)
console.log('[hlix event]', event.type, event.id, event.data)
}
res.sendStatus(200)
})
app.use(express.urlencoded({ extended: false }))
app.get('/', (_req, res) => {
res.type('html').send(`
<h1>hlix partner quickstart</h1>
<p><a href="/hlix/connect">Connect with hlix</a></p>
`)
})
app.get('/hlix/connect', (_req, res) => {
const verifier = randomBytes(32).toString('base64url')
const challenge = createHash('sha256').update(verifier).digest('base64url')
const state = randomBytes(16).toString('base64url')
attempts.set(state, verifier)
res.cookie('hlix_state', state, {
httpOnly: true,
secure: RETURN_URL.startsWith('https://'),
sameSite: 'lax',
maxAge: 10 * 60 * 1000,
})
const url = new URL(`${API_BASE}/v1/api/auth/oauth2/authorize`)
url.search = new URLSearchParams({
response_type: 'code',
client_id: CLIENT_ID,
redirect_uri: RETURN_URL,
scope: 'agents:read requests:write offline_access',
state,
code_challenge: challenge,
code_challenge_method: 'S256',
}).toString()
res.redirect(url.toString())
})
app.get('/hlix/callback', async (req, res) => {
if (req.query.error) {
res.status(400).send(`Connect cancelled: ${String(req.query.error)}`)
return
}
const code = typeof req.query.code === 'string' ? req.query.code : ''
const state = typeof req.query.state === 'string' ? req.query.state : ''
const cookieState = typeof req.cookies.hlix_state === 'string' ? req.cookies.hlix_state : ''
const verifier = attempts.get(state)
attempts.delete(state)
res.clearCookie('hlix_state')
if (!code || !state || state !== cookieState || !verifier) {
res.status(400).send('Invalid state or missing code.')
return
}
const basic = Buffer.from(`${CLIENT_ID}:${CLIENT_SECRET}`).toString('base64')
const tokenRes = await fetch(`${API_BASE}/v1/api/auth/oauth2/token`, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
Authorization: `Basic ${basic}`,
},
body: new URLSearchParams({
grant_type: 'authorization_code',
code,
redirect_uri: RETURN_URL,
code_verifier: verifier,
}),
})
if (!tokenRes.ok) {
res.status(502).send(`Token exchange failed: ${tokenRes.status}`)
return
}
const tokens = (await tokenRes.json()) as { access_token: string; refresh_token?: string }
currentTokens = { accessToken: tokens.access_token, refreshToken: tokens.refresh_token }
const listRes = await fetch(`${API_BASE}/v1/api/partner-app/connections`, {
headers: { Authorization: `Bearer ${currentTokens.accessToken}` },
})
const data = (await listRes.json()) as {
connections: Array<{ connectionId: string; agent: { name: string; service: string }; status: string; manageUrl: string }>
}
const active = data.connections.find((c) => c.status === 'connected')
res.type('html').send(`
<h1>Connected agents</h1>
<pre>${JSON.stringify(data, null, 2)}</pre>
${active ? `
<form method="POST" action="/hlix/send">
<input type="hidden" name="connectionId" value="${active.connectionId}" />
<button type="submit">Send a test request to ${active.agent.name}</button>
</form>
<p><a href="${active.manageUrl}">To manage your agents, go to your hlix account</a></p>
` : '<p>No connected agents yet.</p>'}
`)
})
app.post('/hlix/send', async (req, res) => {
if (!currentTokens) {
res.status(401).send('Connect an agent first.')
return
}
const connectionId = String(req.body.connectionId ?? '')
const requestKey = `quickstart-${randomBytes(8).toString('hex')}`
const response = await fetch(`${API_BASE}/v1/api/partner-app/requests`, {
method: 'POST',
headers: {
Authorization: `Bearer ${currentTokens.accessToken}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
connectionId,
requestKey,
brief: 'Write a two-paragraph summary of how PKCE protects OAuth authorization codes.',
}),
})
const body = await response.json()
res.status(response.status).json(body)
})
app.listen(3000, () => {
console.log('Partner quickstart running at http://localhost:3000')
})

Start the server:

Terminal window
node --env-file=.env --import tsx server.ts

Back on your app page in the partner portal (Test mode selected):

  1. Under Return URLs, add http://localhost:3000/hlix/callback and save.

    The Return URLs panel on the app page with two saved addresses, each with a Remove button, and a field to add another URL.The Return URLs panel on the app page with two saved addresses, each with a Remove button, and a field to add another URL.
  2. Under Event URL, save your reachable event URL (or use a public HTTPS tunnel to http://localhost:3000/hlix/events if hlix cannot reach your local machine directly). In Test mode, hlix accepts https, http://localhost and http://127.0.0.1. Select Send a test event to confirm your server logs test.ping.

    The Event URL panel on the app page with an https address saved, a Save button, and a Send a test event button.The Event URL panel on the app page with an https address saved, a Save button, and a Send a test event button.
  1. Open http://localhost:3000 in your browser and select Connect with hlix.

  2. Sign in (or create an account) on the connect screen, which displays the Test mode badge.

    The Connect with hlix screen for an app in test mode. Three steps, Account, Agent and Connect, lead to a card with a Test mode badge and the title Connect your agents to Northwind Market.The Connect with hlix screen for an app in test mode. Three steps, Account, Agent and Connect, lead to a card with a Test mode badge and the title Connect your agents to Northwind Market.
  3. Pick an agent and a project for it to work in, then confirm.

    The connect card. The agent owner picks a workspace and ticks the agent Content writer, with the project it works in. Two lists say what Northwind Market can and cannot see. Buttons: Cancel and Connect 1 agent.The connect card. The agent owner picks a workspace and ticks the agent Content writer, with the project it works in. Two lists say what Northwind Market can and cannot see. Buttons: Cancel and Connect 1 agent.

Your browser returns to /hlix/callback, which exchanges the code and prints the JSON from GET /v1/api/partner-app/connections:

{
"connections": [
{
"connectionId": "6f1c4b2e-9a8d-4c11-8e2f-3b7a1d5e9c02",
"agent": {
"id": "agt_01j9x7m2k4p8r5t6v3w1y9z0ab",
"name": "Content writer",
"service": "Writes structured articles and summaries in Markdown."
},
"status": "connected",
"manageUrl": "https://app.hlix.ai/connectors?workspace=ws_01j9x7k1m3n5p7q9r2s4t6u8vw#partner-apps"
}
]
}

Select Send a test request on the callback page. Your server posts POST /v1/api/partner-app/requests with a unique requestKey and returns 201:

{
"id": "a41e8c3f-7b2d-4f09-9d6a-5c2e8b1a4f70",
"connectionId": "6f1c4b2e-9a8d-4c11-8e2f-3b7a1d5e9c02",
"status": "received"
}

Watch your terminal. Your event route logs request.started right away, and request.delivered once the agent finishes and passes review. Real agent work takes minutes, so rely on request.delivered rather than polling.

Open Events in the partner portal to inspect the same delivery, its HTTP status and its payload.

The Events page. Filters for app, mode, result and event type sit above a list of events: request.started, agent.connected and test.ping marked Delivered with 200 OK, and one test.ping marked as failed with 500, Your server had an error.The Events page. Filters for app, mode, result and event type sit above a list of events: request.started, agent.connected and test.ping marked Delivered with 200 OK, and one test.ping marked as failed with 500, Your server had an error.
You see Cause Fix
The browser stays on hlix and never returns to localhost The redirect_uri in .env does not match the saved return URL. Save http://localhost:3000/hlix/callback under Return URLs in Test mode.
Event route returns 400 Wrong PARTNER_EVENT_SECRET or the body was parsed as JSON before verifying. Verify you copied the Test mode hes_ secret and kept express.raw before any JSON parser.
test_mode_agent_limit on the connect screen Your Test app already has 5 connected agents across all users. Disconnect an unused Test agent or apply for Live access.
401 Unauthorized from /v1/api/partner-app/* Access token is missing, expired or not a partner token. Refresh the token or run Connect with hlix again.
Portal shows events as Not sent No event URL is saved for Test mode. Save an event URL on the app page, then use Send now in the event log.