# Save the organization's sign-in for a registry

> PUT /v1/registry-sign-ins/{registry}. , deprecated by createRegistryCredential and updateRegistryCredential.

Source: https://legion.ambient.xyz/docs/api/images/put-registry-sign-in

`PUT https://api.legion.ambient.xyz/v1/registry-sign-ins/{registry}`

Authenticate with an API key: `Authorization: Bearer $LEGION_API_KEY`.

, deprecated by `createRegistryCredential` and `updateRegistryCredential`. Saves
a username and a read token as the organization's credential for the whole registry (path prefix
`""`), so the organization's rentals can run images that registry does not serve anonymously. A
second save replaces that credential's secret (`created_at` stays, `updated_at` moves). Needs
`registry.manage`, which owners have (since; before, `rentals.manage`).

**Checked before it is saved.** `image` is the image the sign-in is for, on this same
registry (else 400 `image_registry_mismatch`). Legion exchanges the sign-in at the
registry's own token service for a pull token of that one repository and reads the image's
manifest with it. Nothing is saved, and an existing sign-in is left as it was, when:

- the registry refuses the sign-in, or it has no access to that repository: 422
  `registry_sign_in_rejected`, with `registry`;
- the image does not exist, read with a working sign-in: 422 `image_not_found`;
- the registry or its token service did not answer: 503 `image_registry_unavailable`.

**What each registry expects.** `docker.io`: the Docker Hub username and a read-only
personal access token. `ghcr.io`: the GitHub username and a token with `read:packages` only. `nvcr.io`: the username is literally `$oauthtoken` and the token is an NGC API key. `quay.io`:
a robot account's name (`org+robot`) and its token. Make a token for Legion alone, read only,
so it can be revoked without touching anything else.

**How it is used.** The token is kept in Vault, never in Legion's database, a response, a
log, an event or a problem. It is only ever sent to its registry's own token service,
discovered and pinned when it is saved (never one a registry names later), in exchange for a
pull token of one repository, short-lived as the registry issues it, that reads every tag of
that repository. Hosts get such a pull token while a rental of the image is starting
(`getAgentRegistryCredentials`), never the saved token. The image is pulled on the provider's
machine and runs there, where the provider has root.

`username` is 1 to 255 printable characters and `token` 1 to 4096, neither with spaces or
control characters (400 `invalid_sign_in`). Each organization may save 20 sign-ins an hour,
checked or not (429 `rate_limited`). On a controller without registry sign-ins configured
the answer is 503 `registry_sign_ins_unavailable`. Recorded as the event
`registry_sign_in.created` or `registry_sign_in.replaced` (`org_id`, `user_id`, `registry`,
`client`), never with the token or the username.

## Path parameters

- `registry`, RegistrySignInRegistry, required: The registry of the sign-in.

## Request body

- `username`, string, required: The registry username (`$oauthtoken` on `nvcr.io`, the robot account on `quay.io`).
- `token`, string, required: A read-only token made for Legion. Write-only: kept in Vault, never returned or logged.
- `image`, string, required: The image the sign-in is for, on the same registry. Its manifest is read with the sign-in before it is saved.

Example:

```json
{
  "username": "string",
  "image": "string"
}
```

## Responses

### 200

The sign-in as saved.

- `registry`, RegistrySignInRegistry, required: . A registry Legion pulls private images from with an organization's sign-in, named as image references name it: `docker.io` (Docker Hub), `ghcr.io`, `nvcr.io` (NGC), `quay.io`.
- `username`, string, required: The username the token goes with (`$oauthtoken` on `nvcr.io`).
- `created_at`, string (date-time), required
- `updated_at`, string (date-time), required: When it was last saved; equal to `created_at` until it is replaced.
- `last_used_at`, string (date-time): When a host last got a pull token made from it; absent until then.
- `last_checked_at`, string (date-time), required: When the registry last answered a token exchange with it.
- `last_check_result`, RegistrySignInCheckResult, required: How the sign-in's last check went: `ok`, or `rejected` when the registry refused it (when it was saved, when an image was inspected or a rental created with it, or when a host pulled with it).

Example:

