

# Set up and test a record visibility configuration

This topic shows how to add a record visibility configuration to an existing registry, test it with representative callers, and remove it. It also explains when a change takes effect, how to recover from a failed update, and how to read the configuration state.

## Prerequisites
<a name="registry-record-visibility-configure-prereqs"></a>

Before you set a record visibility configuration, check the permissions and setup in this section. `agent-registry:PutRecordVisibilityConfiguration` is a permission-only action with no API operation of its own. AWS Agent Registry checks it in addition to the `CreateRegistry` or `UpdateRegistry` action.

The following table lists the AWS Identity and Access Management (IAM) actions that each task requires.


| Task | Required actions | Notes | 
| --- | --- | --- | 
| Add, replace, or remove a configuration |  `agent-registry:UpdateRegistry` and `agent-registry:PutRecordVisibilityConfiguration`  | You need both actions whenever the request includes `recordVisibilityConfiguration`, even if the request changes nothing. The service evaluates `PutRecordVisibilityConfiguration` with the registry’s existing tags. | 
| Create a registry with a configuration |  `agent-registry:CreateRegistry` and `agent-registry:PutRecordVisibilityConfiguration`. If you supply tags, also `agent-registry:TagResource`. | The service evaluates `PutRecordVisibilityConfiguration` with the request’s tags as the resource tags. | 
| Read the current and pending configuration |  `agent-registry:GetRegistry`  | Only the registry owner’s account receives the configuration state. | 

