Add an API
Adds a REST API by its OpenAPI description. Each operation becomes a tool at {gateway_url}/mcp, named with the API’s name, a hyphen, and the lowercased operationId. A description the gateway cannot fetch yields an API with no tools. 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 AgentGatewayApi = await client.agentGateways.apis.create('instance_id', {
name: 'name',
spec_url: 'spec_url',
});
console.log(AgentGatewayApi.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_api = client.agent_gateways.apis.create(
instance_id="instance_id",
name="name",
spec_url="spec_url",
)
print(agent_gateway_api.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"),
)
aPI, err := client.AgentGateways.Apis.New(
context.TODO(),
"instance_id",
telnyx.AgentGatewayAPINewParams{
Name: "name",
SpecURL: "spec_url",
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", aPI.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.apis.ApiCreateParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
ApiCreateParams params = ApiCreateParams.builder()
.name("name")
.specUrl("spec_url")
.build();
var response = client.agentGateways().apis().create("instance_id", params);
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
agent_gateway_api = telnyx.agent_gateways.apis.create("instance_id", name: "name", spec_url: "spec_url")
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->create(
'instance_id',
name: 'name',
spec_url: 'spec_url',
);
var_dump($agent_gateway_api);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx agent-gateways:apis create \
--api-key 'My API Key' \
--instance-id 32ce035d-3165-4031-b1a7-a7c0c259590a \
--name name \
--spec-url spec_urlcurl --request POST \
--url https://api.telnyx.com/v2/agent_gateways/{instance_id}/apis \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "petstore",
"spec_url": "https://petstore3.swagger.io/api/v3/openapi.json",
"base_url": "https://petstore3.swagger.io/api/v3",
"open_to_every_key": true
}
'{
"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": "10012",
"title": "Duplicate resource",
"detail": "Resource is a duplicate.",
"meta": {
"url": "https://developers.telnyx.com/docs/overview/errors/10012"
},
"source": {
"pointer": "/name"
}
}
]
}{
"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": "10032",
"title": "Invalid enumerated value",
"detail": "Input tag does not match any of the expected tags: 'none', 'api_key', 'bearer_token', 'basic', 'token', 'authorization', 'oauth_client_credentials', 'passthrough'",
"meta": {
"url": "https://developers.telnyx.com/docs/overview/errors/10032"
},
"source": {
"pointer": "/auth"
}
}
]
}{
"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.
Body
A name for the API, unique on the instance across MCP servers and APIs, regardless of case. Up to 100 letters, digits, _, and .. The gateway prefixes the API's tools with it and a hyphen.
^[A-Za-z0-9_.]{1,100}$The URL of the API's OpenAPI description: OpenAPI 3.0, OpenAPI 3.1, or Swagger 2.0.
Where the gateway sends the API's requests. Without it, the gateway takes the description's first servers entry.
How the gateway authenticates to the API. AWS Signature Version 4 is for MCP servers only. Replaced whole on an update.
- No authentication
- API key
- OAuth client credentials
- Token passthrough
Show child attributes
Show child attributes
The operations the API exposes as tools, by tool name. [] exposes every operation.
Headers sent on every request.
Show child attributes
Show child attributes
Headers copied from the agent's request, by name.
32true lets every key on the instance use the server, granted or not.
Response
The added API
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 AgentGatewayApi = await client.agentGateways.apis.create('instance_id', {
name: 'name',
spec_url: 'spec_url',
});
console.log(AgentGatewayApi.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_api = client.agent_gateways.apis.create(
instance_id="instance_id",
name="name",
spec_url="spec_url",
)
print(agent_gateway_api.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"),
)
aPI, err := client.AgentGateways.Apis.New(
context.TODO(),
"instance_id",
telnyx.AgentGatewayAPINewParams{
Name: "name",
SpecURL: "spec_url",
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", aPI.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.apis.ApiCreateParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
ApiCreateParams params = ApiCreateParams.builder()
.name("name")
.specUrl("spec_url")
.build();
var response = client.agentGateways().apis().create("instance_id", params);
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
agent_gateway_api = telnyx.agent_gateways.apis.create("instance_id", name: "name", spec_url: "spec_url")
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->create(
'instance_id',
name: 'name',
spec_url: 'spec_url',
);
var_dump($agent_gateway_api);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx agent-gateways:apis create \
--api-key 'My API Key' \
--instance-id 32ce035d-3165-4031-b1a7-a7c0c259590a \
--name name \
--spec-url spec_urlcurl --request POST \
--url https://api.telnyx.com/v2/agent_gateways/{instance_id}/apis \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "petstore",
"spec_url": "https://petstore3.swagger.io/api/v3/openapi.json",
"base_url": "https://petstore3.swagger.io/api/v3",
"open_to_every_key": true
}
'{
"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": "10012",
"title": "Duplicate resource",
"detail": "Resource is a duplicate.",
"meta": {
"url": "https://developers.telnyx.com/docs/overview/errors/10012"
},
"source": {
"pointer": "/name"
}
}
]
}{
"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": "10032",
"title": "Invalid enumerated value",
"detail": "Input tag does not match any of the expected tags: 'none', 'api_key', 'bearer_token', 'basic', 'token', 'authorization', 'oauth_client_credentials', 'passthrough'",
"meta": {
"url": "https://developers.telnyx.com/docs/overview/errors/10032"
},
"source": {
"pointer": "/auth"
}
}
]
}{
"errors": [
{
"code": "99903",
"title": "Engine unavailable",
"detail": "The instance's engine did not answer; try again shortly."
}
]
}