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

# Modify labels of an asset

## Overview

Modify labels on a specific asset with granular control over how labels are updated. This endpoint provides three update modes (append, replace, delete) for managing labels on individual assets.

## Update Modes

### Append Mode (Default)

Add new labels while keeping existing ones:

```bash theme={null}
curl -X PATCH "https://api.projectdiscovery.io/v1/asset/123456/labels?update_type=append" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "labels": ["new-label"]
  }'
```

### Replace Mode

Replace all existing labels with new ones:

```bash theme={null}
curl -X PATCH "https://api.projectdiscovery.io/v1/asset/123456/labels?update_type=replace" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "labels": ["only-these-labels"]
  }'
```

### Delete Mode

Remove specific labels from the asset:

```bash theme={null}
curl -X PATCH "https://api.projectdiscovery.io/v1/asset/123456/labels?update_type=delete" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "labels": ["remove-this-label"]
  }'
```

## Query Parameters

| Parameter     | Type   | Required | Default  | Description                                   |
| ------------- | ------ | -------- | -------- | --------------------------------------------- |
| `update_type` | string | No       | `append` | Update mode: `append`, `replace`, or `delete` |

## Request Body

```json theme={null}
{
  "labels": ["label1", "label2", "label3"]
}
```

## Response

```json theme={null}
{
  "message": "Asset labels updated successfully"
}
```

## Detailed Examples

### Example 1: Append Labels

Add labels without affecting existing ones:

**Before:**

```json theme={null}
{
  "id": 123456,
  "name": "https://api.example.com",
  "labels": ["production", "api"]
}
```

**Request:**

```bash theme={null}
curl -X PATCH "https://api.projectdiscovery.io/v1/asset/123456/labels?update_type=append" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "labels": ["critical", "monitoring"]
  }'
```

**After:**

```json theme={null}
{
  "id": 123456,
  "name": "https://api.example.com",
  "labels": ["production", "api", "critical", "monitoring"]
}
```

### Example 2: Replace All Labels

Completely replace the label set:

**Before:**

```json theme={null}
{
  "id": 123456,
  "name": "https://api.example.com",
  "labels": ["production", "api", "old-label", "deprecated"]
}
```

**Request:**

```bash theme={null}
curl -X PATCH "https://api.projectdiscovery.io/v1/asset/123456/labels?update_type=replace" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "labels": ["staging", "testing"]
  }'
```

**After:**

```json theme={null}
{
  "id": 123456,
  "name": "https://api.example.com",
  "labels": ["staging", "testing"]
}
```

### Example 3: Delete Specific Labels

Remove only specific labels:

**Before:**

```json theme={null}
{
  "id": 123456,
  "name": "https://api.example.com",
  "labels": ["production", "api", "needs-review", "temporary"]
}
```

**Request:**

```bash theme={null}
curl -X PATCH "https://api.projectdiscovery.io/v1/asset/123456/labels?update_type=delete" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "labels": ["needs-review", "temporary"]
  }'
```

**After:**

```json theme={null}
{
  "id": 123456,
  "name": "https://api.example.com",
  "labels": ["production", "api"]
}
```

## Use Cases

### 1. Change Asset Classification

Update labels when asset purpose changes:

```bash theme={null}
# Change from staging to production
curl -X PATCH "https://api.projectdiscovery.io/v1/asset/123456/labels?update_type=replace" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "labels": ["production", "critical", "monitored"]
  }'
```

### 2. Remove Temporary Labels

Clean up labels after completing a process:

```bash theme={null}
# Remove temporary labels after review
curl -X PATCH "https://api.projectdiscovery.io/v1/asset/123456/labels?update_type=delete" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "labels": ["under-review", "pending"]
  }'
```

### 3. Update Priority

Change priority labels as situations evolve:

```bash theme={null}
# Upgrade to high priority
curl -X PATCH "https://api.projectdiscovery.io/v1/asset/123456/labels?update_type=delete" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"labels": ["low-priority"]}'

curl -X PATCH "https://api.projectdiscovery.io/v1/asset/123456/labels?update_type=append" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"labels": ["high-priority"]}'
```


## OpenAPI

````yaml patch /v1/asset/{asset_id}/labels
openapi: 3.1.0
info:
  title: PDCP API
  version: '1.0'
  summary: ProjectDiscovery Cloud Platform
  description: >-
    For more details, checkout
    https://docs.projectdiscovery.io/api-reference/editor/scan
servers:
  - url: https://api.projectdiscovery.io
    description: Production
  - url: https://api.dev.projectdiscovery.io
    description: Development
  - url: http://localhost:8085
    description: Localhost
security:
  - X-API-Key: []
paths:
  /v1/asset/{asset_id}/labels:
    parameters:
      - schema:
          type: integer
          format: int64
        name: asset_id
        in: path
        required: true
    patch:
      tags:
        - assets
      summary: Modify labels of an asset
      operationId: patch-v1-asset-id-labels
      parameters:
        - schema:
            type: string
            enum:
              - append
              - replace
              - delete
            default: append
          in: query
          name: update_type
          description: Append or Replace update_type
      requestBody:
        $ref: '#/components/requestBodies/AssetIdLabelsRequest'
      responses:
        '200':
          $ref: '#/components/responses/MessageResponse'
        '400':
          $ref: '#/components/responses/ErrorResponse'
        '401':
          $ref: '#/components/responses/ErrorResponse'
        '404':
          $ref: '#/components/responses/ErrorResponse'
        '500':
          $ref: '#/components/responses/ErrorResponse'
        default:
          $ref: '#/components/responses/ErrorResponse'
components:
  requestBodies:
    AssetIdLabelsRequest:
      content:
        application/json:
          schema:
            type: object
            required:
              - labels
            properties:
              labels:
                type: array
                items:
                  type: string
  responses:
    MessageResponse:
      description: Example response
      content:
        application/json:
          schema:
            type: object
            properties:
              message:
                type: string
            required:
              - message
    ErrorResponse:
      description: Example response
      content:
        application/json:
          schema:
            type: object
            required:
              - message
            properties:
              message:
                type: string
              kind:
                type: string
              code:
                type: string
              error:
                type: string
              error_id:
                type: string
              param:
                type: string
              status:
                type: integer
  securitySchemes:
    X-API-Key:
      name: X-API-Key
      type: apiKey
      in: header

````