Delete an API
Removes an API and returns it as it was. An MCP server’s id answers 404. The instance must be ready; otherwise the request answers 409.
DELETE
/
agent_gateways
/
{instance_id}
/
apis
/
{api_id}
JavaScript
import Telnyx from 'telnyx';
const client = new Telnyx({
apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});
await client.agentGateways.apis.delete('instance_id', 'api_id');import os
from telnyx import Telnyx
client = Telnyx(
api_key=os.environ.get("TELNYX_API_KEY"), # This is the default and can be omitted
)
client.agent_gateways.apis.delete(
"instance_id",
"api_id",
)
package main
import (
"context"
"github.com/team-telnyx/telnyx-go"
"github.com/team-telnyx/telnyx-go/option"
)
func main() {
client := telnyx.NewClient(
option.WithAPIKey("My API Key"),
)
err := client.AgentGateways.Apis.Delete(
context.TODO(),
"instance_id",
"api_id",
)
if err != nil {
panic(err.Error())
}
}
package com.telnyx.sdk.example;
import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
client.agentGateways().apis().delete("instance_id", "api_id");
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
agent_gateway_api = telnyx.agent_gateways.apis.delete("instance_id", "api_id")
puts(agent_gateway_api)<?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_api = $client->agentGateways->apis->delete(
'instance_id',
'api_id',
);
var_dump($agent_gateway_api);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx agent-gateways:apis delete \
--api-key 'My API Key' \
--instance-id 32ce035d-3165-4031-b1a7-a7c0c259590a \
--api-id dbe53cc0-bf7e-4f7a-8d84-752d19890eb3curl --request DELETE \
--url https://api.telnyx.com/v2/agent_gateways/{instance_id}/apis/{api_id} \
--header 'Authorization: Bearer <token>'{
"data": {
"id": "dbe53cc0-bf7e-4f7a-8d84-752d19890eb3",
"name": "petstore",
"spec_url": "https://petstore3.swagger.io/api/v3/openapi.json",
"base_url": "https://petstore3.swagger.io/api/v3",
"auth": {
"type": "none"
},
"tools": [],
"static_headers": {},
"forwarded_headers": [],
"open_to_every_key": true,
"created_at": "2026-10-28T17:07:27.083000Z",
"updated_at": "2026-10-28T17:07:27.083000Z"
}
}{
"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": "99903",
"title": "Engine unavailable",
"detail": "The instance's engine did not answer; try again shortly."
}
]
}Was this page helpful?
JavaScript
import Telnyx from 'telnyx';
const client = new Telnyx({
apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});
await client.agentGateways.apis.delete('instance_id', 'api_id');import os
from telnyx import Telnyx
client = Telnyx(
api_key=os.environ.get("TELNYX_API_KEY"), # This is the default and can be omitted
)
client.agent_gateways.apis.delete(
"instance_id",
"api_id",
)
package main
import (
"context"
"github.com/team-telnyx/telnyx-go"
"github.com/team-telnyx/telnyx-go/option"
)
func main() {
client := telnyx.NewClient(
option.WithAPIKey("My API Key"),
)
err := client.AgentGateways.Apis.Delete(
context.TODO(),
"instance_id",
"api_id",
)
if err != nil {
panic(err.Error())
}
}
package com.telnyx.sdk.example;
import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
client.agentGateways().apis().delete("instance_id", "api_id");
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
agent_gateway_api = telnyx.agent_gateways.apis.delete("instance_id", "api_id")
puts(agent_gateway_api)<?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_api = $client->agentGateways->apis->delete(
'instance_id',
'api_id',
);
var_dump($agent_gateway_api);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx agent-gateways:apis delete \
--api-key 'My API Key' \
--instance-id 32ce035d-3165-4031-b1a7-a7c0c259590a \
--api-id dbe53cc0-bf7e-4f7a-8d84-752d19890eb3curl --request DELETE \
--url https://api.telnyx.com/v2/agent_gateways/{instance_id}/apis/{api_id} \
--header 'Authorization: Bearer <token>'{
"data": {
"id": "dbe53cc0-bf7e-4f7a-8d84-752d19890eb3",
"name": "petstore",
"spec_url": "https://petstore3.swagger.io/api/v3/openapi.json",
"base_url": "https://petstore3.swagger.io/api/v3",
"auth": {
"type": "none"
},
"tools": [],
"static_headers": {},
"forwarded_headers": [],
"open_to_every_key": true,
"created_at": "2026-10-28T17:07:27.083000Z",
"updated_at": "2026-10-28T17:07:27.083000Z"
}
}{
"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": "99903",
"title": "Engine unavailable",
"detail": "The instance's engine did not answer; try again shortly."
}
]
}