# access.update

Replace the access policy atomically at an expected ledger revision.

Capability: op_sys_access_update
Protocol: op-sys.capabilities.v1
Runtime: 0.3.0
Availability: Ledger access and group administration are local or hosted.
Optional integration: false
Canonical page: /docs/reference/op_sys_access_update

## Authority

Ledger access operations check their specified ledger permissions. Group administration and inspection require resource permissions; hosted credential scopes are an additional ceiling. Creating a group grants no ledger access by itself.

## Invocation

CLI, SDK and MCP use the same operation and arguments; where a hosted HTTP binding exists, its route carries the same domain contract. Host paths and environment references refer to the runtime host. Request template: replace placeholder IDs and supply complete contract-specific objects before use. This is not a complete runnable workflow.

### CLI

```sh
op-sys --output json tools call op_sys_access_update \
  --arguments '{"ledger_id":"<ledger_id>","grants":[{"principal":{"issuer":"<issuer>","subject":"<subject>"},"permissions":["ledger.read"]}],"expected_revision":1}'
```

### Python SDK

```python
import json
from op_sys import OpSys

client = OpSys()
arguments = json.loads("{\"ledger_id\":\"<ledger_id>\",\"grants\":[{\"principal\":{\"issuer\":\"<issuer>\",\"subject\":\"<subject>\"},\"permissions\":[\"ledger.read\"]}],\"expected_revision\":1}")
result = client.capabilities.call(
    "op_sys_access_update", arguments
)
print(result)
```

### MCP (initialized connection)

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "op_sys_access_update",
    "arguments": {
      "ledger_id": "<ledger_id>",
      "grants": [
        {
          "principal": {
            "issuer": "<issuer>",
            "subject": "<subject>"
          },
          "permissions": [
            "ledger.read"
          ]
        }
      ],
      "expected_revision": 1
    }
  }
}
```

### HTTP

```sh
curl --fail-with-body --request PUT "$VEYLAR_ENDPOINT/v1/ledgers/$LEDGER_ID/access" \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H "X-Veylar-Tenant: $TENANT_ID" \
  -H 'Content-Type: application/json' \
  --data '{"grants":[{"principal":{"issuer":"<issuer>","subject":"<subject>"},"permissions":["ledger.read"]}],"expected_revision":1}'
