Skip to main content
POST
Rotate the GitLab access token
Replace the GitLab access token Gitar uses, e.g. from the job that rotates it in GitLab. Gitar validates the new token against your connected instance and group before storing it. If validation fails, the current token stays in use.

Prerequisites

Restrictions

The new token must authenticate as the same GitLab user as the current token. This endpoint renews a credential and does not switch accounts. To connect a different GitLab user, update the token from the GitLab settings page in Gitar. The new token must pass the same checks as the connect form, including the api scope and access to the connected group. Each rotation is recorded in the organization’s audit log with the API token that made it.

Example

Organizations with more than one connected GitLab instance must also pass host, e.g. "host": "https://gitlab.example.com".

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json

Request to replace the connected GitLab token.

access_token
string
required

The new GitLab personal or service account access token. It must authenticate as the same GitLab user as the token it replaces.

host
string | null

GitLab instance to update, e.g. https://gitlab.example.com. Required once the organization connects more than one instance.

Response

Token validated and stored

Result of a successful token rotation.

host
string
required

The GitLab instance whose token was replaced.

expires_at_ms
integer<int64> | null

When GitLab says the new token expires, in milliseconds since the Unix epoch. null when the token has no expiry.

Required range: x >= 0