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

# Enrich a specific field on a lead or contact using AI

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

This endpoint uses AI to enrich (populate or enhance) a specific field on a lead or contact. The enrichment process analyzes existing data and external sources to provide intelligent field values.

**Parameters:**
- `organization_id` (required): The organization ID
- `object_type` (required): Either "lead" or "contact"
- `object_id` (required): The ID of the lead or contact to enrich
- `field_id` (required): The ID of the custom field to enrich
- `set_new_value` (optional): Whether to update the field with the enriched value (default: true)
- `overwrite_existing_value` (optional): Whether to overwrite existing field values (default: false)

Reference: https://developer.close.com/api/resources/field-enrichment/create

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: Close API
  version: 1.0.0
paths:
  /enrich_field/:
    post:
      operationId: create
      summary: Enrich a specific field on a lead or contact using AI
      description: >-
        This endpoint uses AI to enrich (populate or enhance) a specific field
        on a lead or contact. The enrichment process analyzes existing data and
        external sources to provide intelligent field values.


        **Parameters:**

        - `organization_id` (required): The organization ID

        - `object_type` (required): Either "lead" or "contact"

        - `object_id` (required): The ID of the lead or contact to enrich

        - `field_id` (required): The ID of the custom field to enrich

        - `set_new_value` (optional): Whether to update the field with the
        enriched value (default: true)

        - `overwrite_existing_value` (optional): Whether to overwrite existing
        field values (default: false)
      tags:
        - subpackage_fieldEnrichment
      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/field_enrichment_create_Response_200'
        '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/RunFieldEnrichment'
servers:
  - url: https://api.close.com/api/v1
components:
  schemas:
    RunFieldEnrichmentObjectType:
      type: string
      enum:
        - lead
        - contact
      title: RunFieldEnrichmentObjectType
    RunFieldEnrichment:
      type: object
      properties:
        field_id:
          type: string
        object_id:
          type: string
        object_type:
          $ref: '#/components/schemas/RunFieldEnrichmentObjectType'
        organization_id:
          type: string
        overwrite_existing_value:
          type: boolean
          default: false
        set_new_value:
          type: boolean
          default: true
      required:
        - field_id
        - object_id
        - object_type
        - organization_id
      title: RunFieldEnrichment
    field_enrichment_create_Response_200:
      type: object
      properties: {}
      description: Empty response body
      title: field_enrichment_create_Response_200
  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 field_enrichment_create_example
import requests

url = "https://api.close.com/api/v1/enrich_field/"

payload = {
    "field_id": "cf_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA",
    "object_id": "lead_s6vHFTK1TSRoH6otXOexWDO9jM4xyb1kELHDoU7Fdsp",
    "object_type": "lead",
    "organization_id": "orga_RbREgmiiwcr1w2b4cOnCMQaQPSIFxMqAD2Dh243uxcH",
    "overwrite_existing_value": False,
    "set_new_value": True
}
headers = {
    "Content-Type": "application/json"
}

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

print(response.json())
```

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

const options = {
  method: 'POST',
  headers: {Authorization: `Basic ${credentials}`, 'Content-Type': 'application/json'},
  body: '{"field_id":"cf_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA","object_id":"lead_s6vHFTK1TSRoH6otXOexWDO9jM4xyb1kELHDoU7Fdsp","object_type":"lead","organization_id":"orga_RbREgmiiwcr1w2b4cOnCMQaQPSIFxMqAD2Dh243uxcH","overwrite_existing_value":false,"set_new_value":true}'
};

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

```go field_enrichment_create_example
package main

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

func main() {

	url := "https://api.close.com/api/v1/enrich_field/"

	payload := strings.NewReader("{\n  \"field_id\": \"cf_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA\",\n  \"object_id\": \"lead_s6vHFTK1TSRoH6otXOexWDO9jM4xyb1kELHDoU7Fdsp\",\n  \"object_type\": \"lead\",\n  \"organization_id\": \"orga_RbREgmiiwcr1w2b4cOnCMQaQPSIFxMqAD2Dh243uxcH\",\n  \"overwrite_existing_value\": false,\n  \"set_new_value\": true\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 field_enrichment_create_example
require 'uri'
require 'net/http'

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

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  \"field_id\": \"cf_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA\",\n  \"object_id\": \"lead_s6vHFTK1TSRoH6otXOexWDO9jM4xyb1kELHDoU7Fdsp\",\n  \"object_type\": \"lead\",\n  \"organization_id\": \"orga_RbREgmiiwcr1w2b4cOnCMQaQPSIFxMqAD2Dh243uxcH\",\n  \"overwrite_existing_value\": false,\n  \"set_new_value\": true\n}"

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

```java field_enrichment_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/enrich_field/")
  .basicAuth("<CLOSE_API_KEY>", "")
  .header("Content-Type", "application/json")
  .body("{\n  \"field_id\": \"cf_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA\",\n  \"object_id\": \"lead_s6vHFTK1TSRoH6otXOexWDO9jM4xyb1kELHDoU7Fdsp\",\n  \"object_type\": \"lead\",\n  \"organization_id\": \"orga_RbREgmiiwcr1w2b4cOnCMQaQPSIFxMqAD2Dh243uxcH\",\n  \"overwrite_existing_value\": false,\n  \"set_new_value\": true\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.close.com/api/v1/enrich_field/', [
  'body' => '{
  "field_id": "cf_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA",
  "object_id": "lead_s6vHFTK1TSRoH6otXOexWDO9jM4xyb1kELHDoU7Fdsp",
  "object_type": "lead",
  "organization_id": "orga_RbREgmiiwcr1w2b4cOnCMQaQPSIFxMqAD2Dh243uxcH",
  "overwrite_existing_value": false,
  "set_new_value": true
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
    'auth' => ['<CLOSE_API_KEY>', ''],
]);

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

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

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

request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"field_id\": \"cf_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA\",\n  \"object_id\": \"lead_s6vHFTK1TSRoH6otXOexWDO9jM4xyb1kELHDoU7Fdsp\",\n  \"object_type\": \"lead\",\n  \"organization_id\": \"orga_RbREgmiiwcr1w2b4cOnCMQaQPSIFxMqAD2Dh243uxcH\",\n  \"overwrite_existing_value\": false,\n  \"set_new_value\": true\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```