> ## Documentation Index
> Fetch the complete documentation index at: https://figranium.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# CredentialsResource: Manage Baserow Credentials

> Manage Baserow output credentials with the Figranium JavaScript SDK. Create, update, delete, and browse databases and tables through a typed resource.

The `CredentialsResource` on `figranium.credentials` lets you manage output credentials for the Figranium platform. Currently, the only supported provider is Baserow. You can create credentials, update their name or configuration, delete them, and browse Baserow metadata such as databases and tables.

```ts theme={null}
import { Figranium } from "@figranium/sdk";

const figranium = new Figranium({ apiKey: process.env.FIGRANIUM_API_KEY! });
```

Every method accepts an optional final `RequestOptions` argument with `signal`, `timeoutMs`, and `headers`. See [Request options](/docs/sdk/js/request-options) for details.

## Methods

<AccordionGroup>
  <Accordion title="list">
    ```ts theme={null}
    list(options?: RequestOptions): Promise<Credential[]>
    ```

    Fetch all stored credentials. Returns an array of `Credential` objects.

    * **HTTP endpoint:** `GET /api/credentials`

    ```ts list-credentials.ts theme={null}
    const credentials = await figranium.credentials.list();
    console.log(credentials);
    // => [{ id: "cred_01", name: "Production Baserow", provider: "baserow", config: { baseUrl: "...", token: "..." } }]
    ```
  </Accordion>

  <Accordion title="create">
    ```ts theme={null}
    create(input: CredentialInput, options?: RequestOptions): Promise<Credential>
    ```

    Create a new credential. The `CredentialInput` shape requires a `name`, `provider` (currently only `"baserow"`), and a `config` object with `baseUrl` and `token`.

    * **HTTP endpoint:** `POST /api/credentials`

    ```ts create-credential.ts theme={null}
    const credential = await figranium.credentials.create({
      name: "Production Baserow",
      provider: "baserow",
      config: {
        baseUrl: "https://baserow.example.com",
        token: process.env.BASEROW_TOKEN!,
      },
    });

    console.log(credential.id);
    ```
  </Accordion>

  <Accordion title="update">
    ```ts theme={null}
    update(
      id: string,
      input: Partial<Pick<CredentialInput, "name" | "config">>,
      options?: RequestOptions
    ): Promise<Credential>
    ```

    Update an existing credential's name or configuration. Pass only the fields you want to change.

    * **HTTP endpoint:** `PUT /api/credentials/:id`

    ```ts update-credential.ts theme={null}
    const updated = await figranium.credentials.update(credential.id, {
      name: "Staging Baserow",
      config: {
        baseUrl: "https://staging.baserow.example.com",
        token: process.env.STAGING_BASEROW_TOKEN!,
      },
    });
    ```
  </Accordion>

  <Accordion title="delete">
    ```ts theme={null}
    delete(id: string, options?: RequestOptions): Promise<{ ok: boolean }>
    ```

    Remove a credential by ID. Returns an object with an `ok` field indicating success.

    * **HTTP endpoint:** `DELETE /api/credentials/:id`

    ```ts delete-credential.ts theme={null}
    const result = await figranium.credentials.delete(credential.id);
    console.log(result.ok);
    ```
  </Accordion>

  <Accordion title="baserowDatabases">
    ```ts theme={null}
    baserowDatabases(id: string, options?: RequestOptions): Promise<Array<{ id: string; name: string; workspaceName: string }>>
    ```

    List the Baserow databases accessible through a credential. Each entry includes the database `id`, `name`, and `workspaceName`.

    * **HTTP endpoint:** `GET /api/credentials/:id/proxy/baserow/databases`

    ```ts list-databases.ts theme={null}
    const databases = await figranium.credentials.baserowDatabases(credential.id);

    for (const db of databases) {
      console.log(`${db.name} (${db.workspaceName})`);
    }
    ```
  </Accordion>

  <Accordion title="baserowTables">
    ```ts theme={null}
    baserowTables(
      id: string,
      databaseId: string | number,
      options?: RequestOptions
    ): Promise<Array<{ id: string; name: string }>>
    ```

    List the tables inside a Baserow database. Pass the credential ID and the database ID (from `baserowDatabases`).

    * **HTTP endpoint:** `GET /api/credentials/:id/proxy/baserow/databases/:databaseId/tables`

    ```ts list-tables.ts theme={null}
    const tables = await figranium.credentials.baserowTables(credential.id, databases[0].id);

    for (const table of tables) {
      console.log(`${table.name} (id: ${table.id})`);
    }
    ```
  </Accordion>
</AccordionGroup>

## Full Baserow workflow

This example creates a credential, lists databases, and then lists tables for the first database:

```ts baserow-workflow.ts theme={null}
const credential = await figranium.credentials.create({
  name: "My Baserow",
  provider: "baserow",
  config: {
    baseUrl: "https://baserow.example.com",
    token: process.env.BASEROW_TOKEN!,
  },
});

const databases = await figranium.credentials.baserowDatabases(credential.id);
if (databases.length === 0) {
  console.log("No databases found");
} else {
  const tables = await figranium.credentials.baserowTables(credential.id, databases[0].id);
  console.log(tables);
}
```

## Types

### `Credential`

```ts theme={null}
interface Credential {
  id: string;
  name: string;
  provider: "baserow";
  config: { baseUrl: string; token: string };
}
```

### `CredentialInput`

```ts theme={null}
interface CredentialInput {
  name: string;
  provider: "baserow";
  config: { baseUrl: string; token: string };
}
```
