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

# Create phone call

> Create an outbound phone call.

> [!WARNING]
>
> Phone calls consume credits.

A `202` response confirms the request was accepted. Use `call_id` to [check its status](https://docs.getkarta.ai/api-reference/calls/get-call.md).

For setup, see [make a phone call](https://docs.getkarta.ai/guides/phone-calls.md). For retries, see [idempotency](https://docs.getkarta.ai/idempotency.md).

> [accordion] Include a caller number, prompt variables, and metadata
>
> Use this JSON body in place of the minimal example. Replace the identifiers and numbers with values for your account.
>
> ```json theme={null}
> {
>   "agent_id": "agentexample",
>   "to_number": "+12025550123",
>   "from_number": "+12025550124",
>   "llm_dynamic_variables": {
>     "customer_name": "Alex"
>   },
>   "transit_data": {
>     "external_id": "example-001"
>   }
> }
> ```


## OpenAPI

````yaml openapi.json POST /voice/calls/phone
openapi: 3.1.0
info:
  title: Karta Public API
  version: 1.0.0-draft
  description: >-
    Karta API reference for accounts, agents, calls, campaigns, WebSocket
    sessions, and billing.
servers:
  - url: https://api.getkarta.ai/public/v1
    description: Production
security:
  - BearerApiKey: []
tags:
  - name: Account
  - name: Agents
  - name: Calls
  - name: Phone numbers
  - name: Campaigns
  - name: Realtime
  - name: Billing
  - name: Webhooks
    description: Outgoing call events delivered to your server.
paths:
  /voice/calls/phone:
    post:
      tags:
        - Calls
      summary: Create phone call
      description: Create an outbound phone call.
      operationId: createPhoneCall
      parameters:
        - name: X-Request-ID
          in: header
          required: false
          description: Optional request-tracing identifier.
          schema:
            type: string
          example: example-request-001
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PhoneCallRequest'
            example:
              agent_id: agentexample
              to_number: '+12025550123'
      responses:
        '202':
          description: Accepted for processing.
          headers:
            X-Request-ID:
              description: Request identifier.
              schema:
                type: string
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PhoneCall'
              example:
                call_id: call_example
                call_status: call_registered
                call_type: sip_call
                agent_id: agentexample
                to_number: '+12025550123'
                from_number: '+12025550124'
                llm_dynamic_variables:
                  customer_name: Alex
                transit_data:
                  external_id: example-001
                batch_item_id: null
        '400':
          description: Invalid request or account configuration.
          headers:
            X-Request-ID:
              description: Request identifier.
              schema:
                type: string
          content:
            application/json:
              schema:
                anyOf:
                  - $ref: '#/components/schemas/AuthProblem'
                    title: Authentication or account configuration error
                  - $ref: '#/components/schemas/RequestProcessingError'
                    title: Request processing error
              examples:
                configuration:
                  summary: Account configuration error
                  value:
                    type: https://httpstatus.es/400
                    title: Missing Data Residency
                    status: 400
                    detail: Client dataResidency not set. Please contact support.
                    instance: example-request-001
                    code: missing_data_residency
                request:
                  summary: Request parsing error (illustrative message)
                  value:
                    message: Unexpected end of JSON input
            application/problem+json:
              schema:
                $ref: '#/components/schemas/VoiceProblem'
                title: Voice service error
              example:
                type: https://api.karta.com/problems/bad-request
                title: Bad Request
                status: 400
                detail: X-Request-ID header is required for this idempotent operation
                instance: /voice/public/v1/calls/phone
                trace_id: example-request-001
        '401':
          description: Authentication failed.
          headers:
            X-Request-ID:
              description: Request identifier.
              schema:
                type: string
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AuthProblem'
                title: Authentication or account configuration error
              examples:
                authentication:
                  summary: Missing API key
                  value:
                    type: https://httpstatus.es/401
                    title: Invalid API Key
                    status: 401
                    detail: API key is required
                    instance: example-request-001
                    code: invalid_api_key
        '403':
          description: API key not permitted for this operation.
          headers:
            X-Request-ID:
              description: Request identifier.
              schema:
                type: string
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AuthProblem'
                title: Authentication or account configuration error
              examples:
                authentication:
                  summary: Wrong key type
                  value:
                    type: https://httpstatus.es/403
                    title: Wrong API Key Type
                    status: 403
                    detail: Widget API keys may only be used on /widget paths
                    instance: example-request-001
                    code: wrong_key_audience
        '404':
          description: Resource not found for this account.
          headers:
            X-Request-ID:
              description: Request identifier.
              schema:
                type: string
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/VoiceProblem'
                title: Voice service error
              example:
                type: https://api.karta.com/problems/not-found
                title: Not Found
                status: 404
                detail: agent not found
                instance: /voice/public/v1/calls/phone
                trace_id: example-request-001
        '409':
          description: Request ID is in progress or was reused with a different payload.
          headers:
            X-Request-ID:
              description: Request identifier.
              schema:
                type: string
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/VoiceProblem'
                title: Voice service error
              example:
                type: https://api.karta.com/problems/conflict
                title: Conflict
                status: 409
                detail: Request with this X-Request-ID is already in progress
                instance: /voice/public/v1/calls/phone
                trace_id: example-request-001
        '422':
          description: Request validation failed.
          headers:
            X-Request-ID:
              description: Request identifier.
              schema:
                type: string
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/VoiceProblem'
                title: Voice service error
              example:
                type: https://api.karta.com/problems/validation-error
                title: Unprocessable Entity
                status: 422
                detail: Validation failed
                instance: /voice/public/v1/calls/phone
                trace_id: example-request-001
                errors:
                  - path: body.agent_id
                    message: Field required
                    type: missing
        '500':
          description: Internal server error.
          headers:
            X-Request-ID:
              description: Request identifier.
              schema:
                type: string
          content:
            application/json:
              schema:
                anyOf:
                  - $ref: '#/components/schemas/AuthProblem'
                    title: Authentication or account configuration error
                  - $ref: '#/components/schemas/RequestProcessingError'
                    title: Request processing error
                  - $ref: '#/components/schemas/ProxyConnectionError'
                    title: Upstream connection error
              examples:
                authentication:
                  summary: Authentication failure
                  value:
                    type: https://httpstatus.es/500
                    title: Internal Server Error
                    status: 500
                    detail: Authentication failed
                    instance: example-request-001
                    code: internal_error
                request:
                  summary: Request processing failure
                  value:
                    message: Internal Server Error
                ProxyConnectionError:
                  summary: Upstream connection failure
                  value:
                    error: Internal Server Error
                    message: Error connecting to voice agent service
            application/problem+json:
              schema:
                $ref: '#/components/schemas/VoiceProblem'
                title: Voice service error
              example:
                type: https://api.karta.com/problems/internal-server-error
                title: Internal Server Error
                status: 500
                detail: An internal server error occurred
                instance: /voice/public/v1/calls/phone
                trace_id: example-request-001
        '503':
          description: Service temporarily unavailable.
          headers:
            X-Request-ID:
              description: Request identifier.
              schema:
                type: string
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/VoiceProblem'
                title: Voice service error
              example:
                type: https://api.karta.com/problems/internal-server-error
                title: Service Unavailable
                status: 503
                detail: Idempotency store unavailable
                instance: /voice/public/v1/calls/phone
                trace_id: example-request-001
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            : "${KARTA_API_KEY:?Set your API key}"

            : "${KARTA_REQUEST_ID:?Set a unique ID; preserve it for retries}"


            curl --fail-with-body
            'https://api.getkarta.ai/public/v1/voice/calls/phone' \
              -H "Authorization: Bearer $KARTA_API_KEY" \
              -H "X-Request-ID: $KARTA_REQUEST_ID" \
              -H 'Content-Type: application/json' \
              -d '{
              "agent_id": "agentexample",
              "to_number": "+12025550123"
            }'
        - lang: python
          label: Python
          source: |-
            import json
            import os
            from urllib.request import Request, urlopen

            # Preserve KARTA_REQUEST_ID and the body when retrying this action.
            body = {'agent_id': 'agentexample', 'to_number': '+12025550123'}
            request = Request(
                'https://api.getkarta.ai/public/v1/voice/calls/phone',
                data=json.dumps(body).encode(),
                headers={
                    "Authorization": f"Bearer {os.environ['KARTA_API_KEY']}",
                    "X-Request-ID": os.environ["KARTA_REQUEST_ID"],
                    "Content-Type": "application/json",
                },
                method="POST",
            )
            with urlopen(request, timeout=30) as response:
                print(response.status, json.load(response))
        - lang: javascript
          label: JavaScript
          source: >-
            // Run on your server. Preserve this ID and body when retrying.

            const { KARTA_API_KEY, KARTA_REQUEST_ID } = process.env;

            if (!KARTA_API_KEY || !KARTA_REQUEST_ID) throw new Error("Set API
            key and request ID");

            const response = await
            fetch("https://api.getkarta.ai/public/v1/voice/calls/phone", {
              method: "POST",
              headers: {
                "Authorization": `Bearer ${KARTA_API_KEY}`,
                "X-Request-ID": KARTA_REQUEST_ID,
                "Content-Type": "application/json",
              },
              body: JSON.stringify({
              "agent_id": "agentexample",
              "to_number": "+12025550123"
            }),

            });

            if (!response.ok) throw new Error(`${response.status}: ${await
            response.text()}`);

            console.log(await response.json());
components:
  schemas:
    PhoneCallRequest:
      type: object
      properties:
        agent_id:
          type: string
          description: Voice agent ID returned by List agents.
          example: agentexample
        to_number:
          type: string
          description: Destination phone number in international format.
          example: '+12025550123'
        from_number:
          type:
            - string
            - 'null'
          description: >-
            Caller number. Omit or pass null to use the agent’s configured
            outbound number.
          example: '+12025550124'
        llm_dynamic_variables:
          type:
            - object
            - 'null'
          properties: {}
          description: Agent prompt variables for this call.
          additionalProperties: true
          example:
            customer_name: Alex
        transit_data:
          type:
            - object
            - 'null'
          properties: {}
          description: Application metadata associated with this call.
          additionalProperties: true
          example:
            external_id: example-001
        batch_item_id:
          type:
            - string
            - 'null'
          description: Optional existing batch-item reference; omit for a standalone call.
          example: null
      required:
        - agent_id
        - to_number
    PhoneCall:
      type: object
      properties:
        call_id:
          type: string
          description: Call identifier.
          example: call_example
        call_status:
          type: string
          description: Current call status.
          example: call_registered
        call_type:
          type:
            - string
            - 'null'
          description: Call type.
          example: sip_call
        agent_id:
          type:
            - string
            - 'null'
          description: Voice agent identifier.
          example: agentexample
        llm_dynamic_variables:
          type:
            - object
            - 'null'
          properties: {}
          description: Agent prompt variables for this call.
          additionalProperties: true
          example:
            customer_name: Alex
        transit_data:
          type:
            - object
            - 'null'
          properties: {}
          description: Application metadata associated with this call.
          additionalProperties: true
          example:
            external_id: example-001
        to_number:
          type:
            - string
            - 'null'
          description: Destination phone number for the call.
          example: '+12025550123'
        from_number:
          type:
            - string
            - 'null'
          description: Caller phone number.
          example: '+12025550124'
        batch_item_id:
          type:
            - string
            - 'null'
          description: Batch item identifier, if applicable.
          example: null
    AuthProblem:
      type: object
      properties:
        type:
          type: string
          description: Identifier for this error category.
        title:
          type: string
          description: Short summary of the error.
        status:
          type: integer
          description: HTTP status code for this response.
        detail:
          type: string
          description: Explanation of the failure.
        instance:
          type: string
          description: Request identifier.
        code:
          type: string
          description: Machine-readable error code.
      title: Authentication or account configuration error
    RequestProcessingError:
      title: Request processing error
      type: object
      properties:
        message:
          type: string
          description: Description of the request-processing failure.
        errors:
          type: array
          items:
            additionalProperties: true
            type: object
          description: Additional error details, when supplied.
    VoiceProblem:
      type: object
      properties:
        type:
          type: string
          description: Identifier for this error category.
        title:
          type: string
          description: Short summary of the error.
        status:
          type: integer
          description: HTTP status code for this response.
        detail:
          type: string
          description: Explanation of the failure.
        instance:
          type: string
          description: Request path.
        trace_id:
          type: string
          description: Request identifier for support and troubleshooting.
        errors:
          type: array
          items:
            type: object
            properties:
              path:
                type: string
              message:
                type: string
              type:
                type: string
      title: Voice service error
    ProxyConnectionError:
      title: Upstream connection error
      type: object
      properties:
        error:
          type: string
          enum:
            - Internal Server Error
          description: Machine-readable error code.
        message:
          type: string
          description: Explanation of the failure.
  securitySchemes:
    BearerApiKey:
      type: http
      scheme: bearer
      description: 'API key in the format: Bearer YOUR_KARTA_API_KEY.'

````

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