Switch Current Organization
curl --request PUT \
--url https://api.virtuoussoftware.com/api/Organization/Switch \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"organizationUserId": "12345"
}
'const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({organizationUserId: '12345'})
};
fetch('https://api.virtuoussoftware.com/api/Organization/Switch', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.virtuoussoftware.com/api/Organization/Switch"
payload = { "organizationUserId": "12345" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)using RestSharp;
var options = new RestClientOptions("https://api.virtuoussoftware.com/api/Organization/Switch");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("Authorization", "Bearer <token>");
request.AddJsonBody("{\n \"organizationUserId\": \"12345\"\n}", false);
var response = await client.PutAsync(request);
Console.WriteLine("{0}", response.Content);
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.virtuoussoftware.com/api/Organization/Switch",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'organizationUserId' => '12345'
]),
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.put("https://api.virtuoussoftware.com/api/Organization/Switch")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"organizationUserId\": \"12345\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.virtuoussoftware.com/api/Organization/Switch")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"organizationUserId\": \"12345\"\n}"
response = http.request(request)
puts response.read_bodyconst url = 'https://api.virtuoussoftware.com/api/Organization/Switch';
const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({organizationUserId: '12345'})
};
fetch(url, options)
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error(err));{
"message": "The request is invalid.",
"modelState": {
"switchOrganization.organizationUserId": [
"An error has occurred."
]
}
}{
"message": "Authorization has been denied for this request."
}"Switching organizations requires a signed-in user, not an API key."{
"message": "Rate limit exceeded. Try again later."
}Account and Permissions
Switch Current Organization
Changes the organization a signed-in user is working in. Send the integer organizationUserId of the target membership, which you can get from the List My Organizations endpoint. The switch updates the user’s saved current organization; it does not change the token used to make this call. Request or refresh a token from the /Token endpoint after switching to work in the new organization. API keys are bound to one organization and cannot switch. To identify the target by its public id instead, use the v2 Switch Current Organization endpoint.
PUT
/
api
/
Organization
/
Switch
Switch Current Organization
curl --request PUT \
--url https://api.virtuoussoftware.com/api/Organization/Switch \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"organizationUserId": "12345"
}
'const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({organizationUserId: '12345'})
};
fetch('https://api.virtuoussoftware.com/api/Organization/Switch', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.virtuoussoftware.com/api/Organization/Switch"
payload = { "organizationUserId": "12345" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)using RestSharp;
var options = new RestClientOptions("https://api.virtuoussoftware.com/api/Organization/Switch");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("Authorization", "Bearer <token>");
request.AddJsonBody("{\n \"organizationUserId\": \"12345\"\n}", false);
var response = await client.PutAsync(request);
Console.WriteLine("{0}", response.Content);
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.virtuoussoftware.com/api/Organization/Switch",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'organizationUserId' => '12345'
]),
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.put("https://api.virtuoussoftware.com/api/Organization/Switch")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"organizationUserId\": \"12345\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.virtuoussoftware.com/api/Organization/Switch")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"organizationUserId\": \"12345\"\n}"
response = http.request(request)
puts response.read_bodyconst url = 'https://api.virtuoussoftware.com/api/Organization/Switch';
const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({organizationUserId: '12345'})
};
fetch(url, options)
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error(err));{
"message": "The request is invalid.",
"modelState": {
"switchOrganization.organizationUserId": [
"An error has occurred."
]
}
}{
"message": "Authorization has been denied for this request."
}"Switching organizations requires a signed-in user, not an API key."{
"message": "Rate limit exceeded. Try again later."
}Authorizations
Response
The switch succeeded, or the target is already the current organization. The response has no body.
Was this page helpful?