home | help
glab(1) 								 glab(1)

NAME
     glab-service-account-token-rotate - Rotate a token of a service account.

SYNOPSIS
     glab service-account token rotate	 [flags]

DESCRIPTION
     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,  de-
       scription, and scopes. Anything using the old value stops working immedi-
       ately.

     * 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.

OPTIONS
     -D,  --duration=30d       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.

     -E, --expires-at=	    Expiry date of the new token, as YYYY-MM-DD. The to-
     ken expires at midnight UTC on that date.

     -g,  --group=""	  Rotate a token of a service account of a group instead
     of a project. Accepts a group ID or full path.

     --jq=""	  Filter JSON output with a jq expression.

     -F, --output="text"      Format output  as  'text'  for  the  token  value,
     'json' for the token with its details.

     -R, --repo=""	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
     -h, --help[=false]      Show help for this command.

EXAMPLE
     # 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)

SEE ALSO
     glab-service-account-token(1)

Auto generated by spf13/cobra	    Nov 2026				 glab(1)

home | help