Models

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.

post/api/models

Request

  • Base URL
    https://app.polytomic.com
  • Auth
    • HTTP bearer
    • or HTTP basic

Query parameters

asyncboolean

Run in the background and return a job instead of the result.

Headers

X-Polytomic-Versionstring

Request body

configurationobject required

Model configuration for the source connection type

connection_idstring uuid required

Connection ID of the model's source, which cannot be changed after the model is created

fieldsstring[] 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.

identifierstring

Source field name of the model's unique identifier

labelsstring[] nullable

Deprecated; ignored

namestring required

Model name

organization_idstring uuid nullable

Ignored for user and organization-scoped API keys, which always act in their own organization

policiesstring[] nullable

Permissions policy IDs applied to the model. On update, a non-empty list replaces the model's policies and an empty or omitted list leaves them unchanged.

tracking_columnsstring[] nullable

Source field names used to detect changed records

Example request

{
  "configuration": {
    "table": "public.users"
  },
  "connection_id": "248df4b7-aa70-47b8-a036-33ac447e668d",
  "enricher": {
    "connection_id": "248df4b7-aa70-47b8-a036-33ac447e668d",
    "enricher_id": "248df4b7-aa70-47b8-a036-33ac447e668d",
    "fields": [
      {
        "name": "phone_number"
      }
    ]
  },
  "fields": [
    "hs_object_id",
    "hubspot_owner_id",
    "dealname"
  ],
  "identifier": "id",
  "labels": [
    "248df4b7-aa70-47b8-a036-33ac447e668d"
  ],
  "name": "Users",
  "organization_id": "248df4b7-aa70-47b8-a036-33ac447e668d",
  "policies": [
    "248df4b7-aa70-47b8-a036-33ac447e668d"
  ],
  "relations": [
    {
      "to": {
        "model_id": "248df4b7-aa70-47b8-a036-33ac447e668d"
      }
    }
  ]
}

Response

OK

Example response

{
  "data": {
    "configuration": {
      "table": "public.contacts"
    },
    "connection_id": "248df4b7-aa70-47b8-a036-33ac447e668d",
    "created_by": {
      "id": "12345678-1234-1234-1234-123456789012",
      "name": "John Doe",
      "type": "user"
    },
    "enricher": {
      "connection_id": "248df4b7-aa70-47b8-a036-33ac447e668d",
      "enricher_id": "248df4b7-aa70-47b8-a036-33ac447e668d",
      "fields": [
        {
          "name": "phone_number"
        }
      ]
    },
    "fields": [
      {
        "created_by": {
          "id": "12345678-1234-1234-1234-123456789012",
          "name": "John Doe",
          "type": "user"
        },
        "description": "Unique identifier",
        "example": 123,
        "id": "248df4b7-aa70-47b8-a036-33ac447e668d",
        "label": "ID",
        "name": "id",
        "remote_type": "string",
        "type": "string",
        "unique": true
      }
    ],
    "id": "248df4b7-aa70-47b8-a036-33ac447e668d",
    "identifier": "id",
    "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"
        }
      }
    ],
    "type": "postgresql",
    "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",
    "type": "createmodel"
  }
}

Changes

    • info

      request property deprecated

    • info

      response property data/allOf[subschema #1: ModelResponse]/labels deprecated

    • breaking

      added to the request property allOf list

    • breaking

      added to the // request property allOf list

    • breaking

      the request property type changed from object to no type

    • breaking

      the // request property type changed from object to no type

    • breaking

      the response's property type changed from object to no type for status

    • breaking

      the response's property type changed from object to no type for status

    • warning

      removed the request property /

    • warning

      removed the request property /

    • warning

      removed the request property /

    • warning

      removed the request property /

    • warning

      removed the request property /

    • warning

      removed the request property ///

    • warning

      removed the request property ///

    • warning

      removed the optional property / from the response with the status

    • warning

      removed the optional property / from the response with the status

    • warning

      removed the optional property / from the response with the status

    • warning

      removed the optional property / from the response with the status

    • warning

      removed the optional property / from the response with the status

    • warning

      removed the optional property / from the response with the status

    • warning

      removed the optional property / from the response with the status

    • warning

      removed the optional property / from the response with the status

    • warning

      removed the optional property / from the response with the status

    • warning

      removed the optional property / from the response with the status

    • warning

      removed the optional property / from the response with the status

    • warning

      removed the optional property / from the response with the status

    • warning

      removed the optional property / from the response with the status

    • warning

      removed the optional property / from the response with the status

    • warning

      removed the optional property / from the response with the status

    • warning

      removed the optional property / from the response with the status

    • warning

      removed the optional property / from the response with the status

    • warning

      removed the optional property / from the response with the status

    • warning

      removed the optional property / from the response with the status

    • warning

      removed the optional property / from the response with the status

    • warning

      removed the optional property / from the response with the status

    • warning

      removed the optional property / from the response with the status

    • warning

      removed the optional property / from the response with the status

    • info

      added to the response property allOf list for the response status

    • info

      added to the response property allOf list for the response status