> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cloudblast.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Security Group

> Creates a new security group. Add firewall rules and attach servers after creation.



## OpenAPI

````yaml POST /security-groups
openapi: 3.0.3
info:
  title: CloudBlast API
  description: >-
    The CloudBlast V2 API provides a modern RESTful interface for managing your
    cloud infrastructure programmatically. All responses follow a consistent `{
    "data": ... }` or `{ "error": ... }` format.
  version: 2.0.0
servers:
  - url: https://console.cloudblast.io/api/v2
    description: Production
security:
  - bearerAuth: []
paths:
  /security-groups:
    post:
      tags:
        - Security Groups
      summary: Create a security group
      description: >-
        Creates a new security group. Add firewall rules and attach servers
        after creation.
      operationId: createSecurityGroup
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - name
              properties:
                name:
                  type: string
                  maxLength: 30
                  example: web-servers
                description:
                  type: string
                  nullable: true
                  example: Allow HTTP/HTTPS traffic
      responses:
        '201':
          description: Security group created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/SecurityGroup'
        '401':
          $ref: '#/components/responses/Unauthenticated'
        '422':
          $ref: '#/components/responses/ValidationError'
components:
  schemas:
    SecurityGroup:
      type: object
      properties:
        id:
          type: integer
          example: 1
        name:
          type: string
          example: web-servers
        description:
          type: string
          nullable: true
          example: Allow HTTP/HTTPS traffic
        vm_count:
          type: integer
          description: Number of servers attached
          example: 3
        rules_count:
          type: integer
          description: Number of firewall rules
          example: 5
        created_at:
          type: string
          format: date-time
          example: '2026-01-10T14:00:00+00:00'
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              description: Machine-readable error code
            message:
              type: string
              description: Human-readable error message
          required:
            - code
            - message
  responses:
    Unauthenticated:
      description: Authentication failed
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: UNAUTHENTICATED
              message: >-
                Missing or invalid Authorization header. Use: Authorization:
                Bearer <token>
    ValidationError:
      description: Validation failed
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: object
                properties:
                  code:
                    type: string
                    example: VALIDATION_ERROR
                  message:
                    type: string
                    example: The given data was invalid.
                  details:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
                    example:
                      name:
                        - The name field is required.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        API token from your CloudBlast account settings. Pass as `Authorization:
        Bearer <token>`.

````