Skip to main content
The Events API receives engagement signals from your application. These events power analytics, personalization, and ranking algorithms.

Endpoints

MethodEndpointDescription
POST/v1/eventsSend single event
POST/v1/events/batchSend multiple events

Event types

Engagement events

EventTriggerRequired Fields
impressionContent appears in viewportcontentId, position
playStartPlayback beginscontentId, startupTime
watchProgressPeriodic progress updatecontentId, currentTime, duration
completionVideo completescontentId, watchTime, looped
swipeUser swipes to nextfromContentId, toContentId, watchTime
likeUser likes contentcontentId
shareUser shares contentcontentId, platform
saveUser saves contentcontentId

Quality events

EventTriggerRequired Fields
rebufferPlayback stallscontentId, duration, currentTime
qualityChangeRendition changescontentId, fromQuality, toQuality
errorPlayback errorcontentId, errorCode, errorMessage

Send event

Send a single engagement event.
POST /v1/events

Request body

event
string
required
Event type (e.g., impression, playStart).
contentId
string
required
Content ID the event relates to.
userId
string
Identified user ID (if available).
deviceId
string
Device identifier.
sessionId
string
Session identifier for grouping events.
timestamp
string
Event timestamp (ISO 8601). Defaults to server time.
data
object
Event-specific data.

Example: Impression event

curl -X POST https://api.shortkit.dev/v1/events \
  -H "Authorization: Bearer pk_live_your_publishable_key" \
  -H "Content-Type: application/json" \
  -d '{
    "event": "impression",
    "contentId": "cnt_abc123",
    "userId": "user_123",
    "sessionId": "sess_xyz789",
    "data": {
      "position": 0,
      "entryPoint": "feed",
      "feedId": "feed_abc123"
    }
  }'

Example: Play start event

curl -X POST https://api.shortkit.dev/v1/events \
  -H "Authorization: Bearer pk_live_your_publishable_key" \
  -H "Content-Type: application/json" \
  -d '{
    "event": "playStart",
    "contentId": "cnt_abc123",
    "userId": "user_123",
    "sessionId": "sess_xyz789",
    "data": {
      "startupTime": 250,
      "rendition": "720p",
      "codec": "h264",
      "autoplay": true
    }
  }'

Example: Completion event

curl -X POST https://api.shortkit.dev/v1/events \
  -H "Authorization: Bearer pk_live_your_publishable_key" \
  -H "Content-Type: application/json" \
  -d '{
    "event": "completion",
    "contentId": "cnt_abc123",
    "userId": "user_123",
    "sessionId": "sess_xyz789",
    "data": {
      "watchTime": 45.2,
      "looped": false,
      "loopCount": 0
    }
  }'

Example: Swipe event

curl -X POST https://api.shortkit.dev/v1/events \
  -H "Authorization: Bearer pk_live_your_publishable_key" \
  -H "Content-Type: application/json" \
  -d '{
    "event": "swipe",
    "contentId": "cnt_def456",
    "userId": "user_123",
    "sessionId": "sess_xyz789",
    "data": {
      "fromContentId": "cnt_abc123",
      "watchTimeOnFrom": 12.5,
      "direction": "next"
    }
  }'

Response

{
  "data": {
    "received": true,
    "eventId": "evt_abc123"
  },
  "meta": {
    "requestId": "req_xyz789"
  }
}

Batch events

Send multiple events in a single request for efficiency.
POST /v1/events/batch

Request body

events
array
required
Array of events (max 100 per request).

Example request

curl -X POST https://api.shortkit.dev/v1/events/batch \
  -H "Authorization: Bearer pk_live_your_publishable_key" \
  -H "Content-Type: application/json" \
  -d '{
    "events": [
      {
        "event": "impression",
        "contentId": "cnt_abc123",
        "userId": "user_123",
        "timestamp": "2024-02-04T12:00:00Z",
        "data": { "position": 0 }
      },
      {
        "event": "playStart",
        "contentId": "cnt_abc123",
        "userId": "user_123",
        "timestamp": "2024-02-04T12:00:01Z",
        "data": { "startupTime": 200 }
      },
      {
        "event": "completion",
        "contentId": "cnt_abc123",
        "userId": "user_123",
        "timestamp": "2024-02-04T12:00:46Z",
        "data": { "watchTime": 45.2 }
      }
    ]
  }'

Response

{
  "data": {
    "received": 3,
    "failed": 0
  },
  "meta": {
    "requestId": "req_xyz789"
  }
}

Event data schemas

Impression data

{
  "position": 0,
  "entryPoint": "feed",
  "feedId": "feed_abc123"
}
FieldTypeDescription
positionintegerPosition in feed (0-indexed)
entryPointstringEntry point: feed, search, direct, share
feedIdstringFeed session ID

PlayStart data

{
  "startupTime": 250,
  "rendition": "720p",
  "codec": "h264",
  "autoplay": true
}
FieldTypeDescription
startupTimeintegerTime to first frame (ms)
renditionstringInitial quality
codecstringVideo codec used
autoplaybooleanWhether autoplay triggered

WatchProgress data

{
  "currentTime": 15.5,
  "duration": 45.2,
  "percentComplete": 34.3,
  "rendition": "720p"
}
FieldTypeDescription
currentTimenumberCurrent playback position
durationnumberTotal duration
percentCompletenumberPercentage watched
renditionstringCurrent quality

Completion data

{
  "watchTime": 45.2,
  "looped": false,
  "loopCount": 0
}
FieldTypeDescription
watchTimenumberTotal watch time
loopedbooleanWhether video looped
loopCountintegerNumber of loops

Rebuffer data

{
  "duration": 1200,
  "currentTime": 12.5,
  "rendition": "720p"
}
FieldTypeDescription
durationintegerRebuffer duration (ms)
currentTimenumberPlayback position when stall occurred
renditionstringQuality when stall occurred

SDK integration

SDKs automatically send events. You can also send custom events:
// Events are sent automatically by the SDK

// Send custom event
shortKit.trackEvent(
    type: "custom_action",
    contentId: "cnt_abc123",
    data: ["action": "bookmark"]
)

Event batching

The SDK batches events for efficiency:
SettingDefaultDescription
batchSize10Events before flush
batchInterval5000msMax time before flush
flushOnBackgroundtrueFlush when app backgrounds
Configure batching:
shortkit.initialize({
  apiKey: 'pk_live_...',
  events: {
    batchSize: 20,
    batchInterval: 10000
  }
});

Validation

Events are validated server-side:
ValidationBehavior
Missing required fieldsEvent rejected
Invalid contentIdEvent rejected
Future timestamp (>5 min)Timestamp adjusted
Duplicate eventIdEvent deduplicated
Failed events in batch requests don’t affect other events.

Best practices

Reduce API calls by batching events. The SDK handles this automatically.
Session IDs group events from a single viewing session, enabling accurate session-level analytics.
Events older than 24 hours may not be processed. The SDK flushes on app background.
The SDK queues events when offline and retries when connectivity returns.

Next steps