> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.phonic.ai/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.phonic.ai/_mcp/server.

# Extract Data

POST https://api.phonic.ai/v1/conversations/{id}/extractions
Content-Type: application/json

Extracts data from a conversation using a schema.

Reference: https://docs.phonic.ai/api-reference/conversations/extract-data

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication header of the form `Bearer <PHONIC_API_KEY>`. Manage your API keys [here](https://phonic.co/api-keys).

## Request

### Path parameters

- `id` (string, required) — The ID of the conversation to extract data from.

### Body (application/json)

This endpoint expects an ExtractDataRequest.

- `schema_id` (string, required) — ID of the extraction schema to use.

## Response

### 201

Success response

- `result` (map from string to any, required) — The extracted data according to the schema.

## Errors

### 400 Bad Request Error

Invalid parameters

- `Error`

### 401 Unauthorized Error

Unauthorized (authentication missing or invalid)

- `error` (BasicErrorError, optional)

### 403 Forbidden Error

Forbidden

- `error` (BasicErrorError, optional)

### 404 Not Found Error

Conversation or schema not found

- `Error`

### 500 Internal Server Error

Internal server error

- `error` (BasicErrorError, optional)

## Types

### BasicError

- `error` (BasicErrorError, optional)

### ValidationError

- `error` (ValidationErrorError, required)
- `param_errors` (map from string to string, required) — Parameter-specific validation errors

### BasicErrorError

- `message` (string, required) — Error message
- `code` (string, optional) — Error code

### ValidationErrorError

- `message` (string, required) — Error message

## Examples

### Extract data response

**Response**

```json
{
  "result": {
    "customer_name": "John Smith",
    "appointment_duration": 45,
    "service_types": [
      "haircut",
      "beard trim"
    ]
  }
}
```

**SDK Code**

```python Extract data response
import requests

url = "https://api.phonic.ai/v1/conversations/id/extractions"

headers = {"Authorization": "Bearer <apiKey>"}

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

print(response.json())
```

```javascript Extract data response
const url = 'https://api.phonic.ai/v1/conversations/id/extractions';
const options = {method: 'POST', headers: {Authorization: 'Bearer <apiKey>'}};

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

```go Extract data response
package main

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

func main() {

	url := "https://api.phonic.ai/v1/conversations/id/extractions"

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

	req.Header.Add("Authorization", "Bearer <apiKey>")

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

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

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

}
```

```ruby Extract data response
require 'uri'
require 'net/http'

url = URI("https://api.phonic.ai/v1/conversations/id/extractions")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <apiKey>'

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

```java Extract data response
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.phonic.ai/v1/conversations/id/extractions")
  .header("Authorization", "Bearer <apiKey>")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.phonic.ai/v1/conversations/id/extractions', [
  'headers' => [
    'Authorization' => 'Bearer <apiKey>',
  ],
]);

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

```csharp Extract data response
using RestSharp;

var client = new RestClient("https://api.phonic.ai/v1/conversations/id/extractions");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <apiKey>");
IRestResponse response = client.Execute(request);
```

```swift Extract data response
import Foundation

let headers = ["Authorization": "Bearer <apiKey>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.phonic.ai/v1/conversations/id/extractions")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers

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()
```

### conversations_extract_data_example

**Request**

```json
{
  "schema_id": "conv_extract_schema_6458e4ac-533c-4bdf-8e6d-c2f06f87fd5c"
}
```

**Response**

```json
{
  "result": {
    "customer_name": "John Smith",
    "appointment_duration": 45,
    "service_types": [
      "haircut",
      "beard trim"
    ]
  }
}
```

**SDK Code**

```python conversations_extract_data_example
import requests

url = "https://api.phonic.ai/v1/conversations/id/extractions"

payload = { "schema_id": "conv_extract_schema_6458e4ac-533c-4bdf-8e6d-c2f06f87fd5c" }
headers = {
    "Authorization": "Bearer <apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript conversations_extract_data_example
const url = 'https://api.phonic.ai/v1/conversations/id/extractions';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <apiKey>', 'Content-Type': 'application/json'},
  body: '{"schema_id":"conv_extract_schema_6458e4ac-533c-4bdf-8e6d-c2f06f87fd5c"}'
};

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

```go conversations_extract_data_example
package main

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

func main() {

	url := "https://api.phonic.ai/v1/conversations/id/extractions"

	payload := strings.NewReader("{\n  \"schema_id\": \"conv_extract_schema_6458e4ac-533c-4bdf-8e6d-c2f06f87fd5c\"\n}")

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

	req.Header.Add("Authorization", "Bearer <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 conversations_extract_data_example
require 'uri'
require 'net/http'

url = URI("https://api.phonic.ai/v1/conversations/id/extractions")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"schema_id\": \"conv_extract_schema_6458e4ac-533c-4bdf-8e6d-c2f06f87fd5c\"\n}"

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

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

HttpResponse<String> response = Unirest.post("https://api.phonic.ai/v1/conversations/id/extractions")
  .header("Authorization", "Bearer <apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"schema_id\": \"conv_extract_schema_6458e4ac-533c-4bdf-8e6d-c2f06f87fd5c\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.phonic.ai/v1/conversations/id/extractions', [
  'body' => '{
  "schema_id": "conv_extract_schema_6458e4ac-533c-4bdf-8e6d-c2f06f87fd5c"
}',
  'headers' => [
    'Authorization' => 'Bearer <apiKey>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp conversations_extract_data_example
using RestSharp;

var client = new RestClient("https://api.phonic.ai/v1/conversations/id/extractions");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"schema_id\": \"conv_extract_schema_6458e4ac-533c-4bdf-8e6d-c2f06f87fd5c\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift conversations_extract_data_example
import Foundation

let headers = [
  "Authorization": "Bearer <apiKey>",
  "Content-Type": "application/json"
]
let parameters = ["schema_id": "conv_extract_schema_6458e4ac-533c-4bdf-8e6d-c2f06f87fd5c"] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.phonic.ai/v1/conversations/id/extractions")! 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()
```