Skip to content

Mock File Schema

This page is a complete reference for the JSON structure of a Mimic mock file. For a friendlier introduction, start with the Mock Files guide.

{
"method": "string",
"path": "string",
"status": 200,
"response": "any",
"consume_body": false,
"query_params": { /* ... */ },
"headers": { /* ... */ },
"body": { /* ... */ }
}
FieldTypeRequiredDescription
methodstringyesHTTP method. Case-insensitive but conventionally uppercase: GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS.
pathstringyesURL path. Must start with /. Wildcards are not supported.
statusnumberyesHTTP status code returned for matching requests.
responseanyyesThe JSON value returned as the response body. Can be an object, array, string, number, boolean, or null.
consume_bodybooleannoIf true, Mimic reads and discards the request body before responding. Required for file uploads and large payloads. Default: false.
query_paramsobjectnoMatch against query string parameters.
headersobjectnoMatch against request headers.
bodyobjectnoMatch against the request body.
{
"query_params": {
"params": {
"<param_name>": "<matcher>"
},
"strict": false
}
}
FieldTypeRequiredDescription
paramsobjectyesMap of parameter name to matcher value.
strictbooleannoIf true, the request must contain only the listed params. Default: false.

A matcher in params can be:

FormMatches when
"value" (string)Param is present and equal to "value".
{ "regex": "^pattern$" }Param is present and matches the regex.
{ "any": null }Param is present, value is anything.

See Query Parameter Matching for examples.

{
"headers": {
"required": {
"<header_name>": "<matcher>"
},
"forbidden": ["<header_name>"],
"strict": false
}
}
FieldTypeRequiredDescription
requiredobjectnoHeaders that must be present and match.
forbiddenstring[]noHeader names that must not be present.
strictbooleannoIf true, the request must contain only the listed required headers. Default: false.
FormMatches when
"value" (string)Header value equals "value" exactly.
{ "prefix": "Bearer " }Header value starts with the prefix.
{ "contains": "json" }Header value contains the substring.
{ "regex": "^pattern$" }Header value matches the regex.
{ "any": null }Header is present, value is anything.

Header names are compared case-insensitively. See Header Matching for examples.

{
"body": {
"type": "json" | "text" | "form",
/* type-specific fields */
}
}
FieldTypeRequiredDescription
exactanynoEntire JSON body must equal this value.
partialobjectnoThese fields must be present in the body. Extras are allowed unless strict: true.
strictbooleannoWith partial, reject requests that have extra fields.

Use exactly one of exact or partial.

FieldTypeRequiredDescription
exactstringnoBody must equal this string exactly.
containsstringnoBody must contain this substring.
regexstringnoBody must match this regex.

Use exactly one of exact, contains, or regex.

FieldTypeRequiredDescription
fieldsobjectyesForm fields that must be present with the given values.
strictbooleannoIf true, reject requests with extra fields. Default: false.

See Request Body Matching for examples.

A mock that combines every matcher type:

{
"method": "POST",
"path": "/api/search",
"status": 200,
"consume_body": true,
"query_params": {
"params": {
"type": "user",
"page": { "regex": "^[0-9]+$" }
},
"strict": false
},
"headers": {
"required": {
"authorization": { "prefix": "Bearer " },
"content-type": { "contains": "json" }
},
"forbidden": ["x-debug"],
"strict": false
},
"body": {
"type": "json",
"partial": {
"query": "Alice"
}
},
"response": {
"results": [
{ "id": 1, "name": "Alice Johnson" }
],
"total": 1
}
}

This mock only matches a request that:

  • Uses POST to /api/search
  • Has ?type=user&page=<digits> in the query string
  • Has an Authorization header starting with Bearer
  • Has a Content-Type header containing json
  • Does not have an x-debug header
  • Has a JSON body containing at least {"query": "Alice"}

See Match Priority for how this scores against other mocks for the same path.