Home
Version 3
Security Groups API

Security Groups API

Creating a Security Group

POST /v2/security_groups/

Fields

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) []
  • [
      {
        "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. []

Request

Headers

Authorization: bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoidWFhLWlkLTY4IiwiZW1haWwiOiJlbWFpbC02MUBzb21lZG9tYWluLmNvbSIsInNjb3BlIjpbImNsb3VkX2NvbnRyb2xsZXIuYWRtaW4iXSwiYXVkIjpbImNsb3VkX2NvbnRyb2xsZXIiXSwiZXhwIjoxNDE2NTI2Njk5fQ.i4aM4URkgjrK_62Yn_e-bZ_wifRW8s_2ECn07rg2NPs
Host: example.org
Content-Type: application/x-www-form-urlencoded
Cookie: 

Route

POST /v2/security_groups

Body

{
  "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"
    }
  ]
}

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.eyJ1c2VyX2lkIjoidWFhLWlkLTY4IiwiZW1haWwiOiJlbWFpbC02MUBzb21lZG9tYWluLmNvbSIsInNjb3BlIjpbImNsb3VkX2NvbnRyb2xsZXIuYWRtaW4iXSwiYXVkIjpbImNsb3VkX2NvbnRyb2xsZXIiXSwiZXhwIjoxNDE2NTI2Njk5fQ.i4aM4URkgjrK_62Yn_e-bZ_wifRW8s_2ECn07rg2NPs" \
	-H "Host: example.org" \
	-H "Content-Type: application/x-www-form-urlencoded" \
	-H "Cookie: "

Response

Headers

Content-Type: application/json;charset=utf-8
Location: /v2/security_groups/f4126546-f23b-4187-80c6-9338372e20cc
X-VCAP-Request-ID: 0876dd45-b218-4a76-864c-79e26b9d41a2
Content-Length: 869
X-Content-Type-Options: nosniff

Status

201 Created

Body

{
  "metadata": {
    "guid": "f4126546-f23b-4187-80c6-9338372e20cc",
    "url": "/v2/security_groups/f4126546-f23b-4187-80c6-9338372e20cc",
    "created_at": "2014-11-13T23:38:19+00:00",
    "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/f4126546-f23b-4187-80c6-9338372e20cc/spaces"
  }
}