---
title: Update a token
---

[Skip to content](#_top)

[API Reference](https://developers.cloudflare.com/api/go)

[AI Search](https://developers.cloudflare.com/api/go/resources/ai_search)

[Tokens](https://developers.cloudflare.com/api/go/resources/ai_search/subresources/tokens)

Copy Markdown

Open in **Claude**Open in **ChatGPT**Open in **Cursor**

---

**Copy Markdown****View as Markdown**

# Update a token

client.AISearch.Tokens.Update(ctx, id, params) (\*[TokenUpdateResponse](<https://developers.cloudflare.com/api/go/resources/ai_search#(resource)%20ai_search.tokens%20%3E%20(model)%20TokenUpdateResponse%20%3E%20(schema)>), error)

PUT/accounts/{account\_id}/ai-search/tokens/{id}

Replace a stored AI Search credential and invalidate cached credentials for instances that use it.

##### Security

<details>

<summary>API Token</summary>



The preferred authorization scheme for interacting with the Cloudflare API. <a href="https://developers.cloudflare.com/fundamentals/api/get-started/create-token/">Create a token</a>.

**Example:**<code>Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY</code>

</details>

<details>

<summary>API Email + API Key</summary>



The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.

**Example:**<code>X-Auth-Email: user@example.com</code>

The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.

**Example:**<code>X-Auth-Key: 144c9defac04969c7bfad8efaa8ea194</code>

</details>

##### ParametersExpand Collapse

id string

formatuuid

[Link to this property](<#(resource)%20ai_search.tokens%20%3E%20(method)%20update%20%3E%20(params)%20default%20%3E%20(param)%20id%20%3E%20(schema)>)

<details>

<summary>

params TokenUpdateParams

</summary>

AccountID param.Field\[string]

Path param

<a href="#(resource)%20ai_search.tokens%20%3E%20(method)%20update%20%3E%20(params)%20default%20%3E%20(param)%20account_id">Link to this property</a>

CfAPIID param.Field\[string]

Body param

<a href="#(resource)%20ai_search.tokens%20%3E%20(method)%20update%20%3E%20(params)%20default%20%3E%20(param)%20cf_api_id">Link to this property</a>

CfAPIKey param.Field\[string]

Body param

<a href="#(resource)%20ai_search.tokens%20%3E%20(method)%20update%20%3E%20(params)%20default%20%3E%20(param)%20cf_api_key">Link to this property</a>

Name param.Field\[string]

Body param

<a href="#(resource)%20ai_search.tokens%20%3E%20(method)%20update%20%3E%20(params)%20default%20%3E%20(param)%20name">Link to this property</a>

Legacy param.Field\[bool]Optional

Body param

<a href="#(resource)%20ai_search.tokens%20%3E%20(method)%20update%20%3E%20(params)%20default%20%3E%20(param)%20legacy">Link to this property</a>

</details>

[Link to this property](<#(resource)%20ai_search.tokens%20%3E%20(method)%20update%20%3E%20(params)%20default>)

##### ReturnsExpand Collapse

<details>

<summary>

type TokenUpdateResponse struct{…}

</summary>

ID string

formatuuid

<a href="#(resource)%20ai_search.tokens%20%3E%20(model)%20TokenUpdateResponse%20%3E%20(schema)%20%3E%20(property)%20id">Link to this property</a>

CfAPIID string

<a href="#(resource)%20ai_search.tokens%20%3E%20(model)%20TokenUpdateResponse%20%3E%20(schema)%20%3E%20(property)%20cf_api_id">Link to this property</a>

CreatedAt Time

formatdate-time

<a href="#(resource)%20ai_search.tokens%20%3E%20(model)%20TokenUpdateResponse%20%3E%20(schema)%20%3E%20(property)%20created_at">Link to this property</a>

ModifiedAt Time

formatdate-time

<a href="#(resource)%20ai_search.tokens%20%3E%20(model)%20TokenUpdateResponse%20%3E%20(schema)%20%3E%20(property)%20modified_at">Link to this property</a>

Name string

<a href="#(resource)%20ai_search.tokens%20%3E%20(model)%20TokenUpdateResponse%20%3E%20(schema)%20%3E%20(property)%20name">Link to this property</a>

CreatedBy stringOptional

<a href="#(resource)%20ai_search.tokens%20%3E%20(model)%20TokenUpdateResponse%20%3E%20(schema)%20%3E%20(property)%20created_by">Link to this property</a>

Enabled boolOptional

<a href="#(resource)%20ai_search.tokens%20%3E%20(model)%20TokenUpdateResponse%20%3E%20(schema)%20%3E%20(property)%20enabled">Link to this property</a>

Legacy boolOptional

<a href="#(resource)%20ai_search.tokens%20%3E%20(model)%20TokenUpdateResponse%20%3E%20(schema)%20%3E%20(property)%20legacy">Link to this property</a>

ModifiedBy stringOptional

<a href="#(resource)%20ai_search.tokens%20%3E%20(model)%20TokenUpdateResponse%20%3E%20(schema)%20%3E%20(property)%20modified_by">Link to this property</a>

</details>

[Link to this property](<#(resource)%20ai_search.tokens%20%3E%20(model)%20TokenUpdateResponse%20%3E%20(schema)>)

### Update a token

Go

HTTPTypeScriptPythonGoTerraform

```
package main

import (
  "context"
  "fmt"

  "github.com/cloudflare/cloudflare-go"
  "github.com/cloudflare/cloudflare-go/ai_search"
  "github.com/cloudflare/cloudflare-go/option"
)

func main() {
  client := cloudflare.NewClient(
    option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
  )
  token, err := client.AISearch.Tokens.Update(
    context.TODO(),
    "62af0db3-c410-40b2-9ee3-0e93f6dd1de0",
    ai_search.TokenUpdateParams{
      AccountID: cloudflare.F("c3dc5f0b34a14ff8e1b3ec04895e1b22"),
      CfAPIID: cloudflare.F("a1b2c3d4e5f6"),
      CfAPIKey: cloudflare.F("abc123"),
      Name: cloudflare.F("my-token"),
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", token.ID)
}
```

200 example

```
{
  "result": {
    "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
    "cf_api_id": "cf_api_id",
    "created_at": "2019-12-27T18:11:19.117Z",
    "modified_at": "2019-12-27T18:11:19.117Z",
    "name": "name",
    "created_by": "created_by",
    "enabled": true,
    "legacy": true,
    "modified_by": "modified_by"
  },
  "success": true
}
```

##### Returns Examples

200 example

```
{
  "result": {
    "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
    "cf_api_id": "cf_api_id",
    "created_at": "2019-12-27T18:11:19.117Z",
    "modified_at": "2019-12-27T18:11:19.117Z",
    "name": "name",
    "created_by": "created_by",
    "enabled": true,
    "legacy": true,
    "modified_by": "modified_by"
  },
  "success": true
}
```