Managing databases from the API

Getting database information

Getting all of the databases in a workspace

To list all of the databases in a specific workspace:

GET /api/v1/workspaces/:workspace_name/databases

The response contains an array of database objects. For each database, the database object contains the following fields:

[
  {
    "id": "c50db909-6617-40d8-8c81-47de1b2e9806",
    "name": "CREATED_FROM_API",
    "created_at": "2025-03-20T08:44:41Z",
    "updated_at": "2025-03-20T08:44:42Z",
    "last_generated": "2025-03-20T08:44:42Z",
    "data_url": "http://fabricate.tonic.ai/rails/active_storage/blobs/redirect/eyJfcmFpbHMiOnsiZGF0YSI6IjFjMTg5MjNmLWZkZDAtNDRhZC04Y2U5LTE3Mjk5ZTBkNDEyNCIsInB1ciI6ImJsb2JfaWQifX0=--c9d77fa2a060bfd8c90813f960a901d7ea75c7c1/CREATED_FROM_API.zip",
    "workspace": {
      "id": "7edef645-87a5-46ef-9ea1-cce33cd9a543",
      "name": "Fabricate"
    },
  }
]

Where:

id

The UUID of the database.

name

The name of the database.

created_at

The date and time when the database was created.

updated_at

The date and time the database configuration was most recently updated.

last_generated

The date and time that the database data was most recently generated.

data_url

The URL to download the most recently generated data. Until the data is generated, this is null.

workspace

The identifier and name of the workspace that the database belongs to.

For an example, go to list-databases.js in the fabricate-api-examples GitHub repository.

Getting details for a specific database

To get the details for a specific database by name:

GET /api/v1/workspaces/:workspace_name/databases/:database_name

The response is a database object with the full details about the database configuration. For information about the database object, go to Data model.

For an example, go to get-database.js in the fabricate-api-examples GitHub repository.

Creating and managing database configuration

Creating or updating a database

To create a database or update an existing database:

POST /api/v1/workspaces/:workspace_name/databases

The request body is a database object with the database configuration.

The response contains a database object with the new or updated database configuration.

For information about the database object, go to Data model.

For an example, go to upsert-database.js in the fabricate-api-examples GitHub repository.

Deleting a database

To delete a database:

DELETE /api/v1/workspaces/:workspace_name/databases/:database_name

Returns an empty response body with a 200 status code.

For an example, go to delete-database.js in the fabricate-api-examples GitHub repository.

Adding static data to a table

In Fabricate, instead of generating the data for a table, you can provide static data in the form of a .csv file. For more information, go to Attaching static data to a table.

From the API, to update the .csv file content:

POST /api/v1/workspaces/:workspace_name/databases/:database_name/entities/:table_name/source

This method expects a multipart/form-data request body with a file parameter that contains the contents of the .csv file to use for the table data.

The response contains an empty response body with a 200 code.

For an example, go to update-source-data.js in the fabricate-api-examples GitHub repository.

Last updated