Setting up your account
Don't have credentials yet? Reach out to support@pleevi.ai!
Fetching an access token
To obtain an OAuth2 access token, you need to provide your client_id and client_secret.
Endpoint
POST /v1/identity/client-login
Request Headers
Authorization: Basic authentication header containing yourclient_id:client_secretbase64 encoded.
Request Parameters
The request must include the following parameters in the body using the application/x-www-form-urlencoded format with UTF-8 encoding:
grant_type(REQUIRED): Must be set to the valueclient_credentials.
Request Example
- cURL
- Python
- JavaScript
curl -X POST "https://api.pleevi.ai/v1/identity/client-login" \
-u your_client_id:your_client_secret \
-d "grant_type=client_credentials"
import requests
from requests.auth import HTTPBasicAuth
url = "https://api.pleevi.ai/v1/identity/client-login"
auth = HTTPBasicAuth("your_client_id", "your_client_secret")
data = {"grant_type": "client_credentials"}
response = requests.post(url, auth=auth, data=data)
print(response.json()) # Print the response
const axios = require("axios");
const url = "https://api.pleevi.ai/v1/identity/client-login";
const auth = {
username: "your_client_id",
password: "your_client_secret"
};
const data = new URLSearchParams({ grant_type: "client_credentials" });
axios.post(url, data, { auth })
.then(response => console.log(response.data))
.catch(error => console.error(error.response?.data || error.message));
Response
On successful authentication, the response will contain an OAuth2 access token.
{
"access_token": "your_access_token",
"type": "bearer",
"expires_in": 3600
}
Make sure to securely store your client_id and client_secret, and never expose them in your client-side code.
info
For any issues or further assistance, feel free to contact us at support@pleevi.ai.
Authenticating
All of our endpoints require this access_token. It should be included in the Authorization header in the Bearer format
For example, to retrieve a site (see later):
- cURL
- Python
- JavaScript
curl -X 'GET' \
'https://api.pleevi.ai/v1/sites/<SITE_ID>' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer <YOUR_ACCESS_TOKEN>'
import requests
url = "https://api.pleevi.ai/v1/sites/<SITE_ID>"
headers = {
"accept": "application/json",
"Content-Type": "application/json",
"Authorization": "Bearer <YOUR_ACCESS_TOKEN>"
}
response = requests.get(url, headers=headers)
print(response.json()) # Print the response
const axios = require("axios");
const url = "https://api.pleevi.ai/v1/sites/<SITE_ID>";
const headers = {
accept: "application/json",
"Content-Type": "application/json",
Authorization: "Bearer <YOUR_ACCESS_TOKEN>",
};
axios
.get(url, { headers })
.then((response) => console.log(response.data))
.catch((error) => console.error(error.response?.data || error.message));