> 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.

# Create

POST https://api.phonic.ai/v1/extraction_schemas
Content-Type: application/json

Creates a new extraction schema in a project.

Reference: https://docs.phonic.ai/api-reference/extraction-schemas/create

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

### Query parameters

- `project` (string, optional, default: main) — The name of the project to create the extraction schema in.

### Body (application/json)

This endpoint expects a CreateExtractionSchemaRequest.

- `name` (string, required) — A name for the extraction schema.
- `prompt` (string, required) — Instructions for how to extract data from conversations.
- `fields` (list of ExtractionField, required) — Array of field definitions.

## Response

### 201

Success response

- `id` (string, required) — The ID of the created extraction schema.
- `name` (string, required) — The name of the created extraction schema.

## Errors

### 400 Bad Request Error

Invalid parameters

- `Error`

### 404 Not Found Error

Project not found

- `Error`

### 409 Conflict Error

Extraction schema name already exists

- `Error`

## Types

### ExtractionField

- `name` (string, required) — The field name.
- `type` (enum, required) — The field type.
  - Allowed values: `string`, `int`, `float`, `bool`, `string[]`, `int[]`, `float[]`, `bool[]`
- `description` (string, required, nullable) — Description of the field. May be null, but the property must be present.

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

### Created extraction schema response

**Response**

```json
{
  "id": "conv_extract_schema_c818e617-59f9-4f43-936e-ca8a794f9ccf",
  "name": "Appointment details"
}
```

**SDK Code**

```python Created extraction schema response
import requests

url = "https://api.phonic.ai/v1/extraction_schemas"

querystring = {"project":"main"}

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

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

print(response.json())
```

```javascript Created extraction schema response
const url = 'https://api.phonic.ai/v1/extraction_schemas?project=main';
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 Created extraction schema response
package main

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

func main() {

	url := "https://api.phonic.ai/v1/extraction_schemas?project=main"

	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 Created extraction schema response
require 'uri'
require 'net/http'

url = URI("https://api.phonic.ai/v1/extraction_schemas?project=main")

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 Created extraction schema response
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.phonic.ai/v1/extraction_schemas?project=main")
  .header("Authorization", "Bearer <apiKey>")
  .asString();
```

```php Created extraction schema response
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

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

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

```csharp Created extraction schema response
using RestSharp;

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

```swift Created extraction schema response
import Foundation

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

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

### extraction_schemas_create_example

**Request**

```json
{
  "name": "Appointment details",
  "prompt": "Dates should be in `9 Apr 2025` format. Prices should be in $150.00 format.",
  "fields": [
    {
      "name": "Date",
      "type": "string",
      "description": "The date of the appointment"
    },
    {
      "name": "Copay",
      "type": "string",
      "description": "Amount of money the patient pays for the appointment"
    },
    {
      "name": "Confirmed as booked",
      "type": "bool",
      "description": "Is the appointment confirmed as booked?"
    }
  ]
}
```

**Response**

```json
{
  "id": "conv_extract_schema_c818e617-59f9-4f43-936e-ca8a794f9ccf",
  "name": "Appointment details"
}
```

**SDK Code**

```python extraction_schemas_create_example
import requests

url = "https://api.phonic.ai/v1/extraction_schemas"

querystring = {"project":"main"}

payload = {
    "name": "Appointment details",
    "prompt": "Dates should be in `9 Apr 2025` format. Prices should be in $150.00 format.",
    "fields": [
        {
            "name": "Date",
            "type": "string",
            "description": "The date of the appointment"
        },
        {
            "name": "Copay",
            "type": "string",
            "description": "Amount of money the patient pays for the appointment"
        },
        {
            "name": "Confirmed as booked",
            "type": "bool",
            "description": "Is the appointment confirmed as booked?"
        }
    ]
}
headers = {
    "Authorization": "Bearer <apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript extraction_schemas_create_example
const url = 'https://api.phonic.ai/v1/extraction_schemas?project=main';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <apiKey>', 'Content-Type': 'application/json'},
  body: '{"name":"Appointment details","prompt":"Dates should be in `9 Apr 2025` format. Prices should be in $150.00 format.","fields":[{"name":"Date","type":"string","description":"The date of the appointment"},{"name":"Copay","type":"string","description":"Amount of money the patient pays for the appointment"},{"name":"Confirmed as booked","type":"bool","description":"Is the appointment confirmed as booked?"}]}'
};

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

