- Base URL:
https://presence.sls.epilot.io - Full API Docs: https://docs.epilot.io/api/presence
import { epilot } from '@epilot/sdk' epilot.authorize(() => '<token>') const { data } = await epilot.presence.heartbeatPresence(...)
import { getClient, authorize } from '@epilot/sdk/presence' const presenceClient = getClient() authorize(presenceClient, () => '<token>') const { data } = await presenceClient.heartbeatPresence(...)
Presence
Schemas
PresenceResourceTypePresenceStateSessionIdInstanceIdPresenceHeartbeatPresenceLeavePresenceMemberPresenceRosterErrorResponse
Announces the caller on a resource, or refreshes their presence there, and returns everyone currently present.
POST /v1/presence/{resource_type}/{resource_id}/heartbeat
const { data } = await client.heartbeatPresence( { resource_type: 'example', resource_id: 'example', x-epilot-org-id: 'example', }, { session_id: 'f7c1b2a0-3e4d-4c8e-9a1b-2d3e4f5a6b7c', instance_id: 'b1f0c2d3e4', state: 'editing' }, )
Response
{
"members": [
{
"user_id": "123456",
"user_org": "123",
"state": "editing",
"last_seen_at": "1970-01-01T00:00:00.000Z",
"is_self": true
}
],
"ttl_seconds": 60,
"heartbeat_interval_seconds": 20,
"truncated": true
}Removes the caller's session from the resource at once, for example when the tab closes or the user navigates away.
POST /v1/presence/{resource_type}/{resource_id}/leave
const { data } = await client.leavePresence( { resource_type: 'example', resource_id: 'example', x-epilot-org-id: 'example', }, { session_id: 'f7c1b2a0-3e4d-4c8e-9a1b-2d3e4f5a6b7c', instance_id: 'b1f0c2d3e4' }, )
Kind of resource, and the permission needed to see who is present on it:
journey:entity:viewon the journey. The resource ID is the journey's entity ID.customer_portal:customer_portal:viewon the portalinstaller_portal:installer_portal:viewon the portalflow: `workflow:de
type PresenceResourceType = "journey" | "customer_portal" | "installer_portal" | "flow"
viewing: the resource is open. editing: it is open with unsaved changes.
type PresenceState = "viewing" | "editing"
Generated by the client, one per browser tab. A user can be present with several tabs.
type SessionId = string
Optional. Generated by the client each time it starts sending heartbeats in a tab. A leave that carries it only takes effect while that instance sent the session's latest heartbeat, so a late leave from an earlier instance in the same tab cannot remove the session.
type InstanceId = string
type PresenceHeartbeat = { session_id: string instance_id?: string state?: "viewing" | "editing" }
type PresenceLeave = { session_id: string instance_id?: string }
A user present on the resource. Several tabs of the same user count as one member.
type PresenceMember = { user_id: string user_org?: string state: "viewing" | "editing" last_seen_at: string // date-time is_self: boolean }
type PresenceRoster = { members: Array<{ user_id: string user_org?: string state: "viewing" | "editing" last_seen_at: string // date-time is_self: boolean }> ttl_seconds: number heartbeat_interval_seconds: number truncated?: boolean }
type ErrorResponse = { status?: number error?: string | object[] }