HCC Docs

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.serve reports its flows on the first request (call server.register() to do it at startup). The report also sets url as 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 using env() takes hcc.serve({ env }) and hcc.flows.deploy(flows, { env }).
  • Don't mix it with hcc deploy on one environment. A report activates versions it hasn't seen, so it would activate over what hcc deploy just did. While moving over, set register: false and pass flowSecret.
  • Both environments from one deploy. With a live key, alsoTest: true registers the same definitions in test too, with the same endpoint URL: hcc.flows.deploy(flows, { endpointUrl, alsoTest: true }) and hcc.queues.deploy(queues, { alsoTest: true }). The response's test holds the test versions and endpoint. A test key with alsoTest is 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 with alsoTest, and also returns the test secret (or pass testFlowSecret, like flowSecret).