Create a new Team

Follow this guide to create API functionality to create a team on your product using the Cofor.io Product SDK for Node.js.

To create a new team for your product, the user needs to first login or signup to Cofor.io through the OAuth screen. Send the user to https://cofor.io/oauth/create on the frontend with the query parameters: product_id, redirect_uri and optionally, state. (Use state to send information about product plan, etc.).

🚧

Email Verification

The user will be required to verify their email if creating a new account.

If the user is authenticated, a team creation token will be generated that allows the product to create a team on behalf of the user. Call the following function to create a new team using the team creation token provided.

const { team, membership, confirm_url } = await cio.NewTeam(TEAM_CREATION_TOKEN, team_name, scopes=[], data={}, subscribe_to_plans=[], trial_days=0);

The subscribe_to_plans argument is a list of Stripe pricing plans with quantities (optional) to subscribe the team to. The schema is as follows:

[{
    plan_id: String, // Stripe pricing plan id
    quantity: Number // Optional quantity
}, ... ]

Pass the name of the team into team_name and the number of days of trial to give the user in trial_days.

After creating the team, the user needs to confirm that they would like to login to the team. This is how a team login is created for the user. Send the user to https://cofor.io/oauth/confirm with the following URL query parameters:

  • product - product ID
  • user - user ID of the owner (returned by cio.NewTeam)
  • membership - membership ID of the owner (returned by cio.NewTeam)
  • redirect_uri - URL to return the user to after successful login or in case of error
  • state - (Optional) any provided value which will be returned to the redirect URI as is.

The confirmation URL (minus redirect_uri which you can add yourself) is returned as well.

📘

The Team Object

The returned team object is an instantiated Team class object with various built-in functions to manage your team and memberships. See Full SDK Reference for more information.