POST
Store a repository credential

Authorizations

Authorization
string
header
required

Authorization: Bearer twk_<prefix>_<secret>.

The prefix is public and safe to log: it is what identifies which credential leaked. The secret is never logged, never returned after creation, and stored only as a SHA-256 hash.

Body

application/json

The body for both /registry-credentials and /git-credentials. Which schemes are accepted depends on which surface you POST to, and a scheme offered to the wrong one is refused:

The last four are exchanged by the server for a short-lived registry login at scan time; a long-lived registry password is never derived from them and never stored. assume_role stores no secret at all: the role's trust policy must require the external_id the response returns, which is what stops another tenant naming the same role.

A scheme whose host does not match (azure_service_principal against ghcr.io, say) is refused at save time rather than at scan time, so a misconfiguration is visible when it is made.

name
string
required
registry
string
required

The host. Canonicalised on storage, and the matching key: see RegistryCredential.registry.

Example:

"ghcr.io"

scheme
enum<string>
required
Available options:
basic,
token,
bearer,
assume_role,
aws_access_key,
azure_service_principal,
gcp_service_account
username
string

Required for basic, assume_role, aws_access_key and azure_service_principal; must be omitted or empty for token, bearer and gcp_service_account. See the table above for what it holds in each case.

secret
string

Write-only. It has no counterpart on any response, and no endpoint returns it. Required for every scheme except assume_role, which refuses one.

Response

Stored. The response carries status, never the secret.

A stored registry credential, without its secret. There is no read path for the plaintext at any permission, so no response anywhere carries one. A customer who has lost their token rotates it.

id
string<uuid>
required
name
string
required

What a human calls it, such as "ACME production Harbor".

kind
enum<string>
required

registry for a credential served by /registry-credentials, git for one served by /git-credentials. The listings return only their own kind, but the routes that take an {id} reach any credential the organization holds, so rotating the credential behind a cloud account or a cluster answers with cloud or kubernetes. The two surfaces share this schema and are separate stores: github.com serves both a registry and a repository host, the tokens differ, and they are rotated on different schedules.

Available options:
registry,
git,
cloud,
kubernetes
registry
string
required

The canonicalised host this credential authenticates to, such as ghcr.io or registry.example.com:5000, or github.com or bitbucket.example.com:8443 for a git credential. Also the matching key: a credential is selected for a scan by the host of the image or repository being scanned, never named by the caller.

Example:

"ghcr.io"

scheme
enum<string>
required

How this credential authenticates. See CreateRegistryCredential for which schemes each surface accepts and what each requires.

Available options:
basic,
token,
bearer,
assume_role,
aws_access_key,
azure_service_principal,
gcp_service_account
status
enum<string>
required

unverified has never authenticated, active last did so successfully, invalid was rejected by the registry, disabled was switched off by an administrator. A timeout or an unreachable host leaves the status untouched rather than marking it invalid.

Available options:
unverified,
active,
invalid,
disabled
created_at
string<date-time>
required
updated_at
string<date-time>
required
username
string

Stored in plaintext deliberately: it is not a secret, and it is what makes "which account is this" answerable. What it holds depends on the scheme: a username for basic, the role ARN for assume_role, the access key id for aws_access_key, <tenant-id>/<client-id> for azure_service_principal. Absent for token, bearer and gcp_service_account.

external_id
string

The sts:ExternalId this credential's role trust policy must require. Derived rather than stored, and present only for an Amazon ECR assume_role credential.

status_reason
string

Why the credential is in its current status, classified. Never the registry's raw error, which can echo the request.

last_verified_at
string<date-time>
last_used_at
string<date-time>

When a scan last resolved it. Separate from last_verified_at: verification answers "does this work", use answers "is this still needed".

rotated_at
string<date-time>
created_by
string<uuid>