Invitations
Invitations are how you can invite users to your account. They can be generated for single-use or multiple use for 24 hours.
The invitations model
Invitations are good for 24 hours and have a pretty basic structure.
Properties
- Name
account_role
- Type
- string
- Description
The role that the accepting user will receive within the account. Typically
member
orowner
.
- Name
created_at
- Type
- timestamp
- Description
Invitations expire after 24 hours by default, so this will tell you how much longer you have left.
- Name
invitation_type
- Type
- string
- Description
The type of invitation. One of
24_hour
orone_time
. One time invitations expire as soon as they're used once and are valid for up to 24 hours. 24 hour invitations can be used multiple times for 24 hours.
- Name
name
- Type
- string
- Description
The name of the account the invitation is good for. Used for showing users before they accept the invitation.
- Name
active
- Type
- boolean
- Description
Whether or not the invitation is still active. Once an invitation has been claimed or expires, looking it up will show it as not valid.
List all invitations
Returns a list of all active invitations on a given account. Once an invitation has been claimed or expires, it will no longer be returned.
Required attributes
- Name
account_id
- Type
- uuid
- Description
Unique UUID for the account you're trying to lookup
Optional attributes
- Name
results_limit
- Type
- integer
- Description
Limit the number of results returned. Default is 50.
- Name
results_offset
- Type
- integer
- Description
Offset the results returned. Default is 0.
Request
curl -G https://YOUR_SUPABASE/rest/v1/rpc/get_account_invitations \
-X POST \
-H "Authorization: Bearer SUPABASE_AUTH_TOKEN" \
-H "apikey: SUPABASE_ANON_KEY" \
-H "Content-Type: application/json"
-d '{"account_id": "uuid"}'
Response
[
{
"account_role": "member",
"created_at": "timestamp",
"invitation_type": "24_hour",
"invitation_id": "uuid"
},
...
]
Create an invitation
Create a new invitation for an account with a given role. This will return a unique token that can be used to lookup the invitation later. Users then send this token along with an accept URL to the user they're inviting.
Required attributes
- Name
account_id
- Type
- uuid
- Description
Unique UUID for the account you're creating an invitation to
- Name
account_role
- Type
- string
- Description
The role that the accepting user will receive within the account. Typically
member
orowner
.
- Name
invitation_type
- Type
- string
- Description
The type of invitation. One of
24_hour
orone_time
. One time invitations expire as soon as they're used once and are valid for up to 24 hours. 24 hour invitations can be used multiple times for 24 hours.
Request
curl -G https://YOUR_SUPABASE/rest/v1/rpc/create_invitation \
-X POST \
-H "Authorization: Bearer SUPABASE_AUTH_TOKEN" \
-H "apikey: SUPABASE_ANON_KEY" \
-H "Content-Type: application/json"
-d '{"account_id": "uuid", "account_role": "member", "invitation_type": "one_time"}'
Response
{
"token": "your-user-invitation-token"
}
Lookup an invitation
Lookup a single invitation. Used on invitation accept pages to let the user know what account they've been invited to.
Required attributes
- Name
lookup_invitation_token
- Type
- string
- Description
Unique token for the invitation you're trying to lookup
Request
curl -G https://YOUR_SUPABASE/rest/v1/rpc/lookup_invitation \
-X POST \
-H "Authorization: Bearer SUPABASE_AUTH_TOKEN" \
-H "apikey: SUPABASE_ANON_KEY" \
-H "Content-Type: application/json"
-d '{"lookup_invitation_token": "string"}'
Response
{
"name": "Your Team",
"active": true
}
Accept an invitation
Accept an invitation using the given account token. If valid, will add the user to the account and return the account ID for navigation.
Required attributes
- Name
lookup_invitation_token
- Type
- string
- Description
Unique token for the invitation you're trying to lookup
Request
curl -G https://YOUR_SUPABASE/rest/v1/rpc/accept_invitation \
-X POST \
-H "Authorization: Bearer SUPABASE_AUTH_TOKEN" \
-H "apikey: SUPABASE_ANON_KEY" \
-H "Content-Type: application/json"
-d '{"lookup_invitation_token": "string"}'
Response
{
"account_id": "uuid",
"slug": "your-team",
"account_role": "member"
}
Delete an invitation
Allows any owner of the account to delete an active invitation before it gets accepted.
Required attributes
- Name
invitation_id
- Type
- uuid
- Description
Unique ID for the invitation you want to delete. You get this from the get_account_invitations endpoint.
Request
curl -G https://YOUR_SUPABASE/rest/v1/rpc/delete_invitation \
-X POST \
-H "Authorization: Bearer SUPABASE_AUTH_TOKEN" \
-H "apikey: SUPABASE_ANON_KEY" \
-H "Content-Type: application/json"
-d '{"invitation_id": "uuid"}'
Response
No response