> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://apidocs.polytomic.com/2023-04-25/api-reference/models/update/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://apidocs.polytomic.com/_mcp/server. # Update Model PATCH https://app.polytomic.com/api/models/{id} Content-Type: application/json Updates a model's configuration. Reference: https://apidocs.polytomic.com/2023-04-25/api-reference/models/update ## Authentication - `Authorization` header (basic auth, required) — This is the Polytomic deployment key (on-premises only) - `Authorization` header (bearer token, required) — This is the Polytomic API key ## Request ### Path parameters - `id` (string, required) ### Query parameters - `async` (boolean, optional) ### Body (application/json) This endpoint expects a V2UpdateModelRequest. - `configuration` (map from string to any, required) - `connection_id` (string, required) - `name` (string, required) - `additional_fields` (list of ModelModelFieldRequest, optional, nullable) - `enricher` (V2Enrichment, optional) - `fields` (list of string, optional, nullable) - `identifier` (string, optional) - `labels` (list of string, optional, nullable) - `organization_id` (string, optional, nullable) - `policies` (list of string, optional, nullable) - `refresh` (boolean, optional) - `relations` (list of ModelRelation, optional, nullable) - `tracking_columns` (list of string, optional, nullable) ## Response ### 200 OK - `data` (V2ModelResponse, optional) - `job` (V2JobResponse, optional) ## Errors ### 400 Bad Request Error Bad Request - `key` (string, optional) - `message` (string, optional) - `metadata` (map from string to any, optional) - `status` (integer, optional) ### 401 Unauthorized Error Unauthorized - `code` (integer, optional) — Application-specific error code. - `context` (map from string to any, optional) — Application context. - `error` (string, optional) — Error message. - `status` (string, optional) — Status text. ### 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) ### V2Enrichment - `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 V2ModelField, 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) ### V2ModelResponse - `configuration` (map from string to any, optional) - `connection_id` (string, optional) - `created_at` (datetime, optional) - `created_by` (OutputActor, optional) - `enricher` (V2Enrichment, optional) - `fields` (list of V2ModelField, 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 V2Relation, optional) - `tracking_columns` (list of string, optional) - `type` (string, optional) - `updated_at` (datetime, optional) - `updated_by` (OutputActor, optional) - `version` (integer, optional) ### V2JobResponse - `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. ### V2ModelField - `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 ### V2Relation - `from` (string, optional) - `to` (V2RelationTo, optional) ### V2RelationTo - `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/models/248df4b7-aa70-47b8-a036-33ac447e668d" payload = { "configuration": { "table": "public.users" }, "connection_id": "248df4b7-aa70-47b8-a036-33ac447e668d", "name": "Users" } headers = { "X-Polytomic-Version": "X-Polytomic-Version" "Content-Type": "application/json" } response = requests.patch(url, json=payload, headers=headers, auth=("", "")) print(response.json()) ``` ```javascript const url = 'https://app.polytomic.com/api/models/248df4b7-aa70-47b8-a036-33ac447e668d'; const credentials = btoa(":"); const options = { method: 'PATCH', headers: { 'X-Polytomic-Version': 'X-Polytomic-Version', Authorization: `Basic ${credentials}`, '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/models/248df4b7-aa70-47b8-a036-33ac447e668d" 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("PATCH", url, payload) req.Header.Add("X-Polytomic-Version", "X-Polytomic-Version") req.SetBasicAuth("", "") 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/models/248df4b7-aa70-47b8-a036-33ac447e668d") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Patch.new(url) request["X-Polytomic-Version"] = 'X-Polytomic-Version' request.basic_auth("", "") 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 response = Unirest.patch("https://app.polytomic.com/api/models/248df4b7-aa70-47b8-a036-33ac447e668d") .header("X-Polytomic-Version", "X-Polytomic-Version") .basicAuth("", "") .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 request('PATCH', 'https://app.polytomic.com/api/models/248df4b7-aa70-47b8-a036-33ac447e668d', [ 'body' => '{ "configuration": { "table": "public.users" }, "connection_id": "248df4b7-aa70-47b8-a036-33ac447e668d", "name": "Users" }', 'headers' => [ 'Content-Type' => 'application/json', 'X-Polytomic-Version' => 'X-Polytomic-Version', ], 'auth' => ['', ''], ]); echo $response->getBody(); ``` ```csharp using RestSharp; using RestSharp.Authenticators; var client = new RestClient("https://app.polytomic.com/api/models/248df4b7-aa70-47b8-a036-33ac447e668d"); client.Authenticator = new HttpBasicAuthenticator("", ""); var request = new RestRequest(Method.PATCH); request.AddHeader("X-Polytomic-Version", "X-Polytomic-Version"); 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 credentials = Data(":".utf8).base64EncodedString() let headers = [ "X-Polytomic-Version": "X-Polytomic-Version", "Authorization": "Basic \(credentials)", "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/models/248df4b7-aa70-47b8-a036-33ac447e668d")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "PATCH" 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() ```