> For a complete page index, fetch https://developer.close.com/llms.txt # Update an opportunity PUT https://api.close.com/api/v1/opportunity/{id}/ Content-Type: application/json **custom.FIELD\_ID** (optional) * See description for `custom.FIELD_ID` in `POST /opportunity/` above. * Additionally, you can unset a single field by using `{ "custom.FIELD_ID": null }`, e.g.: ``` { "custom.cf_v6S011I6MqcbVvB2FA5Nk8dr5MkL8sWuCiG8cUleO9c": null } ``` If you're trying to update a custom field and that custom field accepts multiple values, you can also specify `.add` or `.remove` as part of the field key to add/remove a single value to/from a list of values, e.g.: ``` { "custom.cf_v6S011I6MqcbVvB2FA5Nk8dr5MkL8sWuCiG8cUleO9c.add": "Wednesday" } ``` Reference: https://developer.close.com/api/resources/opportunities/update ## 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 ### Path parameters - `id` (string, required) ### Body (application/json) This endpoint expects an UpdateOpportunity. - `attachments` (list of AttachmentIn, optional) - `confidence` (integer, optional) - `contact_id` (string, optional, nullable) - `date_won` (datetime, optional, nullable) — If not set on the resource or in the request, `date_won` will be set automatically to today's date when setting `status_id` to a status with type `won`. The `x-tz-offset` header, used to pass your timezone's UTC offset, will be taken into account. - `note` (string, optional) — Plaintext/markdown version of the note. If `note_html` is also provided in the same request, this value is ignored and `note` is derived from the HTML instead. - `note_html` (string, optional, nullable) — Rich-text HTML version of the note. When set, `note` is automatically populated with the plaintext version (tags become markdown), overriding any `note` value passed in the same request. Pass `null` to clear `note_html`; `note` is cleared as well. - `status` (string, optional) - `status_id` (string, optional) — Setting the `status_id` to a status with a type of `won` will automatically set the `date_won` field if it is not already set or provided in the request. Reverting it from a `won` status to an `active` or `lost` will not automatically change `date_won`. - `user_id` (string, optional, nullable) - `value` (integer, optional) - `value_period` (enum, optional) - Allowed values: `one_time`, `monthly`, `annual` ## Response ### 200 Successful response - `annualized_expected_value` (integer, required, nullable) - `annualized_value` (integer, required, nullable) - `confidence` (integer, required) - `contact_id` (string, required, nullable) - `created_by` (string, required, nullable) - `date_created` (datetime, required) - `date_lost` (datetime, required, nullable) - `date_updated` (datetime, required) - `date_won` (date, required, nullable) - `expected_value` (integer, required, nullable) - `id` (string, required) - `lead_id` (string, required) - `note` (string, required, nullable) - `note_html` (string, required, nullable) - `organization_id` (string, required) - `status_id` (string, required) - `updated_by` (string, required, nullable) - `user_id` (string, required) - `value` (integer, required, nullable) - `value_period` (enum, required) - Allowed values: `one_time`, `monthly`, `annual` - `attachments` (list of Attachment, optional) - `comment_summary` (CommentSummary, optional, nullable) - `contact_name` (string, optional, nullable) - `created_by_name` (string, optional, nullable) - `integration_links` (list of RenderedIntegrationLink, optional) - `is_stalled` (boolean, optional) - `lead_name` (string, optional, nullable) - `lead_primary_email` (ContactEmail, optional, nullable) - `lead_primary_phone` (list of ContactPhone, optional, nullable) - `pipeline_id` (string, optional, nullable) - `pipeline_name` (string, optional, nullable) - `stall_status` (StalledOpportunityActionItems, optional, nullable) - `status_display_name` (string, optional) - `status_label` (string, optional) - `status_type` (enum, optional) - Allowed values: `won`, `lost`, `active` - `suggested_action` (OpportunitySuggestedAction, optional, nullable) - `updated_by_name` (string, optional, nullable) - `user_name` (string, optional, nullable) - `value_currency` (string, optional, nullable) - `value_formatted` (string, optional, nullable) ## Errors ### 400 Bad Request Error Bad request - `any` ### 401 Unauthorized Error Unauthorized - `any` ### 404 Not Found Error Not found - `any` ## Types ### AttachmentIn - `filename` (string, required) - `url` (string, required) - `content_type` (string, optional, default: ) ### Attachment - `content_type` (string, required, nullable) - `filename` (string, required, nullable) - `size` (integer, required, nullable) - `url` (string, required) - `thumbnail_url` (string, optional, nullable) ### CommentSummary - `comment_count` (integer, required) - `thread_id` (string, required) ### RenderedIntegrationLink - `name` (string, required) - `url` (string, required) ### ContactEmail - `email` (string, required) - `is_unsubscribed` (boolean, required) - `type` (string, required) ### ContactPhone - `phone` (string, required) - `type` (string, required) - `country` (string, optional, nullable) - `outbound_sms_blocked` (boolean, optional) - `phone_formatted` (string, optional) - `tz_ids` (list of string, optional) ### StalledOpportunityActionItems - `communication_issue` (enum, required) — The communication issue that is causing the stalled opportunity. If there is no issue, set to NoIssue. - Allowed values: `no_issue`, `cant_get_in_touch`, `no_communication_attempts` - `next_action` (ActionItem, required, deprecated) — An action item recommended to progress or resolve the stalled opportunity. ### OpportunitySuggestedAction - `action` (enum, required) - Allowed values: `change_status`, `adjust_close_date`, `follow_up_email`, `follow_up_call`, `follow_up_sms` - `details` (OpportunitySuggestedActionDetails, required, nullable) - `justification` (string, required) ### ActionItem - `action` (enum, required) — The recommended next step to progress or resolve the stalled opportunity - Allowed values: `mark_as_lost`, `change_status`, `follow_up`, `adjust_close_date`, `ask_someone_else_to_reach_out`, `change_communication_method` - `justification` (string, required) — A short justification for the recommended action in the sales pipeline. Maximum 2 sentences. ### OpportunitySuggestedActionDetails ### OpportunityChangeStatusActionDetails - `status_id` (string, required) ### OpportunityFollowUpEmailActionDetails - `contact_id` (string, required) - `message_draft` (string, required) - `subject_draft` (string, required) ### OpportunityFollowUpSMSActionDetails - `contact_id` (string, required) - `message_draft` (string, required) ### OpportunityFollowUpCallActionDetails - `call_plan` (string, required) - `contact_id` (string, required) ### OpportunityAdjustCloseDateActionDetails - `close_date` (date, required) ## Examples **Request** ```json { "status_id": "stat_5ZdiZqcSIkoGVnNOyxiEY58eTGQmFNG3LPlEVQ4V7Nk" } ``` **Response** ```json { "annualized_expected_value": 37500, "annualized_value": 50000, "confidence": 75, "contact_id": null, "created_by": "user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA", "date_created": "2013-02-01T00:54:51.337000+00:00", "date_lost": null, "date_updated": "2013-02-20T10:06:25.248000+00:00", "date_won": "2013-02-20", "expected_value": 37500, "id": "oppo_8eB77gAdf8FMy6GsNHEy84f7uoeEWv55slvUjKQZpJt", "lead_id": "lead_IIDHIStmFcFQZZP0BRe99V1MCoXWz2PGCm6EDmR9v2O", "note": "Bruce needs new software for the Bat Cave.", "note_html": "

