> For a complete page index, fetch https://developer.close.com/llms.txt

# Log an external Call activity

POST https://api.close.com/api/v1/activity/call/
Content-Type: application/json

Use this endpoint to log calls made outside of the Close built-in VoIP system.

*status*: defaults to `completed`

*direction* (optional): `outbound` or `inbound`

*recording_url*: you can post a URL pointing to the MP3 recording of your call. For security reasons, we require the URL to be secure (i.e. starting with https://)

Reference: https://developer.close.com/api/resources/activities/calls/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 <token>`, where token is your auth token.

## Request

### Body (application/json)

This endpoint expects an object.

- `activity_at` (datetime, optional, nullable)
- `contact_id` (string, optional, nullable)
- `conversation_type_id` (string, optional, nullable)
- `created_by` (string, optional, nullable)
- `date_created` (datetime, optional, nullable)
- `direction` (enum, optional)
  - Allowed values: `inbound`, `outbound`
- `duration` (integer, optional, nullable)
- `lead_id` (string, optional, nullable)
- `note` (string, optional, nullable)
- `note_html` (string, optional, nullable)
- `organization_id` (string, optional, nullable)
- `outcome_id` (string, optional, nullable)
- `phone` (string, optional, nullable) — Phone number in E.164 format
- `playbook_id` (string, optional, nullable)
- `quality_info` (string, optional, nullable)
- `recording_url` (string, optional, nullable)
- `source` (enum, optional)
  - Allowed values: `Close.io`, `External`
- `status` (enum, optional)
  - Allowed values: `created`, `in-progress`, `completed`, `cancel`, `no-answer`, `busy`, `failed`, `timeout`
- `user_id` (string, optional, nullable)
- `voicemail_url` (string, optional, nullable)

## Response

### 200

Successful response

- `_type` (string, required)
- `activity_at` (datetime, required, nullable)
- `contact_id` (string, required, nullable)
- `created_by` (string, required, nullable)
- `date_created` (datetime, required)
- `date_updated` (datetime, required)
- `id` (string, required)
- `lead_id` (string, required, nullable)
- `organization_id` (string, required)
- `outcome_id` (string, required, nullable)
- `source` (enum, required) — Source of a phone activity. Describes whether the phone activity (such as a call or an SMS) was handled by Close's telephony provider or handled externally by a 3rd party and is merely logged in Close.
  - Allowed values: `Close.io`, `External`
- `status` (enum, required) — Current status of the call.
  - Allowed values: `created`, `in-progress`, `completed`, `cancel`, `no-answer`, `busy`, `failed`, `timeout`
- `updated_by` (string, required, nullable)
- `user_id` (string, required, nullable)
- `users` (list of string, required)
- `created_by_name` (string, optional, nullable)
- `sequence_id` (string, optional, nullable)
- `sequence_name` (string, optional, nullable)
- `sequence_subscription_id` (string, optional, nullable)
- `updated_by_name` (string, optional, nullable)
- `user_name` (string, optional, nullable)

## Errors

### 400 Bad Request Error

Bad request

- `any`

### 401 Unauthorized Error

Unauthorized

- `any`

### 404 Not Found Error

Not found

- `any`

## Examples

**Request**

```json
{
  "contact_id": "cont_bulY73zoaAwTCLdjHrKzGkzZ942OwtEelJR7kNku9RK",
  "created_by": "user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA",
  "direction": "outbound",
  "duration": 153,
  "lead_id": "lead_fioU1Nk5LC0H0iei9XBGHW2CFZU0yeP2zZCJQP9pC4m",
  "note_html": "<body><p>call notes go here</p></body>",
  "phone": "+16505551234",
  "status": "completed",
  "user_id": "user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA"
}
```

**Response**

```json
{
  "_type": "Call",
  "activity_at": "2013-02-01T00:51:33+00:00",
  "contact_id": "cont_bulY73zoaAwTCLdjHrKzGkzZ942OwtEelJR7kNku9RK",
  "created_by": "user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA",
  "date_created": "2014-05-22T17:39:04.509000+00:00",
  "date_updated": "2014-05-22T17:39:04.509000+00:00",
  "id": "acti_wJGiBIXXBCpBAQacZ7axeOhgTS7TWxyU7ml4WqAswOb",
  "lead_id": "lead_fioU1Nk5LC0H0iei9XBGHW2CFZU0yeP2zZCJQP9pC4m",
  "organization_id": "orga_RbREgmiiwcr1w2b4cOnCMQaQPSIFxMqAD2Dh243uxcH",
  "outcome_id": null,
  "source": "External",
  "status": "completed",
  "updated_by": "user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA",
  "user_id": "user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA",
  "users": [],
  "created_by_name": "Stefan Wójcik",
  "updated_by_name": "Phil Freo",
  "user_name": "Stefan Wójcik",
  "call_method": "external",
  "cost": "0",
  "dialer_id": null,
  "dialer_saved_search_id": null,
  "direction": "outbound",
  "disposition": "answered",
  "duration": 153,
  "local_country_iso": "US",
  "note": "call notes go here",
  "note_html": "<body><p>call notes go here</p></body>",
  "phone": "+16505551234",
  "recording_url": null,
  "remote_country_iso": "US",
  "remote_phone": "+16505551234",
  "remote_phone_formatted": "+1 650-555-1234",
  "voicemail_url": null
}
```

**SDK Code**

```python activities.calls_create_example
import requests

url = "https://api.close.com/api/v1/activity/call/"

payload = {
    "contact_id": "cont_bulY73zoaAwTCLdjHrKzGkzZ942OwtEelJR7kNku9RK",
    "created_by": "user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA",
    "direction": "outbound",
    "duration": 153,
    "lead_id": "lead_fioU1Nk5LC0H0iei9XBGHW2CFZU0yeP2zZCJQP9pC4m",
    "note_html": "<body><p>call notes go here</p></body>",
    "phone": "+16505551234",
    "status": "completed",
    "user_id": "user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA"
}
headers = {
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers, auth=("<CLOSE_API_KEY>", ""))

print(response.json())
```

```javascript activities.calls_create_example
const url = 'https://api.close.com/api/v1/activity/call/';
const credentials = btoa("<CLOSE_API_KEY>:");

const options = {
  method: 'POST',
  headers: {Authorization: `Basic ${credentials}`, 'Content-Type': 'application/json'},
  body: '{"contact_id":"cont_bulY73zoaAwTCLdjHrKzGkzZ942OwtEelJR7kNku9RK","created_by":"user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA","direction":"outbound","duration":153,"lead_id":"lead_fioU1Nk5LC0H0iei9XBGHW2CFZU0yeP2zZCJQP9pC4m","note_html":"<body><p>call notes go here</p></body>","phone":"+16505551234","status":"completed","user_id":"user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go activities.calls_create_example
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.close.com/api/v1/activity/call/"

	payload := strings.NewReader("{\n  \"contact_id\": \"cont_bulY73zoaAwTCLdjHrKzGkzZ942OwtEelJR7kNku9RK\",\n  \"created_by\": \"user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA\",\n  \"direction\": \"outbound\",\n  \"duration\": 153,\n  \"lead_id\": \"lead_fioU1Nk5LC0H0iei9XBGHW2CFZU0yeP2zZCJQP9pC4m\",\n  \"note_html\": \"<body><p>call notes go here</p></body>\",\n  \"phone\": \"+16505551234\",\n  \"status\": \"completed\",\n  \"user_id\": \"user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.SetBasicAuth("<CLOSE_API_KEY>", "")
	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 activities.calls_create_example
require 'uri'
require 'net/http'

url = URI("https://api.close.com/api/v1/activity/call/")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request.basic_auth("<CLOSE_API_KEY>", "")
request["Content-Type"] = 'application/json'
request.body = "{\n  \"contact_id\": \"cont_bulY73zoaAwTCLdjHrKzGkzZ942OwtEelJR7kNku9RK\",\n  \"created_by\": \"user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA\",\n  \"direction\": \"outbound\",\n  \"duration\": 153,\n  \"lead_id\": \"lead_fioU1Nk5LC0H0iei9XBGHW2CFZU0yeP2zZCJQP9pC4m\",\n  \"note_html\": \"<body><p>call notes go here</p></body>\",\n  \"phone\": \"+16505551234\",\n  \"status\": \"completed\",\n  \"user_id\": \"user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA\"\n}"

response = http.request(request)
puts response.read_body
```

```java activities.calls_create_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.close.com/api/v1/activity/call/")
  .basicAuth("<CLOSE_API_KEY>", "")
  .header("Content-Type", "application/json")
  .body("{\n  \"contact_id\": \"cont_bulY73zoaAwTCLdjHrKzGkzZ942OwtEelJR7kNku9RK\",\n  \"created_by\": \"user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA\",\n  \"direction\": \"outbound\",\n  \"duration\": 153,\n  \"lead_id\": \"lead_fioU1Nk5LC0H0iei9XBGHW2CFZU0yeP2zZCJQP9pC4m\",\n  \"note_html\": \"<body><p>call notes go here</p></body>\",\n  \"phone\": \"+16505551234\",\n  \"status\": \"completed\",\n  \"user_id\": \"user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA\"\n}")
  .asString();
```

```php activities.calls_create_example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.close.com/api/v1/activity/call/', [
  'body' => '{
  "contact_id": "cont_bulY73zoaAwTCLdjHrKzGkzZ942OwtEelJR7kNku9RK",
  "created_by": "user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA",
  "direction": "outbound",
  "duration": 153,
  "lead_id": "lead_fioU1Nk5LC0H0iei9XBGHW2CFZU0yeP2zZCJQP9pC4m",
  "note_html": "<body><p>call notes go here</p></body>",
  "phone": "+16505551234",
  "status": "completed",
  "user_id": "user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA"
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
    'auth' => ['<CLOSE_API_KEY>', ''],
]);

echo $response->getBody();
```

```csharp activities.calls_create_example
using RestSharp;
using RestSharp.Authenticators;

var client = new RestClient("https://api.close.com/api/v1/activity/call/");
client.Authenticator = new HttpBasicAuthenticator("<CLOSE_API_KEY>", "");
var request = new RestRequest(Method.POST);

request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"contact_id\": \"cont_bulY73zoaAwTCLdjHrKzGkzZ942OwtEelJR7kNku9RK\",\n  \"created_by\": \"user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA\",\n  \"direction\": \"outbound\",\n  \"duration\": 153,\n  \"lead_id\": \"lead_fioU1Nk5LC0H0iei9XBGHW2CFZU0yeP2zZCJQP9pC4m\",\n  \"note_html\": \"<body><p>call notes go here</p></body>\",\n  \"phone\": \"+16505551234\",\n  \"status\": \"completed\",\n  \"user_id\": \"user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```