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

# Update Leads in Bulk

> Send up to 100 lead updates in one request with PATCH /api/leads/bulk. Each item is handled like PATCH /api/leads and gets its own result.

Send up to 100 lead updates in one request. Each item takes the same body as [`PATCH /api/leads`](https://octanist.com/docs/api-reference/endpoint/update-lead) and follows the same rules: identifier matching, Multiple Match Behavior, status rules, `set`, `conversionEventId`, and pending updates for leads that are not in Octanist yet.

Items are processed one at a time, in the order you send them. Two updates for the same lead are applied one after the other, as with separate requests. One item failing does not stop the others.

The response is `200 OK` with a summary and one result per item, also when some or all items failed. Check `success` on each result. An item that matches no lead succeeds with `"matched": false`, as it does on `PATCH /api/leads`.

## Request Body

| Field | Type | Required | Description |
| - | - | - | - |
| `updates` | array | Yes | 1 to 100 update objects, each with the body of [`PATCH /api/leads`](https://octanist.com/docs/api-reference/endpoint/update-lead#request-body), including at least one identifier |

An empty array, more than 100 items, or a body without `updates` returns `400 VALIDATION_ERROR` and nothing is updated.

## Example Request

```bash theme={null}
curl -X PATCH \
  -H "X-API-KEY: your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "updates": [
      { "externalId": "QUOTE-2026-0042", "status": "won", "value": 5000 },
      { "email": "jane@example.com", "status": "lost", "lossReason": "Too expensive" },
      { "externalId": "QUOTE-2026-0099", "status": "won" }
    ]
  }' \
  "https://octanist.com/api/leads/bulk"
```

## Example Response

```json theme={null}
{
  "success": true,
  "data": {
    "summary": {
      "total": 3,
      "succeeded": 2,
      "failed": 1
    },
    "results": [
      {
        "index": 0,
        "success": true,
        "status": 200,
        "data": {
          "matched": true,
          "leadId": "lead_abc123",
          "externalId": "QUOTE-2026-0042",
          "leadsUpdated": 1,
          "leads": [
            {
              "id": "lead_abc123",
              "externalId": "QUOTE-2026-0042",
              "status": "won",
              "value": 5000,
              "labelId": null,
              "conversionEventId": null,
              "locked": false
            }
          ],
          "message": "Lead updated successfully"
        }
      },
      {
        "index": 1,
        "success": true,
        "status": 200,
        "data": {
          "matched": false,
          "leadId": null,
          "leadsUpdated": 0,
          "leads": [],
          "message": "No lead found matching the provided identifiers. The request was accepted and the missed attempt has been logged."
        }
      },
      {
        "index": 2,
        "success": false,
        "status": 400,
        "error": {
          "code": "VALIDATION_ERROR",
          "message": "A value above 0 is required to mark a lead as won. Send a value with the update, or set one on the lead first."
        }
      }
    ]
  },
  "meta": {
    "requestId": "req_a1b2c3d4e5f6",
    "timestamp": "2026-03-10T12:00:00.000Z"
  }
}
```

## Response Fields

| Field | Type | Description |
| - | - | - |
| `summary.total` | integer | Number of items in the request |
| `summary.succeeded` | integer | Items that succeeded, including items that matched no lead |
| `summary.failed` | integer | Items that failed |
| `results` | array | One result per item, in request order |
| `results[].index` | integer | Position of the item in `updates`, starting at 0 |
| `results[].success` | boolean | Whether the item succeeded |
| `results[].status` | integer | HTTP status the item would get as a single `PATCH /api/leads` request |
| `results[].data` | object | On success: the same `data` as [`PATCH /api/leads`](https://octanist.com/docs/api-reference/endpoint/update-lead#response-fields), including `warnings` when a status was not applied |
| `results[].error` | object | On failure: `code`, `message` and, for validation errors, `details` |

## Error Responses

These errors apply to the whole request. Errors of single items are in `results`.

| Status | Code | Description |
| - | - | - |
| 400 | `VALIDATION_ERROR` | Invalid JSON, or `updates` is missing, empty or longer than 100 items |
| 401 | `UNAUTHORIZED` | Missing or invalid API key |
| 403 | `FORBIDDEN` | A [read-only API key](https://octanist.com/docs/api-reference/authentication.md#key-access), or the organization is a read-only demo |
| 500 | `INTERNAL_ERROR` | Server error |


## OpenAPI

````yaml PATCH /api/leads/bulk
openapi: 3.0.1
info:
  title: Octanist API
  description: >-
    The Octanist API allows you to create, update and read leads, run reports,
    read workspace settings, retrieve statistics, and access ad spend data.
  version: 2.5.0
  contact:
    name: Octanist Support
    url: https://octanist.com/docs
servers:
  - url: https://octanist.com
    description: Production server
security:
  - apiKeyAuth: []
paths:
  /api/leads/bulk:
    patch:
      tags:
        - Bulk
      summary: Update Leads in Bulk
      description: >-
        Send 1 to 100 lead updates. Each item takes the body of PATCH /api/leads
        and is handled like it, in order. One item failing does not stop the
        others; the response is 200 with a result per item.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - updates
              properties:
                updates:
                  type: array
                  minItems: 1
                  maxItems: 100
                  items:
                    $ref: '#/components/schemas/UpdateLeadRequest'
      responses:
        '200':
          description: Result per item
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: object
                    properties:
                      summary:
                        $ref: '#/components/schemas/BulkSummary'
                      results:
                        type: array
                        items:
                          $ref: '#/components/schemas/BulkUpdateItemResult'
                  meta:
                    $ref: '#/components/schemas/Meta'
        '400':
          description: Invalid JSON, or updates is missing, empty or longer than 100 items
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Missing or invalid API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: A read-only API key, or the organization is a read-only demo
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    UpdateLeadRequest:
      type: object
      description: >-
        At least one of id, externalId, email, or phone is required as an
        identifier. `email` and `phone` can be strings or arrays of up to 10
        strings. Identifiers are tried sequentially: id first, then externalId,
        then email values in order, then phone values in order. Identifiers only
        find the lead; send new contact details in `set`.
      properties:
        id:
          type: string
          description: Lead ID (highest priority match)
          example: lead_abc123
        externalId:
          type: string
          minLength: 1
          maxLength: 255
          description: >-
            Customer-owned lead identifier (second priority match). Whitespace
            is trimmed.
          example: QUOTE-2026-0042
        email:
          oneOf:
            - type: string
              format: email
            - type: array
              items:
                type: string
                format: email
              minItems: 1
              maxItems: 10
          description: >-
            Lead email or ordered email candidates (third priority match).
            Arrays are tried sequentially.
          example: john@example.com
        phone:
          oneOf:
            - type: string
            - type: array
              items:
                type: string
              minItems: 1
              maxItems: 10
          description: >-
            Lead phone or ordered phone candidates (fourth priority match).
            Arrays are tried sequentially after all email candidates.
          example: '+1234567890'
        status:
          type: string
          enum:
            - open
            - qualified
            - won
            - lost
          description: >-
            New status. `open` reopens a qualified, won or lost lead;
            conversions already sent are not retracted. Takes precedence over
            `changedTo` if both are provided.
          example: won
        changedTo:
          type: string
          enum:
            - qualified
            - won
            - lost
          description: Legacy alias for `status`. Does not accept `open`.
          example: won
        value:
          oneOf:
            - type: number
              minimum: 0
            - type: string
          description: >-
            Lead value. Strings such as "1.234,56" or "1,234.56" are converted
            to numbers. A string that is not a number, or a negative value,
            returns 400.
          example: 5000
        note:
          type: string
          description: Note to attach to the lead
        lossReason:
          type: string
          description: >-
            Reason for loss (only used when status is `lost`). Free text; when
            the workspace has a fixed list (GET /api/workspace, `lostReasons`),
            send one of those reasons.
        set:
          $ref: '#/components/schemas/LeadSetFields'
        conversionEventId:
          type: string
          description: >-
            ID of a won conversion from GET /api/workspace. Chooses which won
            conversion is sent when this lead is won, in this update or later.
            Other IDs return 400.
          example: conv_won_subscription
    BulkSummary:
      type: object
      properties:
        total:
          type: integer
          example: 3
        succeeded:
          type: integer
          example: 2
        failed:
          type: integer
          example: 1
    BulkUpdateItemResult:
      type: object
      properties:
        index:
          type: integer
          description: Position of the item in the request, starting at 0
          example: 0
        success:
          type: boolean
          example: true
        status:
          type: integer
          description: HTTP status the item would get as a single request
          example: 200
        data:
          allOf:
            - $ref: '#/components/schemas/UpdateLeadResult'
          description: 'On success: the same data as the single endpoint'
        error:
          type: object
          description: On failure
          properties:
            code:
              type: string
              example: VALIDATION_ERROR
            message:
              type: string
            details:
              type: object
    Meta:
      type: object
      properties:
        requestId:
          type: string
          example: req_a1b2c3d4e5f6
        timestamp:
          type: string
          format: date-time
          example: '2026-03-10T12:00:00.000Z'
    ErrorResponse:
      type: object
      properties:
        success:
          type: boolean
          example: false
        error:
          type: object
          properties:
            code:
              type: string
              description: Error code
              example: VALIDATION_ERROR
            message:
              type: string
              description: Human readable error message
              example: Human readable error message
            details:
              type: object
              description: Optional additional error details
        meta:
          $ref: '#/components/schemas/Meta'
    LeadSetFields:
      type: object
      additionalProperties: false
      description: >-
        New values to store on the matched lead. Identifiers only find the lead;
        these fields change it. `null` clears a field. Fields left out are not
        changed. Other keys return 400. `set` never changes more than one lead.
      properties:
        externalId:
          type: string
          nullable: true
          minLength: 1
          maxLength: 255
          description: >-
            Customer-owned ID to store on the lead. Returns 409 when another
            lead already has it.
          example: CRM-88412
        name:
          type: string
          nullable: true
          description: New name
          example: John Doe
        email:
          type: string
          nullable: true
          description: New email address
          example: new@example.com
        phone:
          type: string
          nullable: true
          description: New phone number
          example: '+31612345678'
        custom:
          oneOf:
            - type: string
            - type: object
            - type: array
          nullable: true
          description: >-
            An object is merged into the stored custom data key by key; a key
            set to null is removed. A string or array replaces the stored data,
            as does an object when the stored data is not a JSON object.
          example:
            company: Acme Inc
            fax: null
        labelId:
          type: string
          nullable: true
          description: >-
            Label ID from GET /api/workspace, or null to remove the label. An
            unknown ID returns 400.
          example: label_xyz
    UpdateLeadResult:
      type: object
      properties:
        matched:
          type: boolean
          description: '`true` when a lead matched, `false` when none did'
          example: true
        leadId:
          type: string
          nullable: true
          description: First updated lead
          example: lead_abc123
        externalId:
          type: string
          nullable: true
          description: >-
            External ID of the first updated lead. Left out when no lead
            matched.
          example: QUOTE-2026-0042
        leadsUpdated:
          type: integer
          example: 1
        leads:
          type: array
          items:
            $ref: '#/components/schemas/LeadUpdateSummary'
        warnings:
          type: array
          items:
            type: string
          description: >-
            Only present when a requested status was not applied, one message
            per lead. The other changes were applied.
          example:
            - >-
              Status not changed on lead lead_abc123: it is already won. Send
              "status": "open" first to reopen it.
        message:
          type: string
          example: Lead updated successfully
    LeadUpdateSummary:
      type: object
      description: A lead after the update
      properties:
        id:
          type: string
          example: lead_abc123
        externalId:
          type: string
          nullable: true
          example: QUOTE-2026-0042
        status:
          type: string
          enum:
            - open
            - qualified
            - won
            - lost
          description: >-
            Status after the update. Unlike GET /api/leads, a qualified lead
            shows `qualified`.
          example: won
        value:
          type: number
          nullable: true
          example: 5000
        labelId:
          type: string
          nullable: true
          example: null
        conversionEventId:
          type: string
          nullable: true
          description: Won conversion chosen for this lead, or null for the default
          example: null
        locked:
          type: boolean
          description: '`true` when the lead is over the plan''s lead limit'
          example: false
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: X-API-KEY
      description: API key for authentication

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.