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

# Update the Status of Leads

> Marks leads of a search as qualified or disqualified, the same status the app shows in a saved list and that `GET /searches/{id}` returns and filters on. Leads are identified by the `lead.id` that `GET /searches/{id}` returns. Disqualifying replaces any existing rejection reason; qualifying clears it. Costs no credits or quota. You can update your own searches, or those of your workspace members when you authenticate with a workspace key.

## Description

Marks leads of a search as qualified or disqualified. It is the status the app shows in a saved list, and the one [`GET /searches/{id}`](https://docs.pipecorn.com/api-reference/endpoints/searches/show) returns as `status` and `rejection_reasons` and filters on with `?status=`. Use it to write back a verdict on each lead, for instance after checking them against your ICP.

Leads are identified by the `lead.id` that `GET /searches/{id}` returns for each lead. You can update your own searches, or those of your workspace members when you authenticate with a workspace key. It costs no credits or quota.

## Parameters

### Path Parameters

* **`id`** (required, string, UUID): The ID of the search

### Body Parameters

* **`lead_ids`** (required, array of strings): IDs of the leads to update, from `lead.id` in `GET /searches/{id}`. 1 to 1000
* **`status`** (required, string): `qualified` or `disqualified`
* **`reason`** (optional, string): Why the leads are disqualified. Defaults to `Manually disqualified`. Ignored when qualifying

## Example

```bash theme={null}
curl -X PATCH https://app.pipecorn.com/api/v2/searches/0d6f1c5e-1b7a-4c1e-9a43-6f8e2a1b9c77/leads/status \
  -H "X-API-KEY: $PIPECORN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "lead_ids": ["0b9c7d2e-3f4a-4b5c-8d6e-7f8a9b0c1d2e", "5e1f2a3b-4c5d-4e6f-9a7b-8c9d0e1f2a3b"],
    "status": "disqualified",
    "reason": "Not in our ICP"
  }'
```

## Responses

### 200 OK

```json theme={null}
{
  "search_id": "0d6f1c5e-1b7a-4c1e-9a43-6f8e2a1b9c77",
  "status": "disqualified",
  "rejection_reasons": ["Not in our ICP"],
  "updated": 1,
  "unknown_lead_ids": ["5e1f2a3b-4c5d-4e6f-9a7b-8c9d0e1f2a3b"]
}
```

* `updated` is the number of leads whose status was set.
* `unknown_lead_ids` lists the IDs that matched no lead of this search. The other IDs are still applied.

### 400 Bad Request

`lead_ids` is missing, empty, not an array of strings or longer than 1000; `status` is not `qualified` or `disqualified`; `reason` is not a string; or the body is not valid JSON.

```json theme={null}
{
  "error": "status must be one of: qualified, disqualified"
}
```

### 404 Not Found

The search does not exist, or it belongs to another user outside your account (or outside your workspace, with a workspace key).

```json theme={null}
{
  "error": "Search not found"
}
```

### 422 Unprocessable Entity

The body carries a parameter this endpoint does not take.

```json theme={null}
{
  "error": "Unauthorized parameters detected",
  "unauthorized_params": ["linkedin_urls"],
  "permitted_params": ["lead_ids", "status", "reason"]
}
```

## Notes

* Disqualifying replaces any rejection reason the leads already carry; qualifying clears it
* The search's qualified and disqualified counts are refreshed after the update


## OpenAPI

````yaml PATCH /searches/{id}/leads/status
openapi: 3.0.1
info:
  title: Pipecorn Searches API
  description: Pipecorn List API
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://app.pipecorn.com/api/v2/
security:
  - defaultApiKey: []
paths:
  /searches/{id}/leads/status:
    patch:
      summary: Update the status of leads
      description: >-
        Marks leads of a search as qualified or disqualified, the same status
        the app shows in a saved list and that `GET /searches/{id}` returns and
        filters on. Leads are identified by the `lead.id` that `GET
        /searches/{id}` returns. Disqualifying replaces any existing rejection
        reason; qualifying clears it. Costs no credits or quota. You can update
        your own searches, or those of your workspace members when you
        authenticate with a workspace key.
      parameters:
        - name: id
          in: path
          required: true
          description: ID of the search
          schema:
            type: string
            format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - lead_ids
                - status
              additionalProperties: false
              properties:
                lead_ids:
                  type: array
                  minItems: 1
                  maxItems: 1000
                  items:
                    type: string
                    format: uuid
                  description: >-
                    IDs of the leads to update, as `GET /searches/{id}` returns
                    them in `lead.id`. 1 to 1000.
                  example:
                    - 0b9c7d2e-3f4a-4b5c-8d6e-7f8a9b0c1d2e
                status:
                  type: string
                  enum:
                    - qualified
                    - disqualified
                  description: '`qualified` keeps the leads, `disqualified` rejects them.'
                reason:
                  type: string
                  description: >-
                    Why the leads are disqualified, returned as
                    `rejection_reasons`. Ignored when qualifying. Defaults to
                    `Manually disqualified`.
                  example: Not in our ICP
      responses:
        '200':
          description: Leads updated
          headers:
            RateLimit-Limit:
              $ref: '#/components/headers/RateLimit-Limit'
            RateLimit-Remaining:
              $ref: '#/components/headers/RateLimit-Remaining'
            RateLimit-Reset:
              $ref: '#/components/headers/RateLimit-Reset'
          content:
            application/json:
              schema:
                type: object
                properties:
                  search_id:
                    type: string
                    format: uuid
                    description: ID of the search
                  status:
                    type: string
                    enum:
                      - qualified
                      - disqualified
                  rejection_reasons:
                    type: array
                    items:
                      type: string
                    description: >-
                      Rejection reasons the leads now carry; empty when
                      qualifying
                    example:
                      - Not in our ICP
                  updated:
                    type: integer
                    description: Number of leads updated
                    example: 1
                  unknown_lead_ids:
                    type: array
                    items:
                      type: string
                    description: IDs that matched no lead of the search
                    example: []
        '400':
          description: >-
            Invalid body: `lead_ids` is missing, empty, not an array of strings
            or longer than 1000, `status` is not `qualified` or `disqualified`,
            `reason` is not a string, or the body is not valid JSON
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: 'status must be one of: qualified, disqualified'
        '404':
          description: >-
            Search not found. Also returned for a search that belongs to another
            user outside your account (or outside your workspace, with a
            workspace key)
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Search not found
        '422':
          description: The body carries a parameter this endpoint does not take
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized parameters detected
                  unauthorized_params:
                    type: array
                    items:
                      type: string
                  permitted_params:
                    type: array
                    items:
                      type: string
components:
  headers:
    RateLimit-Limit:
      description: >-
        Requests allowed per minute on your plan for this group of endpoints.
        Absent for unlimited accounts and on endpoints exempt from the plan
        limit.
      schema:
        type: integer
        example: 100
    RateLimit-Remaining:
      description: Requests left in the current one-minute window.
      schema:
        type: integer
        example: 97
    RateLimit-Reset:
      description: >-
        Seconds until the current window resets and `RateLimit-Remaining` is
        back to `RateLimit-Limit`.
      schema:
        type: integer
        example: 42
  securitySchemes:
    defaultApiKey:
      type: apiKey
      in: header
      description: Your API key
      name: X-API-KEY

````

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