> 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

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: Close API
  version: 1.0.0
paths:
  /activity/call/:
    post:
      operationId: create
      summary: Log an external Call activity
      description: >-
        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://)
      tags:
        - subpackage_activitiesCalls
      parameters:
        - name: Authorization
          in: header
          description: Use your API key as the username and leave the password empty.
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CallActivity'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                description: Any type
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                description: Any type
        '404':
          description: Not found
          content:
            application/json:
              schema:
                description: Any type
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateCallActivity'
servers:
  - url: https://api.close.com/api/v1
components:
  schemas:
    CreateCallActivityDirection:
      type: string
      enum:
        - inbound
        - outbound
      title: CreateCallActivityDirection
    CreateCallActivitySource:
      type: string
      enum:
        - Close.io
        - External
      title: CreateCallActivitySource
    CreateCallActivityStatus:
      type: string
      enum:
        - created
        - in-progress
        - completed
        - cancel
        - no-answer
        - busy
        - failed
        - timeout
      title: CreateCallActivityStatus
    CreateCallActivity:
      type: object
      properties:
        activity_at:
          type:
            - string
            - 'null'
          format: date-time
        contact_id:
          type:
            - string
            - 'null'
        conversation_type_id:
          type:
            - string
            - 'null'
        created_by_id:
          type:
            - string
            - 'null'
        custom_fields:
          type:
            - object
            - 'null'
          additionalProperties:
            description: Any type
        date_created:
          type:
            - string
            - 'null'
          format: date-time
        direction:
          $ref: '#/components/schemas/CreateCallActivityDirection'
        duration:
          type:
            - integer
            - 'null'
        lead_id:
          type:
            - string
            - 'null'
        note:
          type:
            - string
            - 'null'
        note_html:
          type:
            - string
            - 'null'
        organization_id:
          type:
            - string
            - 'null'
        outcome_id:
          type:
            - string
            - 'null'
        phone:
          type:
            - string
            - 'null'
          description: Phone number in E.164 format
        playbook_id:
          type:
            - string
            - 'null'
        quality_info:
          type:
            - string
            - 'null'
        recording_url:
          type:
            - string
            - 'null'
          format: uri
        source:
          $ref: '#/components/schemas/CreateCallActivitySource'
        status:
          $ref: '#/components/schemas/CreateCallActivityStatus'
        user_id:
          type:
            - string
            - 'null'
        voicemail_url:
          type:
            - string
            - 'null'
          format: uri
      title: CreateCallActivity
    PhoneActivitySource:
      type: string
      enum:
        - Close.io
        - External
      description: >-
        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.
      title: PhoneActivitySource
    CallStatus:
      type: string
      enum:
        - created
        - in-progress
        - completed
        - cancel
        - no-answer
        - busy
        - failed
        - timeout
      description: Current status of the call.
      title: CallStatus
    CallActivity:
      type: object
      properties:
        _type:
          type: string
        activity_at:
          type:
            - string
            - 'null'
          format: date-time
        contact_id:
          type:
            - string
            - 'null'
        created_by:
          type:
            - string
            - 'null'
        created_by_name:
          type:
            - string
            - 'null'
        date_created:
          type: string
          format: date-time
        date_updated:
          type: string
          format: date-time
        id:
          type: string
        lead_id:
          type:
            - string
            - 'null'
        organization_id:
          type: string
        outcome_id:
          type:
            - string
            - 'null'
        sequence_id:
          type:
            - string
            - 'null'
        sequence_name:
          type:
            - string
            - 'null'
        sequence_subscription_id:
          type:
            - string
            - 'null'
        source:
          $ref: '#/components/schemas/PhoneActivitySource'
        status:
          $ref: '#/components/schemas/CallStatus'
        updated_by:
          type:
            - string
            - 'null'
        updated_by_name:
          type:
            - string
            - 'null'
        user_id:
          type:
            - string
            - 'null'
        user_name:
          type:
            - string
            - 'null'
        users:
          type: array
          items:
            type: string
      required:
        - _type
        - activity_at
        - contact_id
        - created_by
        - date_created
        - date_updated
        - id
        - lead_id
        - organization_id
        - outcome_id
        - source
        - status
        - updated_by
        - user_id
        - users
      title: CallActivity
  securitySchemes:
    ApiKeyAuth:
      type: http
      scheme: basic
      description: Use your API key as the username and leave the password empty.
    OAuth2:
      type: http
      scheme: bearer

```

## SDK Code Examples

```python activities.calls_create_example
import requests

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

payload = {
    "contact_id": "cont_bulY73zoaAwTCLdjHrKzGkzZ942OwtEelJR7kNku9RK",
    "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",
    "created_by": "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","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","created_by":"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  \"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  \"created_by\": \"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  \"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  \"created_by\": \"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  \"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  \"created_by\": \"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",
  "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",
  "created_by": "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  \"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  \"created_by\": \"user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```