/teams/{teamId}/membershipsAlcance teams.writeInvite a new member to join your team. Provide an ID for existing users, or invite unregistered users using an email or phone number. If initiated from a Client SDK, Owbase will send an email or sms with a link to join the team to the invited user, and an account will be created for them if one doesn’t exist. If initiated from a Server SDK, the new member will be added automatically to the team.
You only need to provide one of a user ID, email, or phone number. Owbase will prioritize accepting the user ID > email > phone number if you provide more than one of these parameters.
Use the url parameter to redirect the user from the invitation email to your app. After the user is redirected, use the Update Team Membership Status endpoint to allow the user to accept the invitation to the team.
Please note that to avoid a Redirect Attack Owbase will accept the only redirect URLs under the domains you have added as a platform on the Owbase Console.
Parámetros
Sección titulada «Parámetros»teamId string obligatorio
Team ID.
roles string[] obligatorio
Array of strings. Use this param to set the user roles in the team. A role can be any string. Learn more about roles and permissions. Maximum of 100 roles are allowed, each 81 characters long.
email string
Email of the new team member.
userId string
ID of the user to be added to a team.
phone string
Phone number. Format this number with a leading ‘+’ and a country code, e.g., +16175551212.
url string
URL to redirect the user back to your app from the invitation email. This parameter is not required when an API key is supplied. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an open redirect attack against your project API.
name string
Name of the new team member. Max length: 128 chars.
membershipId string
Membership ID. Choose a custom ID or generate a random ID with ID.unique(). Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can’t start with a special char. Max length is 36 chars.
Acceso: clave de API con el alcance teams.write o sesión del usuario (vale lo que permitan los permisos del recurso).
Respuestas
Sección titulada «Respuestas»201Éxito400Parámetro inválido o faltante401Sin sesión, sin permiso en el recurso o clave sin el alcance404Recurso de la ruta no encontrado429Límite de peticionesTodo error llega como JSON con code, type y message: consulta Errores.
import { Client, Teams } from '@owbase/web';
const client = new Client() .setEndpoint('https://cloud.owbase.dev/v1') // Your API Endpoint .setProject('<YOUR_PROJECT_ID>'); // Your project ID
const teams = new Teams(client);
const result = await teams.createMembership({ teamId: '<TEAM_ID>', roles: ['editor'], userId: '<USER_ID>', // optional phone: '+12065550100', // optional url: 'https://example.com', // optional name: '<NAME>', // optional membershipId: '<MEMBERSHIP_ID>', // optional});
console.log(result);import { Client, Teams } from '@owbase/node';
const client = new Client() .setEndpoint('https://cloud.owbase.dev/v1') // Your API Endpoint .setProject('<YOUR_PROJECT_ID>') // Your project ID .setSession(''); // The user session to authenticate with
const teams = new Teams(client);
const result = await teams.createMembership({ teamId: '<TEAM_ID>', roles: ['editor'], userId: '<USER_ID>', // optional phone: '+12065550100', // optional url: 'https://example.com', // optional name: '<NAME>', // optional membershipId: '<MEMBERSHIP_ID>', // optional});curl -X POST "https://cloud.owbase.dev/v1/teams/<TEAM_ID>/memberships" \ -H "X-Owbase-Project: <PROJECT_ID>" \ -H "X-Owbase-Key: $OWBASE_API_KEY" \ -H "Content-Type: application/json" \ -d '{"roles":[]}'{ "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", "$updatedAt": "2020-10-15T06:38:00.000+00:00", "userId": "5e5ea5c16897e", "userName": "John Doe", "userPhone": "+1 555 555 5555", "teamId": "5e5ea5c16897e", "teamName": "VIP", "invited": "2020-10-15T06:38:00.000+00:00", "joined": "2020-10-15T06:38:00.000+00:00", "confirm": false, "mfa": false, "userAccessedAt": "2020-10-15T06:38:00.000+00:00", "roles": [ "owner" ]}Las descripciones de esta página vienen de la especificación de la API del servidor (licencia BSD-3-Clause), en inglés, y los ejemplos vienen del generador de SDKs (licencia MIT). Los avisos completos están en el archivo NOTICE de los paquetes @owbase/web y @owbase/node.