> ## Documentation Index
> Fetch the complete documentation index at: /docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Replace a key's value

> Sets a new value on a key, as a new version. Agents use it on their next request. Never answers with the value. Audited as rotate.

Takes a managing key (`oc_key_...`) or a signed-in session. See [Custom connections](/docs/integrations/custom-connections.md) for how a key is sent.

Sets a new value on a key, as a new version. Agents use it on their next request. Never answers with the value. Audited as rotate.

> [!NOTE]
>
> **Availability:** OneCLI Cloud and self-hosted.


## OpenAPI

````yaml /openapi.yaml put /v2/items/{id}/value
openapi: 3.1.0
info:
  title: OneCLI API
  version: '2'
  description: >
    The OneCLI API manages what the gateway enforces: vaults, the items in them,
    the agents connected to them, what agents may do with each item,
    organization rules, approvals and activity.


    **Base URL:** `https://api.onecli.sh` (OneCLI Cloud) or your own
    deployment's address (`http://localhost:10254` by default). Every path
    starts with `/v2`.


    ## Authentication


    Send `Authorization: Bearer <credential>`. Which credential an endpoint
    takes is on its page.


    - **Managing key** (`oc_key_...`): acts as the person who made it, in the
    organization it was made in.

    - **Agent credential** (`oc_agent_...`): reads what that agent can use and
    nothing else. On an endpoint for a person it answers `403` with the detail
    `person_required`.

    - **Connect token** (`oc_connect_...`): connects one agent to its own vault
    and does nothing else.

    - **Signed-in session**: the dashboard's own. A few endpoints take a session
    only and refuse every key.


    ## Editions


    Endpoints marked **Cloud** exist on OneCLI Cloud only. Every other endpoint
    exists on OneCLI Cloud and on a self-hosted deployment.
servers:
  - url: https://api.onecli.sh
    description: OneCLI Cloud
  - url: http://localhost:10254
    description: Self-hosted
security: []
tags:
  - name: Vaults
    description: A vault holds items and has agents connected to it.
  - name: Items
    description: >-
      The connected apps, API keys and LLM keys in a vault. Values are
      write-only.
  - name: Permissions
    description: What the agents on a vault may do with one item, per tool.
  - name: Connect tokens
    description: The tokens that connect a new agent to a vault.
  - name: Agents
    description: The agents connected to the vaults you can use.
  - name: Agent sign-ups
    description: How an agent with no credential asks a person to connect it.
  - name: Agent self-service
    description: What an agent reads about itself with its own credential.
  - name: Approvals
    description: The requests the gateway holds until a person answers.
  - name: Rules
    description: 'Organization rules: block, require approval, or rate-limit.'
  - name: Activity
    description: 'What agents did: the request log, usage counts and the audit log.'
  - name: Apps
    description: The apps that can be connected, and the organization's own OAuth apps.
  - name: API keys
    description: 'Managing keys: the keys a person''s scripts call this API with.'
  - name: Organization
    description: You, your organizations, and an organization's name and logo.
  - name: Utility
    description: Health check.
  - name: Members
    description: The people of an organization and their roles.
  - name: Invites
    description: Invite people to an organization by email.
  - name: Groups
    description: Groups of members, used to share vaults and to set roles.
  - name: Vault sharing
    description: The people and groups a vault is shared with.
  - name: Shared items
    description: Items an organization keeps once and shares with chosen vaults.
  - name: Sign-in
    description: 'Single sign-on: identity provider connections, domains and enforcement.'
  - name: Directory tokens
    description: Tokens the organization's directory syncs people and groups with.
  - name: LLM sign-in
    description: Add a Claude or ChatGPT subscription to a vault by signing in.
  - name: Billing
    description: The organization's plan, credits and payment state.
  - name: Support
    description: Write to the OneCLI team, or ask for an app.
paths:
  /v2/items/{id}/value:
    put:
      tags:
        - Items
      summary: Replace a key's value
      description: >-
        Sets a new value on a key, as a new version. Agents use it on their next
        request. Never answers with the value. Audited as rotate.
      operationId: putItemsIdValue
      parameters:
        - description: The item's id.
          in: path
          name: id
          required: true
          schema:
            description: The item's id.
            maxLength: 64
            minLength: 1
            type: string
        - description: >-
            Required. The item's version as you read it. Missing answers 428; a
            newer one answers 409, and nothing changes.
          in: header
          name: if-match
          required: true
          schema:
            description: >-
              Required. The item's version as you read it. Missing answers 428;
              a newer one answers 409, and nothing changes.
            pattern: ^"?\d{1,9}"?$
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ReplaceItemValue'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ItemDetails'
          description: The item, at its new version. Never the value.
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Bad request.
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Not signed in.
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: You cannot use this item's vault.
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: No such key in this organization.
        '409':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: 'If-Match is stale: the key changed since you read it.'
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: >-
            Not valid, an app, a key read from 1Password, or a value a URL path
            cannot carry.
        '428':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: 'No If-Match: send the version you read.'
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Unexpected error.
      security:
        - userBearer: []
components:
  schemas:
    ReplaceItemValue:
      additionalProperties: false
      properties:
        value:
          description: >-
            The key's new value. Stored encrypted. No answer ever carries it
            back.
          maxLength: 10000
          minLength: 1
          type: string
      required:
        - value
      type: object
    ItemDetails:
      allOf:
        - $ref: '#/components/schemas/Item'
        - properties:
            addedBy:
              description: >-
                Who added the key. null: an app, not known, or that person is no
                longer in the organization.
              properties:
                name:
                  type: string
              required:
                - name
              type:
                - object
                - 'null'
            sentAs:
              description: >-
                How the gateway sends a key, the value as dots: a header, a
                query parameter or a path. Built from the stored config, never
                from the value. null: an app, or not known.
              type:
                - string
                - 'null'
          required:
            - sentAs
            - addedBy
          type: object
    Error:
      properties:
        error:
          properties:
            code:
              enum:
                - bad_request
                - validation_failed
                - unauthenticated
                - forbidden
                - not_found
                - conflict
                - gone
                - idempotency_conflict
                - precondition_required
                - rate_limited
                - authorization_pending
                - slow_down
                - access_denied
                - expired_token
                - internal
                - unavailable
              type: string
            details:
              items:
                $ref: '#/components/schemas/ErrorDetail'
              type: array
            message:
              type: string
            requestId:
              description: The X-Request-Id of this call, to quote when asking.
              type:
                - string
                - 'null'
          required:
            - code
            - message
            - details
            - requestId
          type: object
      required:
        - error
      type: object
    Item:
      properties:
        allowPlainHttp:
          description: >-
            The gateway may send this item over plain http://. Off unless a
            person turns it on.
          type: boolean
        createdAt:
          description: ISO 8601.
          type: string
        deletedAt:
          description: >-
            ISO 8601. When it was deleted. null: a live item. A deleted item is
            listed only with deleted=true.
          type:
            - string
            - 'null'
        enabled:
          description: >-
            Off: the gateway does not use the item for any agent, whatever its
            permissions say. Requests to its hosts go out with no credential.
          type: boolean
        hosts:
          description: The hosts the gateway uses this item for.
          items:
            type: string
          type: array
        id:
          type: string
        kind:
          enum:
            - app
            - api_key
            - llm_key
          type: string
        lastUsedAt:
          description: >-
            ISO 8601. When the gateway last used it for a request, to the hour.
            null: never used.
          type:
            - string
            - 'null'
        name:
          type: string
        permissionSummary:
          $ref: '#/components/schemas/PermissionSummary'
        purgeAt:
          description: >-
            ISO 8601. When a deleted item is destroyed for good, unless restored
            first. null: a live item.
          type:
            - string
            - 'null'
        rotatedAt:
          description: >-
            ISO 8601. When the value was last set: made, given a new value, or
            refreshed by the gateway.
          type: string
        service:
          description: >-
            The app or LLM provider, for example github or anthropic. null for a
            plain API key.
          type:
            - string
            - 'null'
        state:
          description: >-
            ready, reauth_required (the app must be signed in again) or
            disconnected.
          enum:
            - ready
            - reauth_required
            - disconnected
          type: string
        vaultId:
          type: string
        version:
          description: >-
            A key's current version, for If-Match on a change. 0 for an app,
            which has no versions.
          type: integer
      required:
        - id
        - vaultId
        - kind
        - name
        - service
        - hosts
        - state
        - permissionSummary
        - allowPlainHttp
        - createdAt
        - rotatedAt
        - lastUsedAt
        - enabled
        - version
        - deletedAt
        - purgeAt
      type: object
    ErrorDetail:
      properties:
        field:
          description: Where the problem is.
          type: string
        issue:
          description: What kind of problem.
          type: string
        message:
          description: The problem in words.
          type: string
      required:
        - field
        - issue
        - message
      type: object
    PermissionSummary:
      properties:
        allow:
          description: Tools always allowed.
          type: integer
        ask:
          description: Tools that need approval.
          type: integer
        item:
          description: >-
            allow: always allowed. ask: needs approval. never: refused. null:
            not set on this vault yet (until the move to vaults, an agent's own
            access still decides).
          enum:
            - allow
            - ask
            - never
            - null
          type:
            - string
            - 'null'
        never:
          description: Tools refused.
          type: integer
      required:
        - item
        - allow
        - ask
        - never
      type: object
  securitySchemes:
    userBearer:
      description: >-
        A managing key (oc_key_...), an older API key (oc_...), or a signed-in
        session.
      scheme: bearer
      type: http

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.