Skip to main content
Use the production base URL https://api.brightalk.ai from a trusted server. This flow creates one immediate asynchronous AI call and then retrieves the resulting call resource.

1. Create a scoped key

In Brightalk API settings, create a bt_live_ key with both calls:read and calls:write. Those are the required least-privilege scopes for creating and polling a call. If you need to run the optional contact-creation example in step 2, also select contacts:write; omit that additional scope when you already have a contact in the same organization. The secret is displayed once, so copy it into your server-side secret manager immediately. Set it as an environment variable without committing it to source control:

2. Obtain an agent and contact reference

List eligible agents with calls:read. (GET /agents also accepts batches:read, but it is not needed for this call workflow.) Save one returned id as the agent_id for step 3. Save every JavaScript sample as .mjs or run it in an ESM project. Top-level await requires ESM, and Node 18 or later provides the built-in fetch used here. Python samples use requests; in a clean environment, install it with python -m pip install requests.
Next, use an existing contact’s opaque id from the same organization. If you do not have one, the following contacts:write request creates or adopts a contact. It uses the reserved illustrative E.164 number +12025550123; replace the sample identity with controlled test data appropriate for your organization.
Contact creation returns 201 for a new contact or 200 for an existing or adopted contact. Save the response id as the contact_id. In step 3, replace agt_demo_001 and con_demo_001 with the agent and contact IDs returned above.

3. Create the call

The request needs calls:write, Brightalk-Version, and a nonsecret Idempotency-Key.
Sending POST /calls with a reachable contact can place a real PSTN call. Confirm the recipient and timing before running a modified example.
A successful request returns 202 Accepted. Save the id from the response:

4. Poll the returned call ID

Replace call_demo_001 with the id from step 3. Poll with calls:read; use backoff between requests and honor rate-limit headers.
Continue while status is queued, dialing, or in_progress.

5. Interpret status and answer_status

status describes execution lifecycle. Stop polling when it is completed, failed, or cancelled. answer_status independently classifies what happened at the destination. A normal no-answer result is status: completed with answer_status: no_answer; it is not a system failure. See Call status lifecycles for every transition.