Manage your organization's members programmatically. This guide covers how to invite new users, track pending invitations, allow users to accept invites, and manage roles using the API.
The Invitation Workflow
The process of adding a new user to an organization involves actions from both the organization administrator and the invited user.
sequenceDiagram
participant Admin
participant API
participant User
Admin->>API: POST /v1/organization/{id}/user/invite
API-->>User: Sends Invitation Email
User->>API: GET /v1/invitations
API-->>User: Returns pending invites
User->>API: POST /v1/invitations/{id}/accept
API-->>Admin: User added to organizationEnd-to-End Process
- 1
Send the invitation
As an organization admin, send an invite to a new user by providing their email address and intended role.
- 2
Track pending invites
Admins can monitor who hasn't responded yet by fetching the list of pending invitations for the organization.
- 3
User retrieves their invites
The invited user authenticates and retrieves a list of all their personal pending invitations across all organizations.
- 4
User accepts the invite
The user accepts a specific invitation using its unique ID, officially joining the organization.
API Endpoints Overview
Depending on your role, you will interact with different sets of endpoints.
Admin Privileges Required
Endpoints nested under /v1/organization/{organization_id}/* generally require the authenticated user to have an active admin role within that specific organization.
Organization Management (Admin)
Use these endpoints to manage the users and invitations within a specific organization.
| Action | Method | Endpoint | Description |
|---|---|---|---|
| Invite User | POST | /v1/organization/{organization_id}/user/invite | Sends an invitation to a user to join the organization. |
| List Pending | GET | /v1/organization/{organization_id}/user/pending | Returns all unanswered invitations for the organization. |
| List All Users | GET | /v1/organization/{organization_id}/user | Returns all users (both active and pending). |
| List Active Users | GET | /v1/organization/{organization_id}/user/active | Returns only users who have accepted their invites. |
| Update Role | PATCH | /v1/organization/{organization_id}/user/{user_id}/role | Changes an existing user's role (e.g., member to admin). |
| Remove User | DELETE | /v1/organization/{organization_id}/user/{user_id} | Removes a user or revokes a pending invitation. |
When building UI dashboards, use the /active endpoint to display current members, and the /pending endpoint to display a separate "Awaiting Response" list.
Personal Invitations (User)
Use these endpoints when acting on behalf of the invited user.
| Action | Method | Endpoint | Description |
|---|---|---|---|
| List My Invites | GET | /v1/invitations | Lists all pending invitations sent to the authenticated user. |
| Accept Invite | POST | /v1/invitations/{invitation_id}/accept | Accepts a specific invitation. |
Examples
Inviting a user
To invite a user, make a POST request to the organization invite endpoint. You will typically need to provide the user's email and their assigned role in the request body.
curl -X POST https://api.example.com/v1/organization/org_123abc/user/invite
-H "Authorization: Bearer $YOUR_API_TOKEN"
-H "Content-Type: application/json"
-d '{
"email": "jane.doe@example.com",
"role": "member"
}'Accepting an invitation
Once a user retrieves their invitation_id from the GET /v1/invitations endpoint, they can accept it:
curl -X POST https://api.example.com/v1/invitations/inv_987xyz/accept
-H "Authorization: Bearer $USER_API_TOKEN"
-H "Content-Type: application/json"Frequently Asked Questions
How do I cancel a pending invitation?
To revoke an invitation before the user accepts it, use the DELETE /v1/organization/{organization_id}/user/{user_id} endpoint. This will invalidate the invitation link.
Can a user belong to multiple organizations?
Yes. The GET /v1/invitations endpoint returns an array of invitations across all organizations that have invited the user's email address. They can accept multiple invitations and switch between organizations in your application.
What happens if I update a user's role while their invite is pending?
It is recommended to cancel the pending invitation and send a new one with the correct role. The PATCH role endpoint is designed for active users who have already joined the organization.