---
title: "Create security group"
method: POST
path: "/api/v2/securitygroups"
tags: ["Security groups"]
---

# Create security group

`POST /api/v2/securitygroups`

Create a new security group.

## Request body

- SecurityGroupV2Create — A security group request.
  - `metadata` ResourceMetadata, required — Metadata required for all API resource reads and writes.
    - `name` string, required — A valid Kubernetes label value, typically used for resource names that can be indexed in the database.
    - `description` string — The resource description, this optionally augments the name with more context.
    - `tags` Tag[] — A list of tags.
      - `name` string, required — A unique tag name.
      - `value` string, required — The value of the tag.
  - `spec` SecurityGroupV2CreateSpec, required — A security group's specification.
    - `rules` SecurityGroupRuleV2[], required — A set of security group rules to apply.
      - `direction` 'ingress' | 'egress', required — The direction of the rule.
      - `protocol` 'any' | 'icmp' | 'tcp' | 'udp' | 'vrrp', required — The layer 3+ protocol to allow.
      - `port` integer — Port number for layer 4 protocols, if not specified matches all ports.
      - `portMax` integer — maxumum port number for layer 4 protocols to include a range.
      - `prefix` string, ipv4 — An IPv4 address.
    - `networkId` string, uuid, required — A network ID.

## Response `201`

A security group.

- SecurityGroupV2Read — A security group.
  - `metadata` ProjectScopedResourceReadMetadata, required — Metadata required for all API resource reads and writes.
    - `name` string, required — A valid Kubernetes label value, typically used for resource names that can be indexed in the database.
    - `description` string — The resource description, this optionally augments the name with more context.
    - `tags` Tag[] — A list of tags.
      - `name` string, required — A unique tag name.
      - `value` string, required — The value of the tag.
    - `id` string, required — The unique resource ID.
    - `creationTime` string, date-time, required — The time the resource was created.
    - `createdBy` string — The user who created the resource.
    - `modifiedTime` string, date-time — The time a resource was updated.
    - `modifiedBy` string — The user who updated the resource.
    - `deletionTime` string, date-time — The time the resource was deleted.
    - `provisioningStatus` 'unknown' | 'provisioning' | 'provisioned' | 'deprovisioning' | 'error', required — The provisioning state of a resource.
    - `healthStatus` 'unknown' | 'healthy' | 'degraded' | 'error', required — The health state of a resource.
    - `organizationId` string, required — The organization identifier the resource belongs to.
    - `projectId` string, required — The project identifier the resource belongs to.
  - `spec` SecurityGroupV2Spec, required — A security group's specification.
    - `rules` SecurityGroupRuleV2[], required — A set of security group rules to apply.
      - `direction` 'ingress' | 'egress', required — The direction of the rule.
      - `protocol` 'any' | 'icmp' | 'tcp' | 'udp' | 'vrrp', required — The layer 3+ protocol to allow.
      - `port` integer — Port number for layer 4 protocols, if not specified matches all ports.
      - `portMax` integer — maxumum port number for layer 4 protocols to include a range.
      - `prefix` string, ipv4 — An IPv4 address.
  - `status` SecurityGroupV2Status, required — Read only status information about a security group.
    - `regionId` string, required — The region a security group belongs to.
    - `networkId` string, required — The network a security group belongs to.

## Other responses

- `400` — Request body failed schema validation, or the request does not contain all the required fields.
- `401` — Authentication failed or the access token has expired.
- `403` — Request was denied by authorization, this may be caused by the authorization token not having the required scope for an API, or the user doesn't have the necessary privileges on the provider platform.
- `500` — An unexpected or unhandled error occurred. This may be a transient error and may succeed on a retry. If this isn't the case, please report it as an issue.

---

[API](https://skmtc.net/nscale/apis/region-service-api.md) · [All operations](https://skmtc.net/nscale/apis/region-service-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/nscale/region-service-api/versions/c2991b23da6e/schema)
