Skip to main content

$client->updateKeyDetails()

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 the second argument to IdealPostcodes::client(), which sends it in the Authorization header. See setup.

Signature​

public function updateKeyDetails(string $key, array $body): ApiKeyDetailsResponse

Arguments​

NameTypeRequiredDescription
$keystringyesAPI Key
$bodyarrayyesThe JSON request body. Keys under Request Body.

Query Parameters​

None.

Request Body​

Pass these as keys of $body.

NameTypeRequiredDescription
namestringnoA name for the key
daily_limitarray<string, mixed>no
monthly_limitarray<string, mixed>no
individual_limitarray<string, mixed>no
allowed_urlsstring|list<string>noA list of allowed URLs. An empty list disables the check. Up to 10 allowed.
redact_daysintnoNumber of days to preserve personal data stored in your key usage history. Set to 0 to prevent personal data storage
notificationsarray<string, mixed>no
ip_forwardingboolnoAccept IP addresses forwarded in the IDPC-Source-IP header
datasetsarray<string, mixed>noDatasets 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​

IdealPostcodes\Responses\ApiKeyDetailsResponse. Read fields as properties, such as $response->result, or as an array with the API's field names. toArray() returns the decoded body.

Errors​

An HTTP error throws ApiException with the HTTP status, the API error code from getCode() and the decoded body. A transport failure throws TransporterException. See error handling.

Example​

update-key-details.phpphp
<?php

declare(strict_types=1);

use IdealPostcodes\IdealPostcodes;

require 'vendor/autoload.php';

$client = IdealPostcodes::client('ak_test', 'uk_test');

$response = $client->updateKeyDetails('ak_test', [
'name' => 'Checkout',
'allowed_urls' => ['https://www.example.com'],
]);

echo $response->result->name, PHP_EOL;