Choose the organization to act in
curl --request PUT \
--url https://app.trustivan.com/api/v1/me/active-org \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"organization_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
'import requests
url = "https://app.trustivan.com/api/v1/me/active-org"
payload = { "organization_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({organization_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a'})
};
fetch('https://app.trustivan.com/api/v1/me/active-org', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://app.trustivan.com/api/v1/me/active-org"
payload := strings.NewReader("{\n \"organization_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n}")
req, _ := http.NewRequest("PUT", 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))
}{
"organization": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"slug": "<string>",
"role": "owner",
"active": true
}
}{
"error": "<string>",
"code": "validation_failed",
"required_scope": "<string>",
"principal": "user"
}{
"error": "<string>",
"code": "validation_failed",
"required_scope": "<string>",
"principal": "user"
}Choose the organization to act in
From the next request on, every session the caller holds acts in this
organization, including NHI Security, which follows
GET /me/context (within its own context cache, at most 60 seconds).
The choice is stored on the user, so it survives a token refresh and
the next sign-in.
The organization must be one the caller belongs to. Any other ID
(another tenant’s, or one that does not exist) is the same 404, and
the refusal is recorded (organization.switch_refused) in the audit
trail of the organization the caller was acting in. A successful switch
is recorded (organization.switched) in the organization entered.
Human sessions only.
PUT
/
me
/
active-org
Choose the organization to act in
curl --request PUT \
--url https://app.trustivan.com/api/v1/me/active-org \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"organization_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
'import requests
url = "https://app.trustivan.com/api/v1/me/active-org"
payload = { "organization_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({organization_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a'})
};
fetch('https://app.trustivan.com/api/v1/me/active-org', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://app.trustivan.com/api/v1/me/active-org"
payload := strings.NewReader("{\n \"organization_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n}")
req, _ := http.NewRequest("PUT", 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))
}{
"organization": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"slug": "<string>",
"role": "owner",
"active": true
}
}{
"error": "<string>",
"code": "validation_failed",
"required_scope": "<string>",
"principal": "user"
}{
"error": "<string>",
"code": "validation_failed",
"required_scope": "<string>",
"principal": "user"
}