Skip to main content
POST
https://{tenantDomain}/api/v2
/
token-exchange-profiles
Go
package example

import (
    context "context"

    management "github.com/auth0/go-auth0/management/management"
    client "github.com/auth0/go-auth0/management/management/client"
    option "github.com/auth0/go-auth0/management/management/option"
)

func do() {
    client := client.NewClient(
        option.WithToken(
            "<token>",
        ),
    )
    request := &management.CreateTokenExchangeProfileRequestContent{
        Name: "name",
        SubjectTokenType: "subject_token_type",
        ActionId: "action_id",
        Type: management.TokenExchangeProfileTypeEnum(
            "custom_authentication",
        ),
    }
    client.TokenExchangeProfiles.Create(
        context.TODO(),
        request,
    )
}
import { ManagementClient } from "auth0";

async function main() {
const client = new ManagementClient({
token: "<token>",
});
await client.tokenExchangeProfiles.create({
name: "name",
subjectTokenType: "subject_token_type",
actionId: "action_id",
type: "custom_authentication",
});
}
main();
import { ManagementClient } from "auth0";

async function main() {
const client = new ManagementClient({
token: "<token>",
});
await client.tokenExchangeProfiles.create({
name: "name",
subjectTokenType: "subject_token_type",
actionId: "action_id",
type: "custom_authentication",
});
}
main();
curl --request POST \
--url https://{tenantDomain}/api/v2/token-exchange-profiles \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Token Exchange Profile 1",
"subject_token_type": "<string>",
"action_id": "<string>",
"type": "custom_authentication"
}
'
import requests

url = "https://{tenantDomain}/api/v2/token-exchange-profiles"

payload = {
"name": "Token Exchange Profile 1",
"subject_token_type": "<string>",
"action_id": "<string>",
"type": "custom_authentication"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}

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

print(response.text)
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://{tenantDomain}/api/v2/token-exchange-profiles",
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([
'name' => 'Token Exchange Profile 1',
'subject_token_type' => '<string>',
'action_id' => '<string>',
'type' => 'custom_authentication'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);

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

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
HttpResponse<String> response = Unirest.post("https://{tenantDomain}/api/v2/token-exchange-profiles")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Token Exchange Profile 1\",\n \"subject_token_type\": \"<string>\",\n \"action_id\": \"<string>\",\n \"type\": \"custom_authentication\"\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://{tenantDomain}/api/v2/token-exchange-profiles")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"Token Exchange Profile 1\",\n \"subject_token_type\": \"<string>\",\n \"action_id\": \"<string>\",\n \"type\": \"custom_authentication\"\n}"

response = http.request(request)
puts response.read_body
{
  "id": "<string>",
  "name": "Token Exchange Profile 1",
  "subject_token_type": "<string>",
  "action_id": "<string>",
  "type": "custom_authentication",
  "created_at": "2024-01-01T00:00:00.000Z",
  "updated_at": "2024-01-01T00:00:00.000Z"
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

name
string
default:Token Exchange Profile 1
required

Friendly name of this profile.

Required string length: 3 - 50
subject_token_type
string<url>
required

Subject token type for this profile. When receiving a token exchange request on the Authentication API, the corresponding token exchange profile with a matching subject_token_type will be executed. This must be a URI.

Required string length: 8 - 100
action_id
string
required

The ID of the Custom Token Exchange action to execute for this profile, in order to validate the subject_token. The action must use the custom-token-exchange trigger.

Required string length: 1 - 36
type
enum<string>
required

The type of the profile, which controls how the profile will be executed when receiving a token exchange request.

Available options:
custom_authentication
Required string length: 1 - 21

Response

Token exchange profile successfully created.

id
string<token-exchange-profile-id>

The unique ID of the token exchange profile.

name
string
default:Token Exchange Profile 1

Friendly name of this profile.

Required string length: 3 - 50
subject_token_type
string<url>

Subject token type for this profile. When receiving a token exchange request on the Authentication API, the corresponding token exchange profile with a matching subject_token_type will be executed. This must be a URI.

Required string length: 8 - 100
action_id
string

The ID of the Custom Token Exchange action to execute for this profile, in order to validate the subject_token. The action must use the custom-token-exchange trigger.

Required string length: 1 - 36
type
enum<string>

The type of the profile, which controls how the profile will be executed when receiving a token exchange request.

Available options:
custom_authentication
Required string length: 1 - 21
created_at
string<date-time>
default:2024-01-01T00:00:00.000Z

The time when this profile was created.

updated_at
string<date-time>
default:2024-01-01T00:00:00.000Z

The time when this profile was updated.