Skip to Content
APINetworksSecurity GroupsSet an Instance's Groups

Set an instance’s security groups

Sets the complete list of security groups on one instance, by name: groups you list are added, groups you leave out are removed. List instances shows each instance’s current groups.

PUT /v1/instance/security-groups
FieldTypeRequiredDescription
instanceIdstringyesThe instance’s ID
securityGroupsarray of stringsyesThe instance’s whole list of group names, 1 to 20, each once
curl -X PUT https://api.redu.cloud/v1/instance/security-groups \ -H "x-api-key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{"instanceId": "9b8a7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d", "securityGroups": ["default", "db-from-app"]}'

Answers once the instance has exactly these groups:

{ "message": "Security groups updated", "security_groups": ["default", "db-from-app"] }

An instance always keeps at least one group: with none, it gets no traffic at all.

When an instance gets a public URL, redu opens that port in the groups the instance has at that moment. A group you attach later does not have it: keep a group with the port, or add the rule to the new group first.


Errors

Errors use the API’s standard shape, { "error": { "code", "message", "hint"? } }.

StatusCodeWhen
400validation_errorThe list is empty, names a group twice, or the instance ID is malformed
400security_group_not_foundOne of the names is not a security group in your account
404instance_not_foundNo such instance in your account
409security_group_name_ambiguousTwo of your security groups share one of the names: rename one
Last updated on