Sahl AI Authentication API
Login
Endpoint: /users/login
Method: POST
Description: This endpoint allows users to authenticate and obtain an access token for further interactions with the Sahl AI APIs.
Request Body:
{
"username": "string",
"password": "string"
}
Parameters:
Name | Type | Required | Description |
---|---|---|---|
username | string | Yes | The user's username. |
password | string | Yes | The user's password. |
Response:
Success (200 OK)
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI1ZjFlYzQyMzQzYjRhNDNhOGM4ZDQzNmMiLCJpYXQiOjE2MjU2Nzg0MzAsImV4cCI6MTYyNTY4MjAzMH0.L0GyITVXU4xRbdCq5WbQmU7M4qm3GqG1Gy8yvx-c3-c"
}
Usage Example:
fetch('/users/login', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
username: 'myuser',
password: 'mypassword'
})
})
.then(response => response.json())
.then(data => {
// Store the token for future API calls
localStorage.setItem('authToken', data.token);
})
.catch(error => {
console.error('Error:', error);
});