> ## Documentation Index
> Fetch the complete documentation index at: https://developers.telnyx.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 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`.



## OpenAPI

````yaml /openapi/source/external/agent-gateway/agent-gateway.json delete /agent_gateways/{instance_id}/apis/{api_id}
openapi: 3.1.0
info:
  version: 1.0.0
  title: Telnyx API
  x-latency-category: interactive
  x-endpoint-cost: light
  description: >-
    Agent Gateway authenticates, authorizes, and audits the requests agents send
    to models, tools, and other agents. Each gateway runs as a dedicated
    instance on the account's
    [*Network*](https://developers.telnyx.com/docs/network/overview). This API
    creates, lists, and deletes instances, and manages the keys, teams, spend
    logs, MCP servers, APIs, tool permissions, and guardrails on them. Each
    instance serves an OpenAI-compatible API at its `gateway_url`.
servers:
  - url: https://api.telnyx.com/v2
    description: Telnyx API v2
security:
  - bearerAuth: []
tags:
  - name: Agent Gateways
    description: Create, list, retrieve, and delete Agent Gateway instances.
  - name: Agent Gateway Keys
    description: Keys on an instance.
  - name: Agent Gateway Teams
    description: 'Teams on an instance: shared model lists, budgets, and rate limits.'
  - name: Agent Gateway Spend Logs
    description: The requests an instance served, with their cost.
  - name: Agent Gateway MCP Servers
    description: MCP servers on an instance, served to agents at one MCP endpoint.
  - name: Agent Gateway APIs
    description: REST APIs on an instance, served to agents as tools.
  - name: Agent Gateway Tool Permissions
    description: The MCP servers and tools a key or team may use.
  - name: Agent Gateway Guardrails
    description: Checks an instance runs on model and tool requests.
  - name: Agent Gateway Policies
    description: Named sets of guardrails an instance applies to requests.
  - name: Agent Gateway Policy Attachments
    description: Where an instance applies each policy.
paths:
  /agent_gateways/{instance_id}/apis/{api_id}:
    delete:
      tags:
        - Agent Gateway APIs
      summary: Delete an API
      description: >-
        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`.
      operationId: DeleteAgentGatewayApi
      parameters:
        - name: instance_id
          in: path
          required: true
          description: The Agent Gateway's `id`.
          schema:
            type: string
            format: uuid
          example: 32ce035d-3165-4031-b1a7-a7c0c259590a
        - name: api_id
          in: path
          required: true
          description: The API's `id`.
          schema:
            type: string
            format: uuid
          example: dbe53cc0-bf7e-4f7a-8d84-752d19890eb3
      responses:
        '200':
          description: The deleted API
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentGatewayApiResponse'
              example:
                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'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TelnyxErrors'
              example:
                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
        '404':
          description: Not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TelnyxErrors'
              example:
                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
        '409':
          description: The instance is not `ready`
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TelnyxErrors'
              example:
                errors:
                  - code: '99901'
                    title: Instance not ready
                    detail: The instance is not ready; its engine is not running.
        '502':
          description: The instance's engine did not answer
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TelnyxErrors'
              example:
                errors:
                  - code: '99903'
                    title: Engine unavailable
                    detail: The instance's engine did not answer; try again shortly.
      x-codeSamples:
        - lang: JavaScript
          source: |-
            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');
        - lang: Python
          source: |
            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",
            )
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\n\t\"github.com/team-telnyx/telnyx-go\"\n\t\"github.com/team-telnyx/telnyx-go/option\"\n)\n\nfunc main() {\n\tclient := telnyx.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\terr := client.AgentGateways.Apis.Delete(\n\t\tcontext.TODO(),\n\t\t\"instance_id\",\n\t\t\"api_id\",\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n}\n"
        - lang: Java
          source: |-
            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");
                }
            }
        - lang: Ruby
          source: >-
            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)
        - lang: PHP
          source: >-
            <?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();
            }
        - lang: CLI
          source: |-
            telnyx agent-gateways:apis delete \
              --api-key 'My API Key' \
              --instance-id 32ce035d-3165-4031-b1a7-a7c0c259590a \
              --api-id dbe53cc0-bf7e-4f7a-8d84-752d19890eb3
components:
  schemas:
    AgentGatewayApiResponse:
      type: object
      required:
        - data
      properties:
        data:
          $ref: '#/components/schemas/AgentGatewayApi'
    TelnyxErrors:
      type: object
      properties:
        errors:
          type: array
          items:
            $ref: '#/components/schemas/TelnyxError'
    AgentGatewayApi:
      type: object
      required:
        - id
        - name
        - spec_url
        - base_url
        - auth
        - tools
        - static_headers
        - forwarded_headers
        - open_to_every_key
        - created_at
        - updated_at
      properties:
        id:
          type: string
          format: uuid
          description: Identifies the API.
        name:
          type: string
          description: >-
            A name for the API, unique on the instance across MCP servers and
            APIs, regardless of case. Letters, digits, `_`, and `.`. The gateway
            prefixes the API's tools with it and a hyphen.
        spec_url:
          type: string
          description: The URL of the API's OpenAPI description.
        base_url:
          type:
            - string
            - 'null'
          description: >-
            Where the gateway sends the API's requests. `null` takes the
            description's first `servers` entry.
        auth:
          $ref: '#/components/schemas/AgentGatewayShownAuth'
        tools:
          type: array
          items:
            type: string
          description: >-
            The operations the API exposes as tools, by tool name. `[]` exposes
            every operation.
        static_headers:
          type: object
          additionalProperties:
            type: string
          description: Headers sent on every request.
        forwarded_headers:
          type: array
          items:
            type: string
          maxItems: 32
          description: Headers copied from the agent's request, by name.
        open_to_every_key:
          type: boolean
          default: false
          description: >-
            `true` lets every key on the instance use the server, granted or
            not.
        created_at:
          type:
            - string
            - 'null'
          format: date-time
        updated_at:
          type:
            - string
            - 'null'
          format: date-time
    TelnyxError:
      type: object
      properties:
        code:
          type: string
        title:
          type: string
        detail:
          type: string
        source:
          type: object
          properties:
            pointer:
              type: string
            parameter:
              type: string
        meta:
          type: object
          properties:
            url:
              type: string
    AgentGatewayShownAuth:
      type: object
      description: >-
        The server's outbound authentication method. Credentials are never
        returned.
      properties:
        type:
          type: string
          description: The method's `type`.
      required:
        - type
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Telnyx API key

````