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

# Initiate a new bulk edit

POST https://api.close.com/api/v1/bulk_action/edit/
Content-Type: application/json

Pass additional parameters depending on which `type` is passed:

 - `set_lead_status` will set the Lead Status on all leads. It expects:
  - `lead_status_id` - ID of the Lead Status to use.
 - `clear_custom_field` will clear/remove/unset a specific custom field from all leads. It expects:
  - `custom_field_id` or `custom_field_name` - ID or exact name of the custom field to remove.
 - `set_custom_field` will set/update/add a specific custom field on all leads. It expects:
  - `custom_field_id` or `custom_field_name` - ID or exact name of the custom field to set/update.
  - `custom_field_value` - New value. Use `custom_field_values` to pass multiple values to custom fields that support it.
  - `custom_field_operation` - `replace`, `add`, or `remove` (defaults to `replace`). Only applicable for custom fields that accept multiple values.

Use `"send_done_email": false` if you don't want to get a confirmation email after the bulk action is done.

Reference: https://developer.close.com/api/resources/bulk-actions/edit/create

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: Close API
  version: 1.0.0
paths:
  /bulk_action/edit/:
    post:
      operationId: create
      summary: Initiate a new bulk edit
      description: >-
        Pass additional parameters depending on which `type` is passed:

         - `set_lead_status` will set the Lead Status on all leads. It expects:
          - `lead_status_id` - ID of the Lead Status to use.
         - `clear_custom_field` will clear/remove/unset a specific custom field from all leads. It expects:
          - `custom_field_id` or `custom_field_name` - ID or exact name of the custom field to remove.
         - `set_custom_field` will set/update/add a specific custom field on all leads. It expects:
          - `custom_field_id` or `custom_field_name` - ID or exact name of the custom field to set/update.
          - `custom_field_value` - New value. Use `custom_field_values` to pass multiple values to custom fields that support it.
          - `custom_field_operation` - `replace`, `add`, or `remove` (defaults to `replace`). Only applicable for custom fields that accept multiple values.

        Use `"send_done_email": false` if you don't want to get a confirmation
        email after the bulk action is done.
      tags:
        - subpackage_bulkActionsEdit
      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/BulkEditAction'
        '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:
              description: Any type
servers:
  - url: https://api.close.com/api/v1
components:
  schemas:
    BulkActionStatus:
      type: string
      enum:
        - created
        - loading
        - processing
        - done
        - paused
        - resuming
        - error
      title: BulkActionStatus
    BulkEditActionType:
      type: string
      enum:
        - set_custom_field
        - clear_custom_field
        - set_lead_status
        - set_contact_custom_field
        - clear_contact_custom_field
        - set_activity_custom_field
        - clear_activity_custom_field
        - set_global_custom_field
        - clear_global_custom_field
        - set_opportunity_custom_field
        - clear_opportunity_custom_field
        - set_custom_object_custom_field
        - clear_custom_object_custom_field
      title: BulkEditActionType
    BulkEditAction:
      type: object
      properties:
        created_by:
          type:
            - string
            - 'null'
        custom_field_name:
          type:
            - string
            - 'null'
        custom_field_value:
          type:
            - string
            - 'null'
        date_created:
          type:
            - string
            - 'null'
          format: date-time
        date_updated:
          type:
            - string
            - 'null'
          format: date-time
        id:
          type: string
        lead_status_id:
          type:
            - string
            - 'null'
        n_leads:
          type:
            - integer
            - 'null'
        n_leads_processed:
          type: integer
        n_objects:
          type:
            - integer
            - 'null'
        n_objects_processed:
          type: integer
        organization_id:
          type: string
        query:
          type:
            - string
            - 'null'
        results_limit:
          type:
            - integer
            - 'null'
        s_query:
          type: object
          additionalProperties:
            description: Any type
        send_done_email:
          type: boolean
        sort:
          type: array
          items:
            type: object
            additionalProperties:
              description: Any type
        status:
          oneOf:
            - $ref: '#/components/schemas/BulkActionStatus'
            - type: 'null'
        type:
          $ref: '#/components/schemas/BulkEditActionType'
        updated_by:
          type:
            - string
            - 'null'
      required:
        - created_by
        - custom_field_name
        - custom_field_value
        - date_created
        - date_updated
        - id
        - lead_status_id
        - n_leads
        - n_leads_processed
        - n_objects
        - n_objects_processed
        - organization_id
        - query
        - results_limit
        - s_query
        - send_done_email
        - sort
        - status
        - type
        - updated_by
      title: BulkEditAction
  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
