---
title: '`glab artifact-registry get-token`'
stage: AI Coding
group: Code Review
info: To determine the technical writer assigned to the Stage/Group associated with this page, see <https://handbook.gitlab.com/handbook/product/ux/technical-writing/#assignments>
---

<!--
This documentation is auto generated by a script.
Please do not edit this file directly. Run `make gen-docs` instead.
-->

Get a short-lived access token for the GitLab Artifact Registry. (EXPERIMENTAL)

## Synopsis

Exchange a GitLab credential for a short-lived access token scoped to the
GitLab Artifact Registry. The command prints the bare token to stdout,
so a shell can capture it directly, for example to feed `docker login`.

Prerequisites:

- A GitLab Enterprise Edition (EE) instance on GitLab 19.1 or later.
- Token exchange enabled on the instance (the
  `gate_token_exchange_endpoint` feature flag).

This feature is an experiment and is not ready for production use.
It might be unstable or removed at any time.
For more information, see
<https://docs.gitlab.com/policy/development_stages_support/>.

```plaintext
glab artifact-registry get-token [flags]
```

## Examples

```console
# Get a token using the default duration
glab artifact-registry get-token

# Get a token valid for one hour
glab artifact-registry get-token --duration 1h

# Get a token as JSON, including its expiry
glab artifact-registry get-token --output json

```

## Options

```plaintext
      --duration duration   How long the token should remain valid. Must be between 1s and 12h0m0s. (default 15m0s)
      --hostname string     GitLab hostname to request the token from. Defaults to the configured GitLab instance.
      --jq string           Filter JSON output with a jq expression.
  -F, --output string       Format output as: text, json. (default "text")
```

## Options inherited from parent commands

```plaintext
  -h, --help   Show help for this command.
```
