# User Management

API7 Enterprise provides built-in user management with role-based access control (RBAC). You can manage users, roles, and permission policies through the Dashboard or the Admin API.

## Prerequisites[​](#prerequisites "Direct link to Prerequisites")

* A [token from the Dashboard](https://docs.api7.ai/api7-gateway/reference/obtain-dashboard-token.md).

## Default Admin Account[​](#default-admin-account "Direct link to Default Admin Account")

When API7 Gateway starts for the first time, it creates a default administrator account:

* **Username**: `admin`
* **Password**: `admin`
* **Role**: `super_admin`

The `super_admin` role is a built-in role with full access to all resources and actions. Change the default password immediately after your first login for security.

## User Lifecycle[​](#user-lifecycle "Direct link to User Lifecycle")

Manage users by inviting them to your organization and assigning appropriate roles.

### Invite a User[​](#invite-a-user "Direct link to Invite a User")

To invite a new user, send a POST request to the `/api/invites` endpoint.

```
curl -k "https://localhost:7443/api/invites" -X POST \

  -H "X-API-KEY: ${API_KEY}" \

  -H "Content-Type: application/json" \

  -d '{

    "username": "developer_jane",

    "password": "TemporaryPassword123!",

    "name": "Jane Doe"

  }'
```

### List Users[​](#list-users "Direct link to List Users")

To retrieve a list of all users:

```
curl -k "https://localhost:7443/api/users" -X GET \

  -H "X-API-KEY: ${API_KEY}"
```

### Update User Labels[​](#update-user-labels "Direct link to Update User Labels")

Retrieve the user before updating so you can preserve any labels that should remain:

```
curl -k "https://localhost:7443/api/users/${USER_ID}" \

  -H "X-API-KEY: ${API_KEY}"
```

Update the user with the complete desired label map:

```
curl -k "https://localhost:7443/api/users/${USER_ID}" -X PUT \

  -H "X-API-KEY: ${API_KEY}" \

  -H "Content-Type: application/json" \

  -d '{

    "labels": {

      "team": "payments",

      "environment": "production"

    }

  }'
```

The `labels` field replaces the complete label map rather than merging individual entries. Include every existing label you want to preserve together with the new values.

Read the user again and confirm the complete label map:

```
curl -k "https://localhost:7443/api/users/${USER_ID}" \

  -H "X-API-KEY: ${API_KEY}"
```

This administrative endpoint does not change a user's name or email. Users update their own display name in the Dashboard or through `PUT /api/me`. Email replacement is available in the Dashboard or through `PUT /api/me/email` and requires a working SMTP configuration and email verification.

### Assign Roles[​](#assign-roles "Direct link to Assign Roles")

Assign one or more roles to a user by updating their assigned roles.

```
curl -k "https://localhost:7443/api/users/${USER_ID}/assigned_roles" -X PUT \

  -H "X-API-KEY: ${API_KEY}" \

  -H "Content-Type: application/json" \

  -d '{

    "roles": ["role_id_1", "role_id_2"]

  }'
```

### Delete a User[​](#delete-a-user "Direct link to Delete a User")

To remove a user from the organization:

```
curl -k "https://localhost:7443/api/users/${USER_ID}" -X DELETE \

  -H "X-API-KEY: ${API_KEY}"
```

## User Fields[​](#user-fields "Direct link to User Fields")

The user resource contains the following key fields:

| Field        | Type   | Description                                                                                |
| ------------ | ------ | ------------------------------------------------------------------------------------------ |
| `id`         | UUID   | Auto-generated unique identifier for the user.                                             |
| `username`   | String | Unique username used for authentication.                                                   |
| `name`       | String | Display name for the user.                                                                 |
| `email`      | String | User's email address.                                                                      |
| `labels`     | Object | Complete set of labels attached to the user.                                               |
| `provider`   | Enum   | Authentication source: `builtin` (local), `sso` (OIDC/SAML), or `scim` (provisioned).      |
| `roles`      | Array  | References to roles assigned to the user.                                                  |
| `boundaries` | Array  | Permission policies attached directly to the user to restrict their effective permissions. |

## Roles[​](#roles "Direct link to Roles")

A role is a collection of permission policies that define what a user can do.

* **Built-in Roles**: API7 Gateway ships with a single built-in role, `Super Admin`, which is bound to the non-editable `super-admin-permission-policy` and grants full access to all resources. The initial administrator account is permanently tied to this role.
* **Custom Roles**: Create roles tailored to your organization's structure, such as `api_provider`, `runtime_admin`, or `viewer`. See [Role-Based Access Control](https://docs.api7.ai/api7-gateway/security-and-compliance/role-based-access-control.md) for design guidance.

### Create a Custom Role[​](#create-a-custom-role "Direct link to Create a Custom Role")

```
curl -k "https://localhost:7443/api/roles" -X POST \

  -H "X-API-KEY: ${API_KEY}" \

  -H "Content-Type: application/json" \

  -d '{

    "name": "API Provider",

    "desc": "Can manage services and routes but cannot delete them.",

    "policies": ["policy_id_1"]

  }'
```

## Permission Policies[​](#permission-policies "Direct link to Permission Policies")

Permission policies define the fine-grained rules for access control. Each policy consists of one or more statements.

A statement includes:

* **Effect**: `allow` or `deny`.
* **Resources**: An array of ARN patterns (e.g., `arn:api7:gateway:gatewaygroup/<.*>`).
* **Actions**: An array of action strings in the form `<namespace>:<Verb><Resource>` (e.g., `gateway:GetGatewayGroup`, `iam:InviteUser`).
* **Conditions**: Optional constraints, such as matching labels (`MatchLabel`) or verifying string arrays (`AllOfStrings`).

See [Permission Policies and Boundaries](https://docs.api7.ai/api7-gateway/security-and-compliance/permission-policies-and-boundaries.md) for the full JSON syntax and [Permission Policy Actions and Resources](https://docs.api7.ai/api7-gateway/reference/permission-policy-action-and-resource.md) for the complete catalog of supported actions and ARNs.

### Example Permission Policy[​](#example-permission-policy "Direct link to Example Permission Policy")

This policy allows read-only access to a specific Gateway Group identified by its ID.

```
{

  "name": "ReadOnlyProdGatewayGroup",

  "desc": "Read-only access to the production gateway group.",

  "policy_document": {

    "statement": [

      {

        "effect": "allow",

        "resources": ["arn:api7:gateway:gatewaygroup/prod-group-id"],

        "actions": [

          "gateway:GetGatewayGroup",

          "gateway:GetGatewayInstance"

        ]

      }

    ]

  }

}
```

## Permission Boundaries[​](#permission-boundaries "Direct link to Permission Boundaries")

Permission boundaries are policies attached directly to a user rather than through a role. They act as a "ceiling" for the user's permissions. Even if a role grants a specific action, the user cannot perform it unless the permission boundary also allows it.

Use boundaries to limit a user's operations to a specific scope, such as a single Gateway Group or environment, regardless of the roles they hold.

## Permission Evaluation[​](#permission-evaluation "Direct link to Permission Evaluation")

API7 Gateway uses a policy-based evaluation engine to authorize requests.

1. The engine collects all policies from the user's assigned roles and their permission boundaries.
2. If any applicable policy has a `deny` effect, the request is immediately denied.
3. The request is only allowed if there is at least one `allow` policy that matches the action and resource.
4. If no policy explicitly allows the action, the request is denied by default.

## Single Sign-On (SSO)[​](#single-sign-on-sso "Direct link to Single Sign-On (SSO)")

API7 Gateway supports external identity providers for authentication and user provisioning.

* **OIDC (OpenID Connect)**: Integrate with providers like Okta, Auth0, or Google.
* **SAML**: Support for enterprise identity systems.
* **LDAP**: Authenticate users against an LDAP directory.
* **SCIM**: Automated user provisioning and de-provisioning from your identity provider.

Users authenticated via SSO or LDAP will have their `provider` field set to `sso`, while users provisioned via SCIM will have their `provider` field set to `scim`. For configuration details, see [SSO for Dashboard](https://docs.api7.ai/api7-gateway/security-and-compliance/sso-dashboard.md) and [SCIM Provisioning for Dashboard](https://docs.api7.ai/api7-gateway/security-and-compliance/authenticate/scim.md).

## Next Steps[​](#next-steps "Direct link to Next Steps")

* [Role-Based Access Control](https://docs.api7.ai/api7-gateway/security-and-compliance/role-based-access-control.md)
* [Permission Policy Reference](https://docs.api7.ai/api7-gateway/reference/permission-policy-action-and-resource.md)
* [SSO Configuration Guide](https://docs.api7.ai/api7-gateway/security-and-compliance/sso-dashboard.md)
* [SCIM Provisioning Guide](https://docs.api7.ai/api7-gateway/security-and-compliance/authenticate/scim.md)
