Update a key
Changes a key’s settings without reissuing it. A field left out stays as it is, and null clears it. models: [] lifts the model restriction. expires_in counts from now. Setting blocked to true makes the instance refuse the key with 401 while keeping its settings and spend; false lets it through again. The instance must be ready; otherwise the request answers 409.
import Telnyx from 'telnyx';
const client = new Telnyx({
apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});
const AgentGatewayKey = await client.agentGateways.keys.update('instance_id', 'key_id', {
name: 'name',
});
console.log(AgentGatewayKey.data);import os
from telnyx import Telnyx
client = Telnyx(
api_key=os.environ.get("TELNYX_API_KEY"), # This is the default and can be omitted
)
agent_gateway_key = client.agent_gateways.keys.update(
instance_id="instance_id",
key_id="key_id",
name="name",
)
print(agent_gateway_key.data)
package main
import (
"context"
"fmt"
"github.com/team-telnyx/telnyx-go"
"github.com/team-telnyx/telnyx-go/option"
)
func main() {
client := telnyx.NewClient(
option.WithAPIKey("My API Key"),
)
key, err := client.AgentGateways.Keys.Update(
context.TODO(),
"instance_id",
"key_id",
telnyx.AgentGatewayKeyUpdateParams{
Name: telnyx.String("name"),
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", key.Data)
}
package com.telnyx.sdk.example;
import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
import com.telnyx.sdk.models.agentGateways.keys.KeyUpdateParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
KeyUpdateParams params = KeyUpdateParams.builder()
.name("name")
.build();
var response = client.agentGateways().keys().update("instance_id", "key_id", params);
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
agent_gateway_key = telnyx.agent_gateways.keys.update("instance_id", "key_id", name: "name")
puts(agent_gateway_key)<?php
require_once dirname(__DIR__) . '/vendor/autoload.php';
use Telnyx\Client;
use Telnyx\Core\Exceptions\APIException;
$client = new Client(apiKey: getenv('TELNYX_API_KEY') ?: 'My API Key');
try {
$agent_gateway_key = $client->agentGateways->keys->update(
'instance_id',
'key_id',
name: 'name',
);
var_dump($agent_gateway_key);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx agent-gateways:keys update \
--api-key 'My API Key' \
--instance-id ecffdf4b-93ea-4a7b-8295-51dfd2077996 \
--key-id 5f1c3a0e9b7d4c2a8e6f0b1d3c5a7e9f2b4d6c8a0e1f3a5c7e9b1d3f5a7c9e0b \
--name namecurl --request PATCH \
--url https://api.telnyx.com/v2/agent_gateways/{instance_id}/keys/{key_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"blocked": true
}
'{
"data": {
"id": "5f1c3a0e9b7d4c2a8e6f0b1d3c5a7e9f2b4d6c8a0e1f3a5c7e9b1d3f5a7c9e0b",
"name": "support-agent",
"team_id": "0b6c5d4e-3f2a-4b1c-9d8e-7f6a5b4c3d2e",
"models": [
"GLM-5.3-Flash"
],
"max_budget": 20,
"budget_resets_every": "30d",
"budget_resets_at": "2026-11-20T19:40:00Z",
"spend": 0,
"expires_at": null,
"created_at": "2026-10-21T19:40:00Z",
"blocked": true,
"requests_per_minute": 60,
"tokens_per_minute": null,
"max_parallel_requests": 4
}
}{
"errors": [
{
"code": "10009",
"title": "Authentication failed",
"detail": "The required authentication headers were either invalid or not included in the request.",
"meta": {
"url": "https://developers.telnyx.com/docs/overview/errors/10009"
}
}
]
}{
"errors": [
{
"code": "10005",
"title": "Resource not found",
"detail": "The requested resource or URL could not be found.",
"meta": {
"url": "https://developers.telnyx.com/docs/overview/errors/10005"
}
}
]
}{
"errors": [
{
"code": "99901",
"title": "Instance not ready",
"detail": "The instance is not ready; its engine is not running."
}
]
}{
"errors": [
{
"code": "10033",
"title": "Value outside of range",
"detail": "Input should be greater than or equal to 1",
"source": {
"pointer": "/requests_per_minute"
},
"meta": {
"url": "https://developers.telnyx.com/docs/overview/errors/10033"
}
}
]
}{
"errors": [
{
"code": "99903",
"title": "Engine unavailable",
"detail": "The instance's engine did not answer; try again shortly."
}
]
}Authorizations
Telnyx API key
Path Parameters
The Agent Gateway's id.
The key's id, a 64-character hash the instance stores in place of the key.
^[0-9a-f]{64}$Body
A field left out stays as it is; null clears it.
A label for people.
1 - 100The models the key may use. [] allows every model.
1001 - 200The most the key may spend, in USD.
x >= 0How often the spend resets.
^[1-9][0-9]{0,6}[smhd]$"30d"
How long from now until the key stops working.
^[1-9][0-9]{0,6}[smhd]$"30d"
Move the key to this team, or null to leave its team.
true makes the instance refuse the key; false lets it through again.
The most requests the key may make per minute.
1 <= x <= 2147483647The most tokens the key may use per minute.
1 <= x <= 2147483647The most requests the key may have in flight at once.
1 <= x <= 2147483647Response
The updated key
A key on an instance, without its value.
Show child attributes
Show child attributes
Was this page helpful?
import Telnyx from 'telnyx';
const client = new Telnyx({
apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});
const AgentGatewayKey = await client.agentGateways.keys.update('instance_id', 'key_id', {
name: 'name',
});
console.log(AgentGatewayKey.data);import os
from telnyx import Telnyx
client = Telnyx(
api_key=os.environ.get("TELNYX_API_KEY"), # This is the default and can be omitted
)
agent_gateway_key = client.agent_gateways.keys.update(
instance_id="instance_id",
key_id="key_id",
name="name",
)
print(agent_gateway_key.data)
package main
import (
"context"
"fmt"
"github.com/team-telnyx/telnyx-go"
"github.com/team-telnyx/telnyx-go/option"
)
func main() {
client := telnyx.NewClient(
option.WithAPIKey("My API Key"),
)
key, err := client.AgentGateways.Keys.Update(
context.TODO(),
"instance_id",
"key_id",
telnyx.AgentGatewayKeyUpdateParams{
Name: telnyx.String("name"),
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", key.Data)
}
package com.telnyx.sdk.example;
import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
import com.telnyx.sdk.models.agentGateways.keys.KeyUpdateParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
KeyUpdateParams params = KeyUpdateParams.builder()
.name("name")
.build();
var response = client.agentGateways().keys().update("instance_id", "key_id", params);
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
agent_gateway_key = telnyx.agent_gateways.keys.update("instance_id", "key_id", name: "name")
puts(agent_gateway_key)<?php
require_once dirname(__DIR__) . '/vendor/autoload.php';
use Telnyx\Client;
use Telnyx\Core\Exceptions\APIException;
$client = new Client(apiKey: getenv('TELNYX_API_KEY') ?: 'My API Key');
try {
$agent_gateway_key = $client->agentGateways->keys->update(
'instance_id',
'key_id',
name: 'name',
);
var_dump($agent_gateway_key);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx agent-gateways:keys update \
--api-key 'My API Key' \
--instance-id ecffdf4b-93ea-4a7b-8295-51dfd2077996 \
--key-id 5f1c3a0e9b7d4c2a8e6f0b1d3c5a7e9f2b4d6c8a0e1f3a5c7e9b1d3f5a7c9e0b \
--name namecurl --request PATCH \
--url https://api.telnyx.com/v2/agent_gateways/{instance_id}/keys/{key_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"blocked": true
}
'{
"data": {
"id": "5f1c3a0e9b7d4c2a8e6f0b1d3c5a7e9f2b4d6c8a0e1f3a5c7e9b1d3f5a7c9e0b",
"name": "support-agent",
"team_id": "0b6c5d4e-3f2a-4b1c-9d8e-7f6a5b4c3d2e",
"models": [
"GLM-5.3-Flash"
],
"max_budget": 20,
"budget_resets_every": "30d",
"budget_resets_at": "2026-11-20T19:40:00Z",
"spend": 0,
"expires_at": null,
"created_at": "2026-10-21T19:40:00Z",
"blocked": true,
"requests_per_minute": 60,
"tokens_per_minute": null,
"max_parallel_requests": 4
}
}{
"errors": [
{
"code": "10009",
"title": "Authentication failed",
"detail": "The required authentication headers were either invalid or not included in the request.",
"meta": {
"url": "https://developers.telnyx.com/docs/overview/errors/10009"
}
}
]
}{
"errors": [
{
"code": "10005",
"title": "Resource not found",
"detail": "The requested resource or URL could not be found.",
"meta": {
"url": "https://developers.telnyx.com/docs/overview/errors/10005"
}
}
]
}{
"errors": [
{
"code": "99901",
"title": "Instance not ready",
"detail": "The instance is not ready; its engine is not running."
}
]
}{
"errors": [
{
"code": "10033",
"title": "Value outside of range",
"detail": "Input should be greater than or equal to 1",
"source": {
"pointer": "/requests_per_minute"
},
"meta": {
"url": "https://developers.telnyx.com/docs/overview/errors/10033"
}
}
]
}{
"errors": [
{
"code": "99903",
"title": "Engine unavailable",
"detail": "The instance's engine did not answer; try again shortly."
}
]
}