> For a complete page index, fetch https://developer.close.com/llms.txt # Create a task POST https://api.close.com/api/v1/task/ Content-Type: application/json Provide the type of task to be created in the `_type` field. Currently only tasks of type `lead` and `outgoing_call` can be created. Reference: https://developer.close.com/api/resources/tasks/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 ### Query parameters - `_fields` (string, optional) — Comma-separated list of fields to include in the response. ### Body (application/json) This endpoint expects a CreateTask. - `CreateTask` - `_type`: `lead` (CreateLeadTask) - `lead_id` (string, required) - `text` (string, required) - `assigned_to` (string, optional, nullable) - `contact_id` (string, optional, nullable) - `created_by` (string, optional) - `date` (CreateTaskDiscriminatorMappingLeadDate, optional) - `date_created` (CreateTaskDiscriminatorMappingLeadDateCreated, optional) - `disable_notification` (boolean, optional, default: false) - `due_date` (CreateTaskDiscriminatorMappingLeadDueDate, optional) - `is_complete` (boolean, optional) - `is_dateless` (boolean, optional) - `organization_id` (string, optional) - `priority` (enum, optional) - Allowed values: `high`, `medium` - `_type`: `outgoing_call` (CreateCallTask) - `contact_id` (string, required) - `lead_id` (string, required) - `agent_config_id` (string, optional, nullable) - `assigned_to` (string, optional, nullable) - `created_by` (string, optional) - `date` (CreateTaskDiscriminatorMappingOutgoingCallDate, optional) - `is_complete` (boolean, optional) - `organization_id` (string, optional) - `priority` (enum, optional) - Allowed values: `high`, `medium` - `text` (string, optional, nullable) ## Response ### 200 Successful response ## Errors ### 400 Bad Request Error Bad request - `any` ### 401 Unauthorized Error Unauthorized - `any` ### 404 Not Found Error Not found - `any` ## Types ### CreateTaskDiscriminatorMappingLeadDate ### CreateTaskDiscriminatorMappingLeadDateCreated ### CreateTaskDiscriminatorMappingLeadDueDate ### CreateTaskDiscriminatorMappingOutgoingCallDate ## Examples ### Create a lead task **Request** ```json { "_type": "lead", "lead_id": "lead_5LmpOyrMQdJSUlbNGBSGfK5XzcioIm7aC94PSQamQJc", "text": "Connect with Account Manager", "assigned_to": "user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA", "date": "2013-02-06", "is_complete": false } ``` **Response** ```json { "_type": "lead", "assigned_to": "user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA", "assigned_to_name": "John Doe", "contact_id": null, "contact_name": null, "created_by": "user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA", "created_by_name": "John Doe", "date": "2013-02-06", "date_created": "2015-02-08T20:30:54.314000+00:00", "date_updated": "2015-02-26T19:11:36.128000+00:00", "id": "task_aRUZXCm9lMb2LwipTPhfFoFbCsUnaoQh1ncQ7WLnjlI", "is_complete": false, "is_dateless": false, "lead_id": "lead_5LmpOyrMQdJSUlbNGBSGfK5XzcioIm7aC94PSQamQJc", "lead_name": "Close", "object_id": null, "object_type": null, "organization_id": "orga_RbREgmiiwcr1w2b4cOnCMQaQPSIFxMqAD2Dh243uxcH", "text": "Connect with Account Manager", "updated_by": "user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA", "updated_by_name": "John Doe" } ``` **SDK Code** ```python Create a lead task import requests url = "https://api.close.com/api/v1/task/" payload = { "_type": "lead", "lead_id": "lead_5LmpOyrMQdJSUlbNGBSGfK5XzcioIm7aC94PSQamQJc", "text": "Connect with Account Manager", "assigned_to": "user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA", "date": "2013-02-06", "is_complete": False } headers = { "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers, auth=("", "")) print(response.json()) ``` ```javascript Create a lead task const url = 'https://api.close.com/api/v1/task/'; const credentials = btoa(":"); const options = { method: 'POST', headers: {Authorization: `Basic ${credentials}`, 'Content-Type': 'application/json'}, body: '{"_type":"lead","lead_id":"lead_5LmpOyrMQdJSUlbNGBSGfK5XzcioIm7aC94PSQamQJc","text":"Connect with Account Manager","assigned_to":"user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA","date":"2013-02-06","is_complete":false}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go Create a lead task package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.close.com/api/v1/task/" payload := strings.NewReader("{\n \"_type\": \"lead\",\n \"lead_id\": \"lead_5LmpOyrMQdJSUlbNGBSGfK5XzcioIm7aC94PSQamQJc\",\n \"text\": \"Connect with Account Manager\",\n \"assigned_to\": \"user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA\",\n \"date\": \"2013-02-06\",\n \"is_complete\": false\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 Create a lead task require 'uri' require 'net/http' url = URI("https://api.close.com/api/v1/task/") 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 \"_type\": \"lead\",\n \"lead_id\": \"lead_5LmpOyrMQdJSUlbNGBSGfK5XzcioIm7aC94PSQamQJc\",\n \"text\": \"Connect with Account Manager\",\n \"assigned_to\": \"user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA\",\n \"date\": \"2013-02-06\",\n \"is_complete\": false\n}" response = http.request(request) puts response.read_body ``` ```java Create a lead task import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.close.com/api/v1/task/") .basicAuth("", "") .header("Content-Type", "application/json") .body("{\n \"_type\": \"lead\",\n \"lead_id\": \"lead_5LmpOyrMQdJSUlbNGBSGfK5XzcioIm7aC94PSQamQJc\",\n \"text\": \"Connect with Account Manager\",\n \"assigned_to\": \"user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA\",\n \"date\": \"2013-02-06\",\n \"is_complete\": false\n}") .asString(); ``` ```php Create a lead task request('POST', 'https://api.close.com/api/v1/task/', [ 'body' => '{ "_type": "lead", "lead_id": "lead_5LmpOyrMQdJSUlbNGBSGfK5XzcioIm7aC94PSQamQJc", "text": "Connect with Account Manager", "assigned_to": "user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA", "date": "2013-02-06", "is_complete": false }', 'headers' => [ 'Content-Type' => 'application/json', ], 'auth' => ['', ''], ]); echo $response->getBody(); ``` ```csharp Create a lead task using RestSharp; using RestSharp.Authenticators; var client = new RestClient("https://api.close.com/api/v1/task/"); client.Authenticator = new HttpBasicAuthenticator("", ""); var request = new RestRequest(Method.POST); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"_type\": \"lead\",\n \"lead_id\": \"lead_5LmpOyrMQdJSUlbNGBSGfK5XzcioIm7aC94PSQamQJc\",\n \"text\": \"Connect with Account Manager\",\n \"assigned_to\": \"user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA\",\n \"date\": \"2013-02-06\",\n \"is_complete\": false\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ### Create an outgoing-call task **Request** ```json { "_type": "outgoing_call", "contact_id": "cont_q4xdpIoJZCgMKY3sFBbGnRGhdgNbGN3yXfCmJSnkGai", "lead_id": "lead_5LmpOyrMQdJSUlbNGBSGfK5XzcioIm7aC94PSQamQJc", "assigned_to": "user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA", "date": "2013-02-06" } ``` **Response** ```json { "_type": "outgoing_call", "assigned_to": "user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA", "assigned_to_name": "John Doe", "contact_id": "cont_q4xdpIoJZCgMKY3sFBbGnRGhdgNbGN3yXfCmJSnkGai", "contact_name": "Jane Smith", "created_by": "user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA", "created_by_name": "John Doe", "date": "2013-02-06", "date_created": "2015-02-08T20:31:12.000000+00:00", "date_updated": "2015-02-08T20:31:12.000000+00:00", "id": "task_bXUZYDn0mNc3MxwiUQigGpGcDtVobpRi2odR8XMokZJ", "is_complete": false, "is_dateless": false, "lead_id": "lead_5LmpOyrMQdJSUlbNGBSGfK5XzcioIm7aC94PSQamQJc", "lead_name": "Close", "object_id": null, "object_type": null, "organization_id": "orga_RbREgmiiwcr1w2b4cOnCMQaQPSIFxMqAD2Dh243uxcH", "text": null, "updated_by": "user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA", "updated_by_name": "John Doe" } ``` **SDK Code** ```python Create an outgoing-call task import requests url = "https://api.close.com/api/v1/task/" payload = { "_type": "outgoing_call", "contact_id": "cont_q4xdpIoJZCgMKY3sFBbGnRGhdgNbGN3yXfCmJSnkGai", "lead_id": "lead_5LmpOyrMQdJSUlbNGBSGfK5XzcioIm7aC94PSQamQJc", "assigned_to": "user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA", "date": "2013-02-06" } headers = { "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers, auth=("", "")) print(response.json()) ``` ```javascript Create an outgoing-call task const url = 'https://api.close.com/api/v1/task/'; const credentials = btoa(":"); const options = { method: 'POST', headers: {Authorization: `Basic ${credentials}`, 'Content-Type': 'application/json'}, body: '{"_type":"outgoing_call","contact_id":"cont_q4xdpIoJZCgMKY3sFBbGnRGhdgNbGN3yXfCmJSnkGai","lead_id":"lead_5LmpOyrMQdJSUlbNGBSGfK5XzcioIm7aC94PSQamQJc","assigned_to":"user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA","date":"2013-02-06"}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go Create an outgoing-call task package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.close.com/api/v1/task/" payload := strings.NewReader("{\n \"_type\": \"outgoing_call\",\n \"contact_id\": \"cont_q4xdpIoJZCgMKY3sFBbGnRGhdgNbGN3yXfCmJSnkGai\",\n \"lead_id\": \"lead_5LmpOyrMQdJSUlbNGBSGfK5XzcioIm7aC94PSQamQJc\",\n \"assigned_to\": \"user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA\",\n \"date\": \"2013-02-06\"\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 Create an outgoing-call task require 'uri' require 'net/http' url = URI("https://api.close.com/api/v1/task/") 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 \"_type\": \"outgoing_call\",\n \"contact_id\": \"cont_q4xdpIoJZCgMKY3sFBbGnRGhdgNbGN3yXfCmJSnkGai\",\n \"lead_id\": \"lead_5LmpOyrMQdJSUlbNGBSGfK5XzcioIm7aC94PSQamQJc\",\n \"assigned_to\": \"user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA\",\n \"date\": \"2013-02-06\"\n}" response = http.request(request) puts response.read_body ``` ```java Create an outgoing-call task import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.close.com/api/v1/task/") .basicAuth("", "") .header("Content-Type", "application/json") .body("{\n \"_type\": \"outgoing_call\",\n \"contact_id\": \"cont_q4xdpIoJZCgMKY3sFBbGnRGhdgNbGN3yXfCmJSnkGai\",\n \"lead_id\": \"lead_5LmpOyrMQdJSUlbNGBSGfK5XzcioIm7aC94PSQamQJc\",\n \"assigned_to\": \"user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA\",\n \"date\": \"2013-02-06\"\n}") .asString(); ``` ```php Create an outgoing-call task request('POST', 'https://api.close.com/api/v1/task/', [ 'body' => '{ "_type": "outgoing_call", "contact_id": "cont_q4xdpIoJZCgMKY3sFBbGnRGhdgNbGN3yXfCmJSnkGai", "lead_id": "lead_5LmpOyrMQdJSUlbNGBSGfK5XzcioIm7aC94PSQamQJc", "assigned_to": "user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA", "date": "2013-02-06" }', 'headers' => [ 'Content-Type' => 'application/json', ], 'auth' => ['', ''], ]); echo $response->getBody(); ``` ```csharp Create an outgoing-call task using RestSharp; using RestSharp.Authenticators; var client = new RestClient("https://api.close.com/api/v1/task/"); client.Authenticator = new HttpBasicAuthenticator("", ""); var request = new RestRequest(Method.POST); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"_type\": \"outgoing_call\",\n \"contact_id\": \"cont_q4xdpIoJZCgMKY3sFBbGnRGhdgNbGN3yXfCmJSnkGai\",\n \"lead_id\": \"lead_5LmpOyrMQdJSUlbNGBSGfK5XzcioIm7aC94PSQamQJc\",\n \"assigned_to\": \"user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA\",\n \"date\": \"2013-02-06\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ```