> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://apidocs.polytomic.com/2024-02-08/api-reference/schemas/get/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://apidocs.polytomic.com/_mcp/server. # Get Schema GET https://app.polytomic.com/api/connections/{id}/schemas/{schema_id} Returns a single schema on a connection. The schema is returned from the connection's cached schema set. If the upstream source has changed since the last inspection, the result may be stale. > 📘 Trigger [`POST /api/connections/{id}/schemas/refresh`](../../../../../api-reference/schemas/refresh) > and wait for it to complete before fetching this endpoint if you need > up-to-date field definitions. Reference: https://apidocs.polytomic.com/api-reference/schemas/get ## 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) — Unique identifier of the connection. - `schema_id` (string, required) — Identifier of the schema within the connection. Format depends on the connection type (e.g. schema.table for databases, object name for SaaS backends). ## Response ### 200 OK - `data` (V3Schema, 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 ### V3Schema - `fields` (list of SchemaField, optional) - `id` (string, optional) - `name` (string, optional) ### SchemaField - `association` (SchemaAssociation, optional) - `id` (string, optional) - `is_primary_key` (boolean, optional) — Whether this field is part of the schema's primary key, including any user override. - `name` (string, optional) - `path` (string, optional) — JSONPath used to extract the field from each source record; only meaningful for document-style backends. - `primary_key_override` (boolean, optional, nullable) — The user-set primary key status for this field, which takes precedence over source_primary_key; omitted when no override is set. - `remote_type` (string, optional) — The type of the field from the remote system. - `source_primary_key` (boolean, optional) — Whether the source system reports this field as part of the schema's primary key. - `type` (enum, optional) - Allowed values: `unknown`, `string`, `number`, `boolean`, `datetime`, `array`, `object`, `binary` - `type_spec` (any, optional) - `user_managed` (boolean, optional) — True when the field's effective definition came from a user override. - `values` (list of PickValue, optional) ### SchemaAssociation - `id` (string, optional) - `name` (string, optional) - `reference_to` (list of string, optional) - `referenced_field` (string, optional) ### PickValue - `label` (string, optional) - `value` (string, optional) ## Examples **Response** ```json { "data": { "fields": [ { "association": { "id": "string", "name": "string", "reference_to": [ "string" ], "referenced_field": "string" }, "id": "email", "is_primary_key": true, "name": "Email", "path": "string", "primary_key_override": true, "remote_type": "varchar(255)", "source_primary_key": false, "type": "unknown", "user_managed": true, "values": [ { "label": "string", "value": "string" } ] } ], "id": "contact", "name": "Contact" } } ``` **SDK Code** ```python import requests url = "https://app.polytomic.com/api/connections/248df4b7-aa70-47b8-a036-33ac447e668d/schemas/public.users" headers = { "X-Polytomic-Version": "X-Polytomic-Version" } response = requests.get(url, headers=headers, auth=("", "")) print(response.json()) ``` ```javascript const url = 'https://app.polytomic.com/api/connections/248df4b7-aa70-47b8-a036-33ac447e668d/schemas/public.users'; const credentials = btoa(":"); const options = { method: 'GET', headers: { 'X-Polytomic-Version': 'X-Polytomic-Version', Authorization: `Basic ${credentials}` } }; 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" "net/http" "io" ) func main() { url := "https://app.polytomic.com/api/connections/248df4b7-aa70-47b8-a036-33ac447e668d/schemas/public.users" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("X-Polytomic-Version", "X-Polytomic-Version") req.SetBasicAuth("", "") 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/connections/248df4b7-aa70-47b8-a036-33ac447e668d/schemas/public.users") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["X-Polytomic-Version"] = 'X-Polytomic-Version' request.basic_auth("", "") response = http.request(request) puts response.read_body ``` ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.get("https://app.polytomic.com/api/connections/248df4b7-aa70-47b8-a036-33ac447e668d/schemas/public.users") .header("X-Polytomic-Version", "X-Polytomic-Version") .basicAuth("", "") .asString(); ``` ```php request('GET', 'https://app.polytomic.com/api/connections/248df4b7-aa70-47b8-a036-33ac447e668d/schemas/public.users', [ 'headers' => [ '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/connections/248df4b7-aa70-47b8-a036-33ac447e668d/schemas/public.users"); client.Authenticator = new HttpBasicAuthenticator("", ""); var request = new RestRequest(Method.GET); request.AddHeader("X-Polytomic-Version", "X-Polytomic-Version"); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let credentials = Data(":".utf8).base64EncodedString() let headers = [ "X-Polytomic-Version": "X-Polytomic-Version", "Authorization": "Basic \(credentials)" ] let request = NSMutableURLRequest(url: NSURL(string: "https://app.polytomic.com/api/connections/248df4b7-aa70-47b8-a036-33ac447e668d/schemas/public.users")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" 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() ```