Skip to main content

User Tokens API

If you’re a Nexus Repository administrator, you can use the user tokens REST API to create and manage tokens for your team. Use the following endpoints to create user tokens, check token metadata, list and delete tokens when you no longer need them. For more details on the example responses, refer to Nexus Repository API Reference documentation.

Create a User Token

The following endpoint creates a user token for the specified userId and realm using the system’s default expiration settings. Note that passCode is displayed only at the time of creation and should be stored securely.

POST /service/rest/v1/security/users/{userId}/{realm}/user-token

Path Parameters:

  • userId: Target user identifier

  • realm: The target user’s authentication realm ID. Use NexusAuthenticatingRealm for local users, LdapRealm for LDAP users, SamlRealm for SAML users, or Crowd for Atlassian Crowd users. Do not use User-Token-Realm for this parameter.

Note

Nexus Repository does not log passCode. Users are advised to store their passCode in a secure location.

Get User Token Metadata

The following endpoint retrieves metadata for the specified userId and realm. It returns only the metadata.

GET /service/rest/v1/security/users/{userId}/{realm}/user-token

Path Parameters:

  • userId: Target user identifier

  • realm: The target user’s authentication realm ID. Use NexusAuthenticatingRealm for local users, LdapRealm for LDAP users, SamlRealm for SAML users, or Crowd for Atlassian Crowd users. Do not use User-Token-Realm for this parameter.

List all User Tokens

The following endpoint retrieves a paginated list of user tokens. It uses filters such as realm, userId, and includeExpired, along with pagination controls like skip and limit, to narrow results and manage large token inventories.

GET /service/rest/v1/security/user-tokens/tokens

Path Parameters:

  • realm: The target user’s authentication realm ID. Use NexusAuthenticatingRealm for local users, LdapRealm for LDAP users, SamlRealm for SAML users, or Crowd for Atlassian Crowd users. Do not use User-Token-Realm for this parameter.

    GET /service/rest/v1/security/user-tokens/tokens?realm=<realmId>
  • userId: Filter by user ID (optional)

  • includeExpired: Include expired tokens (default: false)

  • skip: Number of items to skip for pagination (default: 0)

  • limit: Maximum number of items to return (default: 25, max: 100)

  • nameCode: Filters user tokens by the token nameCode. This is useful to look up the owning userId and realm for a specific user token. This parameter does not expose token secrets. This parameter is available from 3.93 in self-hosted deployments.

    GET /service/rest/v1/security/user-tokens/tokens?nameCode=<token-name-code>

    Note

    The lowercase namecode query parameter continues to be accepted for backward compatibility. Use nameCode for new requests.

Delete a User Token

Permanently deletes the user token for the specified userId and realm, immediately revoking access that depends on that token. After deletion, a new token can be created again for that user/realm.

DELETE /service/rest/v1/security/users/{userId}/{realm}/user-token

Path Parameters:

  • userId: Target user identifier

  • realm: The target user’s authentication realm ID. Use NexusAuthenticatingRealm for local users, LdapRealm for LDAP users, SamlRealm for SAML users, or Crowd for Atlassian Crowd users. Do not use User-Token-Realm for this parameter.

Reset a User Token

Use this endpoint when you need to revoke a user's existing user token and all their supported format-specific tokens.

DELETE /service/rest/v1/security/users/{userId}/{realm}/user-token-reset

Path Parameters:

  • userId: Target user identifier

  • realm: Authentication realm. Use NexusAuthenticatingRealm for local users, or LdapRealm for LDAP users. For all realm IDs, see Available Realms..

The reset does not affect the user's password or service-account tokens.

Note

In self-hosted versions earlier than 3.98.0, the endpoint removes only the user token, just like the Delete a Use Token endpoint. Hence it was deprecated but still works for backward compatibility.

Reset Tokens for a Specific Format

Use this endpoint when you need to revoke a user's tokens for a specific repository format without affecting their user token or tokens for other formats. This endpoint supports resetting format-specific authentication tokens, including bearer tokens and NuGet API keys. For valid format values, see the Nexus Repository API Reference.

DELETE /service/rest/v1/security/users/{userId}/{realm}/format-tokens/{format}

Path Parameters:

  • userId: Target user identifier

  • realm: Authentication realm. Use NexusAuthenticatingRealm for local users, or LdapRealm for LDAP users. For all realm IDs, see Available Realms.

  • format: Supported formats like Conan, Docker, Huggingface, npm, NuGet, OCI and Terraform

Delete All User Tokens

Use this endpoint when you need to revoke user tokens for all users, such as during credential rotation or incident response.

DELETE /service/rest/v1/security/user-tokens

Starting with Nexus Repository Pro 3.99.0, this operation also revokes all users' supported format-specific tokens. In earlier self-hosted versions, it revokes only user tokens.

The operation does not affect user passwords or service-account tokens.