> ## Documentation Index
> Fetch the complete documentation index at: https://docs.revenuebee.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# calls.generateCredentials

> Start a call between a visitor and a voice agent.

Called from your backend when a visitor is about to talk to a voice agent. The credentials go to
the page, which hands them to `gdcall.connect`. Each set is good for one call. See
[Voice calls](https://docs.revenuebee.ai/concepts/voice-calls.md).

> [tab] Upsert
>
> ```ts theme={null}
> // the signed-in user, as a contact: created the first time, found every time after
> const [contact, contactError] = await crm.contacts.upsert({
>   dbId: user.id,
>   name: user.name,
>   emails: [user.email],
> });
> if (contactError) throw new Error(contactError.message);
>
> // credentials for one call with that contact, for the page to pass to gdcall.connect
> const [credentials, callError] = await crm.calls.generateCredentials({
>   agentId: "0199…",
>   partyId: contact.id,
> });
> if (callError) throw new Error(callError.message);
> ```

> [tab] Look up
>
> ```ts theme={null}
> // the customer you already sent, found by your own id
> const [found, lookupError] = await crm.contacts.resolve({ dbId: user.id });
> if (lookupError) throw new Error(lookupError.message);
>
> // credentials for one call with that contact, for the page to pass to gdcall.connect
> const [credentials, callError] = await crm.calls.generateCredentials({
>   agentId: "0199…",
>   partyId: found.partyId,
> });
> if (callError) throw new Error(callError.message);
> ```

> [tab] Saved id
>
> ```ts theme={null}
> // the contact.id you saved in your own database the first time
> const [credentials, callError] = await crm.calls.generateCredentials({
>   agentId: "0199…",
>   partyId: user.crmPartyId,
> });
> if (callError) throw new Error(callError.message);
> ```

**Upsert** creates the customer if they're new. **Look up** finds one you've already sent. **Saved id** is fastest: store `contact.id` in your own database the first time, and skip the extra call.

**agentId** `string` *required*

The voice agent's id, from its Connect tab. The agent has to be on.

**partyId** `string`

The CRM's id for the customer: the `id` that [`contacts.upsert`](https://docs.revenuebee.ai/sdk/upsert-contact) returns, or what
[`contacts.resolve`](https://docs.revenuebee.ai/sdk/resolve-contact) finds from your own id. The call is filed under that contact and the agent
knows who it is talking to. Leave it out for an anonymous visitor.

## Returns

**credentials** `object`

**properties**

**callId** `string`

The call's id.

**url** `string`

Where the call connects. Pass the whole object to `gdcall.connect`.

**expiresAt** `string`

When it stops being accepted, ISO 8601.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.