Skip to main content
The Accounts service provides methods for managing accounts, which are the top-level containers for users, collections, and data in SnackBase.

Overview

import { SnackBaseClient } from "@snackbase/sdk";

const client = new SnackBaseClient({
  baseUrl: "https://api.example.com",
});

// Access the accounts service
const accounts = client.accounts;

List Accounts

const result = await client.accounts.list();

console.log(result.items);
console.log(result.total);

Get an Account

const account = await client.accounts.get("account-id");

console.log(account.id);
console.log(account.name);

Create an Account

const account = await client.accounts.create({
  name: "Acme Corporation",
  slug: "acme-corp",
});
Account slugs must be unique across the entire SnackBase instance.

Update an Account

const updated = await client.accounts.update("account-id", {
  name: "Updated Account Name",
});

Delete an Account

await client.accounts.delete("account-id");
Deleting an account permanently deletes all users, collections, and records within it. This action cannot be undone.

Get Account Users

const users = await client.accounts.getUsers("account-id");

Account Object

interface Account {
  id: string;
  name: string;
  slug: string;
  description?: string;
  settings?: Record<string, any>;
  createdAt: string;
  updatedAt: string;
}

Next Steps