Exchange external JWT for MLM tokens
curl --request POST \
--url https://app.mlm-platform.com/api/v1/auth/exchange \
--header 'Content-Type: application/json' \
--header 'x-tenant-api-key: <api-key>' \
--data '
{
"externalJwt": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...",
"provider": "open-ears"
}
'import requests
url = "https://app.mlm-platform.com/api/v1/auth/exchange"
payload = {
"externalJwt": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...",
"provider": "open-ears"
}
headers = {
"x-tenant-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-tenant-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({externalJwt: 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...', provider: 'open-ears'})
};
fetch('https://app.mlm-platform.com/api/v1/auth/exchange', 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.mlm-platform.com/api/v1/auth/exchange",
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([
'externalJwt' => 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...',
'provider' => 'open-ears'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-tenant-api-key: <api-key>"
],
]);
$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.mlm-platform.com/api/v1/auth/exchange"
payload := strings.NewReader("{\n \"externalJwt\": \"eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...\",\n \"provider\": \"open-ears\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-tenant-api-key", "<api-key>")
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.mlm-platform.com/api/v1/auth/exchange")
.header("x-tenant-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"externalJwt\": \"eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...\",\n \"provider\": \"open-ears\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.mlm-platform.com/api/v1/auth/exchange")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-tenant-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"externalJwt\": \"eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...\",\n \"provider\": \"open-ears\"\n}"
response = http.request(request)
puts response.read_body{
"accessToken": "<string>",
"refreshToken": "<string>",
"tokenType": "Bearer",
"expiresIn": 123,
"scope": "<string>",
"mlmUserId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"isNewUser": true
}{
"error": "Validation failed",
"code": "VALIDATION_ERROR",
"details": {
"email": "Invalid email format"
}
}{
"error": "Token validation failed",
"code": "TOKEN_EXCHANGE_FAILED"
}{
"error": "User is banned",
"code": "USER_BANNED"
}Federated Auth
Exchange external JWT for MLM tokens
Exchanges a JWT from an external identity provider (e.g., Open Ears) for MLM platform access and refresh tokens. If the user doesn’t exist and auto-creation is enabled for the provider, a new user is created.
POST
/
api
/
v1
/
auth
/
exchange
Exchange external JWT for MLM tokens
curl --request POST \
--url https://app.mlm-platform.com/api/v1/auth/exchange \
--header 'Content-Type: application/json' \
--header 'x-tenant-api-key: <api-key>' \
--data '
{
"externalJwt": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...",
"provider": "open-ears"
}
'import requests
url = "https://app.mlm-platform.com/api/v1/auth/exchange"
payload = {
"externalJwt": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...",
"provider": "open-ears"
}
headers = {
"x-tenant-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-tenant-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({externalJwt: 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...', provider: 'open-ears'})
};
fetch('https://app.mlm-platform.com/api/v1/auth/exchange', 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.mlm-platform.com/api/v1/auth/exchange",
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([
'externalJwt' => 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...',
'provider' => 'open-ears'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-tenant-api-key: <api-key>"
],
]);
$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.mlm-platform.com/api/v1/auth/exchange"
payload := strings.NewReader("{\n \"externalJwt\": \"eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...\",\n \"provider\": \"open-ears\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-tenant-api-key", "<api-key>")
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.mlm-platform.com/api/v1/auth/exchange")
.header("x-tenant-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"externalJwt\": \"eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...\",\n \"provider\": \"open-ears\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.mlm-platform.com/api/v1/auth/exchange")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-tenant-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"externalJwt\": \"eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...\",\n \"provider\": \"open-ears\"\n}"
response = http.request(request)
puts response.read_body{
"accessToken": "<string>",
"refreshToken": "<string>",
"tokenType": "Bearer",
"expiresIn": 123,
"scope": "<string>",
"mlmUserId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"isNewUser": true
}{
"error": "Validation failed",
"code": "VALIDATION_ERROR",
"details": {
"email": "Invalid email format"
}
}{
"error": "Token validation failed",
"code": "TOKEN_EXCHANGE_FAILED"
}{
"error": "User is banned",
"code": "USER_BANNED"
}Authorizations
Tenant API key for authentication
Body
application/json
⌘I