Create Firewall Rule
curl --request POST \
--url https://api.mkinf.io/v0.1/projects/{id}/vpc/firewall-rules \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"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"
}
'import requests
url = "https://api.mkinf.io/v0.1/projects/{id}/vpc/firewall-rules"
payload = {
"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"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
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'
})
};
fetch('https://api.mkinf.io/v0.1/projects/{id}/vpc/firewall-rules', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.mkinf.io/v0.1/projects/{id}/vpc/firewall-rules",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'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'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.mkinf.io/v0.1/projects/{id}/vpc/firewall-rules"
payload := strings.NewReader("{\n \"name\": \"mkinf-allow-tcp-udp\",\n \"action\": \"allow\",\n \"destinations\": [\n {\n \"resource_id\": \"75dbe735-17d6-4544-91f3-0f93c2c1c903\"\n }\n ],\n \"direction\": \"ingress\",\n \"protocols\": [\n \"tcp\",\n \"udp\"\n ],\n \"sources\": [\n {\n \"cidr\": \"0.0.0.0/0\"\n }\n ],\n \"vpc_network_id\": \"695b751c-2eaa-4e8b-8eb2-84cb367a69fe\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.mkinf.io/v0.1/projects/{id}/vpc/firewall-rules")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"mkinf-allow-tcp-udp\",\n \"action\": \"allow\",\n \"destinations\": [\n {\n \"resource_id\": \"75dbe735-17d6-4544-91f3-0f93c2c1c903\"\n }\n ],\n \"direction\": \"ingress\",\n \"protocols\": [\n \"tcp\",\n \"udp\"\n ],\n \"sources\": [\n {\n \"cidr\": \"0.0.0.0/0\"\n }\n ],\n \"vpc_network_id\": \"695b751c-2eaa-4e8b-8eb2-84cb367a69fe\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.mkinf.io/v0.1/projects/{id}/vpc/firewall-rules")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"mkinf-allow-tcp-udp\",\n \"action\": \"allow\",\n \"destinations\": [\n {\n \"resource_id\": \"75dbe735-17d6-4544-91f3-0f93c2c1c903\"\n }\n ],\n \"direction\": \"ingress\",\n \"protocols\": [\n \"tcp\",\n \"udp\"\n ],\n \"sources\": [\n {\n \"cidr\": \"0.0.0.0/0\"\n }\n ],\n \"vpc_network_id\": \"695b751c-2eaa-4e8b-8eb2-84cb367a69fe\"\n}"
response = http.request(request)
puts response.read_body{
"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": ""
}
}Firewall
Create Firewall Rule
Create a new VPC firewall rule
POST
/
projects
/
{id}
/
vpc
/
firewall-rules
Create Firewall Rule
curl --request POST \
--url https://api.mkinf.io/v0.1/projects/{id}/vpc/firewall-rules \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"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"
}
'import requests
url = "https://api.mkinf.io/v0.1/projects/{id}/vpc/firewall-rules"
payload = {
"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"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
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'
})
};
fetch('https://api.mkinf.io/v0.1/projects/{id}/vpc/firewall-rules', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.mkinf.io/v0.1/projects/{id}/vpc/firewall-rules",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'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'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.mkinf.io/v0.1/projects/{id}/vpc/firewall-rules"
payload := strings.NewReader("{\n \"name\": \"mkinf-allow-tcp-udp\",\n \"action\": \"allow\",\n \"destinations\": [\n {\n \"resource_id\": \"75dbe735-17d6-4544-91f3-0f93c2c1c903\"\n }\n ],\n \"direction\": \"ingress\",\n \"protocols\": [\n \"tcp\",\n \"udp\"\n ],\n \"sources\": [\n {\n \"cidr\": \"0.0.0.0/0\"\n }\n ],\n \"vpc_network_id\": \"695b751c-2eaa-4e8b-8eb2-84cb367a69fe\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.mkinf.io/v0.1/projects/{id}/vpc/firewall-rules")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"mkinf-allow-tcp-udp\",\n \"action\": \"allow\",\n \"destinations\": [\n {\n \"resource_id\": \"75dbe735-17d6-4544-91f3-0f93c2c1c903\"\n }\n ],\n \"direction\": \"ingress\",\n \"protocols\": [\n \"tcp\",\n \"udp\"\n ],\n \"sources\": [\n {\n \"cidr\": \"0.0.0.0/0\"\n }\n ],\n \"vpc_network_id\": \"695b751c-2eaa-4e8b-8eb2-84cb367a69fe\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.mkinf.io/v0.1/projects/{id}/vpc/firewall-rules")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"mkinf-allow-tcp-udp\",\n \"action\": \"allow\",\n \"destinations\": [\n {\n \"resource_id\": \"75dbe735-17d6-4544-91f3-0f93c2c1c903\"\n }\n ],\n \"direction\": \"ingress\",\n \"protocols\": [\n \"tcp\",\n \"udp\"\n ],\n \"sources\": [\n {\n \"cidr\": \"0.0.0.0/0\"\n }\n ],\n \"vpc_network_id\": \"695b751c-2eaa-4e8b-8eb2-84cb367a69fe\"\n}"
response = http.request(request)
puts response.read_body{
"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": ""
}
}Create a new firewall rule in a project.
Required Parameters
name: Rule nameaction: “allow” or “deny”direction: “ingress” or “egress”vpc_network_id: Network IDsources: Source specificationsdestinations: Destination specificationsprotocols: Protocol list (e.g., “tcp”, “udp”)
Optional Parameters
source_ports: Source port rangesdestination_ports: Destination port ranges
Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
Project id
Body
application/json
Available options:
allow, deny Show child attributes
Show child attributes
Available options:
ingress, egress tcp, udp
Show child attributes
Show child attributes
[80, 443, 3000-8080]
[80, 443, 3000-8080]
Response
200 - application/json
Show child attributes
Show child attributes
⌘I