```go extraction_schemas_create_example
package main

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

func main() {

	url := "https://api.phonic.ai/v1/extraction_schemas?project=main"

	payload := strings.NewReader("{\n  \"name\": \"Appointment details\",\n  \"prompt\": \"Dates should be in `9 Apr 2025` format. Prices should be in $150.00 format.\",\n  \"fields\": [\n    {\n      \"name\": \"Date\",\n      \"type\": \"string\",\n      \"description\": \"The date of the appointment\"\n    },\n    {\n      \"name\": \"Copay\",\n      \"type\": \"string\",\n      \"description\": \"Amount of money the patient pays for the appointment\"\n    },\n    {\n      \"name\": \"Confirmed as booked\",\n      \"type\": \"bool\",\n      \"description\": \"Is the appointment confirmed as booked?\"\n    }\n  ]\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 extraction_schemas_create_example
require 'uri'
require 'net/http'

url = URI("https://api.phonic.ai/v1/extraction_schemas?project=main")

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  \"name\": \"Appointment details\",\n  \"prompt\": \"Dates should be in `9 Apr 2025` format. Prices should be in $150.00 format.\",\n  \"fields\": [\n    {\n      \"name\": \"Date\",\n      \"type\": \"string\",\n      \"description\": \"The date of the appointment\"\n    },\n    {\n      \"name\": \"Copay\",\n      \"type\": \"string\",\n      \"description\": \"Amount of money the patient pays for the appointment\"\n    },\n    {\n      \"name\": \"Confirmed as booked\",\n      \"type\": \"bool\",\n      \"description\": \"Is the appointment confirmed as booked?\"\n    }\n  ]\n}"

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

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

HttpResponse<String> response = Unirest.post("https://api.phonic.ai/v1/extraction_schemas?project=main")
  .header("Authorization", "Bearer <apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"name\": \"Appointment details\",\n  \"prompt\": \"Dates should be in `9 Apr 2025` format. Prices should be in $150.00 format.\",\n  \"fields\": [\n    {\n      \"name\": \"Date\",\n      \"type\": \"string\",\n      \"description\": \"The date of the appointment\"\n    },\n    {\n      \"name\": \"Copay\",\n      \"type\": \"string\",\n      \"description\": \"Amount of money the patient pays for the appointment\"\n    },\n    {\n      \"name\": \"Confirmed as booked\",\n      \"type\": \"bool\",\n      \"description\": \"Is the appointment confirmed as booked?\"\n    }\n  ]\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.phonic.ai/v1/extraction_schemas?project=main', [
  'body' => '{
  "name": "Appointment details",
  "prompt": "Dates should be in `9 Apr 2025` format. Prices should be in $150.00 format.",
  "fields": [
    {
      "name": "Date",
      "type": "string",
      "description": "The date of the appointment"
    },
    {
      "name": "Copay",
      "type": "string",
      "description": "Amount of money the patient pays for the appointment"
    },
    {
      "name": "Confirmed as booked",
      "type": "bool",
      "description": "Is the appointment confirmed as booked?"
    }
  ]
}',
  'headers' => [
    'Authorization' => 'Bearer <apiKey>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp extraction_schemas_create_example
using RestSharp;

var client = new RestClient("https://api.phonic.ai/v1/extraction_schemas?project=main");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"name\": \"Appointment details\",\n  \"prompt\": \"Dates should be in `9 Apr 2025` format. Prices should be in $150.00 format.\",\n  \"fields\": [\n    {\n      \"name\": \"Date\",\n      \"type\": \"string\",\n      \"description\": \"The date of the appointment\"\n    },\n    {\n      \"name\": \"Copay\",\n      \"type\": \"string\",\n      \"description\": \"Amount of money the patient pays for the appointment\"\n    },\n    {\n      \"name\": \"Confirmed as booked\",\n      \"type\": \"bool\",\n      \"description\": \"Is the appointment confirmed as booked?\"\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift extraction_schemas_create_example
import Foundation

let headers = [
  "Authorization": "Bearer <apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "name": "Appointment details",
  "prompt": "Dates should be in `9 Apr 2025` format. Prices should be in $150.00 format.",
  "fields": [
    [
      "name": "Date",
      "type": "string",
      "description": "The date of the appointment"
    ],
    [
      "name": "Copay",
      "type": "string",
      "description": "Amount of money the patient pays for the appointment"
    ],
    [
      "name": "Confirmed as booked",
      "type": "bool",
      "description": "Is the appointment confirmed as booked?"
    ]
  ]
] as [String : Any]

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

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