import requests

url = "https://api.close.com/api/v1/bulk_action/edit/"

payload = {
    "lead_status_id": "stat_t7Zd2uspYPvBafR5bu9agrFZFs8GToWIbDnkqSk8nT8",
    "results_limit": None,
    "s_query": {
        "queries": [
            {
                "object_type": "lead",
                "type": "object_type"
            },
            {
                "condition": {
                    "mode": "full_words",
                    "type": "text",
                    "value": "ACME Inc."
                },
                "field": {
                    "field_name": "name",
                    "object_type": "lead",
                    "type": "regular_field"
                },
                "type": "field_condition"
            }
        ],
        "type": "and"
    },
    "sort": [
        {
            "direction": "desc",
            "field": {
                "field_name": "date_created",
                "object_type": "lead",
                "type": "regular_field"
            }
        }
    ],
    "type": "set_lead_status"
}
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/bulk_action/edit/';
const credentials = btoa("<CLOSE_API_KEY>:");

const options = {
  method: 'POST',
  headers: {Authorization: `Basic ${credentials}`, 'Content-Type': 'application/json'},
  body: '{"lead_status_id":"stat_t7Zd2uspYPvBafR5bu9agrFZFs8GToWIbDnkqSk8nT8","results_limit":null,"s_query":{"queries":[{"object_type":"lead","type":"object_type"},{"condition":{"mode":"full_words","type":"text","value":"ACME Inc."},"field":{"field_name":"name","object_type":"lead","type":"regular_field"},"type":"field_condition"}],"type":"and"},"sort":[{"direction":"desc","field":{"field_name":"date_created","object_type":"lead","type":"regular_field"}}],"type":"set_lead_status"}'
};

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/bulk_action/edit/"

	payload := strings.NewReader("{\n  \"lead_status_id\": \"stat_t7Zd2uspYPvBafR5bu9agrFZFs8GToWIbDnkqSk8nT8\",\n  \"results_limit\": null,\n  \"s_query\": {\n    \"queries\": [\n      {\n        \"object_type\": \"lead\",\n        \"type\": \"object_type\"\n      },\n      {\n        \"condition\": {\n          \"mode\": \"full_words\",\n          \"type\": \"text\",\n          \"value\": \"ACME Inc.\"\n        },\n        \"field\": {\n          \"field_name\": \"name\",\n          \"object_type\": \"lead\",\n          \"type\": \"regular_field\"\n        },\n        \"type\": \"field_condition\"\n      }\n    ],\n    \"type\": \"and\"\n  },\n  \"sort\": [\n    {\n      \"direction\": \"desc\",\n      \"field\": {\n        \"field_name\": \"date_created\",\n        \"object_type\": \"lead\",\n        \"type\": \"regular_field\"\n      }\n    }\n  ],\n  \"type\": \"set_lead_status\"\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/bulk_action/edit/")

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  \"lead_status_id\": \"stat_t7Zd2uspYPvBafR5bu9agrFZFs8GToWIbDnkqSk8nT8\",\n  \"results_limit\": null,\n  \"s_query\": {\n    \"queries\": [\n      {\n        \"object_type\": \"lead\",\n        \"type\": \"object_type\"\n      },\n      {\n        \"condition\": {\n          \"mode\": \"full_words\",\n          \"type\": \"text\",\n          \"value\": \"ACME Inc.\"\n        },\n        \"field\": {\n          \"field_name\": \"name\",\n          \"object_type\": \"lead\",\n          \"type\": \"regular_field\"\n        },\n        \"type\": \"field_condition\"\n      }\n    ],\n    \"type\": \"and\"\n  },\n  \"sort\": [\n    {\n      \"direction\": \"desc\",\n      \"field\": {\n        \"field_name\": \"date_created\",\n        \"object_type\": \"lead\",\n        \"type\": \"regular_field\"\n      }\n    }\n  ],\n  \"type\": \"set_lead_status\"\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/bulk_action/edit/")
  .basicAuth("<CLOSE_API_KEY>", "")
  .header("Content-Type", "application/json")
  .body("{\n  \"lead_status_id\": \"stat_t7Zd2uspYPvBafR5bu9agrFZFs8GToWIbDnkqSk8nT8\",\n  \"results_limit\": null,\n  \"s_query\": {\n    \"queries\": [\n      {\n        \"object_type\": \"lead\",\n        \"type\": \"object_type\"\n      },\n      {\n        \"condition\": {\n          \"mode\": \"full_words\",\n          \"type\": \"text\",\n          \"value\": \"ACME Inc.\"\n        },\n        \"field\": {\n          \"field_name\": \"name\",\n          \"object_type\": \"lead\",\n          \"type\": \"regular_field\"\n        },\n        \"type\": \"field_condition\"\n      }\n    ],\n    \"type\": \"and\"\n  },\n  \"sort\": [\n    {\n      \"direction\": \"desc\",\n      \"field\": {\n        \"field_name\": \"date_created\",\n        \"object_type\": \"lead\",\n        \"type\": \"regular_field\"\n      }\n    }\n  ],\n  \"type\": \"set_lead_status\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.close.com/api/v1/bulk_action/edit/', [
  'body' => '{
  "lead_status_id": "stat_t7Zd2uspYPvBafR5bu9agrFZFs8GToWIbDnkqSk8nT8",
  "results_limit": null,
  "s_query": {
    "queries": [
      {
        "object_type": "lead",
        "type": "object_type"
      },
      {
        "condition": {
          "mode": "full_words",
          "type": "text",
          "value": "ACME Inc."
        },
        "field": {
          "field_name": "name",
          "object_type": "lead",
          "type": "regular_field"
        },
        "type": "field_condition"
      }
    ],
    "type": "and"
  },
  "sort": [
    {
      "direction": "desc",
      "field": {
        "field_name": "date_created",
        "object_type": "lead",
        "type": "regular_field"
      }
    }
  ],
  "type": "set_lead_status"
}',
  '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/bulk_action/edit/");
client.Authenticator = new HttpBasicAuthenticator("<CLOSE_API_KEY>", "");
var request = new RestRequest(Method.POST);

request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"lead_status_id\": \"stat_t7Zd2uspYPvBafR5bu9agrFZFs8GToWIbDnkqSk8nT8\",\n  \"results_limit\": null,\n  \"s_query\": {\n    \"queries\": [\n      {\n        \"object_type\": \"lead\",\n        \"type\": \"object_type\"\n      },\n      {\n        \"condition\": {\n          \"mode\": \"full_words\",\n          \"type\": \"text\",\n          \"value\": \"ACME Inc.\"\n        },\n        \"field\": {\n          \"field_name\": \"name\",\n          \"object_type\": \"lead\",\n          \"type\": \"regular_field\"\n        },\n        \"type\": \"field_condition\"\n      }\n    ],\n    \"type\": \"and\"\n  },\n  \"sort\": [\n    {\n      \"direction\": \"desc\",\n      \"field\": {\n        \"field_name\": \"date_created\",\n        \"object_type\": \"lead\",\n        \"type\": \"regular_field\"\n      }\n    }\n  ],\n  \"type\": \"set_lead_status\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```