Skip to main content

client.update_key_details

Update Details

Updates a key's settings and returns its private details. Only the fields you send change. A key on an unlimited plan ignores changes to datasets, daily_limit and monthly_limit. Datasets set by your plan cannot be changed here: sending one with a different value returns a 400.

Endpoint​

PUT /keys/{key}/details

See the API reference for this endpoint.

This operation needs a Management Key. Pass it as management_key: to AddressZen::Client.new, which sends it in the Authorization header. See setup.

Signature​

def update_key_details(
key,
name: nil,
daily_limit: nil,
monthly_limit: nil,
individual_limit: nil,
allowed_urls: nil,
redact_days: nil,
notifications: nil,
ip_forwarding: nil,
datasets: nil
)

Arguments​

NameTypeRequiredDescription
keyStringyesAPI Key
keywordskeyword argumentsnoOne per body field, named as the API names them. A keyword left out or nil is not sent.

Query Parameters​

None.

Request Body​

Pass these as keyword arguments too; the SDK sends them as the JSON body.

NameTypeRequiredDescription
nameStringnoA name for the key
daily_limitHashno
monthly_limitHashno
individual_limitHashno
allowed_urlsArray<String>noA list of allowed URLs. An empty list disables the check. Up to 10 allowed.
redact_daysIntegernoNumber of days to preserve personal data stored in your key usage history. Set to 0 to prevent personal data storage
notificationsHashno
ip_forwardingBooleannoAccept IP addresses forwarded in the AZ-Source-IP header
datasetsHashnoDatasets you can switch on or off for this key. Datasets set by your plan (paf, mr, nyb, ecad, ecaf) cannot be changed here: sending one with a different value returns a 400.

Response​

AddressZen::Responses::ApiKeyDetailsResponse. Read fields with readers named as the API names them, such as response.result, or with response["result"]. to_h returns the decoded body.

Errors​

An HTTP error raises AddressZen::ApiError with the HTTP status, the API error code and the decoded body. A transport failure raises AddressZen::TransportError. See error handling.

Example​

update-key-details.rbruby
require "addresszen"

client = AddressZen::Client.new(api_key: "ak_test", management_key: "uk_test")

response = client.update_key_details(
"ak_test",
name: "Checkout",
allowed_urls: ["https://www.example.com"]
)

puts response.result.name