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

# Create a new OpportunityStatusChange activity

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

Creating an opportunity status change does not change the opportunity's status. It only logs the status change event. This should only be used to import historical status changes from another system.

Reference: https://developer.close.com/api/resources/activities/opportunity-status-changes/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 any.

- `any`

## 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)
- `new_status_id` (string, required)
- `old_status_id` (string, required)
- `opportunity_id` (string, required, nullable)
- `organization_id` (string, required)
- `updated_by` (string, required, nullable)
- `user_id` (string, required, nullable)
- `users` (list of string, required)
- `created_by_name` (string, optional, nullable)
- `new_pipeline_id` (string, optional)
- `new_pipeline_name` (string, optional)
- `new_status_label` (string, optional)
- `new_status_type` (enum, optional)
  - Allowed values: `won`, `lost`, `active`
- `old_pipeline_id` (string, optional)
- `old_pipeline_name` (string, optional)
- `old_status_label` (string, optional)
- `old_status_type` (enum, optional)
  - Allowed values: `won`, `lost`, `active`
- `opportunity_confidence` (integer, optional, nullable)
- `opportunity_date_won` (datetime, optional, nullable)
- `opportunity_value` (integer, optional, nullable)
- `opportunity_value_currency` (string, optional, nullable)
- `opportunity_value_formatted` (string, optional, nullable)
- `opportunity_value_period` (enum, optional, nullable)
  - Allowed values: `one_time`, `monthly`, `annual`
- `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
{
  "date_created": "2013-08-23T20:57:45.956000+00:00",
  "lead_id": "lead_fioU1Nk5LC0H0iei9XBGHW2CFZU0yeP2zZCJQP9pC4m",
  "new_status_id": "stat_DetsqwxFOOHx2JnhqtovutN3zeuARGfzB21x5t1W88G",
  "old_status_id": "stat_ue534UFRaocoMJJA9CYCwnMsRJP2qt6YGnpZOAx7ckK",
  "opportunity_id": "oppo_fn2kSFXS06akJ7XisR7vQQeObyK4upCc43RiAx1Vyz6"
}
```

**Response**

```json
{
  "_type": "OpportunityStatusChange",
  "activity_at": "2013-08-23T21:21:11.862000+00:00",
  "contact_id": null,
  "created_by": "user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA",
  "date_created": "2013-08-23T21:21:11.862000+00:00",
  "date_updated": "2013-08-23T21:21:11.862000+00:00",
  "id": "acti_CAI2lO44gRLMIvgsKfPZghRyuv1h8S3l7c4cDznXukd",
  "lead_id": "lead_0VaTsortzKpCv1ik6hbNoudduuD0m2Itevet0fKX39G",
  "new_status_id": "stat_DetsqwxFOOHx2JnhqtovutN3zeuARGfzB21x5t1W88G",
  "old_status_id": "stat_ue534UFRaocoMJJA9CYCwnMsRJP2qt6YGnpZOAx7ckK",
  "opportunity_id": "oppo_fn2kSFXS06akJ7XisR7vQQeObyK4upCc43RiAx1Vyz6",
  "organization_id": "orga_RbREgmiiwcr1w2b4cOnCMQaQPSIFxMqAD2Dh243uxcH",
  "updated_by": "user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA",
  "user_id": "user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA",
  "users": [],
  "created_by_name": "Anthony Nemitz",
  "new_pipeline_id": "pipe_6gV01if4wo7r2YTVQDWP2j",
  "new_pipeline_name": "Sales",
  "new_status_label": "Won",
  "new_status_type": "won",
  "old_pipeline_id": "pipe_6gV01if4wo7r2YTVQDWP2j",
  "old_pipeline_name": "Sales",
  "old_status_label": "Active",
  "old_status_type": "active",
  "opportunity_confidence": 100,
  "opportunity_date_won": "2013-08-23T00:00:00+00:00",
  "opportunity_value": 0,
  "opportunity_value_currency": "USD",
  "opportunity_value_formatted": null,
  "opportunity_value_period": "one_time",
  "updated_by_name": "Anthony Nemitz",
  "user_name": "Anthony Nemitz"
}
```

**SDK Code**

```python
import requests

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

payload = {
    "date_created": "2013-08-23T20:57:45.956000+00:00",
    "lead_id": "lead_fioU1Nk5LC0H0iei9XBGHW2CFZU0yeP2zZCJQP9pC4m",
    "new_status_id": "stat_DetsqwxFOOHx2JnhqtovutN3zeuARGfzB21x5t1W88G",
    "old_status_id": "stat_ue534UFRaocoMJJA9CYCwnMsRJP2qt6YGnpZOAx7ckK",
    "opportunity_id": "oppo_fn2kSFXS06akJ7XisR7vQQeObyK4upCc43RiAx1Vyz6"
}
headers = {
    "Content-Type": "application/json"
}

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

print(response.json())
```

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

