> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.runtype.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.runtype.com/_mcp/server.

# Update client token

PUT https://api.runtype.com/v1/client-tokens/{id}
Content-Type: application/json

Update fields on an existing client token.

Reference: https://docs.runtype.com/api-reference/runtype-api/client-tokens/update-client-token

## Authentication

- `Authorization` header (bearer token, required) — API key or Clerk session token

## Servers

- `https://api.runtype.com` (Production, default)
- `https://api.runtype-staging.com` (Staging)

## Request

### Path parameters

- `id` (string, required)

### Body (application/json)

This endpoint expects an object.

- `agentIds` (list of string, optional)
- `allowedOrigins` (list of string, optional) — Allowed request origins for this token. Each entry is an exact origin (https://app.example.com), a wildcard subdomain (https://*.example.com), '*' for all origins, or the literal 'native' — a sentinel that admits requests carrying NO Origin header (native mobile apps). A token with 'native' has effectively no origin protection and relies on its capability scope.
- `config` (map from string to any, optional)
- `defaultFlowId` (string, optional)
- `flowIds` (list of string, optional)
- `isActive` (boolean, optional)
- `maxMessagesPerSession` (double, optional)
- `name` (string, optional)
- `pinToVersion` (string, optional) — Legacy widget-version mode: 'latest' or 'published'. A NEW agent version id (agentver_...) is rejected; echoing back the value already stored is accepted and ignored, so a read-modify-write client can save unrelated fields. Use targetVersionId to pin a version.
- `rateLimitPerHour` (double, optional)
- `rateLimitPerMinute` (double, optional)
- `sessionIdleTimeoutMinutes` (double, optional)
- `targetAlias` (string, optional, nullable)
- `targetVersionId` (string, optional, nullable)

## Response

### 200

Updated client token

- `clientToken` (V1ClientTokensIdPutResponsesContentApplicationJsonSchemaClientToken, required)
- `warnings` (list of V1ClientTokensIdPutResponsesContentApplicationJsonSchemaWarningsItems, required)

## Errors

### 400 Bad Request Error

Validation error

- `error` (string, required)
- `code` (string, optional) — Stable error code. `insufficient_scope` marks an API key that lacks a scope this request needs.
- `details` (list of ErrorDetailsItems, optional)
- `requiredScopes` (list of string, optional) — On `insufficient_scope`: every API key scope this request needs.

### 401 Unauthorized Error

Unauthorized

- `error` (string, required)
- `code` (string, optional) — Stable error code. `insufficient_scope` marks an API key that lacks a scope this request needs.
- `details` (list of ErrorDetailsItems, optional)
- `requiredScopes` (list of string, optional) — On `insufficient_scope`: every API key scope this request needs.

### 403 Forbidden Error

Forbidden

- `error` (string, required)
- `code` (string, optional) — Stable error code. `insufficient_scope` marks an API key that lacks a scope this request needs.
- `details` (list of ErrorDetailsItems, optional)
- `requiredScopes` (list of string, optional) — On `insufficient_scope`: every API key scope this request needs.

### 404 Not Found Error

Client token or referenced flow not found

- `error` (string, required)
- `code` (string, optional) — Stable error code. `insufficient_scope` marks an API key that lacks a scope this request needs.
- `details` (list of ErrorDetailsItems, optional)
- `requiredScopes` (list of string, optional) — On `insufficient_scope`: every API key scope this request needs.

### 500 Internal Server Error

Internal server error

- `error` (string, required)
- `code` (string, optional) — Stable error code. `insufficient_scope` marks an API key that lacks a scope this request needs.
- `details` (list of ErrorDetailsItems, optional)
- `requiredScopes` (list of string, optional) — On `insufficient_scope`: every API key scope this request needs.

## Types

### V1ClientTokensIdPutResponsesContentApplicationJsonSchemaClientToken

- `agentIds` (list of string, required)
- `allowedOrigins` (list of string, required)
- `config` (map from string to any, required)
- `createdAt` (string, required)
- `defaultFlowId` (string, required, nullable)
- `environment` (enum, required)
  - Allowed values: `test`, `live`
- `flowIds` (list of string, required)
- `id` (string, required)
- `isActive` (boolean, required)
- `lastUsedAt` (string, required, nullable)
- `maxMessagesPerSession` (integer, required, nullable)
- `name` (string, required, nullable)
- `pinToVersion` (string, required, nullable)
- `rateLimitPerHour` (integer, required, nullable)
- `rateLimitPerMinute` (integer, required, nullable)
- `sessionIdleTimeoutMinutes` (integer, required, nullable)
- `targetAlias` (string, required, nullable) — Release alias this token follows, re-resolved on every admission. Null when the token follows no pointer.
- `targetVersionId` (string, required, nullable) — Exact agent version this token runs. Null when the token pins no version.
- `tokenHint` (string, required, nullable)
- `tokenPrefix` (string, required)
- `tokenValue` (string, required, nullable)
- `updatedAt` (string, required)
- `conversationCount` (integer, optional)
- `productSurfaceId` (string, optional, nullable)

### V1ClientTokensIdPutResponsesContentApplicationJsonSchemaWarningsItems

- `message` (string, required)
- `type` (string, required)

### ErrorDetailsItems

- `message` (string, required)
- `code` (string, optional) — Stable Runtype validation code (e.g. MISSING_REQUIRED_FIELD, INVALID_ENUM).
- `path` (string, optional) — Dotted JSON path to the offending field.
- `suggestion` (string, optional) — Actionable hint (allowed values, accepted range, …).

## Examples

**Request**

```json
{
  "allowedOrigins": [
    "https://example.com",
    "https://app.example.com"
  ],
  "config": {
    "theme": {
      "mode": "dark",
      "primaryColor": "#28a745"
    },
    "welcomeMessage": "Welcome! How can I assist you?"
  },
  "isActive": true,
  "name": "Updated Widget Name",
  "rateLimitPerMinute": 20
}
```

**Response**

```json
{
  "clientToken": {
    "agentIds": [
      "string"
    ],
    "allowedOrigins": [
      "string"
    ],
    "config": {},
    "createdAt": "string",
    "defaultFlowId": "string",
    "environment": "test",
    "flowIds": [
      "string"
    ],
    "id": "string",
    "isActive": true,
    "lastUsedAt": "string",
    "maxMessagesPerSession": 1,
    "name": "string",
    "pinToVersion": "string",
    "rateLimitPerHour": 1,
    "rateLimitPerMinute": 1,
    "sessionIdleTimeoutMinutes": 1,
    "targetAlias": "string",
    "targetVersionId": "string",
    "tokenHint": "string",
    "tokenPrefix": "string",
    "tokenValue": "string",
    "updatedAt": "string",
    "conversationCount": 1,
    "productSurfaceId": "string"
  },
  "warnings": [
    {
      "message": "string",
      "type": "string"
    }
  ]
}
```

**SDK Code**

```python Update Client Token
import requests

url = "https://api.runtype.com/v1/client-tokens/id"

payload = {
    "allowedOrigins": ["https://example.com", "https://app.example.com"],
    "config": {
        "theme": {
            "mode": "dark",
            "primaryColor": "#28a745"
        },
        "welcomeMessage": "Welcome! How can I assist you?"
    },
    "isActive": True,
    "name": "Updated Widget Name",
    "rateLimitPerMinute": 20
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.put(url, json=payload, headers=headers)

print(response.json())
```

```javascript Update Client Token
const url = 'https://api.runtype.com/v1/client-tokens/id';
const options = {
  method: 'PUT',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"allowedOrigins":["https://example.com","https://app.example.com"],"config":{"theme":{"mode":"dark","primaryColor":"#28a745"},"welcomeMessage":"Welcome! How can I assist you?"},"isActive":true,"name":"Updated Widget Name","rateLimitPerMinute":20}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Update Client Token
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.runtype.com/v1/client-tokens/id"

	payload := strings.NewReader("{\n  \"allowedOrigins\": [\n    \"https://example.com\",\n    \"https://app.example.com\"\n  ],\n  \"config\": {\n    \"theme\": {\n      \"mode\": \"dark\",\n      \"primaryColor\": \"#28a745\"\n    },\n    \"welcomeMessage\": \"Welcome! How can I assist you?\"\n  },\n  \"isActive\": true,\n  \"name\": \"Updated Widget Name\",\n  \"rateLimitPerMinute\": 20\n}")

	req, _ := http.NewRequest("PUT", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Update Client Token
require 'uri'
require 'net/http'

url = URI("https://api.runtype.com/v1/client-tokens/id")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"allowedOrigins\": [\n    \"https://example.com\",\n    \"https://app.example.com\"\n  ],\n  \"config\": {\n    \"theme\": {\n      \"mode\": \"dark\",\n      \"primaryColor\": \"#28a745\"\n    },\n    \"welcomeMessage\": \"Welcome! How can I assist you?\"\n  },\n  \"isActive\": true,\n  \"name\": \"Updated Widget Name\",\n  \"rateLimitPerMinute\": 20\n}"

response = http.request(request)
puts response.read_body
```

```java Update Client Token
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.put("https://api.runtype.com/v1/client-tokens/id")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"allowedOrigins\": [\n    \"https://example.com\",\n    \"https://app.example.com\"\n  ],\n  \"config\": {\n    \"theme\": {\n      \"mode\": \"dark\",\n      \"primaryColor\": \"#28a745\"\n    },\n    \"welcomeMessage\": \"Welcome! How can I assist you?\"\n  },\n  \"isActive\": true,\n  \"name\": \"Updated Widget Name\",\n  \"rateLimitPerMinute\": 20\n}")
  .asString();
```

```php Update Client Token
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('PUT', 'https://api.runtype.com/v1/client-tokens/id', [
  'body' => '{
  "allowedOrigins": [
    "https://example.com",
    "https://app.example.com"
  ],
  "config": {
    "theme": {
      "mode": "dark",
      "primaryColor": "#28a745"
    },
    "welcomeMessage": "Welcome! How can I assist you?"
  },
  "isActive": true,
  "name": "Updated Widget Name",
  "rateLimitPerMinute": 20
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Update Client Token
using RestSharp;

var client = new RestClient("https://api.runtype.com/v1/client-tokens/id");
var request = new RestRequest(Method.PUT);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"allowedOrigins\": [\n    \"https://example.com\",\n    \"https://app.example.com\"\n  ],\n  \"config\": {\n    \"theme\": {\n      \"mode\": \"dark\",\n      \"primaryColor\": \"#28a745\"\n    },\n    \"welcomeMessage\": \"Welcome! How can I assist you?\"\n  },\n  \"isActive\": true,\n  \"name\": \"Updated Widget Name\",\n  \"rateLimitPerMinute\": 20\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Update Client Token
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "allowedOrigins": ["https://example.com", "https://app.example.com"],
  "config": [
    "theme": [
      "mode": "dark",
      "primaryColor": "#28a745"
    ],
    "welcomeMessage": "Welcome! How can I assist you?"
  ],
  "isActive": true,
  "name": "Updated Widget Name",
  "rateLimitPerMinute": 20
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.runtype.com/v1/client-tokens/id")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PUT"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```