# Tokens ## List tokens. `client.aiSearch.tokens.list(TokenListParamsparams, RequestOptionsoptions?): V4PagePaginationArray` **get** `/accounts/{account_id}/ai-search/tokens` List tokens. ### Parameters - `params: TokenListParams` - `account_id: string` Path param - `order_by?: "created_at"` Query param: Order By Column Name - `"created_at"` - `order_by_direction?: "asc" | "desc"` Query param: Order By Direction - `"asc"` - `"desc"` - `page?: number` Query param - `per_page?: number` Query param ### Returns - `TokenListResponse` - `id: string` - `cf_api_id: string` - `created_at: string` - `modified_at: string` - `name: string` - `created_by?: string | null` - `enabled?: boolean` - `legacy?: boolean` - `modified_by?: string | null` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); // Automatically fetches more pages as needed. for await (const tokenListResponse of client.aiSearch.tokens.list({ account_id: 'c3dc5f0b34a14ff8e1b3ec04895e1b22', })) { console.log(tokenListResponse.id); } ``` #### Response ```json { "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 } ``` ## Create new tokens. `client.aiSearch.tokens.create(TokenCreateParamsparams, RequestOptionsoptions?): TokenCreateResponse` **post** `/accounts/{account_id}/ai-search/tokens` Create a new tokens. ### Parameters - `params: TokenCreateParams` - `account_id: string` Path param - `cf_api_id: string` Body param - `cf_api_key: string` Body param - `name: string` Body param ### Returns - `TokenCreateResponse` - `id: string` - `cf_api_id: string` - `created_at: string` - `modified_at: string` - `name: string` - `created_by?: string | null` - `enabled?: boolean` - `legacy?: boolean` - `modified_by?: string | null` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const token = await client.aiSearch.tokens.create({ account_id: 'c3dc5f0b34a14ff8e1b3ec04895e1b22', cf_api_id: 'cf_api_id', cf_api_key: 'cf_api_key', name: 'name', }); console.log(token.id); ``` #### Response ```json { "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 } ``` ## Read tokens. `client.aiSearch.tokens.read(stringid, TokenReadParamsparams, RequestOptionsoptions?): TokenReadResponse` **get** `/accounts/{account_id}/ai-search/tokens/{id}` Read tokens. ### Parameters - `id: string` - `params: TokenReadParams` - `account_id: string` ### Returns - `TokenReadResponse` - `id: string` - `cf_api_id: string` - `created_at: string` - `modified_at: string` - `name: string` - `created_by?: string | null` - `enabled?: boolean` - `legacy?: boolean` - `modified_by?: string | null` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const response = await client.aiSearch.tokens.read('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { account_id: 'c3dc5f0b34a14ff8e1b3ec04895e1b22', }); console.log(response.id); ``` #### Response ```json { "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 } ``` ## Update tokens. `client.aiSearch.tokens.update(stringid, TokenUpdateParamsparams, RequestOptionsoptions?): TokenUpdateResponse` **put** `/accounts/{account_id}/ai-search/tokens/{id}` Update tokens. ### Parameters - `id: string` - `params: TokenUpdateParams` - `account_id: string` Path param - `cf_api_id: string` Body param - `cf_api_key: string` Body param - `name: string` Body param ### Returns - `TokenUpdateResponse` - `id: string` - `cf_api_id: string` - `created_at: string` - `modified_at: string` - `name: string` - `created_by?: string | null` - `enabled?: boolean` - `legacy?: boolean` - `modified_by?: string | null` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const token = await client.aiSearch.tokens.update('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { account_id: 'c3dc5f0b34a14ff8e1b3ec04895e1b22', cf_api_id: 'cf_api_id', cf_api_key: 'cf_api_key', name: 'name', }); console.log(token.id); ``` #### Response ```json { "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 } ``` ## Delete tokens. `client.aiSearch.tokens.delete(stringid, TokenDeleteParamsparams, RequestOptionsoptions?): TokenDeleteResponse` **delete** `/accounts/{account_id}/ai-search/tokens/{id}` Delete tokens. ### Parameters - `id: string` - `params: TokenDeleteParams` - `account_id: string` ### Returns - `TokenDeleteResponse` - `id: string` - `cf_api_id: string` - `created_at: string` - `modified_at: string` - `name: string` - `created_by?: string | null` - `enabled?: boolean` - `legacy?: boolean` - `modified_by?: string | null` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const token = await client.aiSearch.tokens.delete('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { account_id: 'c3dc5f0b34a14ff8e1b3ec04895e1b22', }); console.log(token.id); ``` #### Response ```json { "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 } ``` ## Domain Types ### Token List Response - `TokenListResponse` - `id: string` - `cf_api_id: string` - `created_at: string` - `modified_at: string` - `name: string` - `created_by?: string | null` - `enabled?: boolean` - `legacy?: boolean` - `modified_by?: string | null` ### Token Create Response - `TokenCreateResponse` - `id: string` - `cf_api_id: string` - `created_at: string` - `modified_at: string` - `name: string` - `created_by?: string | null` - `enabled?: boolean` - `legacy?: boolean` - `modified_by?: string | null` ### Token Read Response - `TokenReadResponse` - `id: string` - `cf_api_id: string` - `created_at: string` - `modified_at: string` - `name: string` - `created_by?: string | null` - `enabled?: boolean` - `legacy?: boolean` - `modified_by?: string | null` ### Token Update Response - `TokenUpdateResponse` - `id: string` - `cf_api_id: string` - `created_at: string` - `modified_at: string` - `name: string` - `created_by?: string | null` - `enabled?: boolean` - `legacy?: boolean` - `modified_by?: string | null` ### Token Delete Response - `TokenDeleteResponse` - `id: string` - `cf_api_id: string` - `created_at: string` - `modified_at: string` - `name: string` - `created_by?: string | null` - `enabled?: boolean` - `legacy?: boolean` - `modified_by?: string | null`