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 with idealpostcodes.WithManagementKey(...) when you create the client, which sends it in the Authorization header. See setup.

Signature​

func (c *Client) UpdateKeyDetails(ctx context.Context, key string, body UpdateKeyDetailsBody) (*APIKeyDetailsResponse, error)

Arguments​

NameTypeRequiredDescription
ctxcontext.ContextyesCancels the request and sets its deadline.
keystringyesAPI Key
bodyUpdateKeyDetailsBodyyesThe JSON request body. Fields under Request Body.

Query Parameters​

None.

Request Body​

Set these as fields of body, named in Studly case (post_town is PostTown). An optional field is a pointer, set with new(value), or a map; nil sends nothing.

NameTypeRequiredDescription
namestringnoA name for the key
daily_limitmap[string]anyno
monthly_limitmap[string]anyno
individual_limitmap[string]anyno
allowed_urls[]stringnoA 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
notificationsmap[string]anyno
ip_forwardingboolnoAccept IP addresses forwarded in the IDPC-Source-IP header
datasetsmap[string]anynoDatasets 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.APIKeyDetailsResponse. Fields the API may leave out or send as null are pointers. RawJSON() returns the body as received. See responses.

Errors​

An HTTP error returns *idealpostcodes.APIError with the HTTP status, the API error code and the body; match it with errors.AsType. A transport failure returns the net/http error, wrapped. See error handling.

Example​

update-key-details/main.gogo
package main

import (
	"context"
	"fmt"
	"log"

	idealpostcodes "go.ideal-postcodes.co.uk/sdk"
)

func main() {
	client := idealpostcodes.NewClient("ak_test", idealpostcodes.WithManagementKey("uk_test"))
	res, err := client.UpdateKeyDetails(context.Background(), "ak_test", idealpostcodes.UpdateKeyDetailsBody{
		Name:        new("Checkout"),
		AllowedURLs: new([]string{"https://www.example.com"}),
	})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(res.Result.Name)
}