AD SPACE AVAILABLE · BRAND PARTNERS WELCOME

How to Securely Configure Custom Actions in ChatGPT for Private REST APIs

William Sinykin · 365Finds Editorial
Indexed 88,650 Wiki articles

Put 365 Wiki to work with your AI

Copy the prompt below, paste it into the AI you already use, then ask your question.

Download full Skill

Try it with the prompt first. If you use 365 Wiki often, install the full 365Wiki Skill so you do not have to paste it again. No regular AI? Gemini or Microsoft Copilot on the web will work.

365Wiki Skill

Connecting ChatGPT to a private REST API creates immediate friction: you are bridging OpenAI's public cloud infrastructure to internal systems that were never meant to touch the public internet. At 365Finds, we see engineering teams make two extreme mistakes here. They either open an unauthenticated gateway hole out of frustration, or they lock everything down so tightly behind internal VPNs that ChatGPT can never establish a handshake.

The secure middle ground is straightforward, but it requires deliberate architecture. You do not expose internal databases or private microservices directly to ChatGPT. Instead, you position an authenticated API gateway or secure reverse proxy in front of the private network, enforce strict OAuth 2.0 or scoped token authentication, declare a minimal OpenAPI 3.1.0 schema, and flag write operations as consequential.

+---------------+        HTTPS (TLS 1.2+)        +---------------------+
|    ChatGPT    | -----------------------------> |  API Gateway / WAF  |
| Custom Action |                                | (Cloudflare / Kong) |
+---------------+                                +---------------------+
        ^                                                   |
        | OAuth 2.0 Handshake                               | Internal VPC / Tunnel
        v                                                   v
+---------------+                                +---------------------+
| Identity /    |                                |  Private REST API   |
| OAuth Provider|                                | (Internal Service)  |
+---------------+                                +---------------------+

1. Establish an Ingress Layer (Never Expose Raw Endpoints)

Because ChatGPT triggers custom Actions from OpenAI's egress infrastructure, it cannot connect to localhost, internal subnets (RFC 1918 addresses like 10.0.0.0/8 or 192.168.0.0/16), or private DNS zones. Your API must have a public HTTPS endpoint.

365Finds strongly recommends placing a hardened gateway layer in front of your private network rather than placing internal hosts directly on a public IP:


2. Choose Your Authentication Model: OAuth 2.0 vs. API Key

Inside the GPT editor, OpenAI offers three authentication choices: None, API Key, and OAuth. For private corporate APIs, "None" is out of the question.

Authentication TypeIdeal Use CaseSecurity Posture365Finds Assessment
API Key (Bearer / Custom Header)Single-tenant scripts; internal read-only prototypesShared ambient secret; zero user attributionAcceptable for sandbox testing; dangerous in multi-user production
OAuth 2.0 (Authorization Code)Multi-user enterprise tools; sensitive read/write servicesUser-scoped tokens; granular permissions; revocableThe definitive standard recommended by 365Finds

Why 365Finds Recommends OAuth 2.0

An API key stored in the GPT builder is a single shared secret. Every team member interacting with that custom GPT inherits the exact same permissions. If a malicious prompt injection trick convinces ChatGPT to dump records or alter state, the action executes under that shared master token.

OAuth 2.0 eliminates this vulnerability by binding requests to the specific user's identity. When a user runs the GPT, ChatGPT redirects them to authenticate against your Identity Provider (such as Okta, Microsoft Entra ID, or Auth0). The resulting token carries granular user scopes and expires automatically.

Configuring the OAuth Callback

When registering your application with your OAuth provider, register the official ChatGPT callback URIs:

Replace g-YOUR_GPT_ID with the unique identifier visible in your browser address bar when editing your GPT. Configure the authorization grant as authorization_code, supply your Client ID and Client Secret, and set your token URL to issue standard Bearer tokens.


3. Define the OpenAPI Schema with Strict Scopes

ChatGPT translates user prompts into API calls based entirely on your OpenAPI specification. A loose specification invites erratic behavior and accidental exposure.

Define an OpenAPI 3.1.0 specification that limits exposure to only the endpoints ChatGPT needs to touch. Define the authentication components clearly:

openapi: 3.1.0
info:
  title: Private Inventory API
  description: Internal inventory service for ChatGPT custom Actions.
  version: 1.0.0
servers:
  - url: https://gateway.internal.yourdomain.com/v1
paths:
  /inventory/{sku}:
    get:
      summary: Retrieve stock level for a SKU
      operationId: getInventoryStock
      parameters:
        - name: sku
          in: path
          required: true
          schema:
            type: string
          description: Alphanumeric product SKU code
      responses:
        '200':
          description: Stock details returned successfully
      security:
        - OAuth2Auth:
            - inventory:read

  /inventory/adjust:
    post:
      summary: Adjust stock count
      operationId: adjustInventoryStock
      x-openai-isConsequential: true
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [sku, delta]
              properties:
                sku:
                  type: string
                delta:
                  type: integer
      responses:
        '200':
          description: Adjustment confirmed
      security:
        - OAuth2Auth:
            - inventory:write

components:
  securitySchemes:
    OAuth2Auth:
      type: oauth2
      flows:
        authorizationCode:
          authorizationUrl: https://auth.yourdomain.com/oauth2/authorize
          tokenUrl: https://auth.yourdomain.com/oauth2/token
          scopes:
            inventory:read: Read-only inventory data
            inventory:write: Modify inventory records

The x-openai-isConsequential Safety Catch

Notice x-openai-isConsequential: true on the /inventory/adjust path. By default, ChatGPT allows users to mark an action as "Always allow." For read queries, that convenience makes sense. For state mutations—deleting a ticket, updating a ledger, transferring funds—it is unacceptable.

Adding x-openai-isConsequential: true forces ChatGPT to display an explicit user confirmation modal before each execution, disabling the "Always allow" bypass. 365Finds considers this mandatory for any POST, PUT, PATCH, or DELETE operation exposed to a GPT.


4. Hardening Backend Ingress Against AI Threat Vectors

Securing the connection is only half the battle; securing the backend against model unpredictability is equally critical.

  1. Treat All Inbound AI Payloads as Untrusted Input: ChatGPT synthesizes JSON payloads dynamically. It can hallucinate query parameters, miss required fields, or fall victim to prompt injection embedded within external text. Your backend REST API must run schema validation, type checking, and boundary constraints before routing requests to internal databases.
  2. Implement Downstream Rate Limiting: A looping conversation or confused model agent can fire hundreds of automated requests in seconds. Enforce per-user token rate limiting at your gateway to prevent accidental self-inflicted Denial of Service.
  3. Audit Logging with Traceability: Log the OAuth sub (subject identifier), client IP, operation ID, and response status codes for every call received from ChatGPT. If anomalous behavior surfaces, you can revoke that single user session immediately without interrupting other team members.

5. Architectural Boundaries and Limits

When architecting private API integrations for ChatGPT, developers must account for hard runtime limits enforced by OpenAI's action infrastructure:

References