curl --request POST \
--url https://api.jtl-cloud.com/account/identity/act-as-user-token \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"userId": "<string>",
"tenantId": "<string>"
}
'import requests
url = "https://api.jtl-cloud.com/account/identity/act-as-user-token"
payload = {
"userId": "<string>",
"tenantId": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({userId: '<string>', tenantId: '<string>'})
};
fetch('https://api.jtl-cloud.com/account/identity/act-as-user-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://api.jtl-cloud.com/account/identity/act-as-user-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([
'userId' => '<string>',
'tenantId' => '<string>'
]),
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;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.jtl-cloud.com/account/identity/act-as-user-token"
payload := strings.NewReader("{\n \"userId\": \"<string>\",\n \"tenantId\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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://api.jtl-cloud.com/account/identity/act-as-user-token")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"userId\": \"<string>\",\n \"tenantId\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.jtl-cloud.com/account/identity/act-as-user-token")
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 \"userId\": \"<string>\",\n \"tenantId\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"accessToken": "<string>",
"refreshToken": "<string>",
"expiresIn": 123
}Mint an impersonation token for a user
Mints a token for the named user, scoped to the named tenant, on behalf of the calling app. The app authenticates with its own service-account token in the Authorization header; account-service is the exchange actor. The app must be installed for the tenant, have opted in to acting on behalf of a user, and the user must be a member of the tenant.
curl --request POST \
--url https://api.jtl-cloud.com/account/identity/act-as-user-token \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"userId": "<string>",
"tenantId": "<string>"
}
'import requests
url = "https://api.jtl-cloud.com/account/identity/act-as-user-token"
payload = {
"userId": "<string>",
"tenantId": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({userId: '<string>', tenantId: '<string>'})
};
fetch('https://api.jtl-cloud.com/account/identity/act-as-user-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://api.jtl-cloud.com/account/identity/act-as-user-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([
'userId' => '<string>',
'tenantId' => '<string>'
]),
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;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.jtl-cloud.com/account/identity/act-as-user-token"
payload := strings.NewReader("{\n \"userId\": \"<string>\",\n \"tenantId\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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://api.jtl-cloud.com/account/identity/act-as-user-token")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"userId\": \"<string>\",\n \"tenantId\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.jtl-cloud.com/account/identity/act-as-user-token")
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 \"userId\": \"<string>\",\n \"tenantId\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"accessToken": "<string>",
"refreshToken": "<string>",
"expiresIn": 123
}Body
Represents a request to mint an impersonation token for a user on behalf of the calling app. The app authenticates with its own service-account token in the Authorization header (identified by its urn:jtl:app_id claim); no user token is needed.
Gets or sets the Zitadel user id to impersonate (the subject of the minted token).
1Gets or sets the tenant to act in. The app must be installed for it and the user must be a member of it; the minted token is stamped with this tenant.
1Response
The user-subject access token, its refresh token and lifetime.
Represents the response for a minted on-behalf-of-user token.
Was this page helpful?