Close
API DOCUMENTATION

Login API

Table of Contents

Login API

 

Description

This API endpoint is used to retrieve the access token using the email and password provided by Hozint.

 

The access token expires after 5 minutes. Use the Refresh Token API to obtain a new access token. The refresh token is valid for 30 minutes.

 

Endpoint

POST /api/login/

 

No URL parameters are required.

 

Request

 curl -X ‘POST’ \

  ‘https://admin.hozint.ai/api/login/’ \

  -H ‘accept: application/json’ \

  -H ‘Content-Type: application/json’ \

  -H ‘X-CSRFTOKEN: YOUR_CSRF_TOKEN’ \

  -d ‘{

  “email”: “user@example.com”,

  “password”: “your_password”

}’

 

Data Returned by API

  • Email Address
  • Access Token
  • Refresh Token

 

How to query the  API 

Add the email address and the password of the user in the request body.

Note: You need to use the Login API and get authorized before accessing other APIs.

 

Logout API

 

Description

This endpoint allows a user to log out by invalidating the provided refresh token.

 

Endpoint

POST /api/logout/

 

Request

curl -X ‘POST’ \

  ‘https://admin.hozint.ai/api/logout/’ \

  -H ‘accept: application/json’ \

  -H ‘Authorization: Bearer YOUR_ACCESS_TOKEN’ \

  -H ‘Content-Type: application/json’ \

  -H ‘X-CSRFTOKEN: YOUR_CSRF_TOKEN’ \

  -d ‘{

  “refresh”: “YOUR_REFRESH_TOKEN”

}’

 

Data Returned by Login API

When the logout is successful “Logout Successful!” message is displayed.

If an invalid token is provided this message will be displayed “Token is invalid or expired”.

 

How to query the  Login API 

Provide the refresh token in the request body and execute it which will invalidate the refresh token.

 

Refresh Token API

 

Description

This API endpoint refreshes an access token using a refresh token. The response contains a new access token and a new refresh token.

 

Endpoint

Post/api/token/refresh/

 

Request

curl -X ‘POST’ \

  ‘https://admin.hozint.ai/api/token/refresh/’ \

  -H ‘accept: application/json’ \

  -H ‘Content-Type: application/json’ \

  -H ‘X-CSRFTOKEN: <YOUR_CSRF_TOKEN>’ \

  -d ‘{

  “refresh”: “<YOUR_REFRESH_TOKEN>”

}’

 

Data Returned by API

  • Access Token

The new access token.

It is a JSON Web Token (JWT) used to authenticate API requests.

  • Refresh Token

The new refresh token.

It is a JWT used to obtain new access tokens without requiring re-authentication.

 

How to query API 

Pass the refresh token in the request body and obtain the new access and refresh tokens.