Without `PutRecordVisibilityConfiguration`, the request returns `AccessDeniedException`. For the other registry permissions, see [IAM Permissions](registry-iam-permissions.md). You also need the following:
+  **The owner account and a registry that accepts updates** – Only the account that owns the registry can set, replace, or remove its configuration. An `UpdateRegistry` call from another account returns `AccessDeniedException` with the message `Cross-account access is not allowed for operation: UpdateRegistry`. The registry must be `READY`, or `UPDATE_FAILED` when you retry a failed change. For that case, see [Recover from a failed update](#registry-record-visibility-configure-failed). While a create or update is in progress, wait for it to finish. To create a registry, see [Create a registry](registry-create-manage.md#registry-create).
+  **IAM credentials for configuration management** – Configuration management always uses IAM, even on a registry that uses JSON Web Token (JWT) authorization for discovery. For more information, see [Authorization scope](registry-supported-auth-types.md#registry-auth-scope).
+  **Declared metadata fields** – You must declare each `customMetadata/<key>` field that a configuration names in the registry’s default schema or in a record-type schema. If one request supplies both a schema and a configuration, the service validates the schema first. For more information, see [Define a custom metadata schema](registry-custom-metadata-schema.md).
+  **Approved, labeled records** – A configuration evaluates the approved revision of each record. To create and approve records, see [Create and manage records](registry-create-manage-records.md) and [Reviewing registry records](registry-reviewing-records.md).
+  **Controls on the attributes that the configuration trusts** – You need to restrict who can set principal tags, token claims, and record labels before a configuration relies on them. For more information, see [Security considerations for record visibility configurations](registry-record-visibility-security.md).
+  ** `kms:Decrypt` for IAM callers on a customer managed key** – IAM discovery callers need the AWS Key Management Service (AWS KMS) permission `kms:Decrypt` on the key for Search and BatchGet. They can also need it for List when a record visibility configuration restricts what they can see. They might need it even when no records come back. For details, see [KMS permissions used by each API operation](registry-data-encryption.md#registry-encryption-per-api).
+  **Key permissions for configuration management on a customer managed key** – If a registry encrypted with a customer managed key has a custom metadata schema, the IAM principal that manages the configuration also needs the key permissions that `GetRegistry` and `UpdateRegistry` need to read that schema. For those permissions, see the `GetRegistry` and `UpdateRegistry` rows in [KMS permissions used by each API operation](registry-data-encryption.md#registry-encryption-per-api).

## Add or replace a configuration
<a name="registry-record-visibility-configure-api"></a>

A registry has one record visibility configuration document. To add a configuration or change it, you send the whole document, and it replaces any current configuration. The following example sets up department access, and the procedures after it apply the example to an existing registry.

**Adding a configuration can require `kms:Decrypt` for List**  
On a registry encrypted with a customer managed key, `ListDiscoverableRegistryRecords` and the MCP list tool can require `kms:Decrypt` from an IAM caller when a record visibility configuration restricts which records that caller can see. Search and BatchGet already require it. List calls that succeeded before you add a configuration can then fail with an AWS KMS error. Before you add a configuration, allow `kms:Decrypt` on the key for every IAM principal that lists the registry’s records, in its identity policy and in the key policy. For details, see [KMS permissions used by each API operation](registry-data-encryption.md#registry-encryption-per-api).

### Example – Department access
<a name="registry-record-visibility-configure-walkthrough"></a>

In this example, each caller discovers only the records labeled with the caller’s department. The example uses the following setup:
+  **A trusted caller attribute** – Two IAM roles in the owner’s account, `FinanceReader` and `LegalReader`. An administrator sets a `department` principal tag on each role, `finance` and `legal`, and the roles can’t change their own tags. For more information, see [Prevent callers from setting their own principal tags](registry-record-visibility-security.md#registry-record-visibility-security-tags). Both roles can call the discovery operations. For the actions, see [Registry data plane actions](registry-iam-permissions.md#registry-iam-data-plane).
+  **One schema field** – The registry’s default schema declares `department` as a string, as in the following schema. For instructions, see [Defining the schema](registry-custom-metadata-schema.md#registry-custom-metadata-schema-define).

  ```json
  {"type": "object", "properties": {"department": {"type": "string"}}}
  ```
+  **One approved, labeled record** – The registry has one approved record, `finance-mcp`, labeled `department=finance`. For instructions, see [Create a registry record](registry-create-manage-records.md#registry-create-record) and [Approve a record](registry-reviewing-records.md#registry-reviewing-approve).

Save the following configuration document as `configuration.json`:

```json
{
  "version": "1",
  "statements": [
    {
      "sid": "same-department",
      "effect": "Allow",
      "principal": {
        "iam:principalTag/department": {"Exists": true}
      },
      "resource": {
        "customMetadata/department": {
          "StringEquals": {"ref": "iam:principalTag/department"}
        }
      }
    }
  ]
}
```

The statement applies to callers that have a `department` principal tag. Each of those callers discovers the records whose `department` label equals the caller’s tag value. A record without a `department` label matches no caller. The following table shows the results that you expect when you [test the configuration](#registry-record-visibility-configure-test).


| Caller | Search and List | BatchGet of `finance-mcp`  | 
| --- | --- | --- | 
|  `FinanceReader` (`department=finance`) |  `finance-mcp`  | The record | 
|  `LegalReader` (`department=legal`) | No records |  `RESOURCE_NOT_FOUND`  | 
| A role with discovery permissions and no `department` tag | No records |  `RESOURCE_NOT_FOUND`  | 

The configuration evaluates the registry owner’s own roles in the same way. An administrator role without a `department` tag discovers nothing from this registry.

### Example – Department access on a JWT registry
<a name="registry-record-visibility-configure-walkthrough-jwt"></a>

On a registry that uses JWT authorization, the configuration tests a token claim instead of a principal tag. This variant assumes that your identity provider (IdP) issues a `department` claim that only IdP administrators can change. For authorizer setup, see [Set up a JWT manually with your own identity provider](registry-supported-auth-types.md#registry-jwt-manual).

```json
{
  "version": "1",
  "statements": [
    {
      "sid": "same-department",
      "effect": "Allow",
      "principal": {"jwt:claim/department": {"Exists": true}},
      "resource": {
        "customMetadata/department": {"StringEquals": {"ref": "jwt:claim/department"}}
      }
    }
  ]
}
```

Test it with three users: one whose token carries the `department` claim `finance`, one with `legal`, and one with no `department` claim. The expected results match the preceding table. If the claim arrives as an array, a record matches when its label equals any element. For the claim values that the configuration accepts, see [Supported caller values](registry-record-visibility-fields.md#registry-record-visibility-claim-normalization).

### Console
<a name="registry-record-visibility-configure-console"></a>

The console sets a configuration on an existing registry. It can’t set a configuration when it creates a registry, so create the registry first and wait until its status is **Ready**. A new configuration starts with one `Allow` statement whose `principal` and `resource` are both `"*"`.

**To define or edit a record visibility configuration**

1. Open the registry’s details page in the [AWS Agent Registry console](https://console.aws.amazon.com/agent-registry/home?region=us-east-1#).

1. In the **Record visibility configuration** section, choose **Define configuration**. If the registry already has a configuration, choose **Edit configuration**.

1. To select the editing mode, choose **Form** or **JSON**. In **JSON** mode, you can turn on **Show schema reference** to see the document structure beside the editor.

1. Enter the configuration. For the example, in **JSON** mode, replace the editor’s whole contents with the contents of `configuration.json`.

1. Fix any validation errors.

1. Review any suggestions that the console lists. Suggestions don’t block **Apply**.

1. Choose **Apply**.

The **Record visibility configuration** section shows the configuration status. It’s **Creating** while a first configuration is applied, **Updating** while a replacement is applied, and **Removing** while a removal is applied. It’s **Defined** when the configuration is in force.

 **Edit configuration** opens the current configuration. **Apply** sends the whole document as a `put`.

 **Apply** sends a revision only when you edit an existing configuration:
+  **Edit configuration** – **Apply** also sends the revision that the editor loaded. If someone changed the configuration after you opened the editor, **Apply** fails instead of overwriting that change.
+  **Define configuration** – **Apply** sends no revision. It can replace a configuration that someone set after you opened the editor. To set a first configuration only if the registry still has none, use the CLI or an SDK with `"revision": "NO_CONFIG"`. For more information, see [Avoid overwriting concurrent changes](#registry-record-visibility-configure-revisions).

 **Define configuration** or **Edit configuration** stays in the section, but it’s unavailable while a configuration change is pending or the registry is busy with another change. A change left pending by a failed update also counts. The button shows the reason. In an account that the registry is shared with, the button is unavailable and the section shows **Record visibility configuration not available**. To an owner whose registry has no configuration, the section shows **No record visibility configuration found.** 

### AWS CLI
<a name="registry-record-visibility-configure-api-cli"></a>

The following rules apply to `CreateRegistry` and `UpdateRegistry` requests from the AWS CLI, an AWS SDK, or the API:
+  **Whole-document replacement** – A `put` replaces the entire configuration. There’s no partial edit. To change one statement, send the complete new document.
+  **Exactly one of `put` or `delete` ** – An `UpdateRegistry` request whose `recordVisibilityConfiguration` has both members, or neither, returns `ValidationException` with the message `recordVisibilityConfiguration must contain exactly one of put or delete.` 
+  **Omit `recordVisibilityConfiguration` to keep the configuration** – An `UpdateRegistry` request without `recordVisibilityConfiguration` keeps the current configuration. The exception is a retry after a failed update that left a pending configuration change. For more information, see [Recover from a failed update](#registry-record-visibility-configure-failed).
+  **A `put` needs a document** – A `put` must carry a present, nonempty document. To remove a configuration, send `delete`.
+  **A JSON string, not an object** – `CreateRegistry` takes the configuration in `recordVisibilityConfiguration`, and `UpdateRegistry` takes it in `recordVisibilityConfiguration.put.document`. Both are strings that hold the JSON document. Pass your file’s text as that string, and let a tool such as `jq --rawfile` escape it rather than escaping it by hand. Whitespace counts toward the size limit in [Record visibility configuration limits](bedrock-agentcore-limits.md#registry-record-visibility-limits).
+  **Not `discoveryConfiguration` ** – The registry’s `discoveryConfiguration` member holds its authorizer settings, not the record visibility configuration. Set the record visibility configuration only through `recordVisibilityConfiguration`.

If the document itself fails validation, the request returns `ValidationException` with the problems that it found, and nothing changes. For the error format, see [Validation errors and paths](registry-record-visibility-language-reference.md#registry-record-visibility-validation-errors).

The commands in this topic use the shell variable `REGISTRY_ARN` for the registry’s Amazon Resource Name (ARN). Set it to your registry’s ARN. To add or replace the configuration, the following AWS CLI commands read `configuration.json` with `jq --rawfile` and wrap it in a `put`, so they send the file’s text without parsing or re-serializing it:

```bash
REGISTRY_ARN='arn:aws:agent-registry:us-east-1:111122223333:registry/<registryId>'

aws agent-registry-control update-registry \
  --registry-id "$REGISTRY_ARN" \
  --record-visibility-configuration "$(jq -n --rawfile doc configuration.json '{put: {document: $doc}}')" \
  --query '{status: status, pending: recordVisibilityConfigurationState.pending.change}' \
  --region us-east-1
```

When the request changes the configuration, the output shows `"status": "UPDATING"` and `"pending": "PUT"`. If the registry is `READY` and the document matches the configuration in force, no update runs, and the output shows `"status": "READY"` and `"pending": null`. For more information, see [Requests that don’t run an update](#registry-record-visibility-configure-effect-no-op).

To make the replacement conditional on the configuration that you last read, add a `revision`. For more information, see [Avoid overwriting concurrent changes](#registry-record-visibility-configure-revisions).

As an alternative, you can set the configuration when you create a registry. Pass the file with `--record-visibility-configuration`, and declare the `department` field in the same request. Save the schema from the example as `common.json`. The following AWS CLI commands read `common.json` and `configuration.json`:

```bash
jq -n --rawfile common common.json '{defaultSchema: $common}' > schema-config.json

aws agent-registry-control create-registry \
  --name finance-tools \
  --custom-metadata-schema-configuration file://schema-config.json \
  --record-visibility-configuration file://configuration.json \
  --region us-east-1
```

Registry creation is asynchronous. The configuration stays pending while the registry is `CREATING`, and it becomes the current configuration when the registry is `READY`. Before you check discovery results, wait as described in [Test a configuration](#registry-record-visibility-configure-test).

### AWS SDK
<a name="registry-record-visibility-configure-api-sdk"></a>

The request rules in the preceding AWS CLI section also apply to the SDKs. The following Python code reads `configuration.json` as text, and then passes that text as `document` without parsing or re-serializing it:

```python
import boto3

control = boto3.client('agent-registry-control', region_name='us-east-1')
registry_arn = 'arn:aws:agent-registry:us-east-1:111122223333:registry/<registryId>'

with open('configuration.json', encoding='utf-8') as f:
    document = f.read()

response = control.update_registry(
    registryId=registry_arn,
    recordVisibilityConfiguration={'put': {'document': document}},
)
pending = response.get('recordVisibilityConfigurationState', {}).get('pending')
print(response['status'], pending['change'] if pending else 'no pending change')
```

When the request changes the configuration, the script prints `UPDATING PUT`. If the registry is `READY` and the document matches the configuration in force, no update runs, and the script prints `READY no pending change`. To set the configuration when you create a registry instead, pass `recordVisibilityConfiguration=document` to `create_registry`, with the schema in `customMetadataSchemaConfiguration`.

## Test a configuration
<a name="registry-record-visibility-configure-test"></a>

Validation checks a configuration’s syntax, field names, operators, schema declarations, and limits. It doesn’t check that tag names, claim names, or literal values exist, and nothing simulates which records a caller sees. To confirm visibility, test the configuration with real callers against known approved records. For more information about the checks, see [Validation](registry-record-visibility-language-reference.md#registry-record-visibility-validation).

Before you test, wait for the configuration change to take effect. An accepted `UpdateRegistry` request doesn’t mean that the new configuration already applies. The following command waits until the registry is `READY`:

```bash
aws agent-registry-control wait registry-ready \
  --registry-id "$REGISTRY_ARN" --region us-east-1
```

In the AWS SDK for Python (Boto3), use the `registry_ready` waiter:

```python
import boto3

control = boto3.client('agent-registry-control', region_name='us-east-1')
registry_arn = 'arn:aws:agent-registry:us-east-1:111122223333:registry/<registryId>'

control.get_waiter('registry_ready').wait(registryId=registry_arn)
```

If the waiter fails, check the registry status. If it’s still `CREATING` or `UPDATING`, run the waiter again. If it’s `UPDATE_FAILED` or `CREATE_FAILED`, see [Recover from a failed update](#registry-record-visibility-configure-failed).

After the registry is `READY`, wait 30 seconds before you check the results. For more information, see [When the new configuration applies](#registry-record-visibility-configure-effect-timing).

Start with the expected results of the [department example](#registry-record-visibility-configure-walkthrough). As each role, run Search, run List until the response has no `nextToken`, and run BatchGet on the known record ID. A List paged to the end and a BatchGet on a known record ID show whether the caller can discover a record. Search returns only the records that match its query, so use it to check that query. Use the CLI, an SDK, or an HTTP client. The console can’t run BatchGet on an arbitrary record ID, and its **Record directory** isn’t available for registries that use JWT authorization.

The following AWS CLI commands make the three calls as `FinanceReader`, through a named profile, `finance-reader`. They use the shell variable `RECORD_ID` for the ID of `finance-mcp`.

```bash
aws agent-registry search-discoverable-registry-records \
  --registry-ids "$REGISTRY_ARN" --search-query "finance" \
  --query 'registryRecords[].name' \
  --profile finance-reader --region us-east-1

aws agent-registry list-discoverable-registry-records \
  --registry-id "$REGISTRY_ARN" --max-results 50 \
  --query '{names: registryRecords[].name, nextToken: nextToken}' \
  --profile finance-reader --region us-east-1

aws agent-registry batch-get-discoverable-registry-record \
  --entries "[{\"registryId\": \"$REGISTRY_ARN\", \"recordIds\": [\"$RECORD_ID\"]}]" \
  --query '{records: registryRecords[].name, errors: errors[].errorCode}' \
  --profile finance-reader --region us-east-1
```

As `FinanceReader`, each call returns `finance-mcp`. Run the commands again with a `LegalReader` profile. Search and List return no records, and BatchGet returns `RESOURCE_NOT_FOUND` for the record in `errors`. A List response can include a `nextToken`, even on a short or empty page. When it does, run the command again with `--next-token`. For more information, see [Response ordering and pagination](registry-browse-records.md#registry-browse-list-ordering).

With the AWS SDK for Python (Boto3), make the same calls with a session for each role. In the following code, `record_id` holds the ID of `finance-mcp`, and the Search and List paginators follow `nextToken` through every page, including empty pages. Before you conclude that a caller can’t discover a record, check every page of List and the BatchGet result. A record missing from Search shows only that it isn’t among that query’s results.

```python
import boto3

registry_arn = 'arn:aws:agent-registry:us-east-1:111122223333:registry/<registryId>'
record_id = '<recordId>'

discovery = boto3.Session(profile_name='finance-reader').client(
    'agent-registry', region_name='us-east-1')

searched = discovery.get_paginator('search_discoverable_registry_records').paginate(
    registryIds=[registry_arn], searchQuery='finance')
listed = discovery.get_paginator('list_discoverable_registry_records').paginate(
    registryId=registry_arn)
batch = discovery.batch_get_discoverable_registry_record(
    entries=[{'registryId': registry_arn, 'recordIds': [record_id]}])

print([r['name'] for page in searched for r in page['registryRecords']])
print([r['name'] for page in listed for r in page['registryRecords']])
print([r['name'] for r in batch['registryRecords']], [e['errorCode'] for e in batch['errors']])
```

BatchGet can return a newly approved record before Search and List do, while indexing catches up. If they don’t return a newly approved record, wait a few seconds and try again. For more information, see [Eventual consistency in AWS Agent Registry search](registry-search-records.md#registry-search-eventual-consistency).

When the example works, test your own configuration in a non-production registry with the same authorization type, schema, and configuration.

**To test your own configuration**

1. For each caller and record, write down whether you expect the caller to discover the record.

1. Create and approve test records for each case that the configuration distinguishes, where your schema allows them. For example, create one record for each permitted label, one with another label, one with a label in a different case, and one with no label. If the configuration names a field that some record types don’t declare, add a record of such a type.

1. Get credentials or tokens for a caller of each audience, for callers that lack each tested attribute, and for the owner’s own roles.

1. As each caller, run Search and List through every page, and BatchGet on the known record IDs.

1. Compare the results with your expectations, allowing for indexing.

1. Resolve each mismatch before you apply the configuration to a production registry.

For help with unexpected results, see [Record visibility configurations](registry-troubleshooting.md#registry-troubleshooting-record-visibility) in the troubleshooting topic.

## Remove a configuration
<a name="registry-record-visibility-configure-remove"></a>

**Removing a configuration exposes approved records to every authorized caller**  
Removing a configuration restores discovery without a configuration. Every caller can then discover every approved record that its permissions allow, except [quarantined records](registry-quarantining-records.md). Removal doesn’t hide records. To hide every record instead, keep a configuration that does so. For an example, see [Hide every record on purpose](registry-record-visibility-examples.md#registry-record-visibility-examples-hide-all).

To remove a configuration, send `UpdateRegistry` with `recordVisibilityConfiguration.delete`. When the update finishes, the registry has no configuration.

Removal runs a registry update, like any configuration change. For more information, see [How a configuration change takes effect](#registry-record-visibility-configure-effect).

### Console
<a name="registry-record-visibility-configure-remove-console"></a>

**To remove a record visibility configuration**

1. Open the registry’s details page in the [AWS Agent Registry console](https://console.aws.amazon.com/agent-registry/home?region=us-east-1#).

1. In the **Record visibility configuration** section, choose **Edit configuration**.

1. In the configuration editor, choose **Clear configuration**.

1. In the **Clear record visibility configuration?** dialog, choose **Clear configuration**.

The configuration status changes to **Removing**. When the registry is **Ready**, the registry has no configuration. The console sends the removal without a revision. To remove a configuration conditionally, use the CLI or an SDK.

### AWS CLI
<a name="registry-record-visibility-configure-remove-cli"></a>

The following command removes the configuration without a precondition. To make the removal conditional, send `'{"delete": {"revision": "<revision>"}}'` with the current revision instead.

```bash
aws agent-registry-control update-registry \
  --registry-id "$REGISTRY_ARN" \
  --record-visibility-configuration '{"delete": {}}' \
  --query '{status: status, pending: recordVisibilityConfigurationState.pending.change}' \
  --region us-east-1
```

With a configuration in force, the output shows `"status": "UPDATING"` and `"pending": "DELETE"`. When the update finishes, `get-registry` returns no `recordVisibilityConfigurationState`. If the registry is `READY` and has no configuration, no update runs, and the output shows `"status": "READY"` and `"pending": null`.

### AWS SDK
<a name="registry-record-visibility-configure-remove-sdk"></a>

The following code removes the configuration without a precondition. To make the removal conditional, pass `{'delete': {'revision': revision}}`.

```python
import boto3

control = boto3.client('agent-registry-control', region_name='us-east-1')
registry_arn = 'arn:aws:agent-registry:us-east-1:111122223333:registry/<registryId>'

response = control.update_registry(registryId=registry_arn, recordVisibilityConfiguration={'delete': {}})
pending = response.get('recordVisibilityConfigurationState', {}).get('pending')
print(response['status'], pending['change'] if pending else 'no pending change')
```

With a configuration in force, the code prints `UPDATING DELETE`. If the registry is `READY` and has no configuration, no update runs, and the code prints `READY no pending change`.

## How a configuration change takes effect
<a name="registry-record-visibility-configure-effect"></a>

An accepted configuration change runs a registry update. `UpdateRegistry` returns HTTP 202 and moves the registry to `UPDATING`. While the update runs, control-plane record operations, such as creating, approving, and getting records, return `ConflictException`.

The following table shows how the registry status affects a configuration change request.


| Registry status | Configuration change request | 
| --- | --- | 
|  `READY`  | Accepted | 
|  `UPDATING`  |  `ConflictException`  | 
|  `UPDATE_FAILED`  | Accepted as a retry. For more information, see [Recover from a failed update](#registry-record-visibility-configure-failed). | 
|  `CREATING`, `CREATE_FAILED`, `DELETING`, or `DELETE_FAILED`  |  `ConflictException`  | 

### When the new configuration applies
<a name="registry-record-visibility-configure-effect-timing"></a>

A configuration change takes effect within 30 seconds after the registry returns to `READY`. Until then, discovery can still reflect the previous configuration. Adding, changing, or removing a record visibility configuration can also make a caller’s earlier List and Search tokens stop working. To start a list again, see [Response ordering and pagination](registry-browse-records.md#registry-browse-list-ordering). To start a search again, see [Page through search results](registry-search-records.md#registry-search-pagination).

Other changes reach discovery on their own schedules. The following table shows when discovery reflects each change.


| Change | When discovery reflects it | 
| --- | --- | 
| A new approval, or new labels on a newly approved revision | BatchGet can reflect it first. Search follows indexing, and so does List when a record visibility configuration restricts which records the caller can see. For more information, see [Eventual consistency in AWS Agent Registry search](registry-search-records.md#registry-search-eventual-consistency). | 
| A rejection of the record’s approved revision while it’s the latest revision, or a deprecation of the record | Within seconds | 
|  AWS tags on a role, user, registry, or record | Follows IAM timing. For more information, see [Changes that I make are not always immediately visible](https://docs.aws.amazon.com/IAM/latest/UserGuide/troubleshoot_general.html#troubleshoot_general_eventual-consistency) in the *IAM User Guide*. | 
| A change to an AWS Resource Access Manager (AWS RAM) share | Follows AWS RAM timing. For more information, see the [AWS RAM User Guide](https://docs.aws.amazon.com/ram/latest/userguide/what-is.html). | 
| Session tags and JWT claims | Fixed when the session or token is issued. The caller needs a new session or token to pick up a change. | 

### Requests that don’t run an update
<a name="registry-record-visibility-configure-effect-no-op"></a>

In `READY`, an `UpdateRegistry` request that changes no setting returns status `READY` without running an update. A `put` of the configuration in force, or a `delete` without a `revision` when no configuration is in force, changes nothing.

In `UPDATE_FAILED`, an unchanged request reruns the update instead.

### Relabeled records narrow visibility once indexed
<a name="registry-record-visibility-configure-effect-relabel"></a>

Suppose that a newly approved revision changes a record’s labels, so that the configuration narrows who can discover the record. The narrowing applies once that revision is indexed. Until indexing catches up, Search can still return the previous approved revision to callers entitled to it, and so can List when a record visibility configuration restricts which records the caller can see.

 AWS Agent Registry never returns the narrowed revision to a caller that the configuration excludes. BatchGet can reflect a newly approved revision before Search does.

For example, suppose that you approve a new revision of `finance-mcp` labeled `department=legal`. Until the new revision is indexed, Search can still return the earlier finance revision to `FinanceReader`. `FinanceReader` never receives the legal revision.

A change to the configuration document isn’t tied to indexing. To remove a record from every caller’s results quickly, change its status, as described in the following section.

### Withdraw a record urgently
<a name="registry-record-visibility-configure-effect-withdraw"></a>

To withdraw a record from every caller, change its status with `UpdateRegistryRecordStatus`. The change reaches every discovery API within seconds. Choose the status as follows:
+  **Reject the approved revision** – If the record’s latest revision is the approved one, rejecting it withdraws that approval. You can approve the revision again later.
+  **Deprecate the record** – Deprecation removes the record from discovery, even when a newer revision is pending approval. Deprecation is final.

Rejecting a newer revision that is pending approval doesn’t withdraw an older approved revision. The older revision stays discoverable. In that case, deprecate the record. For more information, see [Record lifecycle](registry-record-lifecycle.md).

Use a `Deny` statement on `recordId` only when you need to hide a record from some audiences. A configuration change takes effect only after its registry update finishes. Record status changes need a `READY` registry, so you can’t change a record’s status while a configuration update runs.

## Recover from a failed update
<a name="registry-record-visibility-configure-failed"></a>

If a registry update fails, the registry status is `UPDATE_FAILED`. If the failed update changed the record visibility configuration, the previous configuration stays current and the change stays pending.

When a configuration change is pending, a retry must include `recordVisibilityConfiguration.put` or `recordVisibilityConfiguration.delete`. If `GetRegistry` returns no `recordVisibilityConfigurationState.pending`, nothing is pending, and you can retry the update without `recordVisibilityConfiguration`. When a configuration change is pending, the following retries apply:


| Retry | Result | 
| --- | --- | 
| Send the pending change again: a `put` of the pending document, or a `delete` for a pending removal | Retries the update with that change. | 
|  `put` a different configuration | Replaces the pending change and retries the update. | 
|  `put` the configuration in force, with `current.document` and `current.revision` from the same `GetRegistry` response | Discards the pending change and reruns the update. | 
|  `delete`  | With a configuration in force, removes the configuration when the update succeeds. With no configuration in force, discards the pending change and reruns the update. | 
| Omit `recordVisibilityConfiguration`  | Returns `ConflictException` with the message `The registry has a pending record visibility configuration change from a failed update. Retry UpdateRegistry with recordVisibilityConfiguration.put or recordVisibilityConfiguration.delete to specify the intended configuration.`  | 

In `UPDATE_FAILED`, a request that changes nothing still reruns the update. A failed creation, `CREATE_FAILED`, keeps its pending configuration until you delete the registry.

To retry a pending `put` from the AWS CLI, read the pending document and send it again.

```bash
PENDING=$(aws agent-registry-control get-registry --registry-id "$REGISTRY_ARN" \
  --query recordVisibilityConfigurationState.pending.document --output text --region us-east-1)

aws agent-registry-control update-registry --registry-id "$REGISTRY_ARN" \
  --record-visibility-configuration "$(jq -n --arg doc "$PENDING" '{put: {document: $doc}}')" \
  --query status --output text --region us-east-1
```

The second command prints `UPDATING`. If `pending.change` is `DELETE`, the first command prints `None`. In that case, send `'{"delete": {}}'` instead.

## Avoid overwriting concurrent changes
<a name="registry-record-visibility-configure-revisions"></a>

To make sure that you replace or remove the configuration that you last read, send its revision as a precondition. If someone changed the configuration in the meantime, the request fails instead of overwriting their change. Revisions work as follows:
+ Each committed change, including a removal, gets a new revision. Treat a revision as an opaque value. For a conditional `put` or `delete`, send back `recordVisibilityConfigurationState.current.revision` from `GetRegistry` unchanged.
+ A stale revision returns `ConflictException`, even when the request would otherwise change nothing.
+  `put` with `"revision": "NO_CONFIG"` sets the configuration only if no configuration is in force.
+  `delete` can’t use `NO_CONFIG`. The request returns `ValidationException` with the message `recordVisibilityConfiguration.delete.revision cannot be NO_CONFIG.` 
+ A mismatch returns `ConflictException`, for example `recordVisibilityConfiguration.put.revision does not match the record visibility configuration in force.` 
+ A request without a revision is unconditional. The registry status rules still apply.

The language `version` inside the document, `"1"`, identifies the configuration language. It isn’t the revision. In the console, **Apply** sends the loaded revision only when you edit an existing configuration. **Apply** on a first configuration and **Clear configuration** send no revision.

### AWS CLI
<a name="registry-record-visibility-configure-revisions-cli"></a>

Read the current revision, and then send it with the replacement. If the registry has no configuration in force, the first command returns `NO_CONFIG`, so the put succeeds only while the registry still has none.

```bash
REVISION=$(aws agent-registry-control get-registry --registry-id "$REGISTRY_ARN" \
  --query "recordVisibilityConfigurationState.current.revision || 'NO_CONFIG'" --output text --region us-east-1)

aws agent-registry-control update-registry --registry-id "$REGISTRY_ARN" \
  --record-visibility-configuration "$(jq -n --rawfile doc configuration.json --arg rev "$REVISION" \
    '{put: {document: $doc, revision: $rev}}')" \
  --query status --output text --region us-east-1
```

When the request changes the configuration, the second command prints `UPDATING`. If the registry is `READY` and the document matches the configuration in force, the second command prints `READY`. If it returns `ConflictException`, someone might have changed the configuration after you read it, or the registry might be busy with another change. Read the registry again, and check its status and the configuration’s revision. If the configuration changed, reconcile the other change with yours. Then retry with the current revision. For the messages that name a specific cause, see [`ConflictException` when you set or remove a record visibility configuration](registry-troubleshooting.md#registry-troubleshooting-record-visibility-conflict).

### AWS SDK
<a name="registry-record-visibility-configure-revisions-sdk"></a>

The following code reads the revision and sends it with the replacement configuration from `configuration.json`.

```python
import boto3

control = boto3.client('agent-registry-control', region_name='us-east-1')
registry_arn = 'arn:aws:agent-registry:us-east-1:111122223333:registry/<registryId>'

with open('configuration.json', encoding='utf-8') as f:
    document = f.read()

registry = control.get_registry(registryId=registry_arn)
current = registry.get('recordVisibilityConfigurationState', {}).get('current')
revision = current['revision'] if current else 'NO_CONFIG'
try:
    control.update_registry(registryId=registry_arn, recordVisibilityConfiguration={
        'put': {'document': document, 'revision': revision}})
except control.exceptions.ConflictException as error:
    # A concurrent change, or a registry that is busy with another change
    print('UpdateRegistry returned ConflictException:', error)
```

If the request returns `ConflictException`, the code prints `UpdateRegistry returned ConflictException:` and the error. The configuration might have changed after you read it, or the registry might be busy. Read the registry again, and check its status and the configuration’s revision. If the configuration changed, reconcile the current document with your intended change, and then retry with the current revision. For the messages that name a specific cause, see [`ConflictException` when you set or remove a record visibility configuration](registry-troubleshooting.md#registry-troubleshooting-record-visibility-conflict).

## Check the configuration state
<a name="registry-record-visibility-configure-state"></a>

 `GetRegistry` and `UpdateRegistry` return the configuration state in `recordVisibilityConfigurationState`. The following table describes its members.


| Member | Description | 
| --- | --- | 
|  `current.document`  | The configuration in force, as a JSON string. Absent when the registry has no configuration. | 
|  `current.revision`  | The revision of the configuration in force. | 
|  `pending.change`  |  `PUT` or `DELETE`. Present while a configuration change is pending, including after a failed create or update. | 
|  `pending.document`  | The pending configuration, for a `PUT` change. A `DELETE` change has no document. | 

Only the registry owner’s account receives `recordVisibilityConfigurationState`. The member is absent when the registry has no current configuration and no pending change. `ListRegistries` never includes configuration state, and a caller in an account that the registry is shared with receives none.

When an update succeeds, the registry returns to `READY`, the pending configuration becomes current, and `pending` disappears. A successful removal leaves no `current` configuration.

The returned document can be formatted differently from the text that you sent, for example without whitespace. To compare a local file with the configuration in force, compare parsed JSON rather than text, for example with `jq -S`.