Identity
Initialize visitor session
Create or fetch an anonymous visitor for the provided publishable API key and device identifier, then return a short-lived session token and visitor profile. Returns 201 on first-time creation and 200 on subsequent calls for the same device.
curl -X POST "https://api.siteassist.io/v2/identity/init" \ -H "Content-Type: application/json" \ -d '{ "apiKey": "sa_pk_1234567890abcdef", "saVid": "device-abc-123" }'
{
"sessionToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"visitor": {
"object": "visitor",
"id": "c2a19f0e-8bcb-4a67-9e4a-8f7b8f5d8d2a",
"type": "anonymous",
"externalId": null,
"name": null,
"avatarUrl": null
}
}
{
"sessionToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"visitor": {
"object": "visitor",
"id": "9d1a7c9e-5b21-46f1-9c86-0a2b12345678",
"type": "anonymous",
"externalId": null,
"name": null,
"avatarUrl": null
}
}
{
"error": {
"message": "Invalid request body. Content is required.",
"code": "INVALID_REQUEST_BODY",
"details": {
"field": "content"
}
}
}
{
"error": {
"message": "Authentication required",
"code": "UNAUTHORIZED"
}
}
{
"error": {
"message": "A higher pricing plan is required to access this feature",
"code": "PAYMENT_REQUIRED",
"details": {
"currentPlan": "free",
"requiredPlan": "pro",
"feature": "advanced_ai_models"
}
}
}
{
"error": {
"message": "Access denied to this conversation",
"code": "FORBIDDEN"
}
}
{
"error": {
"message": "Conversation not found!",
"code": "CONVERSATION_NOT_FOUND",
"details": {
"conversationId": "123e4567-e89b-12d3-a456-426614174000"
}
}
}
{
"error": {
"message": "Resource already exists",
"code": "CONFLICT",
"details": {
"resource": "conversation",
"conflictingField": "id"
}
}
}
{
"error": {
"message": "Validation failed",
"code": "VALIDATION_ERROR",
"details": {
"field": "content",
"reason": "Content exceeds maximum length of 10000 characters"
}
}
}
{
"error": {
"message": "Rate limit exceeded. Please try again later.",
"code": "RATE_LIMIT_EXCEEDED",
"details": {
"retryAfter": 60
}
}
}
{
"error": {
"message": "An internal server error occurred",
"code": "INTERNAL_SERVER_ERROR"
}
}
{
"error": {
"message": "Service temporarily unavailable",
"code": "BAD_GATEWAY",
"details": {
"service": "ai_model_service"
}
}
}
{
"error": {
"message": "Service temporarily unavailable",
"code": "SERVICE_UNAVAILABLE",
"details": {
"retryAfter": 30
}
}
}
Get current visitor GET
Return the authenticated visitor associated with the provided bearer token. Useful for verifying session state and retrieving basic profile information.
Retrieve messages from a conversation GET
Retrieve messages from a conversation, ordered chronologically from oldest to newest. Supports pagination and filtering by role or status. Only the conversation owner can access their messages.