Skip to content

func-api-users-patch

Description

Updates a user's super user status and/or environment access.

  • is_super — adds or removes the user from the Cognito super_users group. The last super user cannot be demoted.
  • environments — replaces the user's environment list in DynamoDB. The caller may only grant environments they themselves have access to.

At least one field must be provided. Both fields may be updated in a single request.

Super user access is required.

Invocation

Invoked by API Gateway on an HTTP PATCH /users/{email} request.

API Endpoints

MethodPathAuthDescription
PATCH/users/{email}Super userUpdate super user status and/or environment access

Request Body

json
{
  "is_super": true
}
json
{
  "environments": ["dev", "production"]
}
json
{
  "is_super": false,
  "environments": ["dev"]
}
FieldTypeRequiredDescription
is_superbooleanNo*true to grant super status; false to revoke it
environmentsstring[]No*Replacement list of environments (dev, production). Must be non-empty.

* At least one field must be provided.

Environment Access Rules

The caller's environments are looked up from DynamoDB. If the caller attempts to grant an environment they don't have access to, the request is rejected with 403 Forbidden. Every user — including bootstrapped super users — must have a DynamoDB record.

Response Codes

CodeReason
200 OKUser updated; response echoes the fields that were changed
400 Bad RequestMissing or invalid fields
403 ForbiddenCaller is not a super user, or attempting to grant an environment they don't have
404 Not FoundUser not found in Cognito when updating is_super (user may not have signed in yet)
409 ConflictCannot demote the last super user

See the API Reference for full schema documentation.

Deployment

See the deployment workflow documentation for workflow steps, infrastructure dependencies, and failure scenarios.