> This page is for version 2025-09-18 (default).
> For other versions, use one of these documentation indexes:
> - 2025-09-18 (default): https://apidocs.polytomic.com/2025-09-18/llms.txt
> - 2024-02-08: https://apidocs.polytomic.com/2024-02-08/llms.txt
> - 2023-04-25: https://apidocs.polytomic.com/2023-04-25/llms.txt
> - 2022-12-12: https://apidocs.polytomic.com/2022-12-12/llms.txt
> - 2021-05-23: https://apidocs.polytomic.com/2021-05-23/llms.txt

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

# Preview Model

POST https://app.polytomic.com/api/model-preview
Content-Type: application/json

Submits a job that previews the fields a model would expose without persisting it.

The response contains a job ID that resolves to the list of fields the model
would expose. Poll the job until it completes to retrieve the field list. The
model is not persisted — this endpoint is useful for validating a query or
configuration before calling [`POST /api/models`](../../api-reference/models/create) to save it.

Reference: https://apidocs.polytomic.com/api-reference/models/preview

## Authentication

- `Authorization` header (bearer token, required) — Bearer user API key
- `Authorization` header (basic auth, required) — Basic organization-scoped API key

## Request

### Query parameters

- `async` (boolean, optional)

### Body (application/json)

This endpoint expects a CreateModelRequest.

- `configuration` (map from string to any, required)
- `connection_id` (string, required)
- `name` (string, required)
- `additional_fields` (list of ModelModelFieldRequest, optional, nullable)
- `enricher` (Enrichment, optional)
- `fields` (list of string, optional, nullable) — Technical/source field names to publish in the model. Use source names, not model-field UUIDs or display labels. For example, use dealname rather than Deal Name. Omit or pass an empty array to publish all standard source fields.
- `identifier` (string, optional)
- `labels` (list of string, optional, nullable)
- `organization_id` (string, optional, nullable)
- `policies` (list of string, optional, nullable)
- `relations` (list of ModelRelation, optional, nullable)
- `tracking_columns` (list of string, optional, nullable)

## Response

### 200

OK

- `data` (ModelResponse, optional)
- `job` (JobResponse, optional)

## Errors

### 400 Bad Request Error

Bad Request

- `key` (string, optional)
- `message` (string, optional)
- `metadata` (map from string to any, optional)
- `status` (integer, optional)

### 404 Not Found Error

Not Found

- `key` (string, optional)
- `message` (string, optional)
- `metadata` (map from string to any, optional)
- `status` (integer, optional)

### 500 Internal Server Error

Internal Server Error

- `key` (string, optional)
- `message` (string, optional)
- `metadata` (map from string to any, optional)
- `status` (integer, optional)

## Types

### ModelModelFieldRequest

- `label` (string, required)
- `name` (string, required)
- `type` (string, required)
- `example` (string, optional)

### Enrichment

- `configuration` (map from string to any, optional) — Similar to a model configuration, this configures the enricher. For example, if you wanted to use Apollo to enrich people, you would send `{"object": "people"}` as the configuration. Each enricher configuration can be found in the connection configuration docs.
- `connection_id` (string, optional)
- `enricher_id` (string, optional) — Must be provided to update an existing enrichment
- `fields` (list of ModelField, optional) — If not provided, all fields will be enabled.
- `mappings` (map from string to string, optional) — A map of parent model Source Name to child model Source Name. For example, if your model has a field called `work_email` and the enricher accepts a field called `email`, you'd send a map of `{"work_email":"email"}`. The set of required input mappings varies based on the configuration of the enrichment. You can use the `enrichment/{connection_id}/inputfields` API to discover available input field combinations for a given configuration.

### ModelRelation

- `from` (string, optional)
- `to` (ModelRelationTo, optional)

### ModelResponse

- `configuration` (map from string to any, optional)
- `connection_id` (string, optional)
- `created_at` (datetime, optional)
- `created_by` (OutputActor, optional)
- `enricher` (Enrichment, optional)
- `fields` (list of ModelField, optional)
- `id` (string, optional)
- `identifier` (string, optional)
- `labels` (list of LabelLabel, optional)
- `name` (string, optional)
- `organization_id` (string, optional)
- `policies` (list of string, optional)
- `relations` (list of Relation, optional)
- `tracking_columns` (list of string, optional)
- `type` (string, optional)
- `updated_at` (datetime, optional)
- `updated_by` (OutputActor, optional)
- `version` (integer, optional)

### JobResponse

- `error` (string, optional, nullable) — Error message if the job failed.
- `job_id` (string, optional) — Identifier of the job.
- `result` (any, optional) — Job result. Shape depends on the job type; only populated once status is done.
- `status` (enum, optional)
  - Allowed values: `created`, `running`, `done`, `failed`
- `type` (string, optional) — Job type. Matches the type used to fetch the job.

### ModelField

- `created_at` (datetime, optional)
- `created_by` (OutputActor, optional)
- `description` (string, optional)
- `example` (any, optional)
- `id` (string, optional)
- `label` (string, optional)
- `name` (string, optional)
- `remote_type` (string, optional)
- `type` (string, optional)
- `unique` (boolean, optional)
- `updated_at` (datetime, optional)
- `user_added` (boolean, optional)

