Skip to content

mw gitlab token rotate

Releasev0.35.0 · cfeceb67

mw gitlab token rotate <token-name|token-id> [flags]

Rotate user, group, or project access token, then print the new token on stdout. If multiple tokens with the same name exist, you can specify the ID of the token.

The expiration date of the token will be calculated by adding the duration (default 30 days) to the current date, with expiration occurring at midnight UTC on the calculated date. Alternatively you can specify a different duration using days (d), weeks (w), or hours (h), or provide an explicit end date.

The output format can be either “JSON” or “text”. The JSON output will show the meta information of the rotated token.

Administrators can rotate personal access tokens belonging to other users.

-D, --duration <duration>
Sets the token lifetime in days. Accepts: days (30d), weeks (4w), or hours in multiples of 24 (24h, 168h, 720h). Maximum: 365d. The token expires at midnight UTC on the calculated date. Default: 30d.
-E, --expires-at <DATE>
Sets the token's expiration date and time, in YYYY-MM-DD format. If not specified, --duration is used. Default: 0001-01-01.
-g, --group <string>
Rotate group access token. Ignored if a user or repository argument is set.
-F, --output <string>
Format output as: text, json. 'text' provides the new token value; 'json' outputs the token with metadata. Default: text.
-R, --repo <OWNER/REPO>
Select another repository. Can use either OWNER/REPO or `GROUP/NAMESPACE/REPO` format. Also accepts full URL or Git URL.
-U, --user <string>
Rotate personal access token. Use @me for the current user.
-h, --help
Show help for this command.
--no-interaction
Do not ask any interactive questions
--profile <string>
Saved account profile (login defaults to the verified username)
-v, --verbose <count>
Increase output verbosity. Example: --verbose=2 or -vv
Terminal window
# Rotate project access token of current project (default 30 days)
$ glab token rotate my-project-token
# Rotate project access token with explicit expiration date
$ glab token rotate --repo user/repo my-project-token --expires-at 2025-08-08
# Rotate group access token with 7 day lifetime
$ glab token rotate --group group/sub-group my-group-token --duration 7d
# Rotate personal access token with 2 week lifetime
$ glab token rotate --user @me my-personal-token --duration 2w
# Rotate a personal access token of another user (administrator only)
$ glab token rotate --user johndoe johns-personal-token --duration 90d
Report an issue with this page

Report a documentation issue

The report includes this page’s link, section and documentation version.

Review and submit on Phabricator, or run the command using your saved CLI profile. The command asks before creating the task.