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>"
]
}
'import requests
url = "https://api.projectdiscovery.io/v1/asset/{asset_id}/labels"
payload = { "labels": ["<string>"] }
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({labels: ['<string>']})
};
fetch('https://api.projectdiscovery.io/v1/asset/{asset_id}/labels', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.projectdiscovery.io/v1/asset/{asset_id}/labels",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'labels' => [
'<string>'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.projectdiscovery.io/v1/asset/{asset_id}/labels"
payload := strings.NewReader("{\n \"labels\": [\n \"<string>\"\n ]\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://api.projectdiscovery.io/v1/asset/{asset_id}/labels")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"labels\": [\n \"<string>\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.projectdiscovery.io/v1/asset/{asset_id}/labels")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"labels\": [\n \"<string>\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"message": "<string>"
}{
"message": "<string>",
"kind": "<string>",
"code": "<string>",
"error": "<string>",
"error_id": "<string>",
"param": "<string>",
"status": 123
}{
"message": "<string>",
"kind": "<string>",
"code": "<string>",
"error": "<string>",
"error_id": "<string>",
"param": "<string>",
"status": 123
}{
"message": "<string>",
"kind": "<string>",
"code": "<string>",
"error": "<string>",
"error_id": "<string>",
"param": "<string>",
"status": 123
}{
"message": "<string>",
"kind": "<string>",
"code": "<string>",
"error": "<string>",
"error_id": "<string>",
"param": "<string>",
"status": 123
}{
"message": "<string>",
"kind": "<string>",
"code": "<string>",
"error": "<string>",
"error_id": "<string>",
"param": "<string>",
"status": 123
}Asset Discovery
Modify labels of an asset
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>"
]
}
'import requests
url = "https://api.projectdiscovery.io/v1/asset/{asset_id}/labels"
payload = { "labels": ["<string>"] }
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({labels: ['<string>']})
};
fetch('https://api.projectdiscovery.io/v1/asset/{asset_id}/labels', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.projectdiscovery.io/v1/asset/{asset_id}/labels",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'labels' => [
'<string>'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.projectdiscovery.io/v1/asset/{asset_id}/labels"
payload := strings.NewReader("{\n \"labels\": [\n \"<string>\"\n ]\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://api.projectdiscovery.io/v1/asset/{asset_id}/labels")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"labels\": [\n \"<string>\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.projectdiscovery.io/v1/asset/{asset_id}/labels")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"labels\": [\n \"<string>\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"message": "<string>"
}{
"message": "<string>",
"kind": "<string>",
"code": "<string>",
"error": "<string>",
"error_id": "<string>",
"param": "<string>",
"status": 123
}{
"message": "<string>",
"kind": "<string>",
"code": "<string>",
"error": "<string>",
"error_id": "<string>",
"param": "<string>",
"status": 123
}{
"message": "<string>",
"kind": "<string>",
"code": "<string>",
"error": "<string>",
"error_id": "<string>",
"param": "<string>",
"status": 123
}{
"message": "<string>",
"kind": "<string>",
"code": "<string>",
"error": "<string>",
"error_id": "<string>",
"param": "<string>",
"status": 123
}{
"message": "<string>",
"kind": "<string>",
"code": "<string>",
"error": "<string>",
"error_id": "<string>",
"param": "<string>",
"status": 123
}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
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
update_type | string | No | append | Update 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"]
}
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"]
}'
{
"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"]
}
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"]
}'
{
"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"]
}
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"]
}'
{
"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
Path Parameters
Query Parameters
Append or Replace update_type
Available options:
append, replace, delete Body
application/json
Response
Example response
Was this page helpful?
⌘I