Hey team, is it possible to set up some automation...
# ask-community
s
Hey team, is it possible to set up some automations that receives an email address and invite that email address to a prefect tenant? We are trying to build a self-service platform where stakeholders can request prefect accounts by themselves.
I was trying the GraphQL query below to get existing members, but not sure how the POST request for adding new members would look like
Copy code
{
  tenant(where: {id: {_eq: "xxxxxxxxxxxxxx"}}) {
    id
    name
    memberships {
      id
    }
  }
}
z
For querying for existing members, there's a special query:
Copy code
query {
  user_view_same_tenant {
    username
    first_name
    last_name
    email
    ... etc
  }
}
For adding new members, you can use the
create_membership_invitation
mutation
Copy code
mutation ($input: create_membership_invitation_input!) {
  create_membership_invitation(input: $input) {
    id
  }
}
where input is something like
Copy code
{
  "input": {
    "email": "<mailto:zach+1@prefect.io|zach+1@prefect.io>",
    "role": "USER",
    "role_id": <optionally pass the id of the role for the new user>,
    "tenant_id": <optional, inferred from api key>
  }
}
s
Thank you for the thorough reply. I’ll give it a shot!