mockfly logo

Import Project from JSON

Mockfly allows you to import a project from a JSON file. This is particularly useful if you want to migrate data from another tool, restore a backup, or simply create a project manually or programmatically.

To import a project, simply go to the projects page and look for the "Import Project" button. You can upload a JSON file or paste the JSON content directly.

This page covers Mockfly's own format, the one the Mockfly button of that modal expects. If what you have is an API specification instead, pick OpenAPI in the same Format row and see Import an OpenAPI or Swagger spec — Mockfly turns an OpenAPI 3.x or Swagger 2.0 document into the same kind of project, mapping every path, response and tag for you.

And if your API lives in Postman, pick Postman instead and see Import a Postman collection — a v2.1 export becomes endpoints, folders and responses, with the collection's variables carried over as environment variables.

When there is no specification and no collection either, you can record the API instead: pick HAR in that same Format row and see Import a HAR capture — Mockfly builds the project out of the requests your browser captured, with the status codes and the response bodies the server really returned.

JSON Structure

The JSON file must follow a specific structure to be correctly interpreted by Mockfly. Below is an example of a valid JSON file for importing a project including endpoints, rules, and responses.

{
  "project": {
    "name": "E-commerce API"
  },
  "endpoints": [
    {
      "method": "GET",
      "path": "/products",
      "delay": 0,
      "returnRandomResponse": false,
      "proxyConfiguration": "default",
      "headers": [],
      "responses": [
        {
          "status": 200,
          "body": {
            "products": [
              { "id": 1, "name": "Laptop", "price": 999 },
              { "id": 2, "name": "Smartphone", "price": 599 }
            ]
          },
          "isEnabled": true,
          "rules": []
        }
      ]
    },
    {
      "method": "GET",
      "path": "/products/:id",
      "delay": 500,
      "returnRandomResponse": false,
      "proxyConfiguration": "default",
      "headers": [],
      "responses": [
        {
          "status": 200,
          "body": {
            "id": "{{:id}}",
            "name": "Laptop",
            "price": 999,
            "description": "High performance laptop"
          },
          "isEnabled": true,
          "rules": []
        },
        {
          "status": 404,
          "body": {
            "error": "Product not found"
          },
          "isEnabled": true,
          "rules": [
            {
              "property": "id",
              "comparator": "equal",
              "value": "999",
              "source": "params",
              "andConditions": [],
              "position": 0
            }
          ]
        }
      ]
    },
    {
      "method": "POST",
      "path": "/orders",
      "delay": 200,
      "returnRandomResponse": false,
      "proxyConfiguration": "default",
      "headers": [
        {
            "key": "Location",
            "value": "/orders/123"
        }
      ],
      "responses": [
        {
          "status": 201,
          "body": {
            "message": "Order created successfully",
            "orderId": 123
          },
          "isEnabled": true,
          "rules": []
        }
      ]
    }
  ]
}

Field Descriptions