Fabricate API
Fabricate provides a RESTful API for generating data. The API is available at https://fabricate.mockaroo.com/api/v1.
Examples
You can find examples of how to use the Fabricate API in fabricate-api-examples on GitHub.
Authentication
All requests to the Fabricate API must include an Authorization header with the value:
Bearer <your_api_key>
Get all databases
To list all of the databases in a specific workspace:
GET /api/v1/workspaces/:workspace_name/databases
Returns
Returns an array of objects like
[
{
// The UUID of the database.
"id": "c50db909-6617-40d8-8c81-47de1b2e9806",
// The name of the database.
"name": "CREATED_FROM_API",
// The date and time the database was created.
"created_at": "2025-03-20T08:44:41Z",
// The date and time the database was last updated.
"updated_at": "2025-03-20T08:44:42Z",
// The date and time the data was last generated.
"last_generated": "2025-03-20T08:44:42Z",
// The URL to download the last generated dataset. This will be null until the data has been generated.
"data_url": "http://fabricate.mockaroo.com/rails/active_storage/blobs/redirect/eyJfcmFpbHMiOnsiZGF0YSI6IjFjMTg5MjNmLWZkZDAtNDRhZC04Y2U5LTE3Mjk5ZTBkNDEyNCIsInB1ciI6ImJsb2JfaWQifX0=--c9d77fa2a060bfd8c90813f960a901d7ea75c7c1/CREATED_FROM_API.zip",
// The workspace that the database belongs to.
"workspace": {
"id": "7edef645-87a5-46ef-9ea1-cce33cd9a543",
"name": "Fabricate"
},
}
]
Example
See list-databases.js in the fabricate-api-examples repository on GitHub for an example.
Get a database by name
The get the details for a specific database by name:
GET /api/v1/workspaces/:workspace_name/databases/:database_name
Returns
See Database Attributes below for the structure of the response.
Example
See get-database.js in the fabricate-api-examples repository on GitHub for an example.
Create or update a database
To create a new database or update an existing database:
POST /api/v1/workspaces/:workspace_name/databases
Request Body
This method expects a JSON object as described in the Database Attributes section below.
Returns
See Database Attributes below for the structure of the response.
Example
See upsert-database.js in the fabricate-api-examples repository on GitHub for an example.
Update the Source Data for a Static Table
Fabricate allows you to create static tables that are backed by a CSV file by clicking "Import Data..." in the UI. You can update the source data for a static table using the API:
POST /api/v1/workspaces/:workspace_name/databases/:database_name/entities/:table_name/source
Request Body
This method expects a multipart/form-data request body with a "file" parameter containing the contents of the CSV file to use as the source data.
Returns
An empty response body with a 200 status code.
Example
See update-source-data.js in the fabricate-api-examples repository on GitHub for an example.
Delete 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.
Example
See delete-database.js in the fabricate-api-examples repository on GitHub for an example.
Generate data
To generate data for an existing database:
POST /api/v1/generate_tasks
Request Body
This method expects a JSON object as the request body with the following parameters:
{
"workspace": string, // The name of the workspace in which the database resides.
"database": string, // The name of the database for which to generate data.
"format": string, // (Optional) The format of the generated data. Must be "sql", "sqlite", "postgres-optimized", "csv", or "jsonl". Should be omitted if a connection is provided.
"connection": string, // (Optional) The name of the target database connection into which generated data will be inserted. Should be omitted if a format is provided.
"entity": string, // (Optional) The name of a table to generate. When provided, only data for that table will
// be generated and data will be provided in plain text rather than a zip file. We call it "entity"
// rather than "table" because we plan to support non-relational databases in the future.
"overrides": object, // (Optional) Override database, entity, and field settings. See the section below for details.
}
Note that either the format or connection parameter must be provided, but not both. When the connection parameter is provided, the database and all tables must exist in the target database.
Overrides
The overrides parameter is a JSON object that allows you to override the settings for the database, entity, and fields. Here is the format:
{
"variables": { // Override database variables
"<variable_name>": string // The key is the variable name, value is the variable value to apply.
},
"entities": {
"<entity_name>": entity // see "Entity Attributes" below for details
}
}
Be sure to set the Content-Type request header to "application/json".
Returns
The response will be a JSON object representing a data generation task. For example:
{
"id": string, // The UUID of the task.
"database_id": string, // The UUID of the database for which the task was generated.
"completed": boolean, // true if completed, false if not.
"error": string, // If an error occurred, this will be a string describing the error.
"progress": number, // The progress of the task, as a number between 0 and 1.
"created_at": string, // The date and time the task was created.
"updated_at": string, // The date and time the task was last updated.
"data_url": string, // If the task is completed, this will be the URL to download the generated data.
// If the entity parameter was provided, the data will be provided in plain text, otherwise
// it will be provided as a zip file.
"content_type": string, // The content type of the generated data. You can also use the content_type field to determine
// if the file is a zip file.
}
Example
See generate-data.js in the fabricate-api-examples repository on GitHub for an example.
Daily Limits
Unlike the UI, the API enforces daily limits on the amount of data that can be generated. Each account has a daily limit on the number of rows that can be generated which is specified in the account's plan. The limit is based on the number of rows in the database's largest table. Note that the number of tables in the database does not affect the limit, only the size of the largest table.
Plan | Daily Row Limit of Largest Table |
---|---|
Free | 1000 |
Starter | 1,000,000 |
For example, if you have the Starter plan and you generate data for a database whose largest table has 100,000 rows, you can generate data for that database 10 times before you hit the daily limit for the account. Or, if the largest table has 1,000 rows, you can generate data for that database 1,000 times before you hit the daily limit for the account.
Get the status of a data generation task
To check the status of a data generation task:
GET /api/v1/generate_tasks/:id
Parameters
Name | Type | Description |
---|---|---|
id | string | The UUID of the data generation task to get |
Returns
The response will be a JSON object in the same format as the response from the POST /api/v1/generate_tasks endpoint.
Loading the generated data into your database
The download_url field in the response from GET /api/v1/generate_tasks/:id will contain a URL to download the generated data. Depending on the format of the data, you can load it into your database using the appropriate method:
Postgres
The data is provided as a zip file. Unzip it and run the following command to load the data into your database:
psql -U <username> -d <database> -f path/to/dir/load.sql
Data Model
The API methods above reference the following data model:
Database Attributes
Each database object can contain the following attributes:
{
"id": uuid, // The UUID of the database.
"name": "my_store", // The name of the database.
"created_at": datetime, // The date and time the database was created.
"updated_at": datetime, // The date and time the database was last updated.
"last_generated": datetime, // The date and time the data was last generated.
"data_url": string, // once data has been generated (see below), download it from this url
"platform": string, // The type of the target database.
"variables": { // The default variable values assigned to the database.
"<variable_name>": string
},
"entities": entity[] // see "Entity Attributes" below for details
"workspace": { // The workspace that the database belongs to. You do not need to provide this when creating or updating a database. The workspace is determined by the workspace name in the request path.
"id": uuid,
"name": string
}
}
Entity Attributes
Each entity object can contain the following attributes:
{
"name": string, // The name of the entity.
"records": string, // Use "exact" to generate an exact number of rows. Use "unique" to generate one row for every unique value of a field in this entity.
"unique_records_for": string, // The name of the field that determines the number of unique rows to generate for this entity. Only applies when records is set to "unique".
"record_count": string, // An expression that evaluates to the number of rows to generate for this entity. Only takes for entities whose row count is not determined by a foreign key relationship. Note that this is ignored if records is set "unique" or the the entity has one or more fields that use the Foreign Key generator with a distribution set to something other than "none".
"view": boolean, // If true, the entity will be generated as a view.
"sql": string, // If the entity is a view, this is the SQL to use to generate the view, otherwise it is ignored.
"is_static": boolean, // true if the entity is backed by a static CSV file, false otherwise
"source": { // will be present if the entity is backed by a static CSV file or has an attached CSV file.
"data": string, // the raw data from the CSV file
"filename": string // the name of the CSV file
},
"constraints": constraint[], // see "Constraints Attributes" below for details
"fields": field[] // see "Field Attributes" below for details. For views, this is ignored.
}
Constraints Attributes
Each constraint object can contain the following attributes:
{
"constraint_type": "unique" | "not-equal", // The type of constraint.
"fields": string[] // The names of the fields that the constraint applies to.
}
Field Attributes
Each field object can contain the following attributes:
{
// The following settings apply to all generators
"seed": string, // The seed for the field. When provided, the data in this field will be the same each time the database is generated.
"percent_null": integer, // The "Percent Null" setting in the UI.
"virtual": boolean, // The "Hide this column when exporting" setting in the UI.
"group_key": string, // The "Group Key" setting in the UI.
"postprocessing_sql": string, // The "Postprocessing SQL" setting in the UI.
"data_type": string, // The "<database_type> Type" setting in the UI.
"index": boolean, // The "Index this column" setting in the UI.
// The following settings apply to the Number, Lorem Ipsum, Datetime, and Foreign Key generators
"min": integer, // The "Minimum" setting in the UI.
"max": integer, // The "Maximum" setting in the UI.
"decimals": integer, // The "Decimals" setting in the UI.
"mean": string, // The "Mean" setting in the UI.
"std_dev": string, // The "Standard Deviation" setting in the UI.
"rate": string, // The "Rate" setting in the UI.
"success_probability": string, // The "Success Probability" setting in the UI.
"distribution": string, // The "Distribution" setting in the UI. Must be "autoincrement", "binomial", "exponential", "fixed", "from_column", "none", "geometric", "normal", "poisson", or "uniform". "fixed" and "none" are only valid for the Foreign Key generator. When using the Foreign Key generator, the distribution sets the cardinality of the foreign key relationship and determines the row count of this entity unless distribution is set to "none".
// The following apply to the Number generator:
"curve_type": string, // The "Curve Type" setting in the UI. Must be "linear", "exponential", "logarithmic", or "from_column".
"curve_type_field": string, // The name of the column that contains the curve type when curve_type is "from_column"
"volatility": string, // The "Volatility" setting in the UI.
"volatility_type": string, // The "Volatility Type" setting in the UI. Must be "fixed" or "from_column".
"volatility_field": string, // The name of the column that contains the volatility when volatility_type is "from_column"
// The following settings apply to the Datetime generator
"start_date": string, // The "Start" setting in the UI.
"end_date": string, // The "End" setting in the UI.
"date_only": boolean, // If true, the generated values will only include the date, not the time.
"date_type": string, // The "Type" setting in the UI. Must be "absolute", "relative", or "series". When set to "relative", use the min and max settings to control the range of dates. When set to "series", use the time_range_start_hour, time_range_end_hour, and date_relative_to_field settings to control the range of dates.
"date_operator": string, // Used only when date_type is "relative". Value must be "before" or "after".
"date_unit": string, // Used only when date_type is "relative" or "series". Value must be one of "milliseconds", "seconds", "minutes", "hours", "days", "weeks", "months" or "years".
"time_range_start_hour": string, // Used only when date_type is "series". The start hour of the time range.
"time_range_end_hour": string, // Used only when date_type is "series". The end hour of the time range.
"date_only_weekdays": boolean, // Used only when date_type is "series". If true, the generated dates will be on weekdays only.
// The following apply to Number and Datetime geberators:
"start_field": string, // When using Datetime - series, or Number - series, this is the column to use as the start of the series. When using Datetime - relative, this is the column to use as the relative date.
"end_field": string, // When using Datetime - series, or Number - series, this is the column to use as the end of the series.
// The following settings apply to the Constant generator
"constant_value": any, // The "Value" setting in the UI.
// The following settings apply to the Regular Expression generator
"regex": string, // The "Pattern" setting in the UI.
// The following settings apply to the Lorem Ipsum generator
"lorem_ipsum_unit": string, // The "Generate" setting in the UI. Must be one of: "words", "sentences", or "paragraphs".
// The following settings apply to the Character Sequence generator
"character_sequence": string, // The "Pattern" setting in the UI.
// The following settings apply to the SQL generator
"sql": string, // The "SQL" setting in the UI.
// The following settings apply to the URL generator
"protocol": boolean, // The "Protocol" setting in the UI.
"domain": boolean, // The "Domain" setting in the UI.
"path": boolean, // The "Path" setting in the UI.
"query": boolean, // The "Query" setting in the UI.
"filename": boolean, // The "Filename" setting in the UI.
// The following settings apply to the IP address generator
"ip_address_version": integer, // The "Version" setting in the UI.
// The following settings apply to the Phone Number generator
"phone_number_format": string, // The "Format" setting in the UI. See the UI for the list of valid formats.
// The following settings apply to the Project Name generator
"include_random_project_number": boolean, // The "Append a random number to the project name" setting in the UI.
// The following settings apply to the Rank, Sum, Number (distribution="series"), and Datetime (date_type="series") generators
"partition_by_field": string, // The "Partition By" setting in the UI.
"order_by_field": string, // The "Order By" setting in the UI.
// The following settings apply to the Foreign Key generator and the Column From Another Table generator
"primary_key_entity": string, // The "References Table" field in the Foreign Key generator UI. Called "Source Table" in the Column From Another Table generator UI.
"primary_key_field": string, // The "References Column" field in the Foreign Key generator UI. Called "Source Column" in the Column From Another Table generator UI.
"primary_key_cardinality_field": string, // The "Column containing the number of rows to generate for each key" field in the UI.
// The following fields apply to the Column From Another Table generator
"value_field": string, // Column From Another Table: The "Source Column" field in the UI, Sum: the "Column to Sum" field in the UI, Foreign Key: the "Generate rows for each key until the value in this column is 0 or less" field in the UI
"enable_where": boolean, // The "Select values based on the following criteria:" checkbox in the UI.
"foreign_key_field": string, // The name of the field in this table that references the primary key field in the primary key entity.
// The "Subset" field in the UI available for generators: ICD-10 Procedure, ICD-9 Procedure, List, ICD-10 Diagnosis, Product, Movie, Plant, Animal, File Type, Language, ICD-9 Diagnosis, Location (US), Drug, Car, University, Airport, Location (Global), Company, Hospital, HCPCS, Bank, Flight".
"conditions": [
{
"subset_field": string, // The name of the field in the underlying dataset that will be used to filter the values.
"operator": string, // must be one of "in", "not in", "is null", "is not null". Defaults to "in".
"subset_value": string // A comma-separated list of values to filter the values on. Required for "in" and "not in" operators, otherwise ignored.
}
]
"variants": [ // currently only the Number generator supports variants
{
"conditions": string, // The "Condition(s)" field in the UI.
... // The rest of the attributes are the same as the attributes for the Number generator (min, max, etc.)
// Note: the distribution of the parent field is always used.
}
]
}
Daily Limits
Unlike the UI, the API enforces daily limits on the amount of data that can be generated. Each account has a daily limit on the number of rows that can be generated which is specified in the account's plan. The limit is based on the number of rows in the database's largest table. Note that the number of tables in the database does not affect the limit, only the size of the largest table.
Plan | Daily Row Limit of Largest Table |
---|---|
Free | 1000 |
Silver | 1,000,000 |
Gold | 100,000,000 |
For example, if you have a Silver plan and you generate data for a database whose largest table has 100,000 rows, you can generate data for that database 10 times before you hit the daily limit for the account. Or, if the largest table has 1,000 rows, you can generate data for that database 1,000 times before you hit the daily limit for the account.
Get the status of a data generation task
To check the status of a data generation task:
GET /api/v1/generate_tasks/:id
Parameters
Name | Type | Description |
---|---|---|
id | string | The UUID of the data generation task to get |
Returns
The response will be a JSON object in the same format as the response from the POST /api/v1/generate_tasks endpoint.
Loading the generated data into your database
The download_url field in the response from GET /api/v1/generate_tasks/:id will contain a URL to download the generated data. Depending on the format of the data, you can load it into your database using the appropriate method:
Postgres
The data is provided as a zip file. Unzip it and run the following command to load the data into your database:
psql -U <username> -d <database> -f path/to/dir/load.sql
Fabricate CLI
The Fabricate CLI is the easiest way to load data from fabricate into your database.
Installation
Install the CLI using npm:
npm i -D @fabricate/cli
or yarn:
yarn install -dev @fabricate/cli
Configuring your API Key
In order to use the CLI, you must define an environment variable called "FABRICATE_API_KEY" containing a valid API key.
Limits
The CLI is subject to the same limits as the Fabricate API.
Loading Data
Use the CLI's load command to generate data and load it into your database.
fabricate load \
--source <fabricate_database_name> \
--target <target_database_name> \
--type <database_type> \
--create \
--user <username> \
--host <host> \
--port <port>
The load command accepts the following params:
- source - The name of the database in fabricate to use.
- target - The name of the database to populate.
- create - Include this boolean parameter to create the database if it does not already exist.
- refresh - Include this boolean parameter to regenerate the data from scratch. If not included the previously generated data will be used.
- type - The type of the target database platform. Currently only "postgres" is supported.
- user - The database user to connect with.
- host - The hostname of the target database.
- port - The port on which to connect.
When loading data into postgres, the CLI uses the psql command to load the data. Make sure that the psql command is available in your PATH. Set the PGPASSWORD environment variable to the password for the user specified in the --user parameter.
IP Allowlist
If you want Fabricate to connect directly to your database, you need to allow access from the following IP(s): 5.161.104.100