> For a complete page index, fetch https://developer.close.com/llms.txt # Get an activity report POST https://api.close.com/api/v1/report/activity/ Content-Type: application/json The activity report returns the organization's metrics per time period (**overview** report) or user (**comparison** report). Every report accepts the following parameters: * `datetime_range`: a time range to fetch data for. Either this field or `relative_range` needs to be specified. * `relative_range`: a relative time range to fetch data for. The allowed values are: `today`, `this-week`, `this-month`, `this-quarter`, `this-year`, `yesterday`, `last-week`, `last-month`, `last-quarter`, `last-year`, and `all-time`. Either this field or `datetime_range` needs to be specified. * `query`: a query to apply to the report to filter out data. The value of the field is a dictionary with the key `type` and any type-specific keys. For now only the type `saved_search` is allowed which takes the extra key `saved_search_id` to specify the ID of a saved search. This parameter is *optional*. * `users`: a list of user IDs to limit the report results to. This parameter is *optional*. * `type`: the type of the report. The available values are `overview` and `comparison`. This parameter is *mandatory*. * `metrics`: a list of metrics (see [List Activity Metrics](/api/resources/reporting/list-activity-metrics)) to fetch for the report. This parameter is *mandatory*. The report can be requested either in a JSON format or in a CSV file. The format can be specified with the `accept` header. Reference: https://developer.close.com/api/resources/reporting/get-activity ## 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 ## Errors ### 400 Bad Request Error Bad request - `any` ### 401 Unauthorized Error Unauthorized - `any` ### 404 Not Found Error Not found - `any` ## Examples **Request** ```json { "datetime_range": { "end": "2019-01-08T00:00:00Z", "start": "2019-01-01T00:00:00Z" }, "metrics": [ "calls.outbound.all.count", "emails.sent.all.count" ], "query": { "saved_search_id": "save_ZVc26G33JTNiDNEFdZhBQAONg9cJHleAAHqBJakf239", "type": "saved_search" }, "type": "overview", "users": [ "user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA", "user_Ova4RGFG7pztSeJiiMFdN7O2MFl71nD0uGO3bIOo4Wk" ] } ``` **Response** ```json { "aggregations": { "totals": { "calls.outbound.all.count": 0, "emails.sent.all.count": 0 } }, "data": [ { "calls.outbound.all.count": 0, "datetime": "2019-01-01T00:00:00+00:00", "emails.sent.all.count": 0 }, { "calls.outbound.all.count": 0, "datetime": "2019-01-02T00:00:00+00:00", "emails.sent.all.count": 0 }, { "calls.outbound.all.count": 0, "datetime": "2019-01-03T00:00:00+00:00", "emails.sent.all.count": 0 }, { "calls.outbound.all.count": 0, "datetime": "2019-01-04T00:00:00+00:00", "emails.sent.all.count": 0 }, { "calls.outbound.all.count": 0, "datetime": "2019-01-05T00:00:00+00:00", "emails.sent.all.count": 0 }, { "calls.outbound.all.count": 0, "datetime": "2019-01-06T00:00:00+00:00", "emails.sent.all.count": 0 }, { "calls.outbound.all.count": 0, "datetime": "2019-01-07T00:00:00+00:00", "emails.sent.all.count": 0 } ], "queries": { "leads": { "calls.outbound.all.count": [ "call(direction: \"outbound\" and outgoing_call_date >= \"2019-01-01T00:00:00.000+0000\" and outgoing_call_date < \"2019-01-08T00:00:00.000+0000\" and user in (\"user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA\", \"user_Ova4RGFG7pztSeJiiMFdN7O2MFl71nD0uGO3bIOo4Wk\")) and in:\"save_ZVc26G33JTNiDNEFdZhBQAONg9cJHleAAHqBJakf239\"" ], "emails.sent.all.count": [ "email(direction: \"outgoing\" and sent >= \"2019-01-01T00:00:00.000+0000\" and sent < \"2019-01-08T00:00:00.000+0000\" and status: \"sent\" and user in (\"user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA\", \"user_Ova4RGFG7pztSeJiiMFdN7O2MFl71nD0uGO3bIOo4Wk\")) and in:\"save_ZVc26G33JTNiDNEFdZhBQAONg9cJHleAAHqBJakf239\"" ] } } } ``` **SDK Code** ```python import requests url = "https://api.close.com/api/v1/report/activity/" payload = { "datetime_range": { "end": "2019-01-08T00:00:00Z", "start": "2019-01-01T00:00:00Z" }, "metrics": ["calls.outbound.all.count", "emails.sent.all.count"], "query": { "saved_search_id": "save_ZVc26G33JTNiDNEFdZhBQAONg9cJHleAAHqBJakf239", "type": "saved_search" }, "type": "overview", "users": ["user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA", "user_Ova4RGFG7pztSeJiiMFdN7O2MFl71nD0uGO3bIOo4Wk"] } headers = { "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers, auth=("", "")) print(response.json()) ``` ```javascript const url = 'https://api.close.com/api/v1/report/activity/'; const credentials = btoa(":"); const options = { method: 'POST', headers: {Authorization: `Basic ${credentials}`, 'Content-Type': 'application/json'}, body: '{"datetime_range":{"end":"2019-01-08T00:00:00Z","start":"2019-01-01T00:00:00Z"},"metrics":["calls.outbound.all.count","emails.sent.all.count"],"query":{"saved_search_id":"save_ZVc26G33JTNiDNEFdZhBQAONg9cJHleAAHqBJakf239","type":"saved_search"},"type":"overview","users":["user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA","user_Ova4RGFG7pztSeJiiMFdN7O2MFl71nD0uGO3bIOo4Wk"]}' }; 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://api.close.com/api/v1/report/activity/" payload := strings.NewReader("{\n \"datetime_range\": {\n \"end\": \"2019-01-08T00:00:00Z\",\n \"start\": \"2019-01-01T00:00:00Z\"\n },\n \"metrics\": [\n \"calls.outbound.all.count\",\n \"emails.sent.all.count\"\n ],\n \"query\": {\n \"saved_search_id\": \"save_ZVc26G33JTNiDNEFdZhBQAONg9cJHleAAHqBJakf239\",\n \"type\": \"saved_search\"\n },\n \"type\": \"overview\",\n \"users\": [\n \"user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA\",\n \"user_Ova4RGFG7pztSeJiiMFdN7O2MFl71nD0uGO3bIOo4Wk\"\n ]\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 require 'uri' require 'net/http' url = URI("https://api.close.com/api/v1/report/activity/") 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 \"datetime_range\": {\n \"end\": \"2019-01-08T00:00:00Z\",\n \"start\": \"2019-01-01T00:00:00Z\"\n },\n \"metrics\": [\n \"calls.outbound.all.count\",\n \"emails.sent.all.count\"\n ],\n \"query\": {\n \"saved_search_id\": \"save_ZVc26G33JTNiDNEFdZhBQAONg9cJHleAAHqBJakf239\",\n \"type\": \"saved_search\"\n },\n \"type\": \"overview\",\n \"users\": [\n \"user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA\",\n \"user_Ova4RGFG7pztSeJiiMFdN7O2MFl71nD0uGO3bIOo4Wk\"\n ]\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.post("https://api.close.com/api/v1/report/activity/") .basicAuth("", "") .header("Content-Type", "application/json") .body("{\n \"datetime_range\": {\n \"end\": \"2019-01-08T00:00:00Z\",\n \"start\": \"2019-01-01T00:00:00Z\"\n },\n \"metrics\": [\n \"calls.outbound.all.count\",\n \"emails.sent.all.count\"\n ],\n \"query\": {\n \"saved_search_id\": \"save_ZVc26G33JTNiDNEFdZhBQAONg9cJHleAAHqBJakf239\",\n \"type\": \"saved_search\"\n },\n \"type\": \"overview\",\n \"users\": [\n \"user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA\",\n \"user_Ova4RGFG7pztSeJiiMFdN7O2MFl71nD0uGO3bIOo4Wk\"\n ]\n}") .asString(); ``` ```php request('POST', 'https://api.close.com/api/v1/report/activity/', [ 'body' => '{ "datetime_range": { "end": "2019-01-08T00:00:00Z", "start": "2019-01-01T00:00:00Z" }, "metrics": [ "calls.outbound.all.count", "emails.sent.all.count" ], "query": { "saved_search_id": "save_ZVc26G33JTNiDNEFdZhBQAONg9cJHleAAHqBJakf239", "type": "saved_search" }, "type": "overview", "users": [ "user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA", "user_Ova4RGFG7pztSeJiiMFdN7O2MFl71nD0uGO3bIOo4Wk" ] }', 'headers' => [ 'Content-Type' => 'application/json', ], 'auth' => ['', ''], ]); echo $response->getBody(); ``` ```csharp using RestSharp; using RestSharp.Authenticators; var client = new RestClient("https://api.close.com/api/v1/report/activity/"); client.Authenticator = new HttpBasicAuthenticator("", ""); var request = new RestRequest(Method.POST); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"datetime_range\": {\n \"end\": \"2019-01-08T00:00:00Z\",\n \"start\": \"2019-01-01T00:00:00Z\"\n },\n \"metrics\": [\n \"calls.outbound.all.count\",\n \"emails.sent.all.count\"\n ],\n \"query\": {\n \"saved_search_id\": \"save_ZVc26G33JTNiDNEFdZhBQAONg9cJHleAAHqBJakf239\",\n \"type\": \"saved_search\"\n },\n \"type\": \"overview\",\n \"users\": [\n \"user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA\",\n \"user_Ova4RGFG7pztSeJiiMFdN7O2MFl71nD0uGO3bIOo4Wk\"\n ]\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ```