Skip to main content

Create Security Group

POST/v2.0/security-groups

Creates an empty security group. A new group has no rules, so it denies all ingress and allows all egress until you add rules.

Request​

Parameters​

security_groupobjectrequired

Security group wrapper.

5 fields
namestringrequiredbody

Group name. Names are not unique; the ID is the identifier.

descriptionstringbody

Free-form description.

statefulbooleanbody

Default true. Stateful means return traffic for an allowed connection is permitted automatically. Leave it true unless the deployment supports stateless groups.

tenant_idstringbody

Project ID. Only an administrator can create a group in another project.

tagsarraybody

Tags to attach to the group.

Sample Request​

curl -ks -X POST -H 'Content-Type: application/json' -H 'X-Auth-Token: gAAAAA<...>' \
-d '{
"security_group": {
"name": "web-sg",
"description": "HTTP and HTTPS from anywhere"
}
}' https://api.vietnix.cloud:9696/v2.0/security-groups

Response​

Sample Response​

Response body
{
"security_group": {
"id": "b7e4d2c1-8f3a-4b6d-9c05-1e2f3a4b5c60",
"name": "web-sg",
"description": "HTTP and HTTPS from anywhere",
"stateful": true,
"tenant_id": "f5d834d636c642c7bfe8af86139c6f26",
"project_id": "f5d834d636c642c7bfe8af86139c6f26",
"security_group_rules": [],
"tags": []
}
}

Status Code​

Success​

Status CodeDescription
201 - CreatedThe security group was created.

Error​

Status CodeDescription
400 - Bad RequestThe name is missing or the body is malformed.
401 - UnauthorizedUser must authenticate before making a request.
403 - ForbiddenPolicy does not allow current user to do this operation.
409 - ConflictA group with the same name and project already exists.
note

To use the group, add rules (see Manage Security Group Rules) and then attach it to a port or pass its name in networks.security_groups when creating a VM (see Create VM). A group with no rules blocks all inbound traffic.