Create Token

POST /api/v1/create-token

Common errors include:

  • "400 Bad Request" if the active token quota is exceeded or the request is invalid.
  • "404 Not Found" if the OAuth registration does not exist.
  • "500 Internal Server Error" if token creation fails unexpectedly.

All authenticated endpoints require a bearer token in the Authorization header:

Authorization: Bearer <your_access_token>

Overview

Creates a new OAuth access token for an existing application registration. This endpoint requires authentication and an available access token quota.

Request

Method : Post
Content-Type : Application/json
Authentication : Bearer Token
Base URL : https://apis.divsly.com/api/v1

Request Body Schema

registrationId string Required
The ID of the OAuth registration
email string Optional
Email address to associate with the token
LANGUAGE
REQUEST
  # 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"
    }'
API REQUEST
 // 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();
                    
API REQUEST
 // 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'
   }
  });
API REQUEST
 // 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);

API REQUEST
 # 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()

RESPONSE
{
  "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"
}