Skip to main content

Visitor Registration

POST /register

Registers or updates a visitor and returns a JWT (accessToken) for the chat session. JWT is not required.

Request

POST /register HTTP/1.1
Host: widget-api.chatbot.aithinks.net
Content-Type: application/json
{
"appId": "550e8400-e29b-41d4-a716-446655440000",
"firstName": "Ali",
"lastName": "Yılmaz",
"email": "ali@example.com",
"phone": "905551112233",
"userId": "external-user-123"
}
const { accessToken } = await fetch(`${BASE_URL}/register`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
appId: APP_ID,
firstName: 'Ali',
lastName: 'Yılmaz',
email: 'ali@example.com',
}),
}).then((r) => r.json());

Body fields

FieldRules
appIdRequired, UUID
firstNameOptional, string
lastNameOptional, string
emailOptional; valid email. Required if phone and userId are absent
phoneOptional; digits only, 11–12 characters. Required if email and userId are absent
userIdOptional; external user ID. Required if email and phone are absent

For identity, at least one of email, phone, or userId must be sent.

Fields listed in requiredFields from Widget Settings must also be present in the body; otherwise the request is rejected.

Successful response

{
"accessToken": "<jwt>"
}

Use this token for Message History, Send Message, and the Realtime messages connection.

Errors

StatusMeaning
400Validation error or missing required fields (Missing required fields: ...)
404Chat application does not exist or does not support the widget provider