Creating security groups

POST /v2.0/security-groups

Create a security group.

This operation creates a security group with default security group rules for the IPv4 and IPv6 ether types.

Source: https://docs.openstack.org/api-ref/network/v2/index.html#create-security-group

Request

Parameters

Name In Type Description
security_group body object A security_group object.
tenant_id body string The ID of the project.
project_id body string The ID of the project.
name body string Human-readable name of the resource.
description (Optional) body string A human-readable description for the resource. Default is an empty string.
stateful (Optional) body boolean Indicates if the security group is stateful or stateless.

Example

# curl -ks -H 'Content-Type: application/json' -H 'X-Auth-Token: gAAAAA<...>' -d '
{
    "security_group": {
        "name": "new-group",
        "description": "New security group",
        "stateful": true
    }
}' https://<node_IP_addr>:9696/v2.0/security-groups

Response

Parameters

Name In Type Description
security_group body object A security_group object.
id body string The ID of the security group.
tenant_id body string The ID of the project.
project_id body string The ID of the project.
created_at body string

Time at which the resource has been created.

The date and time stamp format is ISO 8601:

CCYY-MM-DDThh:mm:ss±hh:mm

For example, 2015-08-27T09:49:58-05:00.

The ±hh:mm value, if included, is the time zone as an offset from UTC. In this example, the offset value is -05:00.

updated_at body string

Time at which the resource has been updated. If the resource has not been updated, this field will be null.

The date and time stamp format is ISO 8601:

CCYY-MM-DDThh:mm:ss±hh:mm

For example, 2015-08-27T09:49:58-05:00.

The ±hh:mm value, if included, is the time zone as an offset from UTC. In this example, the offset value is -05:00.

revision_number body integer The revision number of the resource.
name body string Human-readable name of the resource.
description body string A human-readable description for the resource.
security_group_rules body array A list of security_group_rule objects. For details, refer to Listing security group rules.
stateful (Optional) body boolean Indicates if the security group is stateful or stateless.
shared body boolean Indicates whether this security group is shared to the requestor's project.
tags body array The list of tags on the resource.

Status codes

Success

Code Reason
201 - Created Resource was created and is ready to use.

Error

Code Reason
400 - Bad Request

Some content in the request was invalid.

401 - Unauthorized

User must authenticate before making a request.

409 - Conflict

This operation conflicted with another operation on this resource.

Example

{
  "security_group": {
    "id": "e7489f02-f846-46f2-9edf-cc5a2640041a",
    "name": "new-group",
    "stateful": true,
    "tenant_id": "39bbb405942f4fba80bb75e3db78e714",
    "description": "New security group",
    "security_group_rules": [
      {
        "id": "06e821e8-d0dd-491b-b156-bf92aee42299",
        "tenant_id": "39bbb405942f4fba80bb75e3db78e714",
        "security_group_id": "e7489f02-f846-46f2-9edf-cc5a2640041a",
        "ethertype": "IPv6",
        "direction": "egress",
        "protocol": null,
        "port_range_min": null,
        "port_range_max": null,
        "remote_ip_prefix": null,
        "remote_address_group_id": null,
        "normalized_cidr": null,
        "remote_group_id": null,
        "standard_attr_id": 45,
        "description": null,
        "tags": [],
        "created_at": "2025-04-11T12:40:37Z",
        "updated_at": "2025-04-11T12:40:37Z",
        "revision_number": 0,
        "project_id": "39bbb405942f4fba80bb75e3db78e714"
      },
      {
        "id": "5515352c-fa36-4ecd-9a82-a1cfc7421db7",
        "tenant_id": "39bbb405942f4fba80bb75e3db78e714",
        "security_group_id": "e7489f02-f846-46f2-9edf-cc5a2640041a",
        "ethertype": "IPv4",
        "direction": "egress",
        "protocol": null,
        "port_range_min": null,
        "port_range_max": null,
        "remote_ip_prefix": null,
        "remote_address_group_id": null,
        "normalized_cidr": null,
        "remote_group_id": null,
        "standard_attr_id": 44,
        "description": null,
        "tags": [],
        "created_at": "2025-04-11T12:40:37Z",
        "updated_at": "2025-04-11T12:40:37Z",
        "revision_number": 0,
        "project_id": "39bbb405942f4fba80bb75e3db78e714"
      }
    ],
    "tags": [],
    "created_at": "2025-04-11T12:40:37Z",
    "updated_at": "2025-04-11T12:40:37Z",
    "revision_number": 1,
    "project_id": "39bbb405942f4fba80bb75e3db78e714"
  }
}