Skip to content

Create a group rule

Request

OAuth 2.0 scope:
  • okta.groups.manage

Creates a group rule to dynamically add users to the specified group if they match the condition.

Note: Group rules are created with the status set to 'INACTIVE'.

Bodyapplication/jsonrequired
actionsobject(GroupRuleAction)

Defines which users and groups to assign

conditionsobject(GroupRuleConditions)

Defines group rule conditions

namestring, [ 1 .. 50 ] characters

Name of the group rule

typestring
Value:"group_rule"
curl -i -X POST \
  https://subdomain.okta.com/api/v1/groups/rules \
  -H 'Content-Type: application/json' \
  -d '{
    "type": "group_rule",
    "name": "Engineering group rule",
    "conditions": {
      "people": {
        "users": {
          "exclude": [
            "00u22w79JPMEeeuLr0g4"
          ]
        },
        "groups": {
          "exclude": []
        }
      },
      "expression": {
        "value": "user.role==\"Engineer\"",
        "type": "urn:okta:expression:1.0"
      }
    },
    "actions": {
      "assignUserToGroups": {
        "groupIds": [
          "00gjitX9HqABSoqTB0g3"
        ]
      }
    }
  }'

Responses

Success

Bodyapplication/json
actionsobject(GroupRuleAction)

Defines which users and groups to assign

conditionsobject(GroupRuleConditions)

Defines group rule conditions

createdstring, (date-time)read-only

Creation date for group rule

idstringread-only

ID of the group rule

lastUpdatedstring, (date-time)read-only

Date group rule was last updated

namestring, [ 1 .. 50 ] characters

Name of the group rule

statusstring(GroupRuleStatus)

Status of group rule. You can't update the status of a rule from INACTIVE to ACTIVE. You must use the activate and deactivate lifecycle operations.

Enum:"ACTIVE""INACTIVE""INVALID"
typestring

Type to indicate a group rule operation. Only group_rule is allowed.

_embeddedobjectread-only

This object appears with embedded resources related to the group rule if you use the expand query parameter

Response

Example of a group rule

{ "type": "group_rule", "id": "0pr3f7zMZZHPgUoWO0g4", "status": "INACTIVE", "name": "Engineering group rule", "created": "2016-12-01T14:40:04.000Z", "lastUpdated": "2016-12-01T14:40:04.000Z", "conditions": { "people": { … }, "expression": { … } }, "actions": { "assignUserToGroups": { … } } }