LogoLogo
Release notesDocs homeFabricateTonic.ai
  • Tonic Fabricate User Guide
  • Fabricate workflow
  • Tutorial videos
  • Fabricate account
    • Getting started with Fabricate
    • Fabricate license plans
    • Managing your Fabricate account and profile
    • Managing users in your account
  • Databases
    • Supported database types
    • Creating and managing databases
  • Backing up and restoring the database definition
  • Configuring database variables
  • Exporting data from a database
  • Tables and columns
    • Managing database tables
      • Configuring table settings
      • Adding a table to a database
      • Removing a table from a database
      • Attaching static data to a table
      • Regenerating table data
  • Managing table columns
    • Adding and removing columns
    • Configuring a column
    • Generator reference
      • Calculated or related values
      • Data type and specific values
      • Names and other identifying information
      • Telephone numbers and email addresses
      • Geographic locations
      • Air travel
      • Natural science
      • Networks and files
      • Banking and finance
      • Dates and times
      • Vehicles
      • Companies and products
      • Healthcare and health insurance
      • Languages
      • Movies
      • Education
  • Views
    • Creating and managing views
    • Views reference
  • Workspaces
    • About workspaces
  • Creating and managing workspaces
  • Database mock API
    • About mock APIs
    • Defining a mock API
    • Creating and querying database snapshots
  • Mock API reference
  • Fabricate API and CLI
    • About the Fabricate API and CLI
    • Managing Fabricate API keys
    • Daily limits on generated data
    • Using the Fabricate API
      • Authentication for the API
      • Data model
      • Managing databases from the API
      • Generating data from the API
    • Using the Fabricate CLI
      • Setting up CLI access
      • Using the CLI to load data
Powered by GitBook
On this page
  • Database attributes
  • Entity (table) attributes
  • Constraints attributes
  • Field (database column) attributes
Export as PDF
  1. Fabricate API and CLI
  2. Using the Fabricate API

Data model

The Fabricate API references the following data model.

Database attributes

Each database object can contain the following attributes:

{
  "id": uuid,
  "name": "my_store",
  "created_at": datetime,
  "updated_at": datetime,
  "last_generated": datetime,
  "data_url": string,
  "platform": string,
  "variables": {
    "<variable_name>": string
  },
  "entities": entity[]
  "workspace": {
    "id": uuid,
    "name": string
  }
}

id

The UUID of the database

name

The name of the database

created_at

The date and time the database was created.

updated_at

The date and time the database was last updated.

last_generated

The date and time the data was last generated.

data_url

After data is generated, download it from this URL.

platform

The type of the target database.

variables

The default variable values assigned to the database.

entities

workspace

The workspace that the database belongs to. Determined by the workspace name in the request path. You do not provide this when you create or update a database.

Entity (table) attributes

An entity is equivalent to a database table.

Each entity object can contain the following attributes:

{
  "name": string,
  "records": string,
  "unique_records_for": string,
  "record_count": string,
  "view": boolean,
  "sql": string,
  "is_static": boolean,
  "source": {
    "data": string,
    "filename": string
  },
  "constraints": constraint[],
  "fields": field[]
}

name

The name of the entity.

records

Use exact to generate an exact number of rows. Use unique to generate one row for each unique value of a field in this entity.

unique_records_for

Only applies when records is set to unique. The name of the field that determines the number of unique rows to generate for this entity.

record_count

An expression that evaluates to the number of rows to generate for this entity. Only used for entities where the row count is not determined by a foreign key relationship. Ignored if either:

  • records is set to unique

  • The entity has one or more fields that use the Foreign Key generator with a distribution set to something other than none.

view

If true, the entity is generated as a view.

sql

If view is true, the SQL to use to generate the view.

Otherwise ignored.

is_static

true if the entity is backed by a static CSV file.

Otherwise false.

source

Present if the entity is backed by a static CSV file or has an attached CSV file.

source.data

The raw data from the CSV file.

source.filename

The name of the CSV file.

constraints