```json
{
  "registry": "docker.io",
  "username": "string",
  "created_at": "2026-10-15T12:00:00Z",
  "updated_at": "2026-10-15T12:00:00Z",
  "last_used_at": "2026-10-15T12:00:00Z",
  "last_checked_at": "2026-10-15T12:00:00Z",
  "last_check_result": "ok"
}
```

### 400

The request is malformed or fails validation. An image reference that
is not a container image reference answers `invalid_image_reference`.

### 401

Missing, unknown, expired or revoked credentials.

### 403

The caller lacks the permission this operation requires (`forbidden`),
or signed in without having joined an organization yet
(`no_organization`; `getOnboarding` and the invitation and
organization operations under it work), or could not sign in
(`email_unverified`, `account_conflict`, and `domain_not_allowed`). `not_invited` is no longer returned to
session tokens.

`access_not_approved`: a signed-in person who is not approved
for the beta yet. Every operation that takes a credential answers it to
them, except `getMe` and `joinMyWaitlist`; the problem carries
`access` (`waitlisted` or `not_requested`, and the email). Approved
means a member of an organization, holding a pending invitation, or Legion; an API key always belongs to a member.

`oauth_token_mcp_only`: the caller sent an OAuth access token (`lgo_`), which is accepted
only by `mcpMessage` and the tool calls it dispatches. Every other operation answers it, whatever
the token's scope. Use an API key or the Legion web app.

`org_suspended`: the caller's organization is suspended. Every operation that takes a
credential answers it, by session or API key, except `getMe` (which shows `org.suspended_at` and
`org.suspension_reason`) and the support operations under `/v1/support/`.

`terms_not_accepted`: an approved caller who has not accepted
the current version of the Terms of Use and the Acceptable Use Policy. Every operation that takes a credential answers it, except `getMe`,
`acceptLegalDocuments`, `joinMyWaitlist` and the wind-down operations
(`listRentals`, `stopRental`, `deleteRental`, `listHosts`,
`updateListing` with `listed` false, `removeHost`); the problem
carries `legal`. An API key acts for the person who created it, so it
is refused until that person accepts. Terminal
operations also return
`session_required` (called with an API key) and `step_up_required`
(neither a sign-in nor a step-up challenge within the step-up window).

### 422

The registry refused the sign-in (`registry_sign_in_rejected`), the image does not exist
(`image_not_found`), or it is in a format Legion cannot read (`image_manifest_unsupported`). Nothing was saved.

### 429

Rate limited (`code` is `rate_limited`), or the organization asked the
pull-through mirror to copy in too many different tags or digests of one
repository today (`mirror_quota_exceeded`). Retry after the `Retry-After`
seconds.

### 500

An unexpected server error. Safe to retry.

### 503

A dependency is unavailable (`terminal_signing_unavailable`;
`image_registry_unavailable` when the image's registry did not answer in
time or failed; `secrets_unavailable` when secret variables cannot be
stored or read). Safe to retry.

## Errors

- 400 [`image_registry_mismatch`](https://legion.ambient.xyz/docs/errors#image_registry_mismatch)
- 400 [`invalid_image_reference`](https://legion.ambient.xyz/docs/errors#invalid_image_reference)
- 400 [`invalid_sign_in`](https://legion.ambient.xyz/docs/errors#invalid_sign_in)
- 403 [`no_organization`](https://legion.ambient.xyz/docs/errors#no_organization)
- 422 [`image_not_found`](https://legion.ambient.xyz/docs/errors#image_not_found)
- 422 [`image_manifest_unsupported`](https://legion.ambient.xyz/docs/errors#image_manifest_unsupported)
- 422 [`registry_sign_in_rejected`](https://legion.ambient.xyz/docs/errors#registry_sign_in_rejected)
- 429 [`rate_limited`](https://legion.ambient.xyz/docs/errors#rate_limited)
- 503 [`image_registry_unavailable`](https://legion.ambient.xyz/docs/errors#image_registry_unavailable)
- 503 [`registry_sign_ins_unavailable`](https://legion.ambient.xyz/docs/errors#registry_sign_ins_unavailable)

## Example request

```sh
curl -s -X PUT "https://api.legion.ambient.xyz/v1/registry-sign-ins/$REGISTRY" \
  -H "Authorization: Bearer $LEGION_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "username": "string",
  "image": "string"
}'
```
