Global event types
Event types that every managed user or a subset of managed users will have automatically
If you want that all of your managed users or a subset of managed users have the same event type setup automatically then follow along.
Prerequisites
- You need to have an oAuth client setup, since we’ll need the client id and client secret from the oauth client to be included in the api requests. Here is the link for the oauth client setup guide
- You need to have an ESSENTIALS plan or higher
Steps
Overview:
- Create a team.
- Create managed team event type with
assignAllTeamMembers: true
- it is an event type that you can define once and that will be used as a template to create event types for managed users. We call it the parent managed event type and the event types created for managed users based on it are called children managed event types. - Create managed users.
- For each managed user you want to have this event type, create a membership within the team.
Then the managed user will have the event type created. Once you have steps 1 and 2 setup then you simply need to add the managed user to the team and the user will have the event type created. If you then update the parent managed event type then it will automatically update all of the children managed event types.
Create a team by sending a POST request to the create a team endpoint. Example request body:
You will need to note down the “id” of the created team from the response:
Now we will create the managed team event type. Make a POST request to the create an organization team event type endpoint. Example request body:
Note that "schedulingType"
has to be set to "managed"
and "assignAllTeamMembers"
has to be set to true
. "assignAllTeamMembers"
being true
means that once a managed user has membership in the team this event type will be automatically created for the managed user.
You will need to note down the “id” of the created event type from the response:
The team created in the previous step has no members, so we need to create managed users and later their membership in the team. To create a managed user here is the create managed user endpoint. Example request body:
After creating managed user you have to save its “id”, “accessToken” and “refreshToken” in your database and note down the “id” for the next step. Here is response:
Now we will create a membership for this user within the team by making a POST request to the create membership endpoint. Example body:
Note that "accepted"
has to be "true"
and "userId"
has to be the id of the managed user created in the previous step.
Now, if we fetch managed user event types using the get event types endpoint and given our example
query params eventSlug
and username
(?eventSlug=coffee-tasting&username=charlie-clxyyy21o0003sbk7yw5z6tzg-gmail-com
), the response will contain the “global” event type:
Note, that when we create the “parent” managed event type in step 2 it has an id 3672
but the child managed event type belonging to managed user has 3673
, so they are separate entities
and the “child” managed event type is the same as having individually created event type just for that managed user.
Now, if we update the “parent” managed team event type via update an organization team event type endpoint, and fetch
again managed user event type using the get event types endpoint with same query parameters eventSlug
and username
as above,
the child managed event type will also be updated automatically.
Now with this setup you can:
- Each time you create a new managed user simply create membership within the team and have the event type created automatically.
- If you want that already existing managed users have the event type created, you have to create team and then membership within the team just like we saw above.
- You can create a team called “global” where you add all managed users so all managed users have the same event type or a subset of managed users have the same event type belonging to “subset-team” if you want to have a subset of managed users have the same event type.