def invite(
body: MemberInvite,
*,
timeout: float | None = None,
) -> InviteResourceasync def invite(
body: MemberInvite,
*,
timeout: float | None = None,
) -> InviteResourceCreates a pending invite and emails it. This does not create a member, so the returned value is an InviteResource, not a MemberResource: the person becomes a member only when they accept, and until then they live in the invites namespace. Invites expire 3 days after they are sent.
roleId must be a role id from the roles namespace, the id field of a role and not its name. The owner role can never be handed out this way. The email is sent synchronously and the invite is rolled back if delivery fails, so a successful return means the provider accepted the message.
Seats are plan limited and pending invites count against the limit. Free and Dev workspaces allow 1 member in total, Team seats 15 and Enterprise has no seat limit, so on Free and Dev every invite fails with member.seat_limit until the workspace upgrades.
Example
from envless import envless
roles = envless.roles.list_all()
viewer = next(
(role for role in roles if role['systemKey'] == 'viewer'),
None,
)
if viewer:
invite = envless.members.invite(
{'email': 'dev@example.com', 'roleId': viewer['id']}
)
print(invite['id'], invite['status'], invite['expiresAt'])import asyncio
from envless import AsyncEnvless
async def main() -> None:
async with AsyncEnvless() as envless:
roles = await envless.roles.list_all()
viewer = next(
(role for role in roles if role['systemKey'] == 'viewer'),
None,
)
if viewer:
invite = await envless.members.invite(
{'email': 'dev@example.com', 'roleId': viewer['id']}
)
print(invite['id'], invite['status'], invite['expiresAt'])
asyncio.run(main())Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
body['email'] | str | Yes | Address to invite, normalised to lowercase by the API. |
body['roleId'] | str | Yes | Role id from the roles namespace to grant on acceptance. |
timeout | float | No | Seconds each attempt of this call may take, the response body included, before it raises EnvlessNetworkError with is_timeout set. Overrides the client's timeout for this call, and 0 turns the limit off. |
Returns
InviteResource with the invite id, email, status, role and expiresAt.
Worth knowing
- Inviting the key owner themselves is rejected outright (
member.self_invite). - A second invite to the same address fails with
invite.already_pending, and an address that already belongs to a member fails withmember.already_exists. - An unknown
roleIdcomes back asrole.not_found, and the owner role asrole.owner_not_assignable.
Required scopes
members:write
Underlying endpoint
POST /members
Request and response schema, every error code, and a live playground.
In TypeScript
envless.members.invite()
The same method in @goenvless/sdk, with the same request, retries and errors.