List of constraints.

fields

List of fields.

For views, this is ignored.

Constraints attributes

Each constraint object can contain the following attributes:

{
  "constraint_type": "unique" | "not-equal",
  "fields": string[]
}

constraint_type

The type of constraint. Either unique or not-equal.

fields

The names of the fields that the constraint applies to.

Field (database column) attributes

A field is equivalent to a database column.

Each field object can contain the following attributes:

{
  // All generators
  "seed": string,
  "percent_null": integer,
  "virtual": boolean,
  "group_key": string,
  "postprocessing_sql": string,
  "data_type": string,
  "index": boolean,

  // Apply to the Number, Lorem Ipsum, Datetime, and Foreign Key generators.
  "min": integer,
  "max": integer,
  "decimals": integer,
  "mean": string,
  "std_dev": string,
  "rate": string,
  "success_probability": string,
  "distribution": string,

  // Apply to the Number generator:
  "curve_type": string,
  "curve_type_field": string,
  "volatility": string,
  "volatility_type": string,
  "volatility_field": string,

  // Apply to the Datetime generator
  "start_date": string,
  "end_date": string,
  "date_only": boolean,
  "date_type": string,
  "date_operator": string,
  "date_unit": string,
  "time_range_start_hour": string,
  "time_range_end_hour": string,
  "date_only_weekdays": boolean,

  // Apply to Number and Datetime generators:
  "start_field": string,
  "end_field": string,

  // Applies to the Constant generator
  "constant_value": any,

  // Applies to the Regular Expression generator
  "regex": string,

  // Applies to the Lorem Ipsum generator
  "lorem_ipsum_unit": string,

  // Applies to the Character Sequence generator
  "character_sequence": string,

  // Applies to the SQL generator
  "sql": string,

  // Apply to the URL generator
  "protocol": boolean,
  "domain": boolean,
  "path": boolean,
  "query": boolean,
  "filename": boolean,

  // Applies to the IP Address generator
  "ip_address_version": integer,

  // Applies to the Phone Number generator
  "phone_number_format": string,

  // Applies to the Project Name generator
  "include_random_project_number": boolean,

  // Apply to the Rank, Sum, Number (series distribution), and Datetime (series type) generators
  "partition_by_field": string,
  "order_by_field": string,

  // Apply to the Foreign Key generator and the Column From Another Table generator
  "primary_key_entity": string,
  "primary_key_field": string,
  "primary_key_cardinality_field": string,
  
  // Applies to the Column From Another Table, Sum, and Foreign Key generators
  "value_field": string,
  
 // Apply to the Column From Another Table generator
  "enable_where": boolean,
  "foreign_key_field": string,

  // Used to set a weighted distribution of values. Applies to most generators.
  "conditions": [
    {
      "subset_field": string,
      "operator": string,
      "subset_value": string
    }
  ]

  "variants": [ // currently only the Number generator supports variants
    {
      "conditions": string,
      ...                   // Matches the Number generator attributes (min, max,   
                            // and so on)
                            // Always uses the parent field distribution.
    }
  ]
}
Field
Applies to
Description

seed

All

The seed for the field.

percent_null

All

virtual

All

group_key

All

postprocessing_sql

All

data_type

All

The data type for the field in the target database.

index

All

min

A minimum value.

max

A maximum value.

decimals

A number of decimal places to include in a value.

mean

A mean value.

std_dev

A standard deviation value.

rate

A rate of increase value.

success_probability

A success probability value.

distribution

The type of distribution for the value.

curve_type

The type of curve for a series of numerical values.

curve_type_field

When curve_type is from_column, the field to use as the basis for the curve.

volatility

The volatility to apply to a series of numerical values.

volatility_type

The type of volatility.

volatility_field

When volatility_type is from_column, the field to use as the basis for the volatility.

start_date

The earliest date value.

end_date

The latest date value.

date_only

Whether to only include dates and not times in the datetime values.

date_type

Whether the generated datetime values are absolute, relative, or a series.

date_operator

