Save (or replace) the BYOK key for a provider.
const url = 'https://api.tradr.cloud/api/advisor/provider-keys/claude';const options = { method: 'PUT', headers: {'Content-Type': 'application/json'}, body: '{"apiKey":"example","defaultModel":"example"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request PUT \ --url https://api.tradr.cloud/api/advisor/provider-keys/claude \ --header 'Content-Type: application/json' \ --data '{ "apiKey": "example", "defaultModel": "example" }'Encrypts the supplied key at rest (AES-256-GCM, REQ-5.1) and stores only the ciphertext plus a last-4-char masking hint — the plaintext is never persisted or returned (REQ-5.7). Runs a lightweight validation roundtrip against the provider’s listModels endpoint (REQ-5.8, 5s timeout): a 401/403 rejects the save with PROVIDER_KEY_INVALID; a successful probe returns verified: true; a timeout or transient failure stores the key anyway and returns verified: false. Rate limited to 10 saves per user per hour (REQ-5.9). defaultModel is optional — when omitted (a first-time save has no model list to pick from), the server selects the provider’s deterministic default from the probe’s listModels response (REQ-6.4); the user can change it later.
Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Request Bodyrequired
Section titled “Request Bodyrequired”object
Examplegenerated
{ "apiKey": "example", "defaultModel": "example"}Responses
Section titled “Responses”The stored key (ProviderKeyListItem) plus verified: boolean.
Validation error or PROVIDER_KEY_INVALID (key rejected by provider).
Save rate limit reached (10 / hour).