Skip to main content
PATCH
/
v1
/
asset
/
{asset_id}
/
labels
Modify labels of an asset
curl --request PATCH \
  --url https://api.projectdiscovery.io/v1/asset/{asset_id}/labels \
  --header 'Content-Type: application/json' \
  --header 'X-API-Key: <api-key>' \
  --data '{
  "labels": [
    "<string>"
  ]
}'
{
  "message": "<string>"
}

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:
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:
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:
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

ParameterTypeRequiredDefaultDescription
update_typestringNoappendUpdate mode: append, replace, or delete

Request Body

{
  "labels": ["label1", "label2", "label3"]
}

Response

{
  "message": "Asset labels updated successfully"
}

Detailed Examples

Example 1: Append Labels

Add labels without affecting existing ones: Before:
{
  "id": 123456,
  "name": "https://api.example.com",
  "labels": ["production", "api"]
}
Request:
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:
{
  "id": 123456,
  "name": "https://api.example.com",
  "labels": ["production", "api", "critical", "monitoring"]
}

Example 2: Replace All Labels

Completely replace the label set: Before:
{
  "id": 123456,
  "name": "https://api.example.com",
  "labels": ["production", "api", "old-label", "deprecated"]
}
Request:
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:
{
  "id": 123456,
  "name": "https://api.example.com",
  "labels": ["staging", "testing"]
}

Example 3: Delete Specific Labels

Remove only specific labels: Before:
{
  "id": 123456,
  "name": "https://api.example.com",
  "labels": ["production", "api", "needs-review", "temporary"]
}
Request:
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:
{
  "id": 123456,
  "name": "https://api.example.com",
  "labels": ["production", "api"]
}

Use Cases

1. Change Asset Classification

Update labels when asset purpose changes:
# 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:
# 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:
# 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"]}'

Authorizations

X-API-Key
string
header
required

Path Parameters

asset_id
integer
required

Query Parameters

update_type
enum<string>
default:append

Append or Replace update_type

Available options:
append,
replace,
delete

Body

application/json
labels
string[]
required

Response

Example response

message
string
required