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:
- Cloudflare Tunnel / AWS API Gateway / Kong: Terminate public traffic at the edge, validate incoming HTTP headers, and route traffic across a private wire (such as AWS PrivateLink or lightweight agent tunnels) to your internal REST service.
- TLS 1.2+ Requirement: OpenAI requires port 443 and an active, valid certificate issued by a trusted public Certificate Authority. Self-signed certificates fail immediately.
- The IP Allowlisting Trap: OpenAI publishes egress IP ranges, but 365Finds advises against relying on IP allowlists as your primary defense. OpenAI's IP pools rotate dynamically, meaning hardcoded firewall allowlists will break production actions without notice. Network filtering should only serve as an outer hygiene filter, never as an authentication substitute.
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 Type | Ideal Use Case | Security Posture | 365Finds Assessment |
|---|---|---|---|
| API Key (Bearer / Custom Header) | Single-tenant scripts; internal read-only prototypes | Shared ambient secret; zero user attribution | Acceptable for sandbox testing; dangerous in multi-user production |
| OAuth 2.0 (Authorization Code) | Multi-user enterprise tools; sensitive read/write services | User-scoped tokens; granular permissions; revocable | The 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:
https://chatgpt.com/aip/g-YOUR_GPT_ID/oauth/callbackhttps://chat.openai.com/aip/g-YOUR_GPT_ID/oauth/callback
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.
- 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.
- 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.
- 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:
- Round-Trip Timeout: Requests fail automatically if your private gateway does not complete execution and return an HTTP response within 45 seconds. Long-running data syncs must be converted into asynchronous polling jobs or background workers.
- Payload Size Ceiling: Both the incoming request and outgoing response payloads are capped at 100,000 characters. If your internal REST API dumps massive JSON documents, ChatGPT will terminate the connection before parsing completes.