For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Log inBook a demo
GuidesAPI Reference
GuidesAPI Reference
  • API Reference
      • GETGet Enrichment Source
      • POSTEnrichment Fields
      • POSTPreview Model
      • GETList Models
      • POSTCreate Model
      • GETGet Model
      • PUTUpdate Model
      • DELDelete Model
      • GETSample Records
Logo
Log inBook a demo
API ReferenceModels

Create Model

POST
https://app.polytomic.com/api/models
POST
/api/models
$curl -X POST https://app.polytomic.com/api/models \
> -H "Authorization: Bearer <token>" \
> -H "Content-Type: application/json" \
> -d '{
> "configuration": {
> "table": "public.users"
> },
> "connection_id": "248df4b7-aa70-47b8-a036-33ac447e668d",
> "name": "Users"
>}'
1{
2 "data": {
3 "configuration": {
4 "table": "public.contacts"
5 },
6 "connection_id": "248df4b7-aa70-47b8-a036-33ac447e668d",
7 "created_at": "2024-01-15T09:30:00Z",
8 "created_by": {
9 "id": "12345678-1234-1234-1234-123456789012",
10 "name": "John Doe",
11 "type": "user"
12 },
13 "enricher": {
14 "configuration": {},
15 "connection_id": "248df4b7-aa70-47b8-a036-33ac447e668d",
16 "enricher_id": "248df4b7-aa70-47b8-a036-33ac447e668d",
17 "fields": [
18 {
19 "name": "phone_number"
20 }
21 ],
22 "mappings": {}
23 },
24 "fields": [
25 {
26 "created_at": "2024-01-15T09:30:00Z",
27 "created_by": {
28 "id": "12345678-1234-1234-1234-123456789012",
29 "name": "John Doe",
30 "type": "user"
31 },
32 "description": "Unique identifier",
33 "example": null,
34 "id": "248df4b7-aa70-47b8-a036-33ac447e668d",
35 "label": "ID",
36 "name": "id",
37 "remote_type": "string",
38 "type": "string",
39 "unique": true,
40 "updated_at": "2024-01-15T09:30:00Z",
41 "user_added": false
42 }
43 ],
44 "id": "248df4b7-aa70-47b8-a036-33ac447e668d",
45 "identifier": "id",
46 "labels": [
47 {}
48 ],
49 "name": "Contacts",
50 "organization_id": "248df4b7-aa70-47b8-a036-33ac447e668d",
51 "policies": [
52 "248df4b7-aa70-47b8-a036-33ac447e668d"
53 ],
54 "relations": [
55 {
56 "from": "id",
57 "to": {
58 "field": "user_id",
59 "model_id": "248df4b7-aa70-47b8-a036-33ac447e668d"
60 }
61 }
62 ],
63 "tracking_columns": [
64 "string"
65 ],
66 "type": "postgresql",
67 "updated_at": "2024-01-15T09:30:00Z",
68 "updated_by": {
69 "id": "12345678-1234-1234-1234-123456789012",
70 "name": "John Doe",
71 "type": "user"
72 },
73 "version": 1
74 },
75 "job": {
76 "error": "error message",
77 "job_id": "248df4b7-aa70-47b8-a036-33ac447e668d",
78 "result": null,
79 "status": "created",
80 "type": "createmodel"
81 }
82}
Creates a new model. A model defines a query or view over a connection's data — for example, a SQL query, a filtered object, or a joined dataset. Models are used as sources when creating model syncs. The connection referenced by `connection_id` must have source capabilities. Use [`GET /api/connection_types/{id}`](../../api-reference/connections/get-connection-type-schema) to check whether a connection type supports use as a source.
Was this page helpful?
Previous

Get Model

Next

Creates a new model.

A model defines a query or view over a connection’s data — for example, a SQL query, a filtered object, or a joined dataset. Models are used as sources when creating model syncs.

The connection referenced by connection_id must have source capabilities. Use GET /api/connection_types/{id} to check whether a connection type supports use as a source.

Authentication

AuthorizationBearer
Bearer user API key
OR
AuthorizationBasic

Basic organization-scoped API key

Headers

X-Polytomic-VersionstringOptional

Query parameters

asyncbooleanOptional

Request

This endpoint expects an object.
configurationmap from strings to anyRequired
connection_idstringRequiredformat: "uuid"
namestringRequired
additional_fieldslist of objects or nullOptional
enricherobjectOptional
fieldslist of strings or nullOptional
identifierstringOptional
labelslist of strings or nullOptional
organization_idstring or nullOptionalformat: "uuid"
policieslist of strings or nullOptional
relationslist of objects or nullOptional
tracking_columnslist of strings or nullOptional

Response

OK
dataobject
jobobject

Errors

400
Bad Request Error
403
Forbidden Error
500
Internal Server Error