Skip to main content
POST
/
vpc
/
security-groups
Create a security group
curl --request POST \
  --url https://v1.api.altostrat.io/vpc/security-groups \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "name": "Web Application Servers",
  "description": "Allows HTTP/S from the world and SSH from the office.",
  "rules": [
    {
      "direction": "inbound",
      "order": 10,
      "protocol": 6,
      "port": "443",
      "address": "0.0.0.0/0",
      "description": "Allow HTTPS"
    },
    {
      "direction": "inbound",
      "order": 20,
      "protocol": 6,
      "port": "80",
      "address": "0.0.0.0/0",
      "description": "Allow HTTP"
    },
    {
      "direction": "inbound",
      "order": 30,
      "protocol": 6,
      "port": "22",
      "address": "prfx_lst_0ujsswThIGTUYm2K8FjOOfxcYpw",
      "description": "Allow SSH from Office"
    }
  ],
  "sites": [
    "site_0ujsswThIGTUYm2K8FjOOfxcYpw",
    "site_0ujsswThIGTUYm2K8FjOOfxcYpz"
  ]
}
'
import requests

url = "https://v1.api.altostrat.io/vpc/security-groups"

payload = {
"name": "Web Application Servers",
"description": "Allows HTTP/S from the world and SSH from the office.",
"rules": [
{
"direction": "inbound",
"order": 10,
"protocol": 6,
"port": "443",
"address": "0.0.0.0/0",
"description": "Allow HTTPS"
},
{
"direction": "inbound",
"order": 20,
"protocol": 6,
"port": "80",
"address": "0.0.0.0/0",
"description": "Allow HTTP"
},
{
"direction": "inbound",
"order": 30,
"protocol": 6,
"port": "22",
"address": "prfx_lst_0ujsswThIGTUYm2K8FjOOfxcYpw",
"description": "Allow SSH from Office"
}
],
"sites": ["site_0ujsswThIGTUYm2K8FjOOfxcYpw", "site_0ujsswThIGTUYm2K8FjOOfxcYpz"]
}
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: 'Web Application Servers',
description: 'Allows HTTP/S from the world and SSH from the office.',
rules: [
{
direction: 'inbound',
order: 10,
protocol: 6,
port: '443',
address: '0.0.0.0/0',
description: 'Allow HTTPS'
},
{
direction: 'inbound',
order: 20,
protocol: 6,
port: '80',
address: '0.0.0.0/0',
description: 'Allow HTTP'
},
{
direction: 'inbound',
order: 30,
protocol: 6,
port: '22',
address: 'prfx_lst_0ujsswThIGTUYm2K8FjOOfxcYpw',
description: 'Allow SSH from Office'
}
],
sites: ['site_0ujsswThIGTUYm2K8FjOOfxcYpw', 'site_0ujsswThIGTUYm2K8FjOOfxcYpz']
})
};

fetch('https://v1.api.altostrat.io/vpc/security-groups', 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://v1.api.altostrat.io/vpc/security-groups",
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' => 'Web Application Servers',
'description' => 'Allows HTTP/S from the world and SSH from the office.',
'rules' => [
[
'direction' => 'inbound',
'order' => 10,
'protocol' => 6,
'port' => '443',
'address' => '0.0.0.0/0',
'description' => 'Allow HTTPS'
],
[
'direction' => 'inbound',
'order' => 20,
'protocol' => 6,
'port' => '80',
'address' => '0.0.0.0/0',
'description' => 'Allow HTTP'
],
[
'direction' => 'inbound',
'order' => 30,
'protocol' => 6,
'port' => '22',
'address' => 'prfx_lst_0ujsswThIGTUYm2K8FjOOfxcYpw',
'description' => 'Allow SSH from Office'
]
],
'sites' => [
'site_0ujsswThIGTUYm2K8FjOOfxcYpw',
'site_0ujsswThIGTUYm2K8FjOOfxcYpz'
]
]),
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://v1.api.altostrat.io/vpc/security-groups"

