Skip to main content

Access Control

Control table visibility and access permissions using the client.tables.setAccess() method. This operation allows you to make tables public or private, controlling who can access your data.

Method Signature

client.tables.setAccess(request: TableAccessRequest): Promise<ApiResponse<TableRecord>>

Parameters

TableAccessRequest

ParameterTypeRequiredDescription
table_namestringName of the table to modify
is_sharedbooleanWhether the table should be publicly accessible

Return Value

Returns the updated TableRecord with the new access settings:

interface TableRecord {
id: string; // Unique table identifier
name: string; // Table name
account_id: string; // Account identifier
internal_db_name: string; // Database name
db_id?: string; // Database UUID
resource_id?: string; // Resource identifier
description?: string; // Table description
type?: string; // Table type
parent_table_id?: string; // Parent table reference
is_deleted: boolean; // Deletion status
is_public: boolean; // Public visibility
created_by: string; // Creator identifier
created_at: string; // Creation timestamp
updated_at: string; // Last update timestamp
updated_by: string; // Last updater identifier
source?: "boltic" | "copilot"; // Creation source
account_status?: "active" | "suspended" | "deleted"; // Account status
}

Access Levels

Public Tables (is_shared: true)

  • Visibility: Accessible to anyone within account
  • Read Access: Anyone can view table structure and data
  • Write Access: Anyone can write data to the table
  • Use Cases: Public datasets, shared catalogs, open data

Private Tables (is_shared: false)

  • Visibility: Only accessible by table owner
  • Read Access: Restricted to table owner
  • Write Access: Restricted to table owner
  • Use Cases: Internal data, sensitive information, private projects

Examples

Make Table Public

import { createClient } from "@boltic/sdk";

const client = createClient("your-api-key");

const { data: table, error } = await client.tables.setAccess({
table_name: "product_catalog",
is_shared: true,
});

if (error) {
console.error("Failed to make table public:", error.message);
} else {
console.log(`Table "${table.name}" is now public`);
console.log(`Public access: ${table.is_public ? "Yes" : "No"}`);
}

Make Table Private

const { data: table, error } = await client.tables.setAccess({
table_name: "sensitive_data",
is_shared: false,
});

if (error) {
console.error("Failed to make table private:", error.message);
} else {
console.log(`Table "${table.name}" is now private`);
console.log(`Public access: ${table.is_public ? "Yes" : "No"}`);
}

Check Current Access Level

async function checkTableAccess(tableName: string) {
const { data: table, error } = await client.tables.findByName(tableName);

if (error) {
console.error("Table not found:", error.message);
return null;
}

console.log(`Table: ${table.name}`);
console.log(`Access Level: ${table.is_public ? "Public" : "Private"}`);
console.log(`Owner: ${table.created_by}`);
console.log(`Created: ${new Date(table.created_at).toLocaleDateString()}`);

return {
name: table.name,
isPublic: table.is_public,
owner: table.created_by,
createdAt: table.created_at,
};
}

// Usage
await checkTableAccess("my_table");

Best Practices

  1. Default to Private: Start with private tables and make public only when necessary
  2. Validate Sensitivity: Check for sensitive data before making tables public