const options = {
  method: 'POST',
  headers: {Authorization: `Basic ${credentials}`, 'Content-Type': 'application/json'},
  body: '{"date_created":"2013-08-23T20:57:45.956000+00:00","lead_id":"lead_fioU1Nk5LC0H0iei9XBGHW2CFZU0yeP2zZCJQP9pC4m","new_status_id":"stat_DetsqwxFOOHx2JnhqtovutN3zeuARGfzB21x5t1W88G","old_status_id":"stat_ue534UFRaocoMJJA9CYCwnMsRJP2qt6YGnpZOAx7ckK","opportunity_id":"oppo_fn2kSFXS06akJ7XisR7vQQeObyK4upCc43RiAx1Vyz6"}'
};

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/activity/status_change/opportunity/"

	payload := strings.NewReader("{\n  \"date_created\": \"2013-08-23T20:57:45.956000+00:00\",\n  \"lead_id\": \"lead_fioU1Nk5LC0H0iei9XBGHW2CFZU0yeP2zZCJQP9pC4m\",\n  \"new_status_id\": \"stat_DetsqwxFOOHx2JnhqtovutN3zeuARGfzB21x5t1W88G\",\n  \"old_status_id\": \"stat_ue534UFRaocoMJJA9CYCwnMsRJP2qt6YGnpZOAx7ckK\",\n  \"opportunity_id\": \"oppo_fn2kSFXS06akJ7XisR7vQQeObyK4upCc43RiAx1Vyz6\"\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
require 'uri'
require 'net/http'

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

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  \"date_created\": \"2013-08-23T20:57:45.956000+00:00\",\n  \"lead_id\": \"lead_fioU1Nk5LC0H0iei9XBGHW2CFZU0yeP2zZCJQP9pC4m\",\n  \"new_status_id\": \"stat_DetsqwxFOOHx2JnhqtovutN3zeuARGfzB21x5t1W88G\",\n  \"old_status_id\": \"stat_ue534UFRaocoMJJA9CYCwnMsRJP2qt6YGnpZOAx7ckK\",\n  \"opportunity_id\": \"oppo_fn2kSFXS06akJ7XisR7vQQeObyK4upCc43RiAx1Vyz6\"\n}"

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

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

HttpResponse<String> response = Unirest.post("https://api.close.com/api/v1/activity/status_change/opportunity/")
  .basicAuth("<CLOSE_API_KEY>", "")
  .header("Content-Type", "application/json")
  .body("{\n  \"date_created\": \"2013-08-23T20:57:45.956000+00:00\",\n  \"lead_id\": \"lead_fioU1Nk5LC0H0iei9XBGHW2CFZU0yeP2zZCJQP9pC4m\",\n  \"new_status_id\": \"stat_DetsqwxFOOHx2JnhqtovutN3zeuARGfzB21x5t1W88G\",\n  \"old_status_id\": \"stat_ue534UFRaocoMJJA9CYCwnMsRJP2qt6YGnpZOAx7ckK\",\n  \"opportunity_id\": \"oppo_fn2kSFXS06akJ7XisR7vQQeObyK4upCc43RiAx1Vyz6\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.close.com/api/v1/activity/status_change/opportunity/', [
  'body' => '{
  "date_created": "2013-08-23T20:57:45.956000+00:00",
  "lead_id": "lead_fioU1Nk5LC0H0iei9XBGHW2CFZU0yeP2zZCJQP9pC4m",
  "new_status_id": "stat_DetsqwxFOOHx2JnhqtovutN3zeuARGfzB21x5t1W88G",
  "old_status_id": "stat_ue534UFRaocoMJJA9CYCwnMsRJP2qt6YGnpZOAx7ckK",
  "opportunity_id": "oppo_fn2kSFXS06akJ7XisR7vQQeObyK4upCc43RiAx1Vyz6"
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
    'auth' => ['<CLOSE_API_KEY>', ''],
]);

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

```csharp
using RestSharp;
using RestSharp.Authenticators;

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

request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"date_created\": \"2013-08-23T20:57:45.956000+00:00\",\n  \"lead_id\": \"lead_fioU1Nk5LC0H0iei9XBGHW2CFZU0yeP2zZCJQP9pC4m\",\n  \"new_status_id\": \"stat_DetsqwxFOOHx2JnhqtovutN3zeuARGfzB21x5t1W88G\",\n  \"old_status_id\": \"stat_ue534UFRaocoMJJA9CYCwnMsRJP2qt6YGnpZOAx7ckK\",\n  \"opportunity_id\": \"oppo_fn2kSFXS06akJ7XisR7vQQeObyK4upCc43RiAx1Vyz6\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```