Get an access token
curl --request POST \
--url https://sandbox.apocor.ai/v1/oauth/token \
--header 'Content-Type: application/json' \
--data '
{
"client_id": "apocor_1a2b3c4d5e6f7g8h",
"client_secret": "apocor_sk_live_9i8u7y6t5r4e3w2q1..."
}
'import requests
url = "https://sandbox.apocor.ai/v1/oauth/token"
payload = {
"client_id": "apocor_1a2b3c4d5e6f7g8h",
"client_secret": "apocor_sk_live_9i8u7y6t5r4e3w2q1..."
}
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({
client_id: 'apocor_1a2b3c4d5e6f7g8h',
client_secret: 'apocor_sk_live_9i8u7y6t5r4e3w2q1...'
})
};
fetch('https://sandbox.apocor.ai/v1/oauth/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.apocor.ai/v1/oauth/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([
'client_id' => 'apocor_1a2b3c4d5e6f7g8h',
'client_secret' => 'apocor_sk_live_9i8u7y6t5r4e3w2q1...'
]),
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.apocor.ai/v1/oauth/token"
payload := strings.NewReader("{\n \"client_id\": \"apocor_1a2b3c4d5e6f7g8h\",\n \"client_secret\": \"apocor_sk_live_9i8u7y6t5r4e3w2q1...\"\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.apocor.ai/v1/oauth/token")
.header("Content-Type", "application/json")
.body("{\n \"client_id\": \"apocor_1a2b3c4d5e6f7g8h\",\n \"client_secret\": \"apocor_sk_live_9i8u7y6t5r4e3w2q1...\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://sandbox.apocor.ai/v1/oauth/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 \"client_id\": \"apocor_1a2b3c4d5e6f7g8h\",\n \"client_secret\": \"apocor_sk_live_9i8u7y6t5r4e3w2q1...\"\n}"
response = http.request(request)
puts response.read_body{
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"token_type": "Bearer",
"expires_in": 3600
}{
"error": {
"code": "INVALID_CLIENT",
"message": "Invalid client credentials"
}
}Authentication
Get an access token
Exchange an Apocor API key (client_id + client_secret) for a short-lived bearer access token. This is the only credential your services ever need — Apocor manages every upstream provider on your behalf. No Authorization header is required — this endpoint issues the token; it does not consume one.
POST
/
v1
/
oauth
/
token
Get an access token
curl --request POST \
--url https://sandbox.apocor.ai/v1/oauth/token \
--header 'Content-Type: application/json' \
--data '
{
"client_id": "apocor_1a2b3c4d5e6f7g8h",
"client_secret": "apocor_sk_live_9i8u7y6t5r4e3w2q1..."
}
'import requests
url = "https://sandbox.apocor.ai/v1/oauth/token"
payload = {
"client_id": "apocor_1a2b3c4d5e6f7g8h",
"client_secret": "apocor_sk_live_9i8u7y6t5r4e3w2q1..."
}
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({
client_id: 'apocor_1a2b3c4d5e6f7g8h',
client_secret: 'apocor_sk_live_9i8u7y6t5r4e3w2q1...'
})
};
fetch('https://sandbox.apocor.ai/v1/oauth/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.apocor.ai/v1/oauth/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([
'client_id' => 'apocor_1a2b3c4d5e6f7g8h',
'client_secret' => 'apocor_sk_live_9i8u7y6t5r4e3w2q1...'
]),
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.apocor.ai/v1/oauth/token"
payload := strings.NewReader("{\n \"client_id\": \"apocor_1a2b3c4d5e6f7g8h\",\n \"client_secret\": \"apocor_sk_live_9i8u7y6t5r4e3w2q1...\"\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.apocor.ai/v1/oauth/token")
.header("Content-Type", "application/json")
.body("{\n \"client_id\": \"apocor_1a2b3c4d5e6f7g8h\",\n \"client_secret\": \"apocor_sk_live_9i8u7y6t5r4e3w2q1...\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://sandbox.apocor.ai/v1/oauth/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 \"client_id\": \"apocor_1a2b3c4d5e6f7g8h\",\n \"client_secret\": \"apocor_sk_live_9i8u7y6t5r4e3w2q1...\"\n}"
response = http.request(request)
puts response.read_body{
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"token_type": "Bearer",
"expires_in": 3600
}{
"error": {
"code": "INVALID_CLIENT",
"message": "Invalid client credentials"
}
}⌘I