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:

  1. Fetch the user using the user list endpoint
  2. Include ?expand=memberships in the request URL
  3. 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:

  1. Fetch the company using the company list endpoint
  2. Include ?expand=memberships in the request URL
  3. 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"
    }
  ]
}