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
| Field | Rules |
|---|---|
appId | Required, UUID |
firstName | Optional, string |
lastName | Optional, string |
email | Optional; valid email. Required if phone and userId are absent |
phone | Optional; digits only, 11–12 characters. Required if email and userId are absent |
userId | Optional; 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
| Status | Meaning |
|---|---|
400 | Validation error or missing required fields (Missing required fields: ...) |
404 | Chat application does not exist or does not support the widget provider |