```

Named CLI command: op-sys access update (use --help for flags).

SDK convenience: client.access.update(…). The capability adapter may wrap the result.

## Parameters

### ledger_id

Required; string. Stable ledger identity, local or hosted. A display name is not interchangeable with this ID.

minLength: 1; maxLength: 128

### grants

Required; array. Complete ledger grant list with issuer-qualified principals and explicit permissions. Retain an administrator and reconcile the expected revision.

maxItems: 1000
```json
{
  "type": "array",
  "items": {
    "type": "object",
    "additionalProperties": false,
    "properties": {
      "principal": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "issuer": {
            "type": "string",
            "minLength": 1,
            "maxLength": 2048
          },
          "subject": {
            "type": "string",
            "minLength": 1,
            "maxLength": 256
          }
        },
        "required": [
          "issuer",
          "subject"
        ]
      },
      "permissions": {
        "type": "array",
        "items": {
          "type": "string",
          "enum": [
            "ledger.read",
            "ledger.configure",
            "ledger.archive",
            "ledger.delete",
            "contracts.read",
            "contracts.manage",
            "records.append",
            "records.read",
            "records.outcome.own",
            "records.outcome.any",
            "records.erase",
            "files.upload",
            "files.read",
            "files.erase",
            "access.read",
            "access.manage",
            "changes.read",
            "ledger.export",
            "ledger.import",
            "replication.receive",
            "replication.publish",
            "authority.transfer",
            "records.prepare"
          ]
        },
        "maxItems": 23
      },
      "append_contract_ids": {
        "type": "array",
        "items": {
          "type": "string",
          "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$",
          "maxLength": 128
        },
        "minItems": 1,
        "maxItems": 64,
        "uniqueItems": true,
        "description": "Restrict append permission to these contract IDs, across their admitted versions. Omit to grant append access to every admitted contract."
      }
    },
    "required": [
      "principal",
      "permissions"
    ]
  },
  "maxItems": 1000
}
```


### expected_revision

Required; integer. Revision observed before updating an existing resource. Group/collection creation takes no revision.

minimum: 1; maximum: 9007199254740991

### Complete input schema

```json
{
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "ledger_id": {
      "type": "string",
      "minLength": 1,
      "maxLength": 128
    },
    "grants": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "principal": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "issuer": {
                "type": "string",
                "minLength": 1,
                "maxLength": 2048
              },
              "subject": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              }
            },
            "required": [
              "issuer",
              "subject"
            ]
          },
          "permissions": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "ledger.read",
                "ledger.configure",
                "ledger.archive",
                "ledger.delete",
                "contracts.read",
                "contracts.manage",
                "records.append",
                "records.read",
                "records.outcome.own",
                "records.outcome.any",
                "records.erase",
                "files.upload",
                "files.read",
                "files.erase",
                "access.read",
                "access.manage",
                "changes.read",
                "ledger.export",
                "ledger.import",
                "replication.receive",
                "replication.publish",
                "authority.transfer",
                "records.prepare"
              ]
            },
            "maxItems": 23
          },
          "append_contract_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$",
              "maxLength": 128
            },
            "minItems": 1,
            "maxItems": 64,
            "uniqueItems": true,
            "description": "Restrict append permission to these contract IDs, across their admitted versions. Omit to grant append access to every admitted contract."
          }
        },
        "required": [
          "principal",
          "permissions"
        ]
      },
      "maxItems": 1000
    },
    "expected_revision": {
      "type": "integer",
      "minimum": 1,
      "maximum": 9007199254740991
    }
  },
  "required": [
    "ledger_id",
    "grants",
    "expected_revision"
  ]
}
```

## Behavior

- Retry: inspect_and_revise. Concurrency: definition_revision.
- Required rights: access.manage. Check discovery for environment availability and effective authorization.
- Groups contain principals, not ledgers. Membership is bound to an identity issuer and the selected local store or service tenant.
- Grant a group explicit permissions on each ledger through the ledger access policy. Removing membership removes group-derived access; independent grants remain effective.
- Updates compare the current resource or ledger revision. Inspect current state before revising after a conflict.

## Response

Returns Policy. See the complete result schema below; transport envelopes are separate.

### Complete result JSON Schema

```json
{
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "revision": {
      "type": "integer",
      "minimum": 1,
      "maximum": 9007199254740991
    },
    "grants": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "principal": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "issuer": {
                "type": "string",
                "minLength": 1,
                "maxLength": 2048
              },
              "subject": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              }
            },
            "required": [
              "issuer",
              "subject"
            ]
          },
          "permissions": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "ledger.read",
                "ledger.configure",
                "ledger.archive",
                "ledger.delete",
                "contracts.read",
                "contracts.manage",
                "records.append",
                "records.read",
                "records.outcome.own",
                "records.outcome.any",
                "records.erase",
                "files.upload",
                "files.read",
                "files.erase",
                "access.read",
                "access.manage",
                "changes.read",
                "ledger.export",
                "ledger.import",
                "replication.receive",
                "replication.publish",
                "authority.transfer",
                "records.prepare"
              ]
            },
            "maxItems": 23
          },
          "append_contract_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$",
              "maxLength": 128
            },
            "minItems": 1,
            "maxItems": 64,
            "uniqueItems": true,
            "description": "Restrict append permission to these contract IDs, across their admitted versions. Omit to grant append access to every admitted contract."
          }
        },
        "required": [
          "principal",
          "permissions"
        ]
      },
      "maxItems": 1000
    }
  },
  "required": [
    "revision",
    "grants"
  ]
}
```


[Runtime output field catalog](/docs/output-contracts.json) (descriptive contracts, not JSON Schema validators).

CLI: use --output json. For tools call, read the operation result at payload.tool.result; payload.tool.name identifies the capability. The outer envelope is {schema_version: "v1", payload: {tool: {name, result}}}.

Python: client.capabilities.call(name, arguments) returns the operation result. SDK exceptions preserve reason and code.

MCP: tools/call returns JSON text and structuredContent. Application failures set isError; inspect reason/code instead of matching message text.

Related resource schemas (not necessarily a complete operation response):
- [ledger-core.v1.schema.json](/docs/schemas/ledger-core.v1.schema.json)

## Errors and recovery

[Ledger limits and operation catalog](/docs/ledger-core.json)

Canonical operation: access.update

Permissions: access.manage

Retry: inspect_and_revise; concurrency: definition_revision

Codes: invalid_input, contract_invalid, payload_invalid, contract_not_admitted, permission_denied, not_found, revision_conflict, operation_conflict, unsupported, authority_unavailable, outcome_uncertain, outcome_expired, validation_context_unavailable, file_unavailable, integrity_failure, ledger_archived, ledger_deleted, resnapshot_required, identity_changed, authority_fenced, withdrawal_requires_resolution, limit_exceeded, rate_limited, payment_required

[HTTP status mappings and schemas](/docs/ledger-core.openapi.json)

- permission_denied: Check credential scope and the specific ledger or resource administration rights.
- revision_conflict: Read the latest definition and reconcile before updating.

Family reasons are representative, not exhaustive.

A timeout is not proof that a write failed. Reuse the documented retry identity, batch, offset or mutation ID. If this operation has no documented retry identity, inspect its state before repeating it.

On authorization failure, correct the configured identity or grants; do not change the local actor to impersonate a hosted principal. On validation failure, correct the input against the published schema and selected contract.

On a revision or state conflict, retrieve current state and reconcile intent. Do not automatically overwrite a competing update. Preserve unknown additive response fields when building consumers.

## Source manuals

- [ledger-surrounding](/docs/raw/manuals/ledger-surrounding.md)
- [ledger-core](/docs/raw/manuals/ledger-core.md)
- [public-capabilities](/docs/raw/manuals/public-capabilities.md)
- [command-output-schema](/docs/raw/manuals/command-output-schema.md)
