# `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](/docs/api/update-key-details.md) for this endpoint.

This operation needs a Management Key. Pass it with `addresszen.WithManagementKey(...)` when you create the client, which sends it in the `Authorization` header. See [setup](/docs/sdks/go/setup.md).

## Signature

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

## Arguments

| Name   | Type                   | Required | Description                                                        |
| ------ | ---------------------- | -------- | ------------------------------------------------------------------ |
| `ctx`  | `context.Context`      | yes      | Cancels the request and sets its deadline.                         |
| `key`  | `string`               | yes      | API Key                                                            |
| `body` | `UpdateKeyDetailsBody` | yes      | The JSON request body. Fields under [Request Body](#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.

| Name               | Type             | Required | Description                                                                                                                                                                              |
| ------------------ | ---------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `name`             | `string`         | no       | A name for the key                                                                                                                                                                       |
| `daily_limit`      | `map[string]any` | no       |                                                                                                                                                                                          |
| `monthly_limit`    | `map[string]any` | no       |                                                                                                                                                                                          |
| `individual_limit` | `map[string]any` | no       |                                                                                                                                                                                          |
| `allowed_urls`     | `[]string`       | no       | A list of allowed URLs. An empty list disables the check. Up to 10 allowed.                                                                                                              |
| `redact_days`      | `int`            | no       | Number of days to preserve personal data stored in your key usage history. Set to 0 to prevent personal data storage                                                                     |
| `notifications`    | `map[string]any` | no       |                                                                                                                                                                                          |
| `ip_forwarding`    | `bool`           | no       | Accept IP addresses forwarded in the `AZ-Source-IP` header                                                                                                                               |
| `datasets`         | `map[string]any` | no       | Datasets 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.APIKeyDetailsResponse`. Fields the API may leave out or send as null are pointers. `RawJSON()` returns the body as received. See [responses](/docs/sdks/go/responses.md).

## Errors

An HTTP error returns `*addresszen.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](/docs/sdks/go/errors.md).

## Example

update-key-details/main.gogo

```go
package main

import (
	"context"
	"fmt"
	"log"

	addresszen "go.addresszen.com/sdk"
)

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