> For a complete page index, fetch https://developer.close.com/llms.txt # Create a Smart View POST https://api.close.com/api/v1/saved_search/ Content-Type: application/json Create a Lead or Contact Smart View. For Lead Smart Views, the `type` field is optional (since `lead` is the default `type`). When creating a Smart View, you must specify that you want to get objects of the appropriate type via an `object_type` clause as per the [Advanced Filtering](https://developer.close.com/api/resources/advanced-filtering) section. See the examples below. Reference: https://developer.close.com/api/resources/smart-views/create ## Authentication - `Authorization` header (basic auth, required) — Use your API key as the username and leave the password empty. - `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer `, where token is your auth token. ## Request ### Body (application/json) This endpoint expects an any. - `any` ## Response ### 200 Successful response - `date_created` (datetime, required) - `date_updated` (datetime, required) - `description` (string, required, nullable) - `id` (string, required) - `is_shared` (boolean, required) - `is_user_dependent` (boolean, required, nullable) - `name` (string, required) - `organization_id` (string, required) - `query` (string, required, nullable) - `s_query` (map from string to any, required, nullable) - `type` (enum, required) - Allowed values: `lead`, `contact`, `opportunity`, `call`, `email`, `sms`, `meeting`, `note`, `whatsapp_message`, `custom_activity`, `form_submission` - `user_id` (string, required, nullable) - `selected_fields` (list of map from string to any, optional, nullable) - `shared_with` (list of string, optional, nullable) - `sharing_settings` (SharingSettingsEmbeddedResponse, optional, nullable) ## Errors ### 400 Bad Request Error Bad request - `any` ### 401 Unauthorized Error Unauthorized - `any` ### 404 Not Found Error Not found - `any` ## Types ### SharingSettingsEmbeddedResponse - `created_at` (datetime, required, nullable) - `created_by_id` (string, required, nullable) - `group_ids` (list of string, required) - `updated_at` (datetime, required, nullable) - `updated_by_id` (string, required, nullable) - `user_ids` (list of string, required) - `whole_org` (boolean, required) ## Examples ### leadSmartView **Request** ```json { "name": "every lead", "s_query": { "query": { "queries": [ { "object_type": "lead", "type": "object_type" }, { "condition": { "mode": "full_words", "type": "text", "value": "Bluth Company" }, "field": { "field_name": "display_name", "object_type": "lead", "type": "regular_field" }, "type": "field_condition" } ], "type": "and" } }, "type": "lead" } ``` **Response** ```json { "date_created": "2013-02-01T01:03:56.515000+00:00", "date_updated": "2013-02-01T01:03:56.515000+00:00", "description": "", "id": "save_Cin23B1CYKX83dbNnBB4Q5F5QXl9ucmgrqNf0esq1Ir", "is_shared": false, "is_user_dependent": false, "name": "every lead", "organization_id": "orga_RbREgmiiwcr1w2b4cOnCMQaQPSIFxMqAD2Dh243uxcH", "query": null, "s_query": { "query": { "queries": [ { "object_type": "lead", "type": "object_type" }, { "condition": { "mode": "full_words", "type": "text", "value": "Bluth Company" }, "field": { "field_name": "display_name", "object_type": "lead", "type": "regular_field" }, "type": "field_condition" } ], "type": "and" } }, "type": "lead", "user_id": "user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA", "used_recently": true } ``` **SDK Code** ```python leadSmartView import requests url = "https://api.close.com/api/v1/saved_search/" payload = { "name": "every lead", "s_query": { "query": { "queries": [ { "object_type": "lead", "type": "object_type" }, { "condition": { "mode": "full_words", "type": "text", "value": "Bluth Company" }, "field": { "field_name": "display_name", "object_type": "lead", "type": "regular_field" }, "type": "field_condition" } ], "type": "and" } }, "type": "lead" } headers = { "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers, auth=("", "")) print(response.json()) ``` ```javascript leadSmartView const url = 'https://api.close.com/api/v1/saved_search/'; const credentials = btoa(":"); const options = { method: 'POST', headers: {Authorization: `Basic ${credentials}`, 'Content-Type': 'application/json'}, body: '{"name":"every lead","s_query":{"query":{"queries":[{"object_type":"lead","type":"object_type"},{"condition":{"mode":"full_words","type":"text","value":"Bluth Company"},"field":{"field_name":"display_name","object_type":"lead","type":"regular_field"},"type":"field_condition"}],"type":"and"}},"type":"lead"}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go leadSmartView package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.close.com/api/v1/saved_search/" payload := strings.NewReader("{\n \"name\": \"every lead\",\n \"s_query\": {\n \"query\": {\n \"queries\": [\n {\n \"object_type\": \"lead\",\n \"type\": \"object_type\"\n },\n {\n \"condition\": {\n \"mode\": \"full_words\",\n \"type\": \"text\",\n \"value\": \"Bluth Company\"\n },\n \"field\": {\n \"field_name\": \"display_name\",\n \"object_type\": \"lead\",\n \"type\": \"regular_field\"\n },\n \"type\": \"field_condition\"\n }\n ],\n \"type\": \"and\"\n }\n },\n \"type\": \"lead\"\n}") req, _ := http.NewRequest("POST", url, payload) 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 leadSmartView require 'uri' require 'net/http' url = URI("https://api.close.com/api/v1/saved_search/") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request.basic_auth("", "") request["Content-Type"] = 'application/json' request.body = "{\n \"name\": \"every lead\",\n \"s_query\": {\n \"query\": {\n \"queries\": [\n {\n \"object_type\": \"lead\",\n \"type\": \"object_type\"\n },\n {\n \"condition\": {\n \"mode\": \"full_words\",\n \"type\": \"text\",\n \"value\": \"Bluth Company\"\n },\n \"field\": {\n \"field_name\": \"display_name\",\n \"object_type\": \"lead\",\n \"type\": \"regular_field\"\n },\n \"type\": \"field_condition\"\n }\n ],\n \"type\": \"and\"\n }\n },\n \"type\": \"lead\"\n}" response = http.request(request) puts response.read_body ``` ```java leadSmartView import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.close.com/api/v1/saved_search/") .basicAuth("", "") .header("Content-Type", "application/json") .body("{\n \"name\": \"every lead\",\n \"s_query\": {\n \"query\": {\n \"queries\": [\n {\n \"object_type\": \"lead\",\n \"type\": \"object_type\"\n },\n {\n \"condition\": {\n \"mode\": \"full_words\",\n \"type\": \"text\",\n \"value\": \"Bluth Company\"\n },\n \"field\": {\n \"field_name\": \"display_name\",\n \"object_type\": \"lead\",\n \"type\": \"regular_field\"\n },\n \"type\": \"field_condition\"\n }\n ],\n \"type\": \"and\"\n }\n },\n \"type\": \"lead\"\n}") .asString(); ``` ```php leadSmartView request('POST', 'https://api.close.com/api/v1/saved_search/', [ 'body' => '{ "name": "every lead", "s_query": { "query": { "queries": [ { "object_type": "lead", "type": "object_type" }, { "condition": { "mode": "full_words", "type": "text", "value": "Bluth Company" }, "field": { "field_name": "display_name", "object_type": "lead", "type": "regular_field" }, "type": "field_condition" } ], "type": "and" } }, "type": "lead" }', 'headers' => [ 'Content-Type' => 'application/json', ], 'auth' => ['', ''], ]); echo $response->getBody(); ``` ```csharp leadSmartView using RestSharp; using RestSharp.Authenticators; var client = new RestClient("https://api.close.com/api/v1/saved_search/"); client.Authenticator = new HttpBasicAuthenticator("", ""); var request = new RestRequest(Method.POST); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"name\": \"every lead\",\n \"s_query\": {\n \"query\": {\n \"queries\": [\n {\n \"object_type\": \"lead\",\n \"type\": \"object_type\"\n },\n {\n \"condition\": {\n \"mode\": \"full_words\",\n \"type\": \"text\",\n \"value\": \"Bluth Company\"\n },\n \"field\": {\n \"field_name\": \"display_name\",\n \"object_type\": \"lead\",\n \"type\": \"regular_field\"\n },\n \"type\": \"field_condition\"\n }\n ],\n \"type\": \"and\"\n }\n },\n \"type\": \"lead\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ### contactSmartView **Request** ```json { "name": "CEOs", "s_query": { "query": { "queries": [ { "object_type": "contact", "type": "object_type" }, { "condition": { "mode": "full_words", "type": "text", "value": "CEO" }, "field": { "field_name": "title", "object_type": "contact", "type": "regular_field" }, "type": "field_condition" } ], "type": "and" } }, "type": "contact" } ``` **Response** ```json { "date_created": "2013-02-01T01:03:56.515000+00:00", "date_updated": "2013-02-01T01:03:56.515000+00:00", "description": "", "id": "save_Cin23B1CYKX83dbNnBB4Q5F5QXl9ucmgrqNf0esq1Ir", "is_shared": false, "is_user_dependent": false, "name": "every lead", "organization_id": "orga_RbREgmiiwcr1w2b4cOnCMQaQPSIFxMqAD2Dh243uxcH", "query": null, "s_query": { "query": { "queries": [ { "object_type": "lead", "type": "object_type" }, { "condition": { "mode": "full_words", "type": "text", "value": "Bluth Company" }, "field": { "field_name": "display_name", "object_type": "lead", "type": "regular_field" }, "type": "field_condition" } ], "type": "and" } }, "type": "lead", "user_id": "user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA", "used_recently": true } ``` **SDK Code** ```python contactSmartView import requests url = "https://api.close.com/api/v1/saved_search/" payload = { "name": "CEOs", "s_query": { "query": { "queries": [ { "object_type": "contact", "type": "object_type" }, { "condition": { "mode": "full_words", "type": "text", "value": "CEO" }, "field": { "field_name": "title", "object_type": "contact", "type": "regular_field" }, "type": "field_condition" } ], "type": "and" } }, "type": "contact" } headers = { "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers, auth=("", "")) print(response.json()) ``` ```javascript contactSmartView const url = 'https://api.close.com/api/v1/saved_search/'; const credentials = btoa(":"); const options = { method: 'POST', headers: {Authorization: `Basic ${credentials}`, 'Content-Type': 'application/json'}, body: '{"name":"CEOs","s_query":{"query":{"queries":[{"object_type":"contact","type":"object_type"},{"condition":{"mode":"full_words","type":"text","value":"CEO"},"field":{"field_name":"title","object_type":"contact","type":"regular_field"},"type":"field_condition"}],"type":"and"}},"type":"contact"}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go contactSmartView package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.close.com/api/v1/saved_search/" payload := strings.NewReader("{\n \"name\": \"CEOs\",\n \"s_query\": {\n \"query\": {\n \"queries\": [\n {\n \"object_type\": \"contact\",\n \"type\": \"object_type\"\n },\n {\n \"condition\": {\n \"mode\": \"full_words\",\n \"type\": \"text\",\n \"value\": \"CEO\"\n },\n \"field\": {\n \"field_name\": \"title\",\n \"object_type\": \"contact\",\n \"type\": \"regular_field\"\n },\n \"type\": \"field_condition\"\n }\n ],\n \"type\": \"and\"\n }\n },\n \"type\": \"contact\"\n}") req, _ := http.NewRequest("POST", url, payload) 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 contactSmartView require 'uri' require 'net/http' url = URI("https://api.close.com/api/v1/saved_search/") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request.basic_auth("", "") request["Content-Type"] = 'application/json' request.body = "{\n \"name\": \"CEOs\",\n \"s_query\": {\n \"query\": {\n \"queries\": [\n {\n \"object_type\": \"contact\",\n \"type\": \"object_type\"\n },\n {\n \"condition\": {\n \"mode\": \"full_words\",\n \"type\": \"text\",\n \"value\": \"CEO\"\n },\n \"field\": {\n \"field_name\": \"title\",\n \"object_type\": \"contact\",\n \"type\": \"regular_field\"\n },\n \"type\": \"field_condition\"\n }\n ],\n \"type\": \"and\"\n }\n },\n \"type\": \"contact\"\n}" response = http.request(request) puts response.read_body ``` ```java contactSmartView import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.close.com/api/v1/saved_search/") .basicAuth("", "") .header("Content-Type", "application/json") .body("{\n \"name\": \"CEOs\",\n \"s_query\": {\n \"query\": {\n \"queries\": [\n {\n \"object_type\": \"contact\",\n \"type\": \"object_type\"\n },\n {\n \"condition\": {\n \"mode\": \"full_words\",\n \"type\": \"text\",\n \"value\": \"CEO\"\n },\n \"field\": {\n \"field_name\": \"title\",\n \"object_type\": \"contact\",\n \"type\": \"regular_field\"\n },\n \"type\": \"field_condition\"\n }\n ],\n \"type\": \"and\"\n }\n },\n \"type\": \"contact\"\n}") .asString(); ``` ```php contactSmartView request('POST', 'https://api.close.com/api/v1/saved_search/', [ 'body' => '{ "name": "CEOs", "s_query": { "query": { "queries": [ { "object_type": "contact", "type": "object_type" }, { "condition": { "mode": "full_words", "type": "text", "value": "CEO" }, "field": { "field_name": "title", "object_type": "contact", "type": "regular_field" }, "type": "field_condition" } ], "type": "and" } }, "type": "contact" }', 'headers' => [ 'Content-Type' => 'application/json', ], 'auth' => ['', ''], ]); echo $response->getBody(); ``` ```csharp contactSmartView using RestSharp; using RestSharp.Authenticators; var client = new RestClient("https://api.close.com/api/v1/saved_search/"); client.Authenticator = new HttpBasicAuthenticator("", ""); var request = new RestRequest(Method.POST); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"name\": \"CEOs\",\n \"s_query\": {\n \"query\": {\n \"queries\": [\n {\n \"object_type\": \"contact\",\n \"type\": \"object_type\"\n },\n {\n \"condition\": {\n \"mode\": \"full_words\",\n \"type\": \"text\",\n \"value\": \"CEO\"\n },\n \"field\": {\n \"field_name\": \"title\",\n \"object_type\": \"contact\",\n \"type\": \"regular_field\"\n },\n \"type\": \"field_condition\"\n }\n ],\n \"type\": \"and\"\n }\n },\n \"type\": \"contact\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ```