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

# Update API Key Config

Use this API to update the app configuration for a workspace API key. Every field is optional, but **at least one** must be provided. Unknown fields are rejected. All writes are field-merge only — no fields are removed.

<Info>
  This endpoint uses **API-key-level auth**: pass `x-velt-api-key` and `x-velt-auth-token` as headers. You can obtain these from the [Get Auth Tokens](/api-reference/rest-apis/v2/workspace/authtokens-get) endpoint.
</Info>

# Endpoint

`POST https://api.velt.dev/v2/workspace/apikeyconfig/update`

# Headers

<ParamField header="x-velt-api-key" type="string" required>
  Your API key.
</ParamField>

<ParamField header="x-velt-auth-token" type="string" required>
  Your [Auth Token](/security/auth-tokens).
</ParamField>

# Body

#### Params

<ParamField body="data" type="object" required>
  At least one of the following fields must be provided.

  <Expandable title="properties">
    <ParamField body="enablePrivateComments" type="boolean">
      Enable (`true`) or disable (`false`) private comments for this API key.
    </ParamField>

    <ParamField body="requireJwtToken" type="boolean">
      When `true`, the SDK requires a signed JWT to authenticate.
    </ParamField>

    <ParamField body="requireAutoOrgUser" type="boolean">
      When `true`, users are auto-added to the organization on first access.
    </ParamField>

    <ParamField body="defaultDocumentAccessType" type="string">
      Workspace-default document access type. One of `public`, `restricted`, or `organizationPrivate`.
    </ParamField>

    <ParamField body="aiModelApiKey" type="object[]">
      Array of AI model provider keys — pass multiple entries to update several providers in one call. Each raw key is encrypted at rest and is never returned in any response. Must contain at least one entry.

      <Expandable title="entry properties">
        <ParamField body="provider" type="string" required>
          AI provider. One of `openai`, `anthropic`, or `gemini`.
        </ParamField>

        <ParamField body="customerApiKey" type="string" required>
          The provider API key to store (encrypted).
        </ParamField>
      </Expandable>
    </ParamField>
  </Expandable>
</ParamField>

# Example Request

```JSON theme={null}
{
  "data": {
    "requireJwtToken": true,
    "defaultDocumentAccessType": "restricted",
    "aiModelApiKey": [
      { "provider": "openai", "customerApiKey": "sk-openai-..." },
      { "provider": "anthropic", "customerApiKey": "sk-ant-..." },
      { "provider": "gemini", "customerApiKey": "AIza..." }
    ]
  }
}
```

# Example Response

#### Success Response

```JSON theme={null}
{
  "result": {
    "status": "success",
    "message": "API key configuration updated successfully.",
    "data": {
      "requireJwtToken": true,
      "defaultDocumentAccessType": "restricted",
      "aiModelsConfig": {
        "openai": { "displayText": "sk-open...xxxxxxxxxxxxxxxxxxxxxxx" },
        "anthropic": { "displayText": "sk-ant-...xxxxxxxxxxxxxxxxxxxxx" },
        "gemini": { "displayText": "AIza...xxxxxxxxxxxxxxxxxxxxxxxxx" }
      }
    }
  }
}
```

<Note>
  The response echoes the post-write values for the fields you provided. For `aiModelApiKey`, the keys come back masked under `aiModelsConfig` as a map of `provider -> { displayText }` (the same shape as [Get API Key Config](/api-reference/rest-apis/v2/workspace/apikeyconfig-get)) — the raw key value is never returned. When `enablePrivateComments` is the only field and its value already matches the current value, the write is skipped internally and the response is simply `{ "enablePrivateComments": <value> }`.
</Note>

#### Failure Response

##### If no field is provided, or an unknown field is sent

```JSON theme={null}
{
  "error": {
    "status": "INVALID_ARGUMENT",
    "message": "At least one field must be provided for update"
  }
}
```

<ResponseExample>
  ```js theme={null}
  {
    "result": {
      "status": "success",
      "message": "API key configuration updated successfully.",
      "data": {
        "requireJwtToken": true,
        "defaultDocumentAccessType": "restricted",
        "aiModelsConfig": {
          "openai": { "displayText": "sk-open...xxxxxxxxxxxxxxxxxxxxxxx" },
          "anthropic": { "displayText": "sk-ant-...xxxxxxxxxxxxxxxxxxxxx" },
          "gemini": { "displayText": "AIza...xxxxxxxxxxxxxxxxxxxxxxxxx" }
        }
      }
    }
  }
  ```
</ResponseExample>
