REST API Reference
Complete reference for all Retenshun API endpoints. All requests use JSON and return JSON.
Base URL
https://your-domain.com/api/v1
Authentication
All API requests require authentication via the x-api-key header or Authorization: Bearer header.
# Option 1: x-api-key header curl -X GET https://your-domain.com/api/v1/users \ -H "x-api-key: sk_live_YOUR_SECRET_KEY" \ -H "Content-Type: application/json" # Option 2: Authorization Bearer header curl -X GET https://your-domain.com/api/v1/users \ -H "Authorization: Bearer sk_live_YOUR_SECRET_KEY" \ -H "Content-Type: application/json"
Public key (pk_live_...) — Use in browser/client-side code. Can track events, identify users, and manage push tokens.
Secret key (sk_live_...) — Server-side only. Full access to all endpoints. Never expose in client code.
Rate Limiting
API requests are rate-limited per project. If you exceed the limit, you'll receive a 429 Too Many Requests response. Use exponential backoff to retry.
Error Responses
Errors return a consistent JSON format:
{
"error": "Unauthorized",
"message": "Invalid or missing API key",
"status": 401
}Endpoints
Events
Track and query user events.
/api/v1/eventsTrack a single event
Auth: API Key (public or secret)
Request Body
{
"event": "purchase",
"user_id": "user_123",
"anonymous_id": "anon_abc123",
"properties": {
"amount": 49.99,
"product_id": "prod_1"
}
}Response
{ "event": { "id": "evt_abc123", "eventName": "purchase", "userId": "...", ... } }Accepts both SDK format (event, user_id) and legacy format (eventName, userId). Users are auto-created if not found.
/api/v1/events/batchBatch ingest events (SDK)
Auth: API Key (public or secret)
Request Body
{
"batch": [
{
"type": "identify",
"user_id": "user_123",
"anonymous_id": "anon_abc",
"properties": { "email": "john@example.com", "name": "John" }
},
{
"type": "track",
"event": "button_clicked",
"user_id": "user_123",
"properties": { "button": "signup_cta" },
"timestamp": "2026-03-09T12:00:00Z"
}
]
}Response
{ "success": true, "processed": 2, "errors": 0 }Accepts up to 100 items per batch. Supports both "identify" and "track" types. Users are auto-created if not found.
/api/v1/eventsList events
Auth: API Key (secret)
Query Parameters
event, user, search, page, limit
Response
{ "events": [...], "pagination": { "page": 1, "limit": 50, "total": 142, "totalPages": 3 } }/api/v1/events/:idGet a single event
Auth: API Key (secret)
Response
{ "id": "evt_abc", "eventName": "purchase", "userId": "...", "properties": {...}, ... }/api/v1/events/:idDelete an event
Auth: API Key (secret)
Response
{ "deleted": true }Users
Manage end-user profiles and properties.
/api/v1/users/identifyIdentify / upsert a user (SDK)
Auth: API Key (public or secret)
Request Body
{
"user_id": "user_123",
"anonymous_id": "anon_abc123",
"properties": {
"email": "john@example.com",
"name": "John Doe",
"plan": "pro"
}
}Response
{ "success": true, "user": { "id": "...", "externalId": "user_123" } }Creates the user if not found, or updates properties if they already exist. The "email" and "name" fields are extracted to top-level columns.
/api/v1/usersList users
Auth: API Key (secret)
Query Parameters
search, page, limit, filter (active|inactive)
Response
{ "users": [...], "total": 1024, "page": 1 }/api/v1/users/:idGet a user
Auth: API Key (secret)
Response
{ "id": "user_123", "email": "john@example.com", "properties": {...}, ... }/api/v1/users/:idUpdate a user
Auth: API Key (secret)
Request Body
{
"email": "new@example.com",
"properties": {
"plan": "enterprise",
"timezone": "America/New_York"
}
}Response
{ "id": "user_123", "email": "new@example.com", ... }/api/v1/users/:idDelete a user
Auth: API Key (secret)
Response
{ "deleted": true }Segments
Create and manage user segments for targeting.
/api/v1/segmentsList segments
Auth: API Key (secret)
Response
{ "segments": [{ "id": "seg_1", "name": "Power Users", "userCount": 342, ... }] }/api/v1/segmentsCreate a segment
Auth: API Key (secret)
Request Body
{
"name": "Power Users",
"description": "Users with 10+ sessions",
"rules": [
{ "field": "sessionCount", "operator": "gte", "value": 10 }
]
}Response
{ "id": "seg_1", "name": "Power Users", ... }/api/v1/segments/:idUpdate a segment
Auth: API Key (secret)
Request Body
{ "name": "Super Users", "rules": [...] }Response
{ "id": "seg_1", "name": "Super Users", ... }/api/v1/segments/:idDelete a segment
Auth: API Key (secret)
Response
{ "deleted": true }/api/v1/segments/estimateEstimate segment size
Auth: API Key (secret)
Request Body
{ "rules": [{ "field": "plan", "operator": "eq", "value": "pro" }] }Response
{ "estimatedCount": 287 }Automations
Build event-driven automation workflows.
/api/v1/automationsList automations
Auth: API Key (secret)
Response
{ "automations": [...] }/api/v1/automationsCreate an automation
Auth: API Key (secret)
Request Body
{
"name": "Welcome Sequence",
"triggerType": "EVENT",
"triggerEvent": "signed_up",
"active": true,
"steps": [
{ "type": "SEND_EMAIL", "templateId": "tpl_1", "delay": 0 },
{ "type": "WAIT", "delay": 259200 },
{ "type": "SEND_EMAIL", "templateId": "tpl_2" }
]
}Response
{ "id": "auto_1", "name": "Welcome Sequence", ... }/api/v1/automations/:idUpdate an automation
Auth: API Key (secret)
Request Body
{ "name": "Updated Welcome", "active": false }Response
{ "id": "auto_1", "name": "Updated Welcome", ... }/api/v1/automations/:idDelete an automation
Auth: API Key (secret)
Response
{ "deleted": true }Campaigns
Send one-time or scheduled messages to segments.
/api/v1/campaignsList campaigns
Auth: API Key (secret)
Response
{ "campaigns": [...] }/api/v1/campaignsCreate a campaign
Auth: API Key (secret)
Request Body
{
"name": "Spring Sale",
"channel": "EMAIL",
"segmentId": "seg_1",
"templateId": "tpl_3",
"scheduledAt": "2026-04-01T10:00:00Z"
}Response
{ "id": "camp_1", "name": "Spring Sale", "status": "SCHEDULED", ... }/api/v1/campaigns/:idUpdate a campaign
Auth: API Key (secret)
Request Body
{ "name": "Spring Mega Sale" }Response
{ "id": "camp_1", ... }/api/v1/campaigns/:idDelete a campaign
Auth: API Key (secret)
Response
{ "deleted": true }Templates
Manage reusable message templates for email, push, and in-app.
/api/v1/templatesList templates
Auth: API Key (secret)
Query Parameters
channel (EMAIL|PUSH|IN_APP), ai (true|false)
Response
{ "templates": [...] }/api/v1/templatesCreate a template
Auth: API Key (secret)
Request Body
{
"name": "Welcome Email",
"channel": "EMAIL",
"subject": "Welcome to {{company}}!",
"body": "<h1>Hi {{name}}</h1><p>Thanks for joining.</p>",
"tags": ["onboarding"]
}Response
{ "id": "tpl_1", "name": "Welcome Email", ... }/api/v1/templates/:idUpdate a template
Auth: API Key (secret)
Request Body
{ "subject": "Welcome aboard, {{name}}!" }Response
{ "id": "tpl_1", ... }/api/v1/templates/:idDelete a template
Auth: API Key (secret)
Response
{ "deleted": true }Messages
Send messages directly via API.
/api/v1/messagesSend a message
Auth: API Key (secret)
Request Body
{
"userId": "user_123",
"channel": "EMAIL",
"subject": "Your order shipped!",
"body": "<p>Your order #1234 is on its way.</p>"
}Response
{ "id": "msg_1", "status": "sent" }/api/v1/messagesList sent messages
Auth: API Key (secret)
Query Parameters
userId, channel, page, limit
Response
{ "messages": [...], "total": 50 }News Feed
Manage in-app news feed items.
/api/v1/newsList news items
Auth: API Key (secret)
Response
{ "items": [...] }/api/v1/newsCreate a news item
Auth: API Key (secret)
Request Body
{
"title": "New Feature: Dark Mode",
"body": "We just launched dark mode!",
"published": true
}Response
{ "id": "news_1", ... }/api/v1/news/:idUpdate a news item
Auth: API Key (secret)
Request Body
{ "title": "Updated title" }Response
{ "id": "news_1", ... }/api/v1/news/:idDelete a news item
Auth: API Key (secret)
Response
{ "deleted": true }AI Content
Generate AI-powered message content.
/api/v1/ai/generateGenerate content with AI
Auth: API Key (secret)
Request Body
{
"channel": "PUSH",
"context": "Remind users about their abandoned cart",
"tone": "friendly"
}Response
{ "title": "Forgot something?", "body": "Your cart is waiting — complete your order today!" }Channels
Configure notification channel settings (push, email, SMS).
/api/v1/channelsGet channel configuration
Auth: API Key (secret)
Response
{ "email": { "provider": "POSTALYNK", "configured": true }, "push": { "configured": false }, ... }/api/v1/channelsUpdate channel settings
Auth: API Key (secret)
Request Body
{
"emailProvider": "POSTALYNK",
"postalynkApiKey": "pk_your_key",
"postalynkFromEmail": "hello@yourapp.com",
"fcmServerKey": "your_firebase_server_key",
"apnsKeyId": "ABC123DEFG",
"apnsTeamId": "TEAM123456",
"apnsPrivateKey": "-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----",
"apnsBundleId": "com.yourapp.ios",
"apnsEnvironment": "production"
}Response
{ "updated": true }Set fcmServerKey for Android/Web push via FCM. Set APNs fields for direct iOS push delivery without Firebase. If APNs is not configured, iOS pushes fall back to FCM (requires APNs cert uploaded to Firebase). Set email fields to configure PostaLynk email delivery.
Push Tokens
Register and manage push notification tokens for users.
/api/v1/push-tokensRegister a push token
Auth: API Key (public or secret)
Request Body
{
"user_id": "user_123",
"token": "fcm_token_or_web_push_subscription",
"platform": "IOS"
}Response
{ "success": true }Platform must be one of: IOS, ANDROID, WEB. For web, the token is the JSON-stringified PushSubscription object.
/api/v1/push-tokensUnregister a push token
Auth: API Key (public or secret)
Request Body
{
"token": "fcm_token_or_web_push_subscription"
}Response
{ "success": true }/api/v1/push-tokensGet VAPID public key for Web Push
Auth: API Key (public or secret)
Response
{ "success": true, "data": { "vapid_public_key": "BLx...", "push_configured": true } }Use the VAPID public key to create a Web Push subscription in the browser.
Webhooks
Receive real-time event notifications.
/api/v1/webhook/:projectIdWebhook endpoint (inbound)
Auth: HMAC-SHA256 signature
Request Body
{
"event": "message.delivered",
"data": { "messageId": "msg_1", "userId": "user_123" }
}Response
{ "received": true }Verify the X-Signature header using HMAC-SHA256 with your webhook secret.
API Keys
Manage API keys for your project.
/api/v1/api-keysList API keys
Auth: Session (dashboard)
Response
{ "keys": [{ "id": "key_1", "name": "Production", "prefix": "sk_live_abc...", ... }] }/api/v1/api-keysCreate an API key
Auth: Session (dashboard)
Request Body
{ "name": "Production Key", "type": "secret" }Response
{ "id": "key_1", "key": "sk_live_full_key_shown_once", ... }/api/v1/api-keysRevoke an API key
Auth: Session (dashboard)
Request Body
{ "id": "key_1" }Response
{ "deleted": true }Team
Manage team members and invites.
/api/v1/teamList team members
Auth: Session (dashboard)
Response
{ "members": [{ "id": "usr_1", "email": "...", "role": "ADMIN" }] }/api/v1/team/invitesInvite a team member
Auth: Session (dashboard)
Request Body
{ "email": "teammate@example.com", "role": "MEMBER" }Response
{ "invite": { "id": "inv_1", "email": "...", "status": "PENDING" } }Reports
Retrieve analytics and reporting data.
/api/v1/reportsGet analytics report
Auth: API Key (secret)
Query Parameters
range (7d|30d|90d), metrics (events|users|messages)
Response
{ "range": "30d", "events": 12450, "activeUsers": 843, "messagesSent": 2100, ... }