curl https://api.usertour.io/v1/users/usr_123456789?expand=memberships \
-H 'Authorization: Bearer ak_123456789' \
-H 'Content-Type: application/json'
{
"id": "usr_123456789",
"object": "user",
"attributes": {
"name": "John Doe",
"email": "john@example.com"
},
"memberships": [
{
"id": "mem_123456789",
"object": "membership",
"company_id": "comp_123456789",
"role": "admin",
"created_at": "2024-03-20T08:30:00.000Z"
}
]
}
Company Memberships
List memberships
Retrieve company memberships by expanding the memberships field of a user or company object. Direct listing of memberships is not supported.
GET
/
v1
/
company-memberships
curl https://api.usertour.io/v1/users/usr_123456789?expand=memberships \
-H 'Authorization: Bearer ak_123456789' \
-H 'Content-Type: application/json'
{
"id": "usr_123456789",
"object": "user",
"attributes": {
"name": "John Doe",
"email": "john@example.com"
},
"memberships": [
{
"id": "mem_123456789",
"object": "membership",
"company_id": "comp_123456789",
"role": "admin",
"created_at": "2024-03-20T08:30:00.000Z"
}
]
}
Company memberships are accessed through their parent objects (users or companies) using the expansion feature. This design ensures proper data relationships and access control.
Retrieving Memberships
Through Users
To get a user’s memberships:- Fetch the user using the user list endpoint
- Include
?expand=membershipsin the request URL - The response will include the expanded memberships array
curl https://api.usertour.io/v1/users/usr_123456789?expand=memberships \
-H 'Authorization: Bearer ak_123456789' \
-H 'Content-Type: application/json'
Through Companies
To get a company’s memberships:- Fetch the company using the company list endpoint
- Include
?expand=membershipsin the request URL - The response will include the expanded memberships array
curl https://api.usertour.io/v1/companies/comp_123456789?expand=memberships \
-H 'Authorization: Bearer ak_123456789' \
-H 'Content-Type: application/json'
Response
The expanded memberships will be included in the response as an array of membership objects.{
"id": "usr_123456789",
"object": "user",
"attributes": {
"name": "John Doe",
"email": "john@example.com"
},
"memberships": [
{
"id": "mem_123456789",
"object": "membership",
"company_id": "comp_123456789",
"role": "admin",
"created_at": "2024-03-20T08:30:00.000Z"
}
]
}