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

# Create Firewall Rule

> Create a new VPC firewall rule

Create a new firewall rule in a project.

### Required Parameters

* `name`: Rule name
* `action`: "allow" or "deny"
* `direction`: "ingress" or "egress"
* `vpc_network_id`: Network ID
* `sources`: Source specifications
* `destinations`: Destination specifications
* `protocols`: Protocol list (e.g., "tcp", "udp")

### Optional Parameters

* `source_ports`: Source port ranges
* `destination_ports`: Destination port ranges


## OpenAPI

````yaml POST /projects/{id}/vpc/firewall-rules
openapi: 3.1.0
info:
  title: mkinf API v0.1
  description: ''
  version: 1.0.0
servers:
  - url: https://api.mkinf.io/v0.1
    description: Prod Env
security: []
tags: []
paths:
  /projects/{id}/vpc/firewall-rules:
    post:
      tags: []
      summary: Create Firewall Rule
      description: Create a new VPC firewall rule
      parameters:
        - name: id
          in: path
          description: Project id
          required: true
          example: b3e571f6-c87d-4135-8081-ab219e92544e
          schema:
            type: string
            format: uuid
      requestBody:
        content:
          application/json:
            schema:
              properties:
                name:
                  type: string
                vpc_network_id:
                  type: string
                action:
                  type: string
                  enum:
                    - allow
                    - deny
                destination_ports:
                  type: array
                  items:
                    type: string
                    examples:
                      - '80'
                      - 3000-8080
                    description: '[80, 443, 3000-8080]'
                destinations:
                  type: array
                  items:
                    type: object
                    properties:
                      resource_id:
                        type: string
                      cidr:
                        type: string
                direction:
                  type: string
                  enum:
                    - ingress
                    - egress
                protocols:
                  type: array
                  items:
                    type: string
                    examples:
                      - tcp
                      - udp
                    description: tcp, udp
                sources:
                  type: array
                  items:
                    type: object
                    properties:
                      resource_id:
                        type: string
                      cidr:
                        type: string
                source_ports:
                  type: array
                  items:
                    type: string
                    examples:
                      - '80'
                      - 3000-8080
                    description: '[80, 443, 3000-8080]'
              required:
                - name
                - action
                - destinations
                - direction
                - protocols
                - sources
                - vpc_network_id
              type: object
            example:
              name: mkinf-allow-tcp-udp
              action: allow
              destinations:
                - resource_id: 75dbe735-17d6-4544-91f3-0f93c2c1c903
              direction: ingress
              protocols:
                - tcp
                - udp
              sources:
                - cidr: 0.0.0.0/0
              vpc_network_id: 695b751c-2eaa-4e8b-8eb2-84cb367a69fe
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  operation:
                    type: object
                    properties:
                      operation_id:
                        type: string
                      state:
                        type: string
                      metadata:
                        type: object
                        properties:
                          operation_name:
                            type: string
                          id:
                            type: string
                          request:
                            type: object
                            properties: {}
                        required:
                          - operation_name
                          - id
                          - request
                      result:
                        type: 'null'
                      started_at:
                        type: string
                      completed_at:
                        type: string
                    required:
                      - operation_id
                      - state
                      - metadata
                      - result
                      - started_at
                      - completed_at
                required:
                  - operation
              examples:
                '1':
                  summary: Success
                  value:
                    operation:
                      operation_id: a8c24ef2-5b52-41b3-819c-f78f6c2fbff9
                      state: IN_PROGRESS
                      metadata:
                        operation_name: CREATE
                        id: 48ff2db2-3882-496f-8497-3948bc57d1a9
                        request:
                          name: mkinf-allow-tcp-udp
                          direction: DIRECTION_INGRESS
                          action: ACTION_ALLOW
                          sources:
                            - cidr: ''
                              resource_id: 75dbe735-17d6-4544-91f3-0f93c2c1c903
                          source_ports: []
                          destinations:
                            - cidr: ''
                              resource_id: 75dbe735-17d6-4544-91f3-0f93c2c1c903
                          destination_ports: []
                          protocols:
                            - tcp
                            - udp
                          vpc_network_id: ''
                      result: null
                      started_at: '2024-06-16T20:12:16Z'
                      completed_at: ''
          headers: {}
      deprecated: false
      security:
        - bearer: []
components:
  securitySchemes:
    bearer:
      type: http
      scheme: bearer

````