Data buckets overview

What are data buckets?

In Mockoon, a data bucket is a key value store where you can create reusable content or data for your routes.

The data buckets are defined at the environment level and are generated when the server starts. It means that their state persists between each call (see below).

Create a data bucket

To create a new data bucket, open the Data options by clicking on the tab at the top of the window:

Open data bucket view

Add a new data bucket by clicking on the "plus" button:

Add a data bucket

You can change the data bucket title and content on the right part of the screen. Mockoon will automatically attribute a new unique ID to your data bucket. You can use this ID to reference the data using the data helpers. To retrieve a bucket's unique ID, look in the footer under the data bucket content or right-click on a bucket name in the list and click on "Copy ID to clipboard".

Content of a data bucket

Data buckets can contain any text content. They also support all of Mockoon's templating helpers. Mockoon will always try to parse the data bucket's content from JSON to allow you to reference only part of it using the data helpers.

Data buckets generation

Data buckets are generated when the server starts, and their state persist during all mock API calls. To regenerate a data bucket's content, restart the mock server.

If a data bucket contains request helpers, Mockoon will generate the bucket content only after the first call made to a route using this data bucket (by referencing it directly or using a data helper). It allows you to create bucket "configuration" routes that you can call programmatically with the content you want to reuse in your bucket using the request helpers (body, queryParams, etc.).