List all Policies
Returns a list of all policies
Request
curl -X GET https://api.netbird.io/api/policies \
-H 'Accept: application/json' \
-H 'Authorization: Token <TOKEN>'
Response
[
{
"id": "ch8i4ug6lnn4g9hqv7mg",
"name": "ch8i4ug6lnn4g9hqv7mg",
"description": "This is a default policy that allows connections between all the resources",
"enabled": true,
"source_posture_checks": [
"chacdk86lnnboviihd70"
],
"rules": [
{
"id": "ch8i4ug6lnn4g9hqv7mg",
"name": "Default",
"description": "This is a default rule that allows connections between all the resources",
"enabled": true,
"action": "accept",
"bidirectional": true,
"protocol": "tcp",
"ports": [
"80"
],
"port_ranges": [
{
"start": 80,
"end": 320
}
],
"sources": [
{
"id": "ch8i4ug6lnn4g9hqv7m0",
"name": "devs",
"peers_count": 2,
"issued": "api"
}
],
"destinations": [
{
"id": "ch8i4ug6lnn4g9hqv7m0",
"name": "devs",
"peers_count": 2,
"issued": "api"
}
]
}
]
}
]
Create a Policy
Creates a policy
Request-Body Parameters
- Name
id
- Type
- string
- Required
- optional
- Enum
- Description
Policy ID
- Name
name
- Type
- string
- Required
- required
- Enum
- Description
Policy name identifier
- Name
description
- Type
- string
- Required
- required
- Enum
- Description
Policy friendly description
- Name
enabled
- Type
- boolean
- Required
- required
- Enum
- Description
Policy status
- Name
source_posture_checks
- Type
- string[]
- Required
- optional
- Enum
- Description
Posture checks ID's applied to policy source groups
- Name
rules
- Type
- object[]
- Required
- required
- Enum
- Description
Policy rule object for policy UI editor
- Name
id
- Type
- string
- Required
- optional
- Enum
- Description
Policy rule ID
- Name
name
- Type
- string
- Required
- required
- Enum
- Description
Policy rule name identifier
- Name
description
- Type
- string
- Required
- optional
- Enum
- Description
Policy rule friendly description
- Name
enabled
- Type
- boolean
- Required
- required
- Enum
- Description
Policy rule status
- Name
action
- Type
- string
- Required
- required
- Enum
- Description
Policy rule accept or drops packets
- Name
bidirectional
- Type
- boolean
- Required
- required
- Enum
- Description
Define if the rule is applicable in both directions, sources, and destinations.
- Name
protocol
- Type
- string
- Required
- required
- Enum
- Description
Policy rule type of the traffic
- Name
ports
- Type
- string[]
- Required
- optional
- Enum
- Description
Policy rule affected ports
- Name
port_ranges
- Type
- object[]
- Required
- optional
- Enum
- Description
Policy rule affected ports ranges list
- Name
start
- Type
- integer
- Required
- required
- Enum
- Description
The starting port of the range
- Name
end
- Type
- integer
- Required
- required
- Enum
- Description
The ending port of the range
- Name
sources
- Type
- string[]
- Required
- required
- Enum
- Description
Policy rule source group IDs
- Name
destinations
- Type
- string[]
- Required
- required
- Enum
- Description
Policy rule destination group IDs
Request
curl -X POST https://api.netbird.io/api/policies \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-H 'Authorization: Token <TOKEN>' \
--data-raw '{
"id": "ch8i4ug6lnn4g9hqv7mg",
"name": "ch8i4ug6lnn4g9hqv7mg",
"description": "This is a default policy that allows connections between all the resources",
"enabled": true,
"source_posture_checks": [
"chacdk86lnnboviihd70"
],
"rules": [
{
"id": "ch8i4ug6lnn4g9hqv7mg",
"name": "Default",
"description": "This is a default rule that allows connections between all the resources",
"enabled": true,
"action": "accept",
"bidirectional": true,
"protocol": "tcp",
"ports": [
"80"
],
"port_ranges": [
{
"start": 80,
"end": 320
}
],
"sources": [
"ch8i4ug6lnn4g9hqv797"
],
"destinations": [
"ch8i4ug6lnn4g9h7v7m0"
]
}
]
}'
Response
{
"id": "ch8i4ug6lnn4g9hqv7mg",
"name": "ch8i4ug6lnn4g9hqv7mg",
"description": "This is a default policy that allows connections between all the resources",
"enabled": true,
"source_posture_checks": [
"chacdk86lnnboviihd70"
],
"rules": [
{
"id": "ch8i4ug6lnn4g9hqv7mg",
"name": "Default",
"description": "This is a default rule that allows connections between all the resources",
"enabled": true,
"action": "accept",
"bidirectional": true,
"protocol": "tcp",
"ports": [
"80"
],
"port_ranges": [
{
"start": 80,
"end": 320
}
],
"sources": [
{
"id": "ch8i4ug6lnn4g9hqv7m0",
"name": "devs",
"peers_count": 2,
"issued": "api"
}
],
"destinations": [
{
"id": "ch8i4ug6lnn4g9hqv7m0",
"name": "devs",
"peers_count": 2,
"issued": "api"
}
]
}
]
}
Retrieve a Policy
Get information about a Policies
Path Parameters
- Name
policyId
- Type
- string
- Required
- required
- Enum
- Description
The unique identifier of a policy
Request
curl -X GET https://api.netbird.io/api/policies/{policyId} \
-H 'Accept: application/json' \
-H 'Authorization: Token <TOKEN>'
Response
{
"id": "ch8i4ug6lnn4g9hqv7mg",
"name": "ch8i4ug6lnn4g9hqv7mg",
"description": "This is a default policy that allows connections between all the resources",
"enabled": true,
"source_posture_checks": [
"chacdk86lnnboviihd70"
],
"rules": [
{
"id": "ch8i4ug6lnn4g9hqv7mg",
"name": "Default",
"description": "This is a default rule that allows connections between all the resources",
"enabled": true,
"action": "accept",
"bidirectional": true,
"protocol": "tcp",
"ports": [
"80"
],
"port_ranges": [
{
"start": 80,
"end": 320
}
],
"sources": [
{
"id": "ch8i4ug6lnn4g9hqv7m0",
"name": "devs",
"peers_count": 2,
"issued": "api"
}
],
"destinations": [
{
"id": "ch8i4ug6lnn4g9hqv7m0",
"name": "devs",
"peers_count": 2,
"issued": "api"
}
]
}
]
}
Update a Policy
Update/Replace a Policy
Path Parameters
- Name
policyId
- Type
- string
- Required
- required
- Enum
- Description
The unique identifier of a policy
Request-Body Parameters
- Name
id
- Type
- string
- Required
- optional
- Enum
- Description
Policy ID
- Name
name
- Type
- string
- Required
- required
- Enum
- Description
Policy name identifier
- Name
description
- Type
- string
- Required
- required
- Enum
- Description
Policy friendly description
- Name
enabled
- Type
- boolean
- Required
- required
- Enum
- Description
Policy status
- Name
source_posture_checks
- Type
- string[]
- Required
- optional
- Enum
- Description
Posture checks ID's applied to policy source groups
- Name
rules
- Type
- object[]
- Required
- required
- Enum
- Description
Policy rule object for policy UI editor
- Name
id
- Type
- string
- Required
- optional
- Enum
- Description
Policy rule ID
- Name
name
- Type
- string
- Required
- required
- Enum
- Description
Policy rule name identifier
- Name
description
- Type
- string
- Required
- optional
- Enum
- Description
Policy rule friendly description
- Name
enabled
- Type
- boolean
- Required
- required
- Enum
- Description
Policy rule status
- Name
action
- Type
- string
- Required
- required
- Enum
- Description
Policy rule accept or drops packets
- Name
bidirectional
- Type
- boolean
- Required
- required
- Enum
- Description
Define if the rule is applicable in both directions, sources, and destinations.
- Name
protocol
- Type
- string
- Required
- required
- Enum
- Description
Policy rule type of the traffic
- Name
ports
- Type
- string[]
- Required
- optional
- Enum
- Description
Policy rule affected ports
- Name
port_ranges
- Type
- object[]
- Required
- optional
- Enum
- Description
Policy rule affected ports ranges list
- Name
start
- Type
- integer
- Required
- required
- Enum
- Description
The starting port of the range
- Name
end
- Type
- integer
- Required
- required
- Enum
- Description
The ending port of the range
- Name
sources
- Type
- string[]
- Required
- required
- Enum
- Description
Policy rule source group IDs
- Name
destinations
- Type
- string[]
- Required
- required
- Enum
- Description
Policy rule destination group IDs
Request
curl -X PUT https://api.netbird.io/api/policies/{policyId} \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-H 'Authorization: Token <TOKEN>' \
--data-raw '{
"id": "ch8i4ug6lnn4g9hqv7mg",
"name": "ch8i4ug6lnn4g9hqv7mg",
"description": "This is a default policy that allows connections between all the resources",
"enabled": true,
"source_posture_checks": [
"chacdk86lnnboviihd70"
],
"rules": [
{
"id": "ch8i4ug6lnn4g9hqv7mg",
"name": "Default",
"description": "This is a default rule that allows connections between all the resources",
"enabled": true,
"action": "accept",
"bidirectional": true,
"protocol": "tcp",
"ports": [
"80"
],
"port_ranges": [
{
"start": 80,
"end": 320
}
],
"sources": [
"ch8i4ug6lnn4g9hqv797"
],
"destinations": [
"ch8i4ug6lnn4g9h7v7m0"
]
}
]
}'
Response
{
"id": "ch8i4ug6lnn4g9hqv7mg",
"name": "ch8i4ug6lnn4g9hqv7mg",
"description": "This is a default policy that allows connections between all the resources",
"enabled": true,
"source_posture_checks": [
"chacdk86lnnboviihd70"
],
"rules": [
{
"id": "ch8i4ug6lnn4g9hqv7mg",
"name": "Default",
"description": "This is a default rule that allows connections between all the resources",
"enabled": true,
"action": "accept",
"bidirectional": true,
"protocol": "tcp",
"ports": [
"80"
],
"port_ranges": [
{
"start": 80,
"end": 320
}
],
"sources": [
{
"id": "ch8i4ug6lnn4g9hqv7m0",
"name": "devs",
"peers_count": 2,
"issued": "api"
}
],
"destinations": [
{
"id": "ch8i4ug6lnn4g9hqv7m0",
"name": "devs",
"peers_count": 2,
"issued": "api"
}
]
}
]
}
Delete a Policy
Delete a policy
Path Parameters
- Name
policyId
- Type
- string
- Required
- required
- Enum
- Description
The unique identifier of a policy
Request
curl -X DELETE https://api.netbird.io/api/policies/{policyId} \
-H 'Authorization: Token <TOKEN>'