> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.thymia.ai/api-reference/thymia-api/voice-agent-beta/llms.txt.
> For full documentation content, see https://docs.thymia.ai/api-reference/thymia-api/voice-agent-beta/llms-full.txt.

# Create a new call

POST /v1/calls
Content-Type: application/json

Create a new voice agent call session.

Reference: https://docs.thymia.ai/api-reference/thymia-api/voice-agent-beta/create-call-v-1-calls-post

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: Thymia API
  version: 1.0.0
paths:
  /v1/calls:
    post:
      operationId: create-call-v-1-calls-post
      summary: Create a new call
      description: Create a new voice agent call session.
      tags:
        - subpackage_voiceAgentBeta
      parameters:
        - name: x-api-key
          in: header
          description: Your API Activation Key
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/VoiceAgentCallCreateResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/VoiceAgentCallCreate'
components:
  schemas:
    BirthSex:
      type: string
      enum:
        - MALE
        - FEMALE
        - INTERSEX
        - UNKNOWN
      description: An enumeration.
      title: BirthSex
    UserDetails:
      type: object
      properties:
        userLabel:
          type: string
          description: A unique label identifying a user that all model input refers to
        dateOfBirth:
          type: string
          format: date
          description: >-
            An ISO 8601 date; if day or month are unknown, supply the parts
            which *are* known and use `01` for the rest
        birthSex:
          $ref: '#/components/schemas/BirthSex'
          description: The sex assigned to a user at birth
      required:
        - userLabel
        - dateOfBirth
        - birthSex
      title: UserDetails
    LanguageCode:
      type: string
      enum:
        - en
        - en-AU
        - en-GB
        - en-IE
        - en-IN
        - en-US
        - en-ZA
        - es-ES
        - es-US
        - id-ID
        - ja-JP
      description: An enumeration.
      title: LanguageCode
    VoiceAgentCallCreateAgent:
      type: object
      properties: {}
      description: Configuration for the AI voice agent to be used in the call
      title: VoiceAgentCallCreateAgent
    VoiceAgentCallCreateMetadata:
      type: object
      properties: {}
      description: Additional metadata associated with the voice agent call
      title: VoiceAgentCallCreateMetadata
    VoiceAgentCallCreate:
      type: object
      properties:
        phoneNumber:
          type: string
          description: The phone number to call for the voice agent interaction
        user:
          $ref: '#/components/schemas/UserDetails'
          description: The user that this voice agent call is being initiated for
        language:
          $ref: '#/components/schemas/LanguageCode'
          description: The code of the language being spoken by the user in the call
        agent:
          $ref: '#/components/schemas/VoiceAgentCallCreateAgent'
          description: Configuration for the AI voice agent to be used in the call
        webhookUrl:
          type: string
          format: uri
          description: Optional webhook URL to receive call status updates and results
        metadata:
          $ref: '#/components/schemas/VoiceAgentCallCreateMetadata'
          description: Additional metadata associated with the voice agent call
        deleteData:
          type: boolean
          default: false
          description: >-
            Boolean flag indicating if call data should be deleted after
            completion. If True, the call recordings, transcripts, and results
            will be deleted 12 hrs after the call ends. Attempts to retrieve
            results after this time will receive a 404 error. 
      required:
        - user
        - language
        - agent
      title: VoiceAgentCallCreate
    UserDetailsShort:
      type: object
      properties:
        userLabel:
          type: string
          description: A unique label identifying a user in your systems
      required:
        - userLabel
      title: UserDetailsShort
    VoiceAgentCallCreateResponseAgent:
      type: object
      properties: {}
      description: Configuration for the AI voice agent to be used in the call
      title: VoiceAgentCallCreateResponseAgent
    VoiceAgentCallCreateResponse:
      type: object
      properties:
        id:
          type: string
          format: uuid
          description: The id of the newly created call
        user:
          $ref: '#/components/schemas/UserDetailsShort'
        status:
          type: string
          description: Current status of the call
        createdAt:
          type: string
          format: date-time
          description: When the call was submitted to the API
        activityLink:
          type: string
          description: >-
            Optional link to call as a thymia activity, only present if a phone
            number was not provided
        agent:
          $ref: '#/components/schemas/VoiceAgentCallCreateResponseAgent'
          description: Configuration for the AI voice agent to be used in the call
      required:
        - id
        - user
        - status
        - createdAt
        - agent
      title: VoiceAgentCallCreateResponse
    ValidationErrorLocItems:
      oneOf:
        - type: string
        - type: integer
      title: ValidationErrorLocItems
    ValidationError:
      type: object
      properties:
        loc:
          type: array
          items:
            $ref: '#/components/schemas/ValidationErrorLocItems'
        msg:
          type: string
        type:
          type: string
      required:
        - loc
        - msg
        - type
      title: ValidationError
    HTTPValidationError:
      type: object
      properties:
        detail:
          type: array
          items:
            $ref: '#/components/schemas/ValidationError'
      title: HTTPValidationError
  securitySchemes:
    APIKeyHeader:
      type: apiKey
      in: header
      name: x-api-key
      description: Your API Activation Key

