Skip to main content
POST
/
auth
/
token
Obtain JWT access token
curl --request POST \
  --url https://app.targeter.tech/api/auth/token \
  --header 'Content-Type: application/json' \
  --data '
{
  "api_key": "YOUR_ISSUED_PARTNER_KEY",
  "api_secret": "YOUR_ISSUED_PARTNER_SECRET"
}
'
import requests

url = "https://app.targeter.tech/api/auth/token"

payload = {
"api_key": "YOUR_ISSUED_PARTNER_KEY",
"api_secret": "YOUR_ISSUED_PARTNER_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({api_key: 'YOUR_ISSUED_PARTNER_KEY', api_secret: 'YOUR_ISSUED_PARTNER_SECRET'})
};

fetch('https://app.targeter.tech/api/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://app.targeter.tech/api/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([
'api_key' => 'YOUR_ISSUED_PARTNER_KEY',
'api_secret' => 'YOUR_ISSUED_PARTNER_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://app.targeter.tech/api/auth/token"

payload := strings.NewReader("{\n \"api_key\": \"YOUR_ISSUED_PARTNER_KEY\",\n \"api_secret\": \"YOUR_ISSUED_PARTNER_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://app.targeter.tech/api/auth/token")
.header("Content-Type", "application/json")
.body("{\n \"api_key\": \"YOUR_ISSUED_PARTNER_KEY\",\n \"api_secret\": \"YOUR_ISSUED_PARTNER_SECRET\"\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://app.targeter.tech/api/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 \"api_key\": \"YOUR_ISSUED_PARTNER_KEY\",\n \"api_secret\": \"YOUR_ISSUED_PARTNER_SECRET\"\n}"

response = http.request(request)
puts response.read_body
{
  "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6...",
  "token_type": "Bearer",
  "expires_in": 3600
}
{
"error": "Invalid request payload",
"details": [
{
"path": [
"api_key"
],
"message": "Invalid input: expected string, received undefined"
}
]
}
{
"error": "Invalid API credentials"
}
{
"error": "Missing required field",
"details": [
{
"message": "Reference ID is required",
"path": [
"source",
"reference_id"
]
}
]
}

Overview

The partner authentication endpoint allows trusted third-party partners to exchange their issued API credentials for a JWT (JSON Web Token) that can be used to authenticate subsequent API requests on behalf of their clients.

Request

Headers

  • Content-Type: application/json

Body Parameters

api_key
string
required
Your unique API key issued by Targeter for your approved partnership
api_secret
string
required
Your plain-text API secret issued by Targeter. Send the secret exactly as provided — not a bcrypt hash or other encoded form.

Example Request

curl -X POST "https://app.targeter.tech/api/auth/token" \
  -H "Content-Type: application/json" \
  -d '{
    "api_key": "YOUR_ISSUED_PARTNER_KEY",
    "api_secret": "YOUR_ISSUED_PARTNER_SECRET"
  }'
Use snake_case field names (api_key, api_secret). CamelCase names such as apiKey return 400.

Response

Success Response (200)

access_token
string
JWT token to be used in Authorization header for subsequent requests
token_type
string
Token type (always “Bearer”)
expires_in
integer
Token validity in seconds (3600 = 1 hour)

Example Response

{
    "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
    "token_type": "Bearer",
    "expires_in": 3600
}

Error Responses

400 - Invalid request payload

{
    "error": "Invalid request payload",
    "details": [
        {
            "path": ["api_key"],
            "message": "Invalid input: expected string, received undefined"
        }
    ]
}

401 - Invalid API credentials

{
    "error": "Invalid API credentials"
}

500 - Internal server error

{
    "error": "Internal server error"
}

Usage Notes

  • Token Expiration: JWT tokens expire after 1 hour for security
  • Refresh: You must obtain a new token when the current one expires
  • Security: Never expose your issued API secret in client-side code — these are for server-to-server communication only
  • Storage: Store tokens securely and refresh them before expiration
  • Credentials: Only use API credentials issued specifically to your approved partnership
  • Base URL: Your API base URL is provided with your credentials (e.g. https://app.targeter.tech/api)

Next Steps

Once you have your JWT token, you can use it to make authenticated requests on behalf of your clients:
curl -X POST "https://app.targeter.tech/api/campaign" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ ... }'

Body

application/json
api_key
string
required

API key issued for your partnership

Example:

"YOUR_ISSUED_PARTNER_KEY"

api_secret
string
required

Plain-text API secret issued for your partnership (not a bcrypt hash)

Example:

"YOUR_ISSUED_PARTNER_SECRET"

Response

Successfully authenticated

access_token
string
required

JWT for the Authorization header

Example:

"eyJhbGciOiJIUzI1NiIsInR5cCI6..."

token_type
string
required
Example:

"Bearer"

expires_in
integer
required

Token lifetime in seconds

Example:

3600