openapi: 3.1.0
info:
title: Chat Ingestion API
description: |
Minimal API for a GPT Action to POST conversation transcripts to your backend.
Add your API key in the X-API-Key header from the Action's authentication settings.
version: 1.0.0
servers:
- url: https://api.yourdomain.com
description: Your ingestion endpoint base URL
components:
securitySchemes:
apiKeyAuth:
type: apiKey
in: header
name: X-API-Key
schemas:
ChatRole:
type: string
enum: [system, user, assistant, tool]
ToolCall:
type: object
properties:
id:
type: string
name:
type: string
arguments:
type: object
additionalProperties: true
additionalProperties: false
ChatMessage:
type: object
required: [role, content]
properties:
role:
$ref: '#/components/schemas/ChatRole'
content:
oneOf:
- type: string
- type: array
description: Multi-part content (e.g., text and images).
items:
oneOf:
- type: object
required: [type, text]
properties:
type:
type: string
enum: [text]
text:
type: string
- type: object
required: [type, image_url]
properties:
type:
type: string
enum: [image_url]
image_url:
type: string
format: uri
name:
type: string
description: Tool name for tool messages (if applicable)
tool_call_id:
type: string
tool_calls:
type: array
items:
$ref: '#/components/schemas/ToolCall'
createdAt:
type: string
format: date-time
additionalProperties: false
ChatIngestRequest:
type: object
required: [sessionId, messages]
properties:
sessionId:
type: string
description: Stable identifier for the conversation/session
userId:
type: string
description: Your app’s user ID (optional)
model:
type: string
description: Model used by the GPT (optional)
assistantId:
type: string
description: Identifier of the GPT/assistant (optional)
runId:
type: string
description: OpenAI-assigned run ID if available (optional)
messages:
type: array
items:
$ref: '#/components/schemas/ChatMessage'
extra:
type: object
description: Free-form metadata you want to attach
additionalProperties: true
additionalProperties: false
ChatIngestResponse:
type: object
properties:
status:
type: string
enum: [ok]
receivedCount:
type: integer
sessionId:
type: string
additionalProperties: false
security:
- apiKeyAuth: []
paths:
/v1/chat/ingest:
post:
operationId: ingestChat
summary: Ingest a GPT conversation transcript
description: Accepts conversation messages from an OpenAI GPT Action to store or analyze.
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/ChatIngestRequest'
examples:
sample:
value:
sessionId: "sess_123"
userId: "user_42"
model: "gpt-4.1"
assistantId: "gpt_sales_helper"
runId: "run_abc123"
messages:
- role: system
content: "You are a helpful assistant."
createdAt: "2025-09-17T12:00:00Z"
- role: user
content: "Summarize this meeting: https://example.com/notes"
createdAt: "2025-09-17T12:01:00Z"
- role: assistant
content: "Here's a concise summary..."
createdAt: "2025-09-17T12:01:10Z"
extra:
source: "gpt_action"
responses:
'200':
description: Acknowledgement
content:
application/json:
schema:
$ref: '#/components/schemas/ChatIngestResponse'
examples:
ok:
value:
status: ok
receivedCount: 3
sessionId: "sess_123"
'401':
description: Missing or invalid API key
'400':
description: Malformed request
Ideas for Getting Your Notion API Key
Here are some approaches to obtain and use your Notion API key:
- Create a Notion integration: Go to https://www.notion.so/my-integrations and create a new integration to get an API key.
- Set appropriate capabilities: When creating your integration, select the specific capabilities needed (read content, update content, insert content).
- Share pages with your integration: Connect specific pages or databases with your integration by clicking "Share" and adding your integration.
- Use environment variables: Store your Notion API key as an environment variable in your development environment for security.
- Implement a secure backend: Create a backend service that securely stores your Notion API key and proxies requests to the Notion API.
- Set up workspace-level integration: For broader access, configure your integration at the workspace level instead of page-by-page.
- Create different integrations for different purposes: Use separate API keys for different functionalities to maintain principle of least privilege.
- Implement API key rotation: Regularly generate new API keys and update your applications to enhance security.
- Use a secrets manager: Store your Notion API keys in services like AWS Secrets Manager or HashiCorp Vault.
- Monitor API usage: Keep track of your API requests to stay within Notion's rate limits and understand your usage patterns.
After obtaining your API key, you can use it to authenticate requests to the Notion API for your ChatGPT integration.
Ideas for Using Notion Database with GPT Actions
Here are approaches for connecting your custom GPT to a Notion database:
- Direct database linking won't work: Unfortunately, you can't simply paste a Notion database URL into GPT Actions - the API needs an actual HTTP endpoint that can receive and process JSON payloads.
- Create a middleware API: You'll need to build or use a service that sits between ChatGPT and your Notion database, receiving data from GPT Actions and writing to your database.