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

# Click-to-call

> Open a secure Ringee dialer for a contact from your CRM

Click-to-call exchanges a contact for a **short-lived, signed dialer URL**. Your agent opens that URL and Ringee handles caller ID selection, credit checks and the WebRTC call.

> [!NOTE]
>
> Click-to-call is the fastest way to add calling to an existing CRM: one
> server-side request, one redirect, no frontend SDK. If you want the dialer to
> live **inside** your own UI instead of a Ringee tab, use the [Dialer
> SDK](https://docs.ringee.io/dialer-sdk/overview.md).

## Request

```bash theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
curl -X POST https://api.ringee.io/api/integrations/custom/click-to-call \
  -H "Content-Type: application/json" \
  -H "X-Ringee-Api-Key: cik_live_xxxxxxxx…" \
  -d '{
    "contactExternalId": "ext_contact_42",
    "agentEmail": "rep@example.com"
  }'
```

| Field | Type | Required | Description |
| - | - | - | - |
| `contactExternalId` | string | Conditional | Contact id previously linked through `contact.upserted` |
| `phoneNumber` | string | Conditional | Destination number; required if the external contact does not resolve to a number |
| `fromNumber` | string | No | Explicit caller ID; otherwise Ringee resolves one |
| `agentEmail` | string | Conditional | Ringee member who will place the call; required in organizations unless `ownerEmail` is sent |
| `ownerEmail` | string | Conditional | Alias for `agentEmail` when your CRM models a record owner |
| `ownerExternalId` | string | No | Reserved; it cannot currently resolve the agent by itself |

Send at least `contactExternalId` or `phoneNumber`. If both resolve a destination, the explicit `phoneNumber` wins. An unknown `contactExternalId` can still be used with `phoneNumber`, and the returned `contactId` will be `null`.

## Response

A successful request returns **201 Created**:

```json theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
{
  "contactId": "6b2f8f1e-6a2e-4f1c-9a3d-2d1b0c7e4a55",
  "agentUserId": "a91c4d77-1f0b-4a2e-8c3d-77b1e2f4a9c0",
  "toNumber": "+14155550123",
  "fromNumber": "+14155550100",
  "dialerUrl": "https://app.ringee.io/dashboard/dialer?session=…",
  "sessionToken": "eyJhbGciOi…",
  "expiresAt": "2026-09-04T14:05:00.000Z"
}
```

| Field | Description |
| - | - |
| `contactId` | Ringee contact UUID, or `null` when calling a raw number |
| `agentUserId` | Ringee user authorized for the call |
| `toNumber` | Resolved destination number |
| `fromNumber` | Selected caller ID |
| `dialerUrl` | URL to open in the browser; valid for **5 minutes** |
| `sessionToken` | Same signed authorization already embedded in `dialerUrl` |
| `expiresAt` | ISO-8601 expiry for the session |

> [!WARNING]
>
> Pass only `dialerUrl` and `expiresAt` to your frontend. Do not expose the
> separate `sessionToken` field, persist it, or write it to logs. The token is
> already inside `dialerUrl`, so treat that URL as sensitive and short-lived
> too.

## Agent resolution

| Workspace | Behavior |
| - | - |
| Personal | The workspace owner always places the call. `agentEmail` is ignored. |
| Organization | `agentEmail` (or `ownerEmail`) must match a member of that organization, or the request fails with 422. |

> [!WARNING]
>
> Take `agentEmail` from your **authenticated session**, not from a value the
> browser sent. Otherwise any user could place calls as any colleague.

`ownerExternalId` is accepted in the payload but is not yet wired to a resolution strategy — sending it without `agentEmail` returns `422`. Use `agentEmail`.

## Caller ID resolution

An explicit `fromNumber` is normalized and used as the caller ID. When you do not send it, Ringee picks one in this order:

1. the agent's first active **verified caller ID** in that workspace;
2. any **purchased number** on the workspace;
3. otherwise the request fails with `422 No caller ID or purchased number is available for this workspace.`

## Wiring the button

**1. Keep the call server-side**

The request must be made by your backend (or an Edge Function). The `cik_live_` key must never reach the browser.

**2. Pre-open the tab**

Open a blank tab **before** the async request so popup blockers do not swallow it, then navigate it once you have the URL.

```ts theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
const tab = window.open("", "_blank");

try {
  const { dialerUrl } = await fetch("/api/ringee/click-to-call", {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({ contactExternalId: contact.id }),
  }).then((r) => r.json());

  tab!.location.href = dialerUrl;
} catch (error) {
  tab?.close();
  showError(error);
}
```

**3. Guard the button**

Disable it when the contact has no valid phone number, or when the contact is on the Do Not Call list. Ringee blocks DNC numbers server-side too, but failing early is a better experience.

**4. Never auto-dial**

Do not request a dialer URL on page load. Calls must start from a real click.

## Errors

| Status | Cause |
| - | - |
| 400 | Neither `contactExternalId` (linked to a contact) nor `phoneNumber` was provided. |
| 401 | Missing or invalid `X-Ringee-Api-Key`. |
| 422 | `agentEmail` missing on an organization workspace, no member matched the email, or no caller ID is available. |

## Next steps

> [card] [Receive the call back](https://docs.ringee.io/api/outbound-webhooks.md)
>
> Log the call in your CRM when it ends

> [card] [Embed the dialer instead](https://docs.ringee.io/dialer-sdk/overview.md)
>
> Keep agents inside your own UI


## OpenAPI

````yaml POST /api/integrations/custom/click-to-call
openapi: 3.1.0
info:
  title: Ringee Public API
  version: 1.0.0
  description: >-
    The Ringee Public API. Sync contacts and companies, open a secure human
    dialer, list, start and inspect AI Voice Agent calls, and receive signed
    outbound events.


    Authenticate server-to-server requests with the `cik_live_` secret key of an
    active Custom Integration. The key identifies the integration and workspace
    and must never reach a browser. AI Voice Agent routes require an
    organization-scoped integration. Verify Ringee outbound webhooks with the
    separate `whsec_` signing secret.
  contact:
    name: Ringee
    url: https://ringee.io
servers:
  - url: https://api.ringee.io
    description: Ringee Cloud
  - url: '{backendUrl}'
    description: Self-hosted — your BACKEND_URL
    variables:
      backendUrl:
        default: https://ringee.example.com
        description: The BACKEND_URL of your deployment
security:
  - ApiKeyAuth: []
paths:
  /api/integrations/custom/click-to-call:
    post:
      tags:
        - CRM to Ringee
      summary: Open a dialer for a contact
      description: >-
        Exchange a contact for a short-lived, signed dialer URL. Your agent
        opens that URL and Ringee handles caller ID selection, credit checks and
        the WebRTC call.


        Send at least one of `contactExternalId` (linked to a contact that has a
        phone number) or `phoneNumber`.
      operationId: createClickToCallSession
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ClickToCallRequest'
            examples:
              byContact:
                summary: By synced CRM contact
                value:
                  contactExternalId: ext_contact_42
                  agentEmail: rep@example.com
              byNumber:
                summary: By raw phone number
                value:
                  phoneNumber: '+14155550123'
                  agentEmail: rep@example.com
                  fromNumber: '+14155550100'
      responses:
        '201':
          description: A dialer session was created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ClickToCallResult'
              examples:
                created:
                  summary: Dialer session created
                  value:
                    contactId: 6b2f8f1e-6a2e-4f1c-9a3d-2d1b0c7e4a55
                    agentUserId: a91c4d77-1f0b-4a2e-8c3d-77b1e2f4a9c0
                    toNumber: '+14155550123'
                    fromNumber: '+14155550100'
                    dialerUrl: >-
                      https://app.ringee.io/dashboard/dialer?session=eyJhbGciOi...&to=%2B14155550123&from=%2B14155550100
                    sessionToken: eyJhbGciOi...
                    expiresAt: '2026-05-23T14:35:00.000Z'
        '400':
          description: >-
            Neither `contactExternalId` (linked to a contact) nor `phoneNumber`
            was provided.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Missing or invalid `X-Ringee-Api-Key`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: >-
            `agentEmail` is missing on an organization workspace, no member
            matched the email, or no caller ID is available.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    ClickToCallRequest:
      type: object
      properties:
        contactExternalId:
          type: string
          description: >-
            The contact's id in your CRM. Resolves to a Ringee contact if you
            previously synced it with `contact.upserted`.
          examples:
            - ext_contact_42
          example: ext_contact_42
        phoneNumber:
          type: string
          description: >-
            Destination number. Required unless `contactExternalId` resolves to
            a contact that already has one. When both are provided, this
            explicit number wins.
          examples:
            - '+14155550123'
          example: '+14155550123'
        agentEmail:
          type: string
          description: >-
            Email of the Ringee user who will place the call. **Required for
            organization workspaces unless `ownerEmail` is provided.** Take it
            from your authenticated session, never from a value the browser
            sent.
          examples:
            - rep@example.com
          example: rep@example.com
        fromNumber:
          type: string
          description: >-
            Caller ID to use. Defaults to the agent's first active verified
            caller ID, then any purchased number on the workspace.
          examples:
            - '+14155550100'
          example: '+14155550100'
        ownerEmail:
          type: string
          description: >-
            Alias for `agentEmail`, used when your CRM models this as a record
            owner.
        ownerExternalId:
          type: string
          description: >-
            Accepted but not yet wired to a resolution strategy. Sending it
            without `agentEmail` returns 422 — use `agentEmail`.
    ClickToCallResult:
      type: object
      required:
        - contactId
        - agentUserId
        - toNumber
        - fromNumber
        - dialerUrl
        - sessionToken
        - expiresAt
      properties:
        contactId:
          type:
            - string
            - 'null'
          description: >-
            The Ringee contact, when `contactExternalId` resolved to one. `null`
            otherwise.
          examples:
            - 6b2f8f1e-6a2e-4f1c-9a3d-2d1b0c7e4a55
          example: 6b2f8f1e-6a2e-4f1c-9a3d-2d1b0c7e4a55
        agentUserId:
          type: string
          description: The Ringee user who will place the call.
          examples:
            - a91c4d77-1f0b-4a2e-8c3d-77b1e2f4a9c0
          example: a91c4d77-1f0b-4a2e-8c3d-77b1e2f4a9c0
        toNumber:
          type: string
          description: Destination normalized toward E.164 when possible.
          examples:
            - '+14155550123'
          example: '+14155550123'
        fromNumber:
          type: string
          description: The caller ID Ringee selected.
          examples:
            - '+14155550100'
          example: '+14155550100'
        dialerUrl:
          type: string
          format: uri
          description: The URL to open. Valid for **5 minutes**.
          examples:
            - >-
              https://app.ringee.io/dashboard/dialer?session=eyJhbGciOi...&to=%2B14155550123&from=%2B14155550100
          example: >-
            https://app.ringee.io/dashboard/dialer?session=eyJhbGciOi...&to=%2B14155550123&from=%2B14155550100
        sessionToken:
          type: string
          description: >-
            The signed session, already embedded in `dialerUrl`. Do not expose
            this field separately, persist it, or write it to logs — it
            authorizes a call on the agent's behalf.
        expiresAt:
          type: string
          format: date-time
          description: Expiry of the dialer session.
          examples:
            - '2026-05-23T14:35:00.000Z'
          example: '2026-05-23T14:35:00.000Z'
    Error:
      type: object
      properties:
        statusCode:
          type: integer
          examples:
            - 400
          example: 400
        message:
          type: string
          description: What went wrong.
          examples:
            - >-
              Must provide either contactExternalId (linked to a contact) or
              phoneNumber
          example: >-
            Must provide either contactExternalId (linked to a contact) or
            phoneNumber
        error:
          type: string
          examples:
            - Bad Request
          example: Bad Request
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-Ringee-Api-Key
      description: >-
        The `cik_live_` secret key of a Custom Integration. Shown once at
        creation. Server-side only.

````

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