Accounts
Accounts are the core of Basejump. They allow you to manage users, teams, billing and permissions for your app. By default, Basejump enables both personal and team accounts.
Team vs personal accounts
Basejump supports personal accounts, team accounts, or a combination of the two.
- Personal accounts: Owned by a single user, and can only be accessed by that user.
- Team accounts: Supports inviting team members with various permission levels to access the account.
If you opt into both personal and team accounts, your app will operate similar to sites like Github. When a user signs up, a personal account will be created for them. They'll then have the ability to create team accounts as well.
The account model
Not all endpoints return all account data - particularly around billing as that can require additinoal calls to third parties to verify. Below is a breakdown of fields you can expect to get back when interacting with accounts.
Properties
- Name
account_id
- Type
- uuid
- Description
Unique identifier for the account.
- Name
account_role
- Type
- string
- Description
The current user's role within the account. Typically
member
orowner
.
- Name
is_primary_owner
- Type
- boolean
- Description
Tells you if the current user is the primary owner of the account.
- Name
name
- Type
- string
- Description
The name of the account.
- Name
slug
- Type
- string
- Description
Unique slug for the account. Useful for things like subdomains or paths.
- Name
personal_account
- Type
- boolean
- Description
Indicates if the account is a personal account.
- Name
created_at
- Type
- timestamp
- Description
Timestamp of when the account was created.
- Name
updated_at
- Type
- timestamp
- Description
Timestamp of when the account was last updated.
- Name
billing_status
- Type
- string
- Description
The current billing status of the account. One of
trialing
,active
,canceled
,incomplete
,incomplete_expired
,past_due
,unpaid
- Name
metadata
- Type
- json
- Description
Any additional metadata you've added to the account. There are two metadata fields on the accounts table.
public_metadata
andprivate_metadata
. This field returns public metadata. Private is never returned unless you have the service role.
List all accounts
Returns a list of all accounts an authenticated user is a member of. This includes both personal and team accounts.
Request
curl -G https://YOUR_SUPABASE/rest/v1/rpc/get_accounts \
-X POST \
-H "Authorization: Bearer SUPABASE_AUTH_TOKEN" \
-H "apikey: SUPABASE_ANON_KEY" \
-H "Content-Type: application/json"
Response
[
{
"account_id": "uuid",
"account_role": "member",
"is_primary_owner": true,
"name": "Team name",
"slug": "team-slug",
"personal_account": true,
"created_at": "timestamp",
"updated_at": "timestamp",
},
...
]
Create an account
Allows any authenticated user to create a new team account. This endpoint will fail if you've disabled team accounts in your Basejump settings. The user who creates the account will automatically be set as the primary owner.
Optional attributes
- Name
slug
- Type
- string
- Description
Unique slug representing the team. This is not required by default, but can be made required for your setup.
- Name
name
- Type
- string
- Description
Display name of the account
Request
curl https://YOUR_SUPABASE/rest/v1/rpc/create_account \
-X POST \
-H "Authorization: Bearer SUPABASE_AUTH_TOKEN" \
-H "apikey: SUPABASE_ANON_KEY" \
-H "Content-Type: application/json" \
-d '{"name": "Team name", "slug": "team-slug"}'
Response
{
"account_id": "uuid",
"account_role": "owner",
"is_primary_owner": true,
"name": "Your Team",
"slug": "your-team",
"personal_account": false,
"billing_status": "active",
"created_at": "timestamp",
"updated_at": "timestamp",
"metadata": {
"your_field": "your_value"
}
}
Retrieve an account
Allows you to retrieve an account by its account ID.
Required attributes
- Name
account_id
- Type
- uuid
- Description
Unique UUID for the account you're trying to lookup
Request
curl https://YOUR_SUPABASE/rest/v1/rpc/get_account \
-X POST \
-H "Authorization: Bearer SUPABASE_AUTH_TOKEN" \
-H "apikey: SUPABASE_ANON_KEY" \
-H "Content-Type: application/json" \
-d '{"account_id": "uuid"}'
Response
{
"account_id": "uuid",
"account_role": "owner",
"is_primary_owner": true,
"name": "Your Team",
"slug": "your-team",
"personal_account": false,
"billing_enabled": true,
"billing_status": "active",
"created_at": "timestamp",
"updated_at": "timestamp",
"metadata": {
"your_field": "your_value"
}
}
Retrieve personal account
Allows you to retrieve the personal account for the current user
Request
curl https://YOUR_SUPABASE/rest/v1/rpc/get_personal_account \
-X POST \
-H "Authorization: Bearer SUPABASE_AUTH_TOKEN" \
-H "apikey: SUPABASE_ANON_KEY" \
-H "Content-Type: application/json" \
Response
{
"account_id": "uuid",
"account_role": "owner",
"is_primary_owner": true,
"name": "Your Team",
"slug": "your-team",
"personal_account": true,
"billing_enabled": true,
"billing_status": "active",
"created_at": "timestamp",
"updated_at": "timestamp",
"metadata": {
"your_field": "your_value"
}
}
Lookup account by slug
Allows you to retrieve an account by its account slug.
Required attributes
- Name
slug
- Type
- string
- Description
Unique slug for the account you're trying to lookup
Request
curl https://YOUR_SUPABASE/rest/v1/rpc/get_account_by_slug \
-X POST \
-H "Authorization: Bearer SUPABASE_AUTH_TOKEN" \
-H "apikey: SUPABASE_ANON_KEY" \
-H "Content-Type: application/json" \
-d '{"slug": "your-team"}'
Response
{
"account_id": "uuid",
"account_role": "owner",
"is_primary_owner": true,
"name": "Your Team",
"slug": "your-team",
"personal_account": false,
"billing_enabled": true,
"billing_status": "active",
"created_at": "timestamp",
"updated_at": "timestamp",
"metadata": {
"your_field": "your_value"
}
}
Lookup account ID with slug
Allows you to retrieve an account ID with a slug. Mostly useful as a part of other queries.
Required attributes
- Name
slug
- Type
- string
- Description
Unique slug for the account you're trying to lookup
Request
curl https://YOUR_SUPABASE/rest/v1/rpc/get_account_id \
-X POST \
-H "Authorization: Bearer SUPABASE_AUTH_TOKEN" \
-H "apikey: SUPABASE_ANON_KEY" \
-H "Content-Type: application/json" \
-d '{"slug": "your-team"}'
Response
uuid
Update an account
Allows an account owner to update the account's name, slug, or metadata.
Required attributes
- Name
account_id
- Type
- uuid
- Description
Unique UUID for the account you're trying to update
Optional attributes
- Name
name
- Type
- string
- Description
The name of the team / account
- Name
slug
- Type
- string
- Description
A unique identifier for the team. Useful for things like subdomains.
- Name
public_metadata
- Type
- json
- Description
A JSON object containing any custom metadata you'd like to store on the account.
- Name
replace_metadata
- Type
- boolean
- Description
Default false. If true, this will replace the existing metadata object with the new one. If false, it will merge the new metadata with the existing metadata.
Request
curl https://YOUR_SUPABASE/rest/v1/rpc/update_account \
-X POST \
-H "Authorization: Bearer SUPABASE_AUTH_TOKEN" \
-H "apikey: SUPABASE_ANON_KEY" \
-H "Content-Type: application/json" \
-d '{"account_id": "uuid", "slug": "new-slug-1"}'
Response
{
"account_id": "uuid",
"account_role": "owner",
"is_primary_owner": true,
"name": "Your Team",
"slug": "your-team",
"personal_account": false,
"billing_status": "active",
"created_at": "timestamp",
"updated_at": "timestamp",
"metadata": {
"your_field": "your_value"
}
}