Skip to main content
POST
/
v1.0
/
OAuth2
/
tokens
json
{
  "AccountKey": "DID-1234567ab-1a2b-3cd4-...-...........",
  "AccountSecret": "abcdeABCdef...",
  "ApiEndpoint": "https://api.telegent.com/v1.0/numbers/provision"
}
curl -X POST https://api.telegent.com/v1.0/oauth2/tokens \
-H 'Content-Type: application/json' \
-d '{
"AccountKey": "DID-1234567ab-1a2b-3cd4-...-...........",
"AccountSecret": "abcdeABCdef...",
"ApiEndpoint": "https://api.telegent.com/v1.0/numbers/provision"
}'
import requests

url = "https://api.telegent.com/v1.0/OAuth2/tokens"

payload = {
"AccountKey": "DID-1234567ab-1a2b-3cd4-...-...........",
"AccountSecret": "abcdeABCdef...",
"ApiEndpoint": "https://api.telegent.com/v1.0/numbers/provision"
}
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
AccountKey: 'DID-1234567ab-1a2b-3cd4-...-...........',
AccountSecret: 'abcdeABCdef...',
ApiEndpoint: 'https://api.telegent.com/v1.0/numbers/provision'
})
};

fetch('https://api.telegent.com/v1.0/OAuth2/tokens', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.telegent.com/v1.0/OAuth2/tokens",
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([
'AccountKey' => 'DID-1234567ab-1a2b-3cd4-...-...........',
'AccountSecret' => 'abcdeABCdef...',
'ApiEndpoint' => 'https://api.telegent.com/v1.0/numbers/provision'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://api.telegent.com/v1.0/OAuth2/tokens"

payload := strings.NewReader("{\n \"AccountKey\": \"DID-1234567ab-1a2b-3cd4-...-...........\",\n \"AccountSecret\": \"abcdeABCdef...\",\n \"ApiEndpoint\": \"https://api.telegent.com/v1.0/numbers/provision\"\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.telegent.com/v1.0/OAuth2/tokens")
.header("Content-Type", "application/json")
.body("{\n \"AccountKey\": \"DID-1234567ab-1a2b-3cd4-...-...........\",\n \"AccountSecret\": \"abcdeABCdef...\",\n \"ApiEndpoint\": \"https://api.telegent.com/v1.0/numbers/provision\"\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.telegent.com/v1.0/OAuth2/tokens")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"AccountKey\": \"DID-1234567ab-1a2b-3cd4-...-...........\",\n \"AccountSecret\": \"abcdeABCdef...\",\n \"ApiEndpoint\": \"https://api.telegent.com/v1.0/numbers/provision\"\n}"

response = http.request(request)
puts response.read_body
{
  "token": "abcdeghijklmnopqrstuvwxyz...................",
  "successful": true,
  "tokenExpiry": "05/02/2025 06:36:13 PM"
}
{
"StatusCode": 123,
"Message": "<string>"
}
{
"StatusCode": 123,
"Message": "<string>"
}
{
"StatusCode": 123,
"Message": "<string>"
}
{
"StatusCode": 123,
"Message": "<string>"
}
{
"StatusCode": 123,
"Message": "<string>"
}
{
"StatusCode": 123,
"Message": "<string>"
}
{
"StatusCode": 123,
"Message": "<string>"
}
{
"StatusCode": 123,
"Message": "<string>"
}
{
"StatusCode": 123,
"Message": "<string>"
}
{
"StatusCode": 123,
"Message": "<string>"
}

Body

application/json
AccountKey
string
required

Your account key (e.g., DID-1234567ab-1a2b-3cd4-...-...........)

Example:

"DID-1234567ab-1a2b-3cd4-...-..........."

AccountSecret
string
required

Your account secret key

Example:

"abcdeABCdef..."

ApiEndpoint
string<uri>

The specific API endpoint URL this token will be scoped to. Each token is scoped to a single endpoint for security.

Example:

"https://api.telegent.com/v1.0/numbers/provision"

Response

Success — returns the Bearer token and expiry timestamp

The response is of type object.