Skip to main content
POST
/
auth
/
token
Get bearer token
curl --request POST \
  --url https://sandbox-api.polygon.technology/v0.10/auth/token \
  --header 'Content-Type: application/json' \
  --data '
{
  "apiKey": "sk_live_abc123...",
  "apiSecret": "opaque-bearer-secret..."
}
'
import requests

url = "https://sandbox-api.polygon.technology/v0.10/auth/token"

payload = {
"apiKey": "sk_live_abc123...",
"apiSecret": "opaque-bearer-secret..."
}
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({apiKey: 'sk_live_abc123...', apiSecret: 'opaque-bearer-secret...'})
};

fetch('https://sandbox-api.polygon.technology/v0.10/auth/token', 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://sandbox-api.polygon.technology/v0.10/auth/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([
'apiKey' => 'sk_live_abc123...',
'apiSecret' => 'opaque-bearer-secret...'
]),
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://sandbox-api.polygon.technology/v0.10/auth/token"

payload := strings.NewReader("{\n \"apiKey\": \"sk_live_abc123...\",\n \"apiSecret\": \"opaque-bearer-secret...\"\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://sandbox-api.polygon.technology/v0.10/auth/token")
.header("Content-Type", "application/json")
.body("{\n \"apiKey\": \"sk_live_abc123...\",\n \"apiSecret\": \"opaque-bearer-secret...\"\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://sandbox-api.polygon.technology/v0.10/auth/token")

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 \"apiKey\": \"sk_live_abc123...\",\n \"apiSecret\": \"opaque-bearer-secret...\"\n}"

response = http.request(request)
puts response.read_body
{
  "accessToken": "eyJhbGciOiJSUzI1NiIs...",
  "tokenType": "bearer",
  "expiresIn": 3600,
  "expiresAt": "2023-11-07T05:31:56Z"
}
{
"error": "Unauthorized",
"code": 1000,
"msg": "unauthorized access",
"status": 401,
"cause": "signature"
}
{
"error": "Unauthorized",
"code": 1000,
"msg": "unauthorized access",
"status": 401,
"cause": "signature"
}
{
"error": "Unauthorized",
"code": 1000,
"msg": "unauthorized access",
"status": 401,
"cause": "signature"
}
{
"error": "Unauthorized",
"code": 1000,
"msg": "unauthorized access",
"status": 401,
"cause": "signature"
}

Body

application/json
apiKey
string
required

Secret API key identifier. Prefix encodes (mode, env): sk_live_… / sk_sdbx_… on prod; non-prod envs add an env infix (sk_dev_sdbx_…, sk_stg_live_…, …). The matching apiSecret is shown once at key creation and stored only as an HMAC hash.

Example:

"sk_live_abc123..."

apiSecret
string
required

Opaque secret revealed once at key creation; not a typeid.

Example:

"opaque-bearer-secret..."

Response

Token issued

accessToken
string
required
Example:

"eyJhbGciOiJSUzI1NiIs..."

tokenType
enum<string>
required
Available options:
bearer
expiresIn
integer
required
Example:

3600

expiresAt
string<date-time>
required