Update Network Policy
Replace each field that the request contains; a domain list replaces the whole list. Each update increases version by 1, and running browsers pick up the change within seconds.
PATCH
/
network-policies
/
{policy_id}
Update Network Policy
const options = {
method: 'PATCH',
headers: {'X-Browser-Use-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
allow: {domains: ['<string>']},
block: {domains: ['<string>']}
})
};
fetch('https://api.browser-use.com/api/v4/network-policies/{policy_id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));curl --request PATCH \
--url https://api.browser-use.com/api/v4/network-policies/{policy_id} \
--header 'Content-Type: application/json' \
--header 'X-Browser-Use-API-Key: <api-key>' \
--data '
{
"name": "<string>",
"allow": {
"domains": [
"<string>"
]
},
"block": {
"domains": [
"<string>"
]
}
}
'import requests
url = "https://api.browser-use.com/api/v4/network-policies/{policy_id}"
payload = {
"name": "<string>",
"allow": { "domains": ["<string>"] },
"block": { "domains": ["<string>"] }
}
headers = {
"X-Browser-Use-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text){
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"defaultAction": "allow",
"allow": {
"domains": [
"<string>"
]
},
"block": {
"domains": [
"<string>"
]
},
"version": 123,
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z"
}{
"detail": "Network policy not found"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Body
application/json
Request body for updating a network policy; omitted fields keep their values.
Response
Successful Response
A network policy with normalized domains.
Was this page helpful?
⌘I
Update Network Policy
const options = {
method: 'PATCH',
headers: {'X-Browser-Use-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
allow: {domains: ['<string>']},
block: {domains: ['<string>']}
})
};
fetch('https://api.browser-use.com/api/v4/network-policies/{policy_id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));curl --request PATCH \
--url https://api.browser-use.com/api/v4/network-policies/{policy_id} \
--header 'Content-Type: application/json' \
--header 'X-Browser-Use-API-Key: <api-key>' \
--data '
{
"name": "<string>",
"allow": {
"domains": [
"<string>"
]
},
"block": {
"domains": [
"<string>"
]
}
}
'import requests
url = "https://api.browser-use.com/api/v4/network-policies/{policy_id}"
payload = {
"name": "<string>",
"allow": { "domains": ["<string>"] },
"block": { "domains": ["<string>"] }
}
headers = {
"X-Browser-Use-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text){
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"defaultAction": "allow",
"allow": {
"domains": [
"<string>"
]
},
"block": {
"domains": [
"<string>"
]
},
"version": 123,
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z"
}{
"detail": "Network policy not found"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}