VisibleBase
Quickstart

Issue `user_token`

Give the product client a user-scoped credential that can call Base.

user_token must be issued by a trusted environment. Your backend uses AdminClient and asks Base for a token based on product_id + user_id.

import { AdminClient } from "@visiblebase/client";

const client = new AdminClient({
  base_url: "https://base.example.com",
  admin_secret_key: process.env.VISIBLEBASE_ADMIN_SECRET_KEY,
});

const product = await client.products.create({
  name: "Web App",
});

const user = await client.tokens.apply({
  product_id: product.product_id,
  user_id: "user_123",
  metadata: {
    plan: "pro",
  },
  ttl: "7d",
});

Return user.user_token and product.product_id to the product client.

What metadata is for

metadata carries business context such as plan or organization into hooks:

base.all().before(async (ctx) => {
  await quotaService.check({
    product_id: ctx.product.product_id,
    user_id: ctx.user.user_id,
    model: ctx.model.model_id,
  });
});

This is how multiple product clients share one auth and quota layer cleanly.

On this page