### ModelRelationTo

- `field` (string, optional)
- `model_id` (string, optional)

### OutputActor

- `id` (string, optional)
- `name` (string, optional)
- `type` (string, optional)

### LabelLabel

### Relation

- `from` (string, optional)
- `to` (RelationTo, optional)

### RelationTo

- `field` (string, optional)
- `model_id` (string, optional)

## Examples

**Request**

```json
{
  "configuration": {
    "table": "public.users"
  },
  "connection_id": "248df4b7-aa70-47b8-a036-33ac447e668d",
  "name": "Users"
}
```

**Response**

```json
{
  "data": {
    "configuration": {
      "table": "public.contacts"
    },
    "connection_id": "248df4b7-aa70-47b8-a036-33ac447e668d",
    "created_at": "2024-01-15T09:30:00Z",
    "created_by": {
      "id": "12345678-1234-1234-1234-123456789012",
      "name": "John Doe",
      "type": "user"
    },
    "enricher": {
      "configuration": {},
      "connection_id": "248df4b7-aa70-47b8-a036-33ac447e668d",
      "enricher_id": "248df4b7-aa70-47b8-a036-33ac447e668d",
      "fields": [
        {
          "name": "phone_number"
        }
      ],
      "mappings": {}
    },
    "fields": [
      {
        "created_at": "2024-01-15T09:30:00Z",
        "created_by": {
          "id": "12345678-1234-1234-1234-123456789012",
          "name": "John Doe",
          "type": "user"
        },
        "description": "Unique identifier",
        "example": null,
        "id": "248df4b7-aa70-47b8-a036-33ac447e668d",
        "label": "ID",
        "name": "id",
        "remote_type": "string",
        "type": "string",
        "unique": true,
        "updated_at": "2024-01-15T09:30:00Z",
        "user_added": false
      }
    ],
    "id": "248df4b7-aa70-47b8-a036-33ac447e668d",
    "identifier": "id",
    "labels": [
      {}
    ],
    "name": "Contacts",
    "organization_id": "248df4b7-aa70-47b8-a036-33ac447e668d",
    "policies": [
      "248df4b7-aa70-47b8-a036-33ac447e668d"
    ],
    "relations": [
      {
        "from": "id",
        "to": {
          "field": "user_id",
          "model_id": "248df4b7-aa70-47b8-a036-33ac447e668d"
        }
      }
    ],
    "tracking_columns": [
      "string"
    ],
    "type": "postgresql",
    "updated_at": "2024-01-15T09:30:00Z",
    "updated_by": {
      "id": "12345678-1234-1234-1234-123456789012",
      "name": "John Doe",
      "type": "user"
    },
    "version": 1
  },
  "job": {
    "error": "error message",
    "job_id": "248df4b7-aa70-47b8-a036-33ac447e668d",
    "result": null,
    "status": "created",
    "type": "createmodel"
  }
}
```

**SDK Code**

```python
import requests

url = "https://app.polytomic.com/api/model-preview"

payload = {
    "configuration": { "table": "public.users" },
    "connection_id": "248df4b7-aa70-47b8-a036-33ac447e668d",
    "name": "Users"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript
const url = 'https://app.polytomic.com/api/model-preview';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"configuration":{"table":"public.users"},"connection_id":"248df4b7-aa70-47b8-a036-33ac447e668d","name":"Users"}'
};

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://app.polytomic.com/api/model-preview"

	payload := strings.NewReader("{\n  \"configuration\": {\n    \"table\": \"public.users\"\n  },\n  \"connection_id\": \"248df4b7-aa70-47b8-a036-33ac447e668d\",\n  \"name\": \"Users\"\n}")

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

	req.Header.Add("Authorization", "Bearer <token>")
	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://app.polytomic.com/api/model-preview")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"configuration\": {\n    \"table\": \"public.users\"\n  },\n  \"connection_id\": \"248df4b7-aa70-47b8-a036-33ac447e668d\",\n  \"name\": \"Users\"\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://app.polytomic.com/api/model-preview")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"configuration\": {\n    \"table\": \"public.users\"\n  },\n  \"connection_id\": \"248df4b7-aa70-47b8-a036-33ac447e668d\",\n  \"name\": \"Users\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://app.polytomic.com/api/model-preview', [
  'body' => '{
  "configuration": {
    "table": "public.users"
  },
  "connection_id": "248df4b7-aa70-47b8-a036-33ac447e668d",
  "name": "Users"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://app.polytomic.com/api/model-preview");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"configuration\": {\n    \"table\": \"public.users\"\n  },\n  \"connection_id\": \"248df4b7-aa70-47b8-a036-33ac447e668d\",\n  \"name\": \"Users\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "configuration": ["table": "public.users"],
  "connection_id": "248df4b7-aa70-47b8-a036-33ac447e668d",
  "name": "Users"
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://app.polytomic.com/api/model-preview")! 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()
```