> ## Documentation Index
> Fetch the complete documentation index at: https://docs.naturalead.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Update Custom Fields

> Merges custom fields into the lead. Set a field value to `null` to
delete that field.
Requires `leads:import` permission.




## OpenAPI

````yaml PATCH /api/leads/{id}/custom-fields
openapi: 3.1.0
info:
  title: Naturalead Leads API
  version: 1.0.0
  description: |
    API for managing leads in the Naturalead platform. All endpoints require
    API key authentication and are scoped to the caller's account.
servers:
  - url: '{baseUrl}'
    description: API server
    variables:
      baseUrl:
        default: http://localhost:3001
security:
  - ApiKeyAuth: []
  - BearerAuth: []
tags:
  - name: Leads
    description: Lead CRUD, search, filtering, and bulk operations
paths:
  /api/leads/{id}/custom-fields:
    patch:
      tags:
        - Leads
      summary: Update lead custom fields
      description: |
        Merges custom fields into the lead. Set a field value to `null` to
        delete that field.
        Requires `leads:import` permission.
      operationId: updateLeadCustomFields
      parameters:
        - $ref: '#/components/parameters/LeadId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                customFields:
                  type: object
                  additionalProperties:
                    type:
                      - string
                      - 'null'
              required:
                - customFields
      responses:
        '200':
          description: Updated lead
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Lead'
        '400':
          $ref: '#/components/responses/BadRequest'
        '404':
          $ref: '#/components/responses/LeadNotFound'
components:
  parameters:
    LeadId:
      name: id
      in: path
      required: true
      description: Account-scoped sequential lead ID
      schema:
        type: integer
  schemas:
    Lead:
      type: object
      properties:
        id:
          type: integer
          description: Sequential, account-scoped identifier
        name:
          type: string
        phone:
          type: string
          description: Unique per account
        email:
          type: string
          default: ''
        status:
          $ref: '#/components/schemas/LeadStatus'
        accountId:
          type: string
        source:
          type: string
          default: api
        tags:
          type: array
          items:
            type: string
        assignedAgentId:
          type: string
          description: ObjectId reference to AgentConfig
        abTestId:
          type: string
          description: ObjectId reference to AbTest
        agentAssignedBy:
          type: string
          enum:
            - manual
            - ab_test
            - auto
          default: auto
        customFields:
          type: object
          additionalProperties:
            type: string
          description: Key-value string map of custom fields
        lastContactedAt:
          type: string
          format: date-time
        importBatchId:
          type: string
        externalId:
          type: string
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
      required:
        - id
        - name
        - phone
        - email
        - status
        - accountId
    LeadStatus:
      type: string
      enum:
        - new
        - contacted
        - qualified
        - disqualified
  responses:
    BadRequest:
      description: Bad request
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: string
            required:
              - error
    LeadNotFound:
      description: Lead not found
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: string
                example: Lead not found
            required:
              - error
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: API key prefixed with `nl_live_` or `nl_test_`
    BearerAuth:
      type: http
      scheme: bearer
      description: Bearer token using an API key (format nl_live_* or nl_test_*)

````