--- title: '`glab service-account token rotate`' stage: AI Clients group: Developer Clients info: To determine the technical writer assigned to the Stage/Group associated with this page, see --- Rotate a token of a service account. ## Synopsis Rotate a personal access token of a service account of a project or a group. - Rotating revokes the token and creates a new one with the same name, description, and scopes. Anything using the old value stops working immediately. - The new token value is printed only once and cannot be retrieved later. It is the only output on stdout, and the token details go to stderr. - The new token expires after `--duration`, 30 days by default, at 00:00 UTC. Use `--expires-at` for a specific date instead. - A token name matches active tokens only. If several active tokens share the name, use the token ID instead. - Numeric arguments are always treated as IDs. Token IDs and names come from `glab service-account token list`. Finding a token by name for a group service account requires GitLab 17.11 or later. ```plaintext glab service-account token rotate [flags] ``` ## Examples ```console # Rotate token 7 of service account 42 of the current project glab service-account token rotate 42 7 # Rotate a token by its name for 90 days, finding the account by its username glab service-account token rotate release-bot ci --duration 90d # Rotate a token of a group's service account until the end of 2027 glab service-account token rotate 42 7 --expires-at 2027-12-31 --group my-group # Rotate a token and store the new value in a variable TOKEN=$(glab service-account token rotate 42 ci) ``` ## Options ```plaintext -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 time Expiry date of the new token, as YYYY-MM-DD. The token expires at midnight UTC on that date. -g, --group group Rotate a token of a service account of a group instead of a project. Accepts a group ID or full path. --jq string Filter JSON output with a jq expression. -F, --output string Format output as 'text' for the token value, 'json' for the token with its details. (default "text") -R, --repo string Select another repository. You can use either OWNER/REPO or GROUP/NAMESPACE/REPO. The full URL or Git URL is also accepted. ``` ## Options inherited from parent commands ```plaintext -h, --help Show help for this command. ```