All authenticated endpoints require a bearer token in the
Authorization header:
Authorization: Bearer <your_access_token>
Creates a new OAuth access token for an existing application registration. This endpoint requires authentication and an available access token quota.
# cURL
curl -X POST 'https://apis.divsly.com/api/v1/create-token' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
-d '{
"registrationId": "abc123def456",
"email": "user@example.com"
}'
// JavaScript Fetch
const response = await fetch('https://apis.divsly.com/api/v1/create-token', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_ACCESS_TOKEN'
},
body: JSON.stringify({
registrationId: 'abc123def456',
email: 'user@example.com'
})
});
const data = await response.json();
// Node.js Axios
const axios = require('axios');
const response = await axios.post('https://apis.divsly.com/api/v1/create-token', {
registrationId: 'abc123def456',
email: 'user@example.com'
}, {
headers: {
'Authorization': 'Bearer YOUR_ACCESS_TOKEN'
}
});
// PHP
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://apis.divsly.com/api/v1/create-token",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'registrationId' => 'abc123def456',
'email' => 'user@example.com'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer YOUR_ACCESS_TOKEN",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
# Python (using requests)
import requests
import json
url = "https://apis.divsly.com/api/v1/create-token"
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_ACCESS_TOKEN'
}
payload = {
'registrationId': 'abc123def456',
'email': 'user@example.com'
}
response = requests.post(url, headers=headers, json=payload)
data = response.json()
{
"message": "Token created successfully",
"token": {
"id": "token123",
"accessToken": "oauth2_eyJhbG...xyz789",
"expiresAt": "2027-04-02T12:00:00.000Z"
},
"activeTokens": 3,
"maxAllowed": 10
}
{
"message": "Active token quota exceeded or registration not found"
}
{
"message": "OAuth registration not found"
}
{
"message": "Internal server error"
}