Mockzilla logo

Mock Subfolders

Mock subfolders help you group related mocks inside a top-level folder. They also become part of the served URL, so your mock structure can mirror the API paths your application expects.

A top-level folder owns the first URL path prefix:

/api/mock{folderPath}

Top-level folder paths can be nested, such as /api or /app/test. Mockzilla resolves incoming mock requests by choosing the longest matching folder path prefix, then treats the remaining path as the mock path. Subfolders add path segments after the folder path, and the dashboard keeps mock paths relative to the subfolder you are viewing.

URL Examples

Folder pathSubfolder pathMock pathServed URL
/api/users/123/api/mock/api/users/123
/api/users/details/123/api/mock/api/users/details/123
/api/users/details//api/mock/api/users/details
/app/test/invoices/latest/api/mock/app/test/invoices/latest

Example:

  1. Create a folder with URL path /api.
  2. Create a subfolder named Users with path /users.
  3. Create a child subfolder named Details with path /users/details.
  4. Create a mock in Details with path /123.

The mock is served at:

/api/mock/api/users/details/123

Dashboard Workflow

The folder page shows one subfolder level at a time:

  • Click a subfolder card to enter it.
  • Use the upward arrow button to go back one level. From a top-level subfolder, it returns to the folder root.
  • Create subfolders from the current level. You can enter a simple name like Users or paste a full path like /api/users/details; Mockzilla normalizes it for the current folder.
  • Create mocks in the current level.
  • Edit mock paths relative to the selected subfolder. The preview, copy, and open actions always show the complete served URL.
  • Use preview, copy, or open actions to get the full served URL.

You can delete a subfolder only when it has no direct child subfolders and no direct mocks.

Creating Mocks in Subfolders

When you create or edit a mock while inside a subfolder, the Endpoint Path field stays relative to that subfolder.

For example, in folder /api and subfolder /users/details:

Endpoint PathServed URL
/123/api/mock/api/users/details/123
//api/mock/api/users/details
/*/api/mock/api/users/details/*

Subfolder mocks support the same matching features as root mocks:

  • exact paths
  • wildcard paths
  • substring paths
  • query parameter matching
  • wildcard variants
  • response delay
  • dynamic responses
  • proxy and record
  • request-body echo

See Routing & Matching for match strategy details.

Import and Export

Exports include subfolder information so projects can be moved between environments. On import, Mockzilla rebuilds served paths from the folder path and subfolder hierarchy, so copied projects keep the same URL behavior.

For API Clients

Use /api/mock-subfolders to create, list, update, and delete subfolders programmatically.

GET    /api/mock-subfolders?folderId={folderId}&parentId=root
GET    /api/mock-subfolders?folderId={folderId}&parentId={subfolderId}
GET    /api/mock-subfolders?folderId={folderId}&all=true
GET    /api/mock-subfolders?id={subfolderId}
POST   /api/mock-subfolders
PUT    /api/mock-subfolders?id={subfolderId}
DELETE /api/mock-subfolders?id={subfolderId}

Create a root subfolder

{
  "folderId": "folder-uuid",
  "name": "Users",
  "path": "/people"
}

Create a child subfolder

{
  "folderId": "folder-uuid",
  "parentId": "users-subfolder-uuid",
  "name": "Details",
  "path": "/people/details"
}

If path is omitted on create, Mockzilla generates the final URL segment from name. If path contains multiple segments, Mockzilla resolves the hierarchy and creates any missing intermediate subfolders.

Rename, change path, or move a subfolder

{
  "name": "Profiles",
  "path": "/people/profiles",
  "parentId": "users-subfolder-uuid"
}

Changing name only changes the display title. Changing path changes the served path and recomputes descendant paths.

The response includes the subfolder ID, name, parent, and user-facing path.

{
  "id": "details-subfolder-uuid",
  "folderId": "folder-uuid",
  "parentId": "users-subfolder-uuid",
  "name": "Details",
  "path": "/people/details",
  "createdAt": "2026-06-20T00:00:00.000Z"
}

Use mockFolderId when creating or updating a mock through the API.

{
  "name": "User details",
  "folderId": "folder-uuid",
  "mockFolderId": "details-subfolder-uuid",
  "method": "GET",
  "path": "/123",
  "statusCode": 200,
  "response": "{\"id\":\"123\"}"
}

Use null or omit mockFolderId to create a root-level mock.

The mock response includes:

  • path: the path you entered for the mock.
  • relativePath: same as path.
  • effectivePath: the path Mockzilla serves inside the top-level folder.

Example response fields:

{
  "path": "/123",
  "relativePath": "/123",
  "effectivePath": "/users/details/123"
}

The final URL is:

/api/mock{folderPath}{effectivePath}