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.
curl -X GET https://your-domain.com/api/v1/users \ -H "x-api-key: sk_live_YOUR_SECRET_KEY" \ -H "Content-Type: application/json"
Public key (pk_live_...) — Use in browser/client-side code. Can only track events and identify users.
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 an event
Auth: API Key (public or secret)
Request Body
{
"userId": "user_123",
"eventName": "purchase",
"properties": {
"amount": 49.99,
"product_id": "prod_1"
}
}Response
{ "id": "evt_abc123", "status": "ok" }/api/v1/eventsList events
Auth: API Key (secret)
Query Parameters
userId, eventName, from, to, page, limit
Response
{ "events": [...], "total": 142, "page": 1 }/api/v1/events/:idGet a single event
Auth: API Key (secret)
Response
{ "id": "evt_abc", "eventName": "purchase", "userId": "user_123", ... }/api/v1/events/:idDelete an event
Auth: API Key (secret)
Response
{ "deleted": true }Users
Manage end-user profiles and properties.
/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"
}Response
{ "updated": true }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, ... }