Start Here

  • Introduction
  • Quick Start

Core Features

  • Project Settings
  • Schema Builder
  • Dynamic Data
  • Conditional Logic
  • Relationships
  • Consuming your API

Integrations

  • n8n Workflows
  • Make (Integromat)
  • AI Tools

Relationships

Link schemas together to build complex, interconnected data structures without repeating yourself.

What are References?

In a real database, you don't store the full User object inside every Post. You store a reference (Foreign Key).

Mock66 allows you to do something similar, but better for mocking: Embedding. When you reference another schema, we inject the generated data of that schema directly into your response.

Schema A (User)
json
{
  "id": "user_123",
  "name": "Jane Doe"
}
Schema B (Post) embeds User
json
{
  "title": "My Post",
  "author": {
    "id": "user_123",
    "name": "Jane Doe"
  }
}

Creating a Relationship

You can turn any field into a reference using the Visual Builder.

  1. Create the Source Schema: First, create the schema you want to reuse (e.g., "User") and save it.
  2. Create the Parent Schema: Open a new schema (e.g., "Post").
  3. Add a Field: Create a new field named author.
  4. Change Type: Select the type dropdown and choose Ref.
  5. Select Target: A new dropdown will appear showing your existing schemas. Select "User".

Relationship Types

One-to-One (Single Object)

Embeds a single object.

Example: Product has one Manufacturer.

One-to-Many (Array of Objects)

Embeds a list of objects.

To do this, create an Array field first, then select a schema that will be used to populate the array.

Large Children Array Protection: In order to prevent performance issues, Mock66 limits the maximum number of items in an embedded array to 50 items.

Recursion Depth

Infinite Loop Protection: If Schema A references Schema B, and Schema B references Schema A back, you could theoretically generate infinite data.

To prevent your browser or our servers from crashing, Mock66 enforces a hard limit of 3 levels of nesting.

1User (Level 1)
2↳ Posts (Level 2)
3↳ Comments (Level 3)
X↳ Author (Level 4 - Returns Null)

When the limit is reached, the generator will simply return null for that field.

On this page

  • What are References?
  • Creating a Relationship
  • Relationship Types
  • Recursion Depth
Previous
Conditional Logic
Next
Consuming your API