Bruce needs new software for the Bat Cave.

", "organization_id": "orga_RbREgmiiwcr1w2b4cOnCMQaQPSIFxMqAD2Dh243uxcH", "status_id": "stat_5ZdiZqcSIkoGVnNOyxiEY58eTGQmFNG3LPlEVQ4V7Nk", "updated_by": "user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA", "user_id": "user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA", "value": 50000, "value_period": "one_time", "lead_name": "Wayne Enterprises (Sample Lead)", "pipeline_id": "pipe_04fC628PVB0HjK2Qq5EqEf", "pipeline_name": "Sales", "status_label": "Won", "status_type": "won", "user_name": "John Doe", "value_currency": "USD", "value_formatted": "$500" } ``` **SDK Code** ```python opportunities_update_example import requests url = "https://api.close.com/api/v1/opportunity/id/" payload = { "status_id": "stat_5ZdiZqcSIkoGVnNOyxiEY58eTGQmFNG3LPlEVQ4V7Nk" } headers = { "Content-Type": "application/json" } response = requests.put(url, json=payload, headers=headers, auth=("", "")) print(response.json()) ``` ```javascript opportunities_update_example const url = 'https://api.close.com/api/v1/opportunity/id/'; const credentials = btoa(":"); const options = { method: 'PUT', headers: {Authorization: `Basic ${credentials}`, 'Content-Type': 'application/json'}, body: '{"status_id":"stat_5ZdiZqcSIkoGVnNOyxiEY58eTGQmFNG3LPlEVQ4V7Nk"}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go opportunities_update_example package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.close.com/api/v1/opportunity/id/" payload := strings.NewReader("{\n \"status_id\": \"stat_5ZdiZqcSIkoGVnNOyxiEY58eTGQmFNG3LPlEVQ4V7Nk\"\n}") req, _ := http.NewRequest("PUT", 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 opportunities_update_example require 'uri' require 'net/http' url = URI("https://api.close.com/api/v1/opportunity/id/") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Put.new(url) request.basic_auth("", "") request["Content-Type"] = 'application/json' request.body = "{\n \"status_id\": \"stat_5ZdiZqcSIkoGVnNOyxiEY58eTGQmFNG3LPlEVQ4V7Nk\"\n}" response = http.request(request) puts response.read_body ``` ```java opportunities_update_example import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.put("https://api.close.com/api/v1/opportunity/id/") .basicAuth("", "") .header("Content-Type", "application/json") .body("{\n \"status_id\": \"stat_5ZdiZqcSIkoGVnNOyxiEY58eTGQmFNG3LPlEVQ4V7Nk\"\n}") .asString(); ``` ```php opportunities_update_example request('PUT', 'https://api.close.com/api/v1/opportunity/id/', [ 'body' => '{ "status_id": "stat_5ZdiZqcSIkoGVnNOyxiEY58eTGQmFNG3LPlEVQ4V7Nk" }', 'headers' => [ 'Content-Type' => 'application/json', ], 'auth' => ['', ''], ]); echo $response->getBody(); ``` ```csharp opportunities_update_example using RestSharp; using RestSharp.Authenticators; var client = new RestClient("https://api.close.com/api/v1/opportunity/id/"); client.Authenticator = new HttpBasicAuthenticator("", ""); var request = new RestRequest(Method.PUT); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"status_id\": \"stat_5ZdiZqcSIkoGVnNOyxiEY58eTGQmFNG3LPlEVQ4V7Nk\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ```