Without hcc.config.ts
Flows built per request or per tenant, or generated from a database, and projects that can't run a Node CLI, use the lower-level API. It isn't going away.
const hcc = new Hcc({ apiKey: process.env.HCC_API_KEY! }); // hcc_test_… or hcc_live_…
const server = hcc.serve({ flows: [qualify], url: 'https://example.com/hcc' });
// Serve it: a Fetch handler (Next.js, Hono, Bun, Deno)…
export const POST = server;
// …on Workers, in an object: a function as the default export doesn't load…
export default { fetch: (request: Request) => server(request) };
// …or Express / node:http (mount it before express.json(): signatures need the raw body)
app.post('/hcc', hcc.serve.express({ flows: [qualify], url: 'https://example.com/hcc' }));
await hcc.numbers.update(numberId, { flow: 'support' }); // inbound calls run a flow (live keys only)- Registration.
hcc.servereports its flows on the first request (callserver.register()to do it at startup). The report also setsurlas the environment's flow endpoint and fetches its signing secret, so nothing else needs configuring. From CI,hcc.flows.deploy([qualify])activates the version you deploy. A flow usingenv()takeshcc.serve({ env })andhcc.flows.deploy(flows, { env }). - Don't mix it with
hcc deployon one environment. A report activates versions it hasn't seen, so it would activate over whathcc deployjust did. While moving over, setregister: falseand passflowSecret. - Both environments from one deploy. With a live key,
alsoTest: trueregisters the same definitions in test too, with the same endpoint URL:hcc.flows.deploy(flows, { endpointUrl, alsoTest: true })andhcc.queues.deploy(queues, { alsoTest: true }). The response'stestholds the test versions and endpoint. A test key withalsoTestis a 400. - One endpoint for both.
new Hcc({ apiKey: liveKey, testApiKey: testKey }).serve({ flows, url })serves both environments at one URL. Each environment signs its flow events with its own secret: the one that verifies says whose event it is, and an event signed by the other environment is a 401. The startup report goes through the live key withalsoTest, and also returns the test secret (or passtestFlowSecret, likeflowSecret).