Synaplan API (api.php) – Introduction
The api.php
endpoint is the single entry point for Synaplan's API. It supports:
- OpenAI-compatible endpoints under
/v1/*
(chat, images, audio, models) - Simple REST-style actions via
action=
parameters - Anonymous widget sessions (no login) and API key authentication
Authentication
You can access the API in three ways:
- API Key (recommended)
- Send header:
Authorization: Bearer YOUR_API_KEY
- Works with both OpenAI-compatible and REST endpoints
- Send header:
- Logged-in user session (browser)
- Session cookies from the app
- Anonymous widget session
- Initialize via widget loader, then call REST endpoints with the same cookie jar
Create an API token (via Settings)
In the app UI, open Settings
(internally index.php/settings
, see frontend/c_settings.php
). In the "API Keys" section:
- Click "Create API Key"
- Copy the generated key and store it securely
- Use it as
Authorization: Bearer ...
in your API calls
You can also manage keys via REST endpoints when authenticated: getApiKeys
, createApiKey
, setApiKeyStatus
, deleteApiKey
.
Base URL
All examples assume the app is hosted at:
https://app.synaplan.com/api.php
For OpenAI-compatible endpoints, use:
https://app.synaplan.com/api.php/v1/...
Quick start: start a widget chat via REST (no login)
This example starts an anonymous widget chat (owner/member ID 2, widget ID 1) and posts the message "Who are you?"
# 1) Initialize the anonymous widget session and capture cookies
curl -sSL -c cookies.txt \
"https://app.synaplan.com/widgetloader.php?uid=2&widgetid=1" > /dev/null
# 2) Send a message to the chat (REST: action=messageNew)
curl -sS -b cookies.txt -c cookies.txt \
-X POST \
-F "action=messageNew" \
-F "message=Who are you?" \
https://app.synaplan.com/api.php
# Optional: Stream the AI response (Server-Sent Events)
# - pass the lastIds returned by messageNew as comma-separated list
# curl -N -b cookies.txt -X POST \
# -F "action=chatStream" -F "lastIds=12345" \
# https://app.synaplan.com/api.php
Tip: For authenticated users or API keys, you can call action=messageNew
directly without the widget step (the message is posted in your account).