Home
Version 3
Security Groups API

Security Groups API

Creating a Security Group

POST /v2/security_groups/

Request

Route

POST /v2/security_groups

Body

Name Description Default Valid Values Example Values
name The name of the security group.
  • my_super_sec_group
rules The egress rules for apps that belong to this security group. A rule consists of a protocol (tcp,icmp,udp,all), destination CIDR or destination range, port or port range (tcp,udp,all), type (control signal for icmp), code (control signal for icmp), log (enables logging for the egress rule). This field is limited to 16MB. []
  • [
      {
        "protocol": "icmp",
        "destination": "0.0.0.0/0",
        "type": 0,
        "code": 1
      },
      {
        "protocol": "tcp",
        "destination": "0.0.0.0/0",
        "ports": "2048-3000",
        "log": true
      },
      {
        "protocol": "udp",
        "destination": "0.0.0.0/0",
        "ports": "53, 5353"
      },
      {
        "protocol": "all",
        "destination": "0.0.0.0/0"
      }
    ]
space_guids The list of associated spaces. []
{
  "name": "my_super_sec_group",
  "rules": [
    {
      "protocol": "icmp",
      "destination": "0.0.0.0/0",
      "type": 0,
      "code": 1
    },
    {
      "protocol": "tcp",
      "destination": "0.0.0.0/0",
      "ports": "2048-3000",
      "log": true
    },
    {
      "protocol": "udp",
      "destination": "0.0.0.0/0",
      "ports": "53, 5353"
    },
    {
      "protocol": "all",
      "destination": "0.0.0.0/0"
    }
  ]
}

Headers

Authorization: bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoidWFhLWlkLTQwNyIsImVtYWlsIjoiZW1haWwtMjY5QHNvbWVkb21haW4uY29tIiwic2NvcGUiOlsiY2xvdWRfY29udHJvbGxlci5hZG1pbiJdLCJhdWQiOlsiY2xvdWRfY29udHJvbGxlciJdLCJleHAiOjE0NjM2MTg3MjZ9.Eam5bn_RkvDQoKQ23PqVqjDU_AZkvVm87B-jQgcGkkc
Host: example.org
Content-Type: application/x-www-form-urlencoded
Cookie: 

cURL

curl "https://api.[your-domain.com]/v2/security_groups" -d '{
  "name": "my_super_sec_group",
  "rules": [
    {
      "protocol": "icmp",
      "destination": "0.0.0.0/0",
      "type": 0,
      "code": 1
    },
    {
      "protocol": "tcp",
      "destination": "0.0.0.0/0",
      "ports": "2048-3000",
      "log": true
    },
    {
      "protocol": "udp",
      "destination": "0.0.0.0/0",
      "ports": "53, 5353"
    },
    {
      "protocol": "all",
      "destination": "0.0.0.0/0"
    }
  ]
}' -X POST \
	-H "Authorization: bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoidWFhLWlkLTQwNyIsImVtYWlsIjoiZW1haWwtMjY5QHNvbWVkb21haW4uY29tIiwic2NvcGUiOlsiY2xvdWRfY29udHJvbGxlci5hZG1pbiJdLCJhdWQiOlsiY2xvdWRfY29udHJvbGxlciJdLCJleHAiOjE0NjM2MTg3MjZ9.Eam5bn_RkvDQoKQ23PqVqjDU_AZkvVm87B-jQgcGkkc" \
	-H "Host: example.org" \
	-H "Content-Type: application/x-www-form-urlencoded" \
	-H "Cookie: "

Response

Status

201 Created

Body

{
  "metadata": {
    "guid": "966e7ac0-1c1a-4ca9-8a5f-77c96576beb7",
    "url": "/v2/security_groups/966e7ac0-1c1a-4ca9-8a5f-77c96576beb7",
    "created_at": "2016-05-12T00:45:26Z",
    "updated_at": null
  },
  "entity": {
    "name": "my_super_sec_group",
    "rules": [
      {
        "protocol": "icmp",
        "destination": "0.0.0.0/0",
        "type": 0,
        "code": 1
      },
      {
        "protocol": "tcp",
        "destination": "0.0.0.0/0",
        "ports": "2048-3000",
        "log": true
      },
      {
        "protocol": "udp",
        "destination": "0.0.0.0/0",
        "ports": "53, 5353"
      },
      {
        "protocol": "all",
        "destination": "0.0.0.0/0"
      }
    ],
    "running_default": false,
    "staging_default": false,
    "spaces_url": "/v2/security_groups/966e7ac0-1c1a-4ca9-8a5f-77c96576beb7/spaces"
  }
}

Headers

Content-Type: application/json;charset=utf-8
Location: /v2/security_groups/966e7ac0-1c1a-4ca9-8a5f-77c96576beb7
X-VCAP-Request-ID: 31aa0044-1375-4a60-8492-b0a997f6eced
Content-Length: 864
X-Content-Type-Options: nosniff