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

# Create a firewall

> Creates a firewall with an optional initial rule set and pushes it to the upstream provider. Rolls the DB row back if the upstream sync fails.



## OpenAPI

````yaml https://api.vmarea.com/api/public/v1/openapi.json post /api/public/v1/firewalls
openapi: 3.1.0
info:
  title: VMArea Public API
  version: 1.0.0
  description: >-
    The VMArea Public API lets you provision and manage VMs, networks,
    firewalls, SSH keys, backups, and webhooks programmatically. Authenticate
    every request with an API token (`x-api-key` header) created in the
    dashboard. Tokens carry coarse scopes (e.g. `vms:write`); endpoints reject
    calls that lack the scope they require.
  contact:
    name: VMArea Support
    url: https://vmarea.com/support
servers:
  - url: https://api.vmarea.com/api/v1
    description: Production
security:
  - ApiKey: []
paths:
  /api/public/v1/firewalls:
    post:
      tags:
        - Firewalls
      summary: Create a firewall
      description: >-
        Creates a firewall with an optional initial rule set and pushes it to
        the upstream provider. Rolls the DB row back if the upstream sync fails.
      operationId: createFirewall
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  minLength: 1
                  maxLength: 100
                description:
                  type: string
                  maxLength: 500
                  nullable: true
                rules:
                  type: array
                  items:
                    type: object
                    properties:
                      position:
                        type: integer
                        minimum: 0
                        maximum: 1000
                      direction:
                        type: string
                        enum:
                          - IN
                          - OUT
                      action:
                        type: string
                        enum:
                          - ACCEPT
                          - DROP
                          - REJECT
                        default: ACCEPT
                      protocol:
                        type: string
                        enum:
                          - TCP
                          - UDP
                          - ICMP
                          - ESP
                          - GRE
                          - ANY
                        default: TCP
                      port:
                        type: string
                        maxLength: 64
                        nullable: true
                      sourceIps:
                        type: array
                        items:
                          type: string
                          maxLength: 64
                        maxItems: 50
                        default: []
                      destIps:
                        type: array
                        items:
                          type: string
                          maxLength: 64
                        maxItems: 50
                        default: []
                      description:
                        type: string
                        maxLength: 255
                        nullable: true
                    required:
                      - position
                      - direction
                    additionalProperties: false
                  maxItems: 200
                  default: []
              required:
                - name
              additionalProperties: false
      responses:
        '201':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    enum:
                      - true
                  data:
                    type: object
                    properties:
                      id:
                        type: string
                      name:
                        type: string
                      description:
                        type: string
                        nullable: true
                      rules:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: string
                            firewallId:
                              type: string
                            position:
                              type: integer
                            direction:
                              type: string
                              enum:
                                - IN
                                - OUT
                            action:
                              type: string
                              enum:
                                - ACCEPT
                                - DROP
                                - REJECT
                            protocol:
                              type: string
                              enum:
                                - TCP
                                - UDP
                                - ICMP
                                - ESP
                                - GRE
                                - ANY
                            port:
                              type: string
                              nullable: true
                            sourceIps:
                              type: array
                              items:
                                type: string
                            destIps:
                              type: array
                              items:
                                type: string
                            description:
                              type: string
                              nullable: true
                            createdAt:
                              type: string
                              format: date-time
                            updatedAt:
                              type: string
                              format: date-time
                          required:
                            - id
                            - firewallId
                            - position
                            - direction
                            - action
                            - protocol
                            - port
                            - sourceIps
                            - destIps
                            - description
                            - createdAt
                            - updatedAt
                          additionalProperties: false
                      bindings:
                        type: array
                        items:
                          type: object
                          properties:
                            vmId:
                              type: string
                            attachedAt:
                              type: string
                              format: date-time
                            vm:
                              type: object
                              properties:
                                id:
                                  type: string
                                name:
                                  type: string
                                hostname:
                                  type: string
                                  nullable: true
                                status:
                                  type: string
                              required:
                                - id
                                - name
                                - hostname
                                - status
                              additionalProperties: false
                          required:
                            - vmId
                            - attachedAt
                            - vm
                          additionalProperties: false
                      bindingCount:
                        type: integer
                      ruleCount:
                        type: integer
                      createdAt:
                        type: string
                        format: date-time
                      updatedAt:
                        type: string
                        format: date-time
                    required:
                      - id
                      - name
                      - description
                      - rules
                      - bindings
                      - bindingCount
                      - ruleCount
                      - createdAt
                      - updatedAt
                    additionalProperties: false
                required:
                  - success
                  - data
                additionalProperties: false
        '401':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    enum:
                      - false
                  error:
                    type: string
                required:
                  - success
                  - error
                additionalProperties: false
        '403':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    enum:
                      - false
                  error:
                    type: string
                required:
                  - success
                  - error
                additionalProperties: false
        '502':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    enum:
                      - false
                  error:
                    type: string
                required:
                  - success
                  - error
                additionalProperties: false
      security:
        - ApiKey: []
components:
  securitySchemes:
    ApiKey:
      type: apiKey
      name: x-api-key
      in: header
      description: >-
        Long-lived API token created at
        https://vmarea.com/dashboard/settings/api-keys. Tokens are
        scope-restricted; this spec lists the scope each endpoint requires.

````