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.
Before you start
Section titled “Before you start”- 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).
Create an app and copy the keys
Section titled “Create an app and copy the keys”-
Open Apps in the partner portal and select Create an app.

-
Enter an App name, pick an App type and select Create app and get test keys.

-
Copy the Client ID (
hlix_test_...), Client secret (hsk_...) and Event secret (hes_...) from the dialog.
-
Select I have saved them to open the app page.
Configure your environment
Section titled “Configure your environment”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_yoursPARTNER_CLIENT_SECRET=hsk_replace_with_yoursPARTNER_EVENT_SECRET=hes_replace_with_yoursPARTNER_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. |
Run the sample server
Section titled “Run the sample server”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:
npm init -ynpm install express cookie-parsernpm install -D typescript tsx @types/express @types/cookie-parser @types/nodeSave 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:
node --env-file=.env --import tsx server.tsPython (app.py with Flask):
Install dependencies:
python3 -m venv .venvsource .venv/bin/activatepip install flask python-dotenvSave the following code as app.py:
import base64import hashlibimport hmacimport jsonimport osimport secretsimport timefrom urllib.error import HTTPErrorfrom urllib.parse import urlencodefrom urllib.request import Request, urlopen
from dotenv import load_dotenvfrom flask import Flask, jsonify, make_response, redirect, request
load_dotenv()
API_BASE = "https://server.hlix.ai"CLIENT_ID = os.environ["PARTNER_CLIENT_ID"]CLIENT_SECRET = os.environ["PARTNER_CLIENT_SECRET"]EVENT_SECRET = os.environ["PARTNER_EVENT_SECRET"]RETURN_URL = os.environ.get("PARTNER_RETURN_URL", "http://localhost:3000/hlix/callback")TOLERANCE_SECONDS = 300
# In-memory stores for local testing. Use your database in production.attempts: dict[str, str] = {}handled_events: set[str] = set()current_tokens: dict[str, str] = {}
app = Flask(__name__)
def is_from_hlix(raw_body: bytes, timestamp: str | None, signature: str | None) -> bool: if not timestamp or not signature: return False try: sent_at = float(timestamp) except ValueError: return False if abs(time.time() - sent_at) > TOLERANCE_SECONDS: return False
signed = timestamp.encode() + b"." + raw_body expected = "v1=" + hmac.new(EVENT_SECRET.encode(), signed, hashlib.sha256).hexdigest() return hmac.compare_digest(expected, signature)
@app.get("/")def home(): return '<h1>hlix partner quickstart</h1><p><a href="/hlix/connect">Connect with hlix</a></p>'
@app.get("/hlix/connect")def connect(): verifier = secrets.token_urlsafe(32) challenge = base64.urlsafe_b64encode(hashlib.sha256(verifier.encode()).digest()).rstrip(b"=").decode() state = secrets.token_urlsafe(16)
attempts[state] = verifier query = urlencode( { "response_type": "code", "client_id": CLIENT_ID, "redirect_uri": RETURN_URL, "scope": "agents:read requests:write offline_access", "state": state, "code_challenge": challenge, "code_challenge_method": "S256", } ) response = make_response(redirect(f"{API_BASE}/v1/api/auth/oauth2/authorize?{query}")) response.set_cookie( "hlix_state", state, httponly=True, secure=RETURN_URL.startswith("https://"), samesite="Lax", max_age=600, ) return response
@app.get("/hlix/callback")def callback(): if request.args.get("error"): return f"Connect cancelled: {request.args['error']}", 400
code = request.args.get("code", "") state = request.args.get("state", "") cookie_state = request.cookies.get("hlix_state", "") verifier = attempts.pop(state, None)
if not code or not state or state != cookie_state or not verifier: return "Invalid state or missing code.", 400
basic = base64.b64encode(f"{CLIENT_ID}:{CLIENT_SECRET}".encode()).decode() form = urlencode( { "grant_type": "authorization_code", "code": code, "redirect_uri": RETURN_URL, "code_verifier": verifier, } ).encode() token_req = Request( f"{API_BASE}/v1/api/auth/oauth2/token", data=form, headers={"Content-Type": "application/x-www-form-urlencoded", "Authorization": f"Basic {basic}"}, method="POST", ) try: with urlopen(token_req) as resp: tokens = json.loads(resp.read()) except HTTPError as err: return f"Token exchange failed: {err.code}", 502
current_tokens["access_token"] = tokens["access_token"] if "refresh_token" in tokens: current_tokens["refresh_token"] = tokens["refresh_token"]
list_req = Request( f"{API_BASE}/v1/api/partner-app/connections", headers={"Authorization": f"Bearer {current_tokens['access_token']}"}, ) with urlopen(list_req) as resp: data = json.loads(resp.read())
active = next((c for c in data["connections"] if c["status"] == "connected"), None) action_html = ( f'<form method="POST" action="/hlix/send">' f'<input type="hidden" name="connectionId" value="{active["connectionId"]}" />' f'<button type="submit">Send a test request to {active["agent"]["name"]}</button>' f"</form>" f'<p><a href="{active["manageUrl"]}">To manage your agents, go to your hlix account</a></p>' if active else "<p>No connected agents yet.</p>" ) response = make_response(f"<h1>Connected agents</h1><pre>{json.dumps(data, indent=2)}</pre>{action_html}") response.delete_cookie("hlix_state") return response
@app.post("/hlix/send")def send_request(): access_token = current_tokens.get("access_token") if not access_token: return "Connect an agent first.", 401
payload = json.dumps( { "connectionId": request.form.get("connectionId", ""), "requestKey": f"quickstart-{secrets.token_hex(8)}", "brief": "Write a two-paragraph summary of how PKCE protects OAuth authorization codes.", } ).encode() api_req = Request( f"{API_BASE}/v1/api/partner-app/requests", data=payload, headers={"Authorization": f"Bearer {access_token}", "Content-Type": "application/json"}, method="POST", ) try: with urlopen(api_req) as resp: return jsonify(json.loads(resp.read())), resp.status except HTTPError as err: return err.read(), err.code, {"Content-Type": "application/json"}
@app.post("/hlix/events")def events(): raw_body = request.get_data() if not is_from_hlix(raw_body, request.headers.get("hlix-timestamp"), request.headers.get("hlix-signature")): return "", 400
try: event = json.loads(raw_body) except json.JSONDecodeError: return "", 400
if event["id"] not in handled_events: handled_events.add(event["id"]) print("[hlix event]", event["type"], event["id"], event["data"], flush=True) return "", 200
if __name__ == "__main__": app.run(port=3000)Start the server:
python3 app.pyRegister the return URL and event URL
Section titled “Register the return URL and event URL”Back on your app page in the partner portal (Test mode selected):
-
Under Return URLs, add
http://localhost:3000/hlix/callbackand save.
-
Under Event URL, save your reachable event URL (or use a public HTTPS tunnel to
http://localhost:3000/hlix/eventsif hlix cannot reach your local machine directly). In Test mode, hlix acceptshttps,http://localhostandhttp://127.0.0.1. Select Send a test event to confirm your server logstest.ping.
Connect an agent
Section titled “Connect an agent”-
Open
http://localhost:3000in your browser and select Connect with hlix. -
Sign in (or create an account) on the connect screen, which displays the Test mode badge.

-
Pick an agent and a project for it to work in, then confirm.

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" } ]}Send a request
Section titled “Send a request”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"}See the event
Section titled “See the event”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.

If something fails
Section titled “If something fails”| 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. |