/v1/firewall-policiesCreates a firewall policy. The policy is not attached to anything yet, so it has no effect until you attach it to a resource.
Every new policy starts with two default rules, so attaching it does not lock you out:
- TCP port
22from0.0.0.0/0(SSH, needed byrumpty sshand the CLI). - TCP port
8080from0.0.0.0/0(the default VM app port).
You can update or delete these rules like any other.
Policy names must be unique in the workspace. A name already used by another policy is
rejected with 409. The check is on the exact name (after trimming spaces) and is
case-sensitive, so Web servers and web servers can both exist. Names of deleted
policies can be reused.
Authentication
Send your API key as Authorization: Bearer <token>. The request is scoped to the workspace in X-Workspace-Slug.
Headers
X-Workspace-SlugstringRequiredSlug of the workspace the request acts on. You can also pass it as the workspace_slug query parameter.
Request body
namestringRequiredName of the policy. Leading and trailing spaces are trimmed. Must be unique in the workspace.
descriptionstringOptional free-text description. Leading and trailing spaces are trimmed.
is_defaultbooleanMarks the policy as a workspace default. This is a label only. The API does not attach default policies to resources automatically.
Default false
Response
The policy was created with its default rules. attached_resources is omitted because a new policy has no attachments.
successbooleanRequiredtrue when the request succeeded.
messagestringRequiredHuman-readable status message.
dataobjectShow attributesHide attributes
uidstringRequiredUnique identifier of the policy.
namestringRequiredName of the policy, unique in the workspace.
slugstringRequiredURL-friendly form of the name.
descriptionstringFree-text description. Omitted when empty.
is_defaultbooleanRequiredWhether the policy is labelled as a workspace default. It is not applied automatically.
rulesarray of objectsThe policy's rules, oldest first. Omitted when the policy has no rules.
Show item attributesHide item attributes
operation_idstringRequiredOn Add a firewall rule and
Update a firewall rule, the UID of the
first firewall.apply operation queued for the change. An empty string when no
operation was queued, and always empty when rules are returned inside a policy.
uidstringRequiredUnique identifier of the rule.
directionstringRequiredTraffic direction the rule applies to.
One ofinboundoutbound
actionstringRequiredWhat happens to matching traffic. Always allow.
One ofallow
protocolstringRequiredIP protocol the rule matches.
One oftcpudpall
port_startintegerRequiredFirst port of the range. 0 with port_end 0 means all ports.
port_endintegerRequiredLast port of the range.
cidrstringRequiredSource address range in CIDR notation.
descriptionstringNote about the rule. Omitted when empty.
is_defaultbooleanRequiredtrue for the SSH and app-port rules added automatically when the policy was created.
attached_resourcesarray of objectsResources the policy is attached to, newest first. Omitted when there are none.
Show item attributesHide item attributes
operation_idstringRequiredOn Attach a firewall policy, the UID
of the firewall.apply operation queued for the resource. An empty string when the
policy was already attached or no operation could be queued, and always empty when
attachments are returned inside a policy.
uidstringRequiredUnique identifier of the attachment. Use it to detach the policy.
resource_typestringRequiredKind of resource the policy is attached to.
One ofvmdatabasedeployment
resourceobjectRequiredShort description of the attached resource. All fields are empty strings if the resource no longer exists.
Show attributesHide attributes
uidstringRequiredUID of the VM, database or deployment.
namestringRequiredName of the resource.
slugstringRequiredSlug of the resource.
statusstringRequiredCurrent status of the resource. For VMs and databases this is the display status.
created_atstring (date-time)RequiredWhen the policy was created (RFC 3339).
updated_atstring (date-time)RequiredWhen the policy itself was last changed. Rule changes do not update it.
Errors
| Status | Meaning |
|---|---|
400 | Validation failed: the body is not valid JSON (invalid request) or name is missing or blank (policy name is required). |
401 | The API key is missing, invalid, expired or revoked. |
403 | You cannot access the workspace, your role does not allow this action, or the account is suspended. |
409 | Another policy in the workspace already has this name. |
Errors use the standard error format.