Skip to content

Create a new access control policy with specified permissions and conditions

Request

Requires permissions::modify permission.

resources is a top-level field on the policy object, not nested inside statements.

Resource names use TGRN format, e.g. tgrn:tg::nodes:node/{uid} or tgrn:tg::access-apps:app/{uid}. Use * to match all resources of a type.

Action names must match the exact permission identifier accepted by the API, e.g. nodes::configure:apigw.

Security
JWTAuthorizer
Bodyapplication/json

Policy

descriptionstring

Policy description

Example:"My policy description"
namestring

Policy name

Example:"my-policy"
resourcesArray of strings
conditionsobject
statementsArray of objects
curl -i -X POST \
  https://apidocs.trustgrid.io/_mock/v2/policy \
  -H 'Authorization: Bearer <YOUR_JWT_HERE>' \
  -H 'Content-Type: application/json' \
  -d '{
    "description": "My policy description",
    "name": "my-policy",
    "resources": [
      "string"
    ],
    "conditions": {
      "all": {
        "eq": {
          "tg:node:tags:environment": [
            "production"
          ],
          "tg:node:tags:another-tag": [
            "always-match"
          ]
        },
        "ne": {
          "tg:node:tags:environment": [
            "staging"
          ],
          "tg:node:tags:another-tag": [
            "dont-match"
          ]
        }
      },
      "any": {
        "eq": {
          "tg:node:tags:environment": [
            "production"
          ],
          "tg:node:tags:another-tag": [
            "always-match"
          ]
        },
        "ne": {
          "tg:node:tags:environment": [
            "staging"
          ],
          "tg:node:tags:another-tag": [
            "dont-match"
          ]
        }
      },
      "none": {
        "eq": {
          "tg:node:tags:environment": [
            "production"
          ],
          "tg:node:tags:another-tag": [
            "always-match"
          ]
        },
        "ne": {
          "tg:node:tags:environment": [
            "staging"
          ],
          "tg:node:tags:another-tag": [
            "dont-match"
          ]
        }
      }
    },
    "statements": [
      {
        "actions": [
          "string"
        ],
        "effect": "allow"
      }
    ]
  }'

Responses

OK

Response
No content