Skip to content

Initialize visitor session

POST
/identity/init
curl --request POST \
--url https://api.siteassist.io/v2/identity/init \
--header 'Content-Type: application/json' \
--data '{ "apiKey": "sa_pk_1234567890abcdef", "saVid": "device-abc-123" }'

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.

Media typeapplication/json

Publishable API key and device identifier used to create or rehydrate an anonymous visitor session.

object
apiKey
required
string
>= 1 characters
saVid
required
string
>= 1 characters <= 100 characters
Example
{
"apiKey": "sa_pk_1234567890abcdef",
"saVid": "device-abc-123"
}

Successfully initialized existing visitor session

Media typeapplication/json

The visitor session payload. Returned with 200 when the visitor already exists for the device.

object
sessionToken
required
string
visitor
required
object
object
string
default: visitor
Allowed values: visitor
id
required
string format: uuid
type
required
string
Allowed values: anonymous identified
externalId
required
string
nullable
name
required
string
nullable
avatarUrl
required
string
nullable
Example
{
"sessionToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"visitor": {
"object": "visitor",
"id": "c2a19f0e-8bcb-4a67-9e4a-8f7b8f5d8d2a",
"type": "anonymous",
"externalId": null,
"name": null,
"avatarUrl": null
}
}

Successfully created a new anonymous visitor and session

Media typeapplication/json

The visitor session payload. Returned with 201 when a new visitor was created for the device.

object
sessionToken
required
string
visitor
required
object
object
string
default: visitor
Allowed values: visitor
id
required
string format: uuid
type
required
string
Allowed values: anonymous identified
externalId
required
string
nullable
name
required
string
nullable
avatarUrl
required
string
nullable
Example
{
"sessionToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"visitor": {
"object": "visitor",
"id": "9d1a7c9e-5b21-46f1-9c86-0a2b12345678",
"type": "anonymous",
"externalId": null,
"name": null,
"avatarUrl": null
}
}

Bad Request - The request body or parameters are invalid

Media typeapplication/json
object
error
required
object
message
required

Human-readable error message describing what went wrong

string
code

Machine-readable error code for programmatic handling

string
details

Additional error details and context

object
key
additional properties
nullable
Example
{
"error": {
"message": "Invalid request body. Content is required.",
"code": "INVALID_REQUEST_BODY",
"details": {
"field": "content"
}
}
}

Unauthorized - Authentication token is missing or invalid

Media typeapplication/json
object
error
required
object
message
required

Human-readable error message describing what went wrong

string
code

Machine-readable error code for programmatic handling

string
details

Additional error details and context

object
key
additional properties
nullable
Example
{
"error": {
"message": "Authentication required",
"code": "UNAUTHORIZED"
}
}

Payment Required - A higher pricing plan is required to access the resource

Media typeapplication/json
object
error
required
object
message
required

Human-readable error message describing what went wrong

string
code

Machine-readable error code for programmatic handling

string
details

Additional error details and context

object
key
additional properties
nullable
Example
{
"error": {
"message": "A higher pricing plan is required to access this feature",
"code": "PAYMENT_REQUIRED",
"details": {
"currentPlan": "free",
"requiredPlan": "pro",
"feature": "advanced_ai_models"
}
}
}

Forbidden - Access denied to the requested resource

Media typeapplication/json
object
error
required
object
message
required

Human-readable error message describing what went wrong

string
code

Machine-readable error code for programmatic handling

string
details

Additional error details and context

object
key
additional properties
nullable
Example
{
"error": {
"message": "Access denied to this conversation",
"code": "FORBIDDEN"
}
}

Not Found - The requested resource was not found

Media typeapplication/json
object
error
required
object
message
required

Human-readable error message describing what went wrong

string
code

Machine-readable error code for programmatic handling

string
details

Additional error details and context

object
key
additional properties
nullable
Example
{
"error": {
"message": "Conversation not found!",
"code": "CONVERSATION_NOT_FOUND",
"details": {
"conversationId": "123e4567-e89b-12d3-a456-426614174000"
}
}
}

Conflict - The request could not be completed due to a conflict

Media typeapplication/json
object
error
required
object
message
required

Human-readable error message describing what went wrong

string
code

Machine-readable error code for programmatic handling

string
details

Additional error details and context

object
key
additional properties
nullable
Example
{
"error": {
"message": "Resource already exists",
"code": "CONFLICT",
"details": {
"resource": "conversation",
"conflictingField": "id"
}
}
}

Unprocessable Entity - The request was well-formed but contains semantic errors

Media typeapplication/json
object
error
required
object
message
required

Human-readable error message describing what went wrong

string
code

Machine-readable error code for programmatic handling

string
details

Additional error details and context

object
key
additional properties
nullable
Example
{
"error": {
"message": "Validation failed",
"code": "VALIDATION_ERROR",
"details": {
"field": "content",
"reason": "Content exceeds maximum length of 10000 characters"
}
}
}

Too Many Requests - Rate limit exceeded or quota reached

Media typeapplication/json
object
error
required
object
message
required

Human-readable error message describing what went wrong

string
code

Machine-readable error code for programmatic handling

string
details

Additional error details and context

object
key
additional properties
nullable
Example
{
"error": {
"message": "Rate limit exceeded. Please try again later.",
"code": "RATE_LIMIT_EXCEEDED",
"details": {
"retryAfter": 60
}
}
}

Internal Server Error - An unexpected error occurred

Media typeapplication/json
object
error
required
object
message
required

Human-readable error message describing what went wrong

string
code

Machine-readable error code for programmatic handling

string
details

Additional error details and context

object
key
additional properties
nullable
Example
{
"error": {
"message": "An internal server error occurred",
"code": "INTERNAL_SERVER_ERROR"
}
}

Bad Gateway - The server received an invalid response from an upstream server

Media typeapplication/json
object
error
required
object
message
required

Human-readable error message describing what went wrong

string
code

Machine-readable error code for programmatic handling

string
details

Additional error details and context

object
key
additional properties
nullable
Example
{
"error": {
"message": "Service temporarily unavailable",
"code": "BAD_GATEWAY",
"details": {
"service": "ai_model_service"
}
}
}

Service Unavailable - The server is temporarily unable to handle the request

Media typeapplication/json
object
error
required
object
message
required

Human-readable error message describing what went wrong

string
code

Machine-readable error code for programmatic handling

string
details

Additional error details and context

object
key
additional properties
nullable
Example
{
"error": {
"message": "Service temporarily unavailable",
"code": "SERVICE_UNAVAILABLE",
"details": {
"retryAfter": 30
}
}
}