- 22 Dec 2023
- 1 Minute to read
- Print
- DarkLight
Users - Invites
- Updated on 22 Dec 2023
- 1 Minute to read
- Print
- DarkLight
To add a new user to a tenant, a current user with the tenant administrator role must send an invite to the user. This applies both for existing users of another tenant or entirely new users. After being invited, users then can accept or decline invites. If a user accepts the invitation, the user is automatically added to the tenant.
Argument | Example | Description |
---|---|---|
created_by | "ben@cogniac.co" | (read only) The email of the user who sent the invite. |
invited_user_email | "jane@cogniac.co" | (read only) The email of the invites user. |
invitation_status | "pending", "accepted", "declined" | The status of the invite. can be "pending", "accepted", or "declined". |
tenant_name | "My Tenant" | (read only) The name of the tenant the invite is for. |
tenant_id | "d3s1hwewhrhr" | (read only) The id of the tenant the invite is for. |
resend_counter | 3 | (read only) The number of time the invitation was resent. |
last_resend_by | "jane@cogniac.co" | (read only) The email of the user who last resent the invite. |
last_resend_at | 1508432670 | (read only) The date the invite was the last resent. |
created_at | 1508432670 | (read only) The date the invite was created. |
accepted_at | 1508432670 | (read only) The date the invite was accepted. |
Get User Invites
The Get User Invites endpoint returns "pending" user invites.
GET /1/users/{user_id}/invites
Host: https://api.cogniac.io
Example: Get All Pending User Invites
curl -X GET https://api.cogniac.io/1/users/current/invites \
-H "Authorization: Bearer abcdefg.hijklmnop.qrstuvwxyz" \
-H "Content-Type: application/json" \
| json_pp
import 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/invites'
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}")
[
{
"last_resend_at": 1508432670,
"accepted_at": null,
"tenant_id": "d3s1hwewhrhr",
"created_at": 1508432670,
"last_resend_by": "jane@cogniac.co",
"created_by": "jane@cogniac.co",
"resend_counter": 3,
"tenant_name": "My Organization Tenant",
"invited_user_email": "test@cogniac.co",
"invitation_status": "pending"
}
]
Update User Invite
tenant_id
and invitation_status
are required fields. invitation_status
must equal "accepted" or "declined".
POST /1/users/{user_id}/invites
Host: https://api.cogniac.io
{
"invitation_status": "accepted",
"tenant_id": "d3s7hwewhttr"
}
{
"last_resend_at": 1508432670,
"accepted_at": 1508432670,
"tenant_id": "d3s7hwewhttr",
"created_at": 1508432670,
"last_resend_by": "jane@cogniac.co",
"created_by": "jane@cogniac.co",
"resend_counter": 3,
"tenant_name": "My Organization Tenant",
"invited_user_email": "test@cogniac.co",
"invitation_status": "accepted"
}