For relative datetimes, the comparison operator (before or after)

date_unit

For relative or series datetimes, the unit of time.

time_range_start_hour

For series datetimes, the start hour of the range.

time_range_end_hour

For series datetimes, the end hour of the range.

date_only_weekdays

For series datetimes, whether to only generate datetime values that occur on weekdays.

start_field

For series of numbers or datetime values, the column to use for the start of the series. For relative datetimes, the column to use for the relative date.

end_field

For series of numbers or datetime values, the column to use for the end of the series.

constant_value

The constant value to assign to the field.

regex

The regular expression pattern that the field value must match.

lorem_ipsum_unit

The unit of content to generate - words, sentences, or paragraphs.

character_sequence

The pattern to use for the character sequence.

sql

The SQL to use to generate the field values.

protocol

Whether to include the protocol in the generated URLs.

domain

Whether to include the domain in the generated URLs.

path

Whether to include the path in the generated URLs.

query

Whether to include a query in the generated URLs.

filename

Whether to include a filename in the generated URLs.

ip_address_version

The type of IP address (IPv4 or IPv6) to generate.

phone_number_format

The format to use for the telephone number.

partition_by_field

The field to use to partition the data.

order_by_field

The field to use to sort the rows within each partition.

primary_key_entity

The referenced table.

primary_key_field

The referenced field from the referenced table.

primary_key_cardinality_field

The field that contains the number of rows to generate.

value_field

The source column for a column from another table. The column to sum values for. The column to configure the number of values for a foreign key.

enable_where

Whether to select values based on provided criteria.

foreign_key_field

The name of a foreign key field.

conditions

condition.subset_field

The name of the field to use to filter the generated values for the current field.

condition.operator

The comparison operator to use to check the values in subset_field.

condition.subset_value

A comma-separated list of values to use for the in and not in comparisons.

variants

A set of variants for a distribution of numeric values.

Last updated 6 days ago

List of entities and their attributes. For the list of entity attributes, go to .

For the list of constraint attributes, go to .

For the list of field attributes. go to .

For the list of field attributes, go to .

When provided, the data in this field is the same each time the database is generated. For more information, go to .

The percentage of rows for which to set the field to null. For more information, go to .

Whether to hide the field when the data is exported. For more information, go to .

The group key to use to link a set of fields. For more information, go to .

SQL to run on the field after the initial generation. For more information, go to .

Whether to index this field. For more information, go to .

(series)

(series)

(series)

(series)

Used to configure the weighted distribution of values for the field. For more information, go to .

Entity (table) attributes
Constraints attributes
Field (database column) attributes
Field (database column) attributes
URL
URL
URL
URL
URL
IP Address
Setting a seed for consistent values
Setting a percentage of null values
Excluding the column from exported data
Using a group key to link column values
Adding SQL for postprocessing
Indexing a column
Configuring a weighted value distribution for a column
Regular Expression
Character Sequence
SQL
Rank
Sum
Rank
Sum
Foreign Key
Column From Another Table
Foreign Key
Column From Another Table
Foreign Key
Column From Another Table
Column From Another Table
Foreign Key
Sum
Column From Another Table
Column From Another Table
Number
Number
Number
Number
Number
Constant
Lorem Ipsum
Number
Number
Number
Foreign Key
Number
Lorem Ipsum
Datetime
Foreign Key
Number
Lorem Ipsum
Datetime
Foreign Key
Number
Lorem Ipsum
Datetime
Foreign Key
Number
Lorem Ipsum
Datetime
Foreign Key
Number
Lorem Ipsum
Datetime
Foreign Key
Number
Lorem Ipsum
Datetime
Foreign Key
Number
Lorem Ipsum
Datetime
Foreign Key
Number
Lorem Ipsum
Datetime
Datetime
Datetime
Datetime
Datetime
Datetime
Datetime
Datetime
Datetime
Datetime
Number
Datetime
Number
Datetime
Datetime
Datetime
Phone Number (Global)
Phone Number (US)