
HavivO.09641 (Customer) asked a question.
Hello,
I'm trying to create with python group rule to assign all okta users that are members in group A to group B
in the okta UI it looks like this:
I'm trying to get the syntax to create this API call with python
all I found in the documentation is the following example:
curl -v -X POST \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: SSWS ${api_token}" \
-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"
]
}
}
}' "https://${yourOktaDomain}/api/v1/groups/rules"
but failed to adjust it to my needs,
can you please assist?
Thanks, Or

Hi @HavivO.09641 (Customer) , Thank you for reaching out to the Okta Community!
Please note that providing custom scripting is outside of Okta Support scope.
That being said, I can try to provide some general advice.
If you are looking for a simple rule like
IF users are part of GroupA THEN Assign to GroupB
You will need to leverage the involved group IDs in the request.
Here is an API request example where 00g144wasdfljB1r0x8 and 00g144xtwasdvcRcO0x8 are the respective group IDs :
curl -v -X POST \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: SSWS ${api_token}" \
-d '{
"type": "group_rule",
"name": "API_GroupRuleTEST",
"conditions": {
"expression": {
"value": "isMemberOfAnyGroup(\"00g144wasdfljB1r0x8\")",
"type": "urn:okta:expression:1.0"
}
},
"actions": {
"assignUserToGroups": {
"groupIds": [
"00g144xtwasdvcRcO0x8"
]
}
},
"allGroupsValid": true
}
Please note that newly created group rules are always INACTIVE. You'll need to run a separate request .
https://developer.okta.com/docs/reference/api/groups/#activate-a-group-rule
If my answer helped, remember to mark it as best to increase its visibility for other members of the Okta Community who might have the same questions as you.
Hope my answer helps!
--
Help others in the community by liking or hitting Select as Best if this response helped you.