```

## SDK Code Examples

```python
import requests

url = "https://api.example.com/v1/calls"

payload = {
    "user": {
        "userLabel": "42baba59-fa4a-4a22-ba1c-2e4a88a3badb",
        "dateOfBirth": "1990-08-24",
        "birthSex": "MALE"
    },
    "language": "en-GB",
    "agent": {
        "id": "patient-intake",
        "context": { "name": "Greg" }
    }
}
headers = {
    "x-api-key": "<apiKey>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api.example.com/v1/calls';
const options = {
  method: 'POST',
  headers: {'x-api-key': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"user":{"userLabel":"42baba59-fa4a-4a22-ba1c-2e4a88a3badb","dateOfBirth":"1990-08-24","birthSex":"MALE"},"language":"en-GB","agent":{"id":"patient-intake","context":{"name":"Greg"}}}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.example.com/v1/calls"

	payload := strings.NewReader("{\n  \"user\": {\n    \"userLabel\": \"42baba59-fa4a-4a22-ba1c-2e4a88a3badb\",\n    \"dateOfBirth\": \"1990-08-24\",\n    \"birthSex\": \"MALE\"\n  },\n  \"language\": \"en-GB\",\n  \"agent\": {\n    \"id\": \"patient-intake\",\n    \"context\": {\n      \"name\": \"Greg\"\n    }\n  }\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("x-api-key", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.example.com/v1/calls")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"user\": {\n    \"userLabel\": \"42baba59-fa4a-4a22-ba1c-2e4a88a3badb\",\n    \"dateOfBirth\": \"1990-08-24\",\n    \"birthSex\": \"MALE\"\n  },\n  \"language\": \"en-GB\",\n  \"agent\": {\n    \"id\": \"patient-intake\",\n    \"context\": {\n      \"name\": \"Greg\"\n    }\n  }\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.example.com/v1/calls")
  .header("x-api-key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"user\": {\n    \"userLabel\": \"42baba59-fa4a-4a22-ba1c-2e4a88a3badb\",\n    \"dateOfBirth\": \"1990-08-24\",\n    \"birthSex\": \"MALE\"\n  },\n  \"language\": \"en-GB\",\n  \"agent\": {\n    \"id\": \"patient-intake\",\n    \"context\": {\n      \"name\": \"Greg\"\n    }\n  }\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.example.com/v1/calls', [
  'body' => '{
  "user": {
    "userLabel": "42baba59-fa4a-4a22-ba1c-2e4a88a3badb",
    "dateOfBirth": "1990-08-24",
    "birthSex": "MALE"
  },
  "language": "en-GB",
  "agent": {
    "id": "patient-intake",
    "context": {
      "name": "Greg"
    }
  }
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'x-api-key' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.example.com/v1/calls");
var request = new RestRequest(Method.POST);
request.AddHeader("x-api-key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"user\": {\n    \"userLabel\": \"42baba59-fa4a-4a22-ba1c-2e4a88a3badb\",\n    \"dateOfBirth\": \"1990-08-24\",\n    \"birthSex\": \"MALE\"\n  },\n  \"language\": \"en-GB\",\n  \"agent\": {\n    \"id\": \"patient-intake\",\n    \"context\": {\n      \"name\": \"Greg\"\n    }\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "x-api-key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "user": [
    "userLabel": "42baba59-fa4a-4a22-ba1c-2e4a88a3badb",
    "dateOfBirth": "1990-08-24",
    "birthSex": "MALE"
  ],
  "language": "en-GB",
  "agent": [
    "id": "patient-intake",
    "context": ["name": "Greg"]
  ]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.example.com/v1/calls")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```