Users - Tenants
- 22 Dec 2023
 - 1 Minute to read
 
- Print
 - DarkLight
 
Users - Tenants
- Updated on 22 Dec 2023
 - 1 Minute to read
 
- Print
 - DarkLight
 
Article summary
Did you find this summary helpful?    
Thank you for your feedback!
This endpoint returns a list of all tenants the user has access to.
For more information on the Tenant object, see Tenants.
GET /1/users/{user_id}/tenants
Host: https://api.cogniac.ioExample: Retrieve a User's Tenants
curl -X GET https://api.cogniac.io/1/users/current/tenants \
-H "Authorization: Bearer abcdefg.hijklmnop.qrstuvwxyz" \
-H "Content-Type: application/json" \
| json_ppimport requests
import json
from pprint import pprint
url_prefix = 'https://api.cogniac.io'
api_version = "1"
token = ''  # add your token here
headers = {'Authorization': f'Bearer {token}',
           'Content-Type': 'application/json'}
url = f'{url_prefix}/{api_version}/users/current/tenants'
res = requests.get(url, headers=headers)
if res.status_code == 200:
    response_data = json.loads(res.content)
    pprint(response_data)
else:
    print(f"Error: {res.status_code}, {res.text},{res.headers}"){
  "tenants": [
    {
      "tenant_id": "pixdsp63lqc7", 
      "type": "orgtenant", 
      "name": "My Private Tenant"
    },
    {
      "tenant_id": "l9xdsp63rsc2", 
      "type": "orgtenant", 
      "name": "My Organization Tenant"
    }
  ]
}Was this article helpful?