payload := strings.NewReader("{\n \"name\": \"Web Application Servers\",\n \"description\": \"Allows HTTP/S from the world and SSH from the office.\",\n \"rules\": [\n {\n \"direction\": \"inbound\",\n \"order\": 10,\n \"protocol\": 6,\n \"port\": \"443\",\n \"address\": \"0.0.0.0/0\",\n \"description\": \"Allow HTTPS\"\n },\n {\n \"direction\": \"inbound\",\n \"order\": 20,\n \"protocol\": 6,\n \"port\": \"80\",\n \"address\": \"0.0.0.0/0\",\n \"description\": \"Allow HTTP\"\n },\n {\n \"direction\": \"inbound\",\n \"order\": 30,\n \"protocol\": 6,\n \"port\": \"22\",\n \"address\": \"prfx_lst_0ujsswThIGTUYm2K8FjOOfxcYpw\",\n \"description\": \"Allow SSH from Office\"\n }\n ],\n \"sites\": [\n \"site_0ujsswThIGTUYm2K8FjOOfxcYpw\",\n \"site_0ujsswThIGTUYm2K8FjOOfxcYpz\"\n ]\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://v1.api.altostrat.io/vpc/security-groups")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Web Application Servers\",\n \"description\": \"Allows HTTP/S from the world and SSH from the office.\",\n \"rules\": [\n {\n \"direction\": \"inbound\",\n \"order\": 10,\n \"protocol\": 6,\n \"port\": \"443\",\n \"address\": \"0.0.0.0/0\",\n \"description\": \"Allow HTTPS\"\n },\n {\n \"direction\": \"inbound\",\n \"order\": 20,\n \"protocol\": 6,\n \"port\": \"80\",\n \"address\": \"0.0.0.0/0\",\n \"description\": \"Allow HTTP\"\n },\n {\n \"direction\": \"inbound\",\n \"order\": 30,\n \"protocol\": 6,\n \"port\": \"22\",\n \"address\": \"prfx_lst_0ujsswThIGTUYm2K8FjOOfxcYpw\",\n \"description\": \"Allow SSH from Office\"\n }\n ],\n \"sites\": [\n \"site_0ujsswThIGTUYm2K8FjOOfxcYpw\",\n \"site_0ujsswThIGTUYm2K8FjOOfxcYpz\"\n ]\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://v1.api.altostrat.io/vpc/security-groups")

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\": \"Web Application Servers\",\n \"description\": \"Allows HTTP/S from the world and SSH from the office.\",\n \"rules\": [\n {\n \"direction\": \"inbound\",\n \"order\": 10,\n \"protocol\": 6,\n \"port\": \"443\",\n \"address\": \"0.0.0.0/0\",\n \"description\": \"Allow HTTPS\"\n },\n {\n \"direction\": \"inbound\",\n \"order\": 20,\n \"protocol\": 6,\n \"port\": \"80\",\n \"address\": \"0.0.0.0/0\",\n \"description\": \"Allow HTTP\"\n },\n {\n \"direction\": \"inbound\",\n \"order\": 30,\n \"protocol\": 6,\n \"port\": \"22\",\n \"address\": \"prfx_lst_0ujsswThIGTUYm2K8FjOOfxcYpw\",\n \"description\": \"Allow SSH from Office\"\n }\n ],\n \"sites\": [\n \"site_0ujsswThIGTUYm2K8FjOOfxcYpw\",\n \"site_0ujsswThIGTUYm2K8FjOOfxcYpz\"\n ]\n}"

response = http.request(request)
puts response.read_body
{
  "id": "sec_grp_0ujsswThIGTUYm2K8FjOOfxcYpw",
  "name": "Default Web Servers",
  "description": "Allows inbound HTTP/HTTPS traffic from anywhere.",
  "status": "active",
  "sites": [
    "site_12345"
  ],
  "rules": [
    {
      "id": "fltr_0ujsswThIGTUYm2K8FjOOfxcYpw",
      "direction": "inbound",
      "order": 10,
      "protocol": 6,
      "port": "443",
      "address": "0.0.0.0/0",
      "description": "Allow inbound HTTPS traffic"
    }
  ]
}
{
"type": "invalid_request_error",
"code": "parameter_missing",
"message": "The 'name' parameter is required for this request.",
"doc_url": "https://docs.altostrat.io/errors/parameter_missing"
}
{
"type": "invalid_request_error",
"code": "parameter_missing",
"message": "The 'name' parameter is required for this request.",
"doc_url": "https://docs.altostrat.io/errors/parameter_missing"
}
{
"type": "invalid_request_error",
"code": "parameter_missing",
"message": "The 'name' parameter is required for this request.",
"doc_url": "https://docs.altostrat.io/errors/parameter_missing"
}
{
"type": "invalid_request_error",
"code": "parameter_missing",
"message": "The 'name' parameter is required for this request.",
"doc_url": "https://docs.altostrat.io/errors/parameter_missing"
}

Authorizations

Authorization
string
header
required

Authentication is performed via an Auth0-issued JSON Web Token (JWT). Provide the token in the Authorization header with the Bearer scheme.

Body

application/json

The details of the new security group.

Defines the writable properties for creating or updating a security group.

name
string
required

A human-readable name for the security group.

Required string length: 3 - 255
Example:

"Web Application Firewall"

rules
object[]
required

A list of firewall rules. The order of rules is determined by the order property within each rule object. The entire list of rules is replaced on update.

Maximum array length: 250
sites
string[]
required

A list of site IDs to which this security group should be applied. The entire list of sites is replaced on update.

description
string | null

An optional description for the security group.

Maximum string length: 1024
Example:

"Allows inbound HTTP/S and blocks common attack vectors."

Response

The security group was created successfully.

Represents a container for a stateful firewall ruleset.

id
string
read-only

The unique identifier for the security group, prefixed with sec_grp_.

Example:

"sec_grp_0ujsswThIGTUYm2K8FjOOfxcYpw"

name
string

A human-readable name for the security group.

Example:

"Default Web Servers"

description
string

An optional description for the security group, providing more context.

Example:

"Allows inbound HTTP/HTTPS traffic from anywhere."

status
enum<string>
read-only

The current synchronization status of the security group. syncing means changes are being deployed and the resource is locked from modification.

Available options:
active,
syncing,
failed
Example:

"active"

sites
string[]

A list of site IDs to which this security group is currently applied.

rules
object[]

An ordered list of firewall rules that define the security policy.