> ## 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 web call

> Create a web call and retrieve its connection credentials.

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

Keep the connection token private. See [idempotency](https://docs.getkarta.ai/idempotency.md) before retrying.


## OpenAPI

````yaml openapi.json POST /voice/calls/web
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/web:
    post:
      tags:
        - Calls
      summary: Create web call
      description: Create a web call and retrieve its connection credentials.
      operationId: createWebCall
      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/WebCallRequest'
            example:
              agent_id: agentexample
              interaction_mode: voice
              source: api
      responses:
        '200':
          description: Successful response.
          headers:
            X-Request-ID:
              description: Request identifier.
              schema:
                type: string
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebCall'
              example:
                call_id: call_example
                call_status: call_registered
                call_type: web_call
                agent_id: agentexample
                interaction_mode: voice
                source: api
                llm_dynamic_variables: {}
                transit_data: null
                token: EXAMPLE_CONNECTION_TOKEN
                url: wss://connection.example.invalid
        '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/web
                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
        '402':
          description: Insufficient credit balance.
          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/error
                title: Error
                status: 402
                detail: insufficient_balance
                instance: /voice/public/v1/calls/web
                trace_id: example-request-001
        '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 with agentexample id
                instance: /voice/public/v1/calls/web
                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/web
                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/web
                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/web
                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/web
                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/web' \
              -H "Authorization: Bearer $KARTA_API_KEY" \
              -H "X-Request-ID: $KARTA_REQUEST_ID" \
              -H 'Content-Type: application/json' \
              -d '{
              "agent_id": "agentexample",
              "interaction_mode": "voice",
              "source": "api"
            }'
        - 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', 'interaction_mode': 'voice',
            'source': 'api'}

            request = Request(
                'https://api.getkarta.ai/public/v1/voice/calls/web',
                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/web", {
              method: "POST",
              headers: {
                "Authorization": `Bearer ${KARTA_API_KEY}`,
                "X-Request-ID": KARTA_REQUEST_ID,
                "Content-Type": "application/json",
              },
              body: JSON.stringify({
              "agent_id": "agentexample",
              "interaction_mode": "voice",
              "source": "api"
            }),

            });

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

            console.log(await response.json());
components:
  schemas:
    WebCallRequest:
      type: object
      properties:
        agent_id:
          type: string
          description: Agent code from the agent list.
        branch_id:
          type:
            - string
            - 'null'
          description: Specific agent branch; omit to use configured routing.
        interaction_mode:
          type:
            - string
            - 'null'
          enum:
            - voice
            - chat
            - vision
            - null
          description: >-
            Defaults to voice unless source is widget and the widget supplies a
            mode.
        source:
          type:
            - string
            - 'null'
          enum:
            - widget
            - dashboard
            - api
            - other
            - null
        llm_dynamic_variables:
          type:
            - object
            - 'null'
          properties: {}
          description: Agent prompt variables for this call.
          additionalProperties: true
        transit_data:
          type:
            - object
            - 'null'
          properties: {}
          description: Application metadata associated with this call.
          additionalProperties: true
      required:
        - agent_id
    WebCall:
      type: object
      properties:
        call_id:
          type: string
        call_status:
          type: string
          description: Current call status.
        call_type:
          type:
            - string
            - 'null'
        agent_id:
          type:
            - string
            - 'null'
        llm_dynamic_variables:
          type:
            - object
            - 'null'
          properties: {}
          description: Agent prompt variables for this call.
          additionalProperties: true
        transit_data:
          type:
            - object
            - 'null'
          properties: {}
          description: Application metadata associated with this call.
          additionalProperties: true
        interaction_mode:
          type:
            - string
            - 'null'
          enum:
            - voice
            - chat
            - vision
            - null
        source:
          type:
            - string
            - 'null'
          enum:
            - widget
            - dashboard
            - api
            - other
            - null
        token:
          type:
            - string
            - 'null'
          description: Connection credential. Keep private and do not log.
        url:
          type:
            - string
            - 'null'
          description: Connection service URL.
    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.