Mock APIs
Teams
Organisations
Data sources
Database connections
Usage
Access control
Stub Mappings
- GETGet all stub mappings
- POSTCreate a new stub mapping
- DELDelete all stub mappings
- POSTReset stub mappings
- POSTPersist stub mappings
- POSTImport stub mappings
- GETGet stub mapping by ID
- PUTUpdate a stub mapping
- DELDelete a stub mapping
- POSTFind stub mappings matching metadata
- POSTDelete stub mappings matching metadata
Requests
OpenAPI
Imports
Create a new stub mapping
Basic authentication header of the form Basic <encoded-value>
, where <encoded-value>
is the base64-encoded string username:password
.
The ID of the Mock API
This stub mapping's unique identifier
Alias for the id
The stub mapping's name
The scheme (protocol) part of the request URL
The hostname part of the request URL
The HTTP port number of the request URL
The HTTP request method e.g. GET
The path and query to match exactly against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified.
The path to match exactly against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified.
The path regex to match against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified.
The path and query regex to match against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified.
Path parameter patterns to match against in the <key>: { "<predicate>": "<value>" } form. Can only be used when the urlPathPattern URL match type is in use and all keys must be present as variables in the path template.
Query parameter patterns to match against in the <key>: { "<predicate>": "<value>" } form
application/x-www-form-urlencoded form parameter patterns to match against in the <key>: { "<predicate>": "<value>" } form
Header patterns to match against in the <key>: { "<predicate>": "<value>" } form
Pre-emptive basic auth credentials to match against
Cookie patterns to match against in the <key>: { "<predicate>": "<value>" } form
Request body patterns to match against in the <key>: { "<predicate>": "<value>" } form
Require the state of the Mock API to match the provided patterns. More information on this feature can be found here.
Multipart patterns to match against headers and body.
The HTTP status code to be returned
The HTTP status message to be returned
Map of response headers to send
Extra request headers to send when proxying to another host.
Request headers to remove when proxying to another host.
The response body as a string. Only one of body, base64Body, jsonBody or bodyFileName may be specified.
A base64 encoded string used to describe binary data.
The response body as a JSON object. Only one of body, base64Body, jsonBody or bodyFileName may be specified.
The path to the file containing the response body, relative to the configured file root. Only one of body, base64Body, jsonBody or bodyFileName may be specified.
The fault to apply (instead of a full, valid response).
Number of milliseconds to delay be before sending the response.
The delay distribution. Valid property configuration is either median/sigma/type or lower/type/upper.
The parameters for chunked dribble delay - chopping the response into pieces and sending them at delayed intervals
Read-only flag indicating false if this was the default, unmatched response. Not present otherwise.
The base URL of the target to proxy matching requests to.
A path segment to remove from the beginning in incoming request URL paths before proxying to the target.
Parameters to apply to response transformers.
List of names of transformers to apply to this response.
Indicates that the stub mapping should be persisted immediately on create/update/delete and survive resets to default.
This stub mapping's priority relative to others. 1 is highest.
The name of the scenario that this stub mapping is part of
The required state of the scenario in order for this stub to be matched.
The new state for the scenario to be updated to after this stub is served.
A map of the names of post serve action extensions to trigger and their parameters.
The list of serve event listeners
Arbitrary metadata to be used for e.g. tagging, documentation. Can also be used to find and remove stubs.
curl --request POST \
--url https://wmc.wiremockapi.cloud/v1/mock-apis/{mockApiId}/mappings \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '{
"request": {
"method": "GET",
"url": "/some/thing"
},
"response": {
"body": "Hello world!",
"headers": {
"Content-Type": "text/plain"
},
"status": 200
}
}'
{
"id": "76ada7b0-49ae-4229-91c4-396a36f18e09",
"priority": 3,
"request": {
"headers": {
"Accept": {
"equalTo": "text/plain"
}
},
"method": "GET",
"url": "/some/thing"
},
"response": {
"body": "Hello world!",
"headers": {
"Content-Type": "text/plain"
},
"status": 200
}
}
Authorizations
Basic authentication header of the form Basic <encoded-value>
, where <encoded-value>
is the base64-encoded string username:password
.
Path Parameters
The ID of the Mock API
5 - 10
Body
This stub mapping's unique identifier
Alias for the id
The stub mapping's name
The scheme (protocol) part of the request URL
http
, https
The hostname part of the request URL
The HTTP port number of the request URL
1 < x < 65535
The HTTP request method e.g. GET
The path and query to match exactly against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified.
The path to match exactly against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified.
The path regex to match against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified.
The path and query regex to match against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified.
Path parameter patterns to match against in the <key>: { "<predicate>": "<value>" } form. Can only be used when the urlPathPattern URL match type is in use and all keys must be present as variables in the path template.
Require the state of the Mock API to match the provided patterns. More information on this feature can be found here.
require-state
The context of the item to match. Can be templated.
The key of the item to match. Cannot be templated.
Multipart patterns to match against headers and body.
Determines whether all or any of the parts must match the criteria for an overall match.
ALL
, ANY
The HTTP status code to be returned
The HTTP status message to be returned
Extra request headers to send when proxying to another host.
Request headers to remove when proxying to another host.
The response body as a string. Only one of body, base64Body, jsonBody or bodyFileName may be specified.
A base64 encoded string used to describe binary data.
The response body as a JSON object. Only one of body, base64Body, jsonBody or bodyFileName may be specified.
The path to the file containing the response body, relative to the configured file root. Only one of body, base64Body, jsonBody or bodyFileName may be specified.
The fault to apply (instead of a full, valid response).
CONNECTION_RESET_BY_PEER
, EMPTY_RESPONSE
, MALFORMED_RESPONSE_CHUNK
, RANDOM_DATA_THEN_CLOSE
Number of milliseconds to delay be before sending the response.
Read-only flag indicating false if this was the default, unmatched response. Not present otherwise.
The base URL of the target to proxy matching requests to.
A path segment to remove from the beginning in incoming request URL paths before proxying to the target.
Parameters to apply to response transformers.
List of names of transformers to apply to this response.
Indicates that the stub mapping should be persisted immediately on create/update/delete and survive resets to default.
This stub mapping's priority relative to others. 1 is highest.
x > 1
The name of the scenario that this stub mapping is part of
The required state of the scenario in order for this stub to be matched.
The new state for the scenario to be updated to after this stub is served.
A map of the names of post serve action extensions to trigger and their parameters.
The list of serve event listeners
change-state
The operation to perform. * SET
- set the value of a state item in the state cache. * DELETE
- delete a state item from the state cache. * REQUEST_VAR
- set a variable that will be available for the lifetime of the request.
SET
, DELETE
, REQUEST_VAR
The context of the item to perform the operation on. Relevant only when operation
is SET
or DELETE
. Can be templated.
The key of the item to perform the operation on. Cannot be templated.
The value to set the item to. Relevant only when operation
is SET
or REQUEST_VAR
. Can be templated.
Arbitrary metadata to be used for e.g. tagging, documentation. Can also be used to find and remove stubs.
Response
This stub mapping's unique identifier
Alias for the id
The stub mapping's name
The scheme (protocol) part of the request URL
http
, https
The hostname part of the request URL
The HTTP port number of the request URL
1 < x < 65535
The HTTP request method e.g. GET
The path and query to match exactly against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified.
The path to match exactly against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified.
The path regex to match against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified.
The path and query regex to match against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified.
Path parameter patterns to match against in the <key>: { "<predicate>": "<value>" } form. Can only be used when the urlPathPattern URL match type is in use and all keys must be present as variables in the path template.
Require the state of the Mock API to match the provided patterns. More information on this feature can be found here.
require-state
The context of the item to match. Can be templated.
The key of the item to match. Cannot be templated.
Multipart patterns to match against headers and body.
Determines whether all or any of the parts must match the criteria for an overall match.
ALL
, ANY
The HTTP status code to be returned
The HTTP status message to be returned
Extra request headers to send when proxying to another host.
Request headers to remove when proxying to another host.
The response body as a string. Only one of body, base64Body, jsonBody or bodyFileName may be specified.
A base64 encoded string used to describe binary data.
The response body as a JSON object. Only one of body, base64Body, jsonBody or bodyFileName may be specified.
The path to the file containing the response body, relative to the configured file root. Only one of body, base64Body, jsonBody or bodyFileName may be specified.
The fault to apply (instead of a full, valid response).
CONNECTION_RESET_BY_PEER
, EMPTY_RESPONSE
, MALFORMED_RESPONSE_CHUNK
, RANDOM_DATA_THEN_CLOSE
Number of milliseconds to delay be before sending the response.
Read-only flag indicating false if this was the default, unmatched response. Not present otherwise.
The base URL of the target to proxy matching requests to.
A path segment to remove from the beginning in incoming request URL paths before proxying to the target.
Parameters to apply to response transformers.
List of names of transformers to apply to this response.
Indicates that the stub mapping should be persisted immediately on create/update/delete and survive resets to default.
This stub mapping's priority relative to others. 1 is highest.
x > 1
The name of the scenario that this stub mapping is part of
The required state of the scenario in order for this stub to be matched.
The new state for the scenario to be updated to after this stub is served.
A map of the names of post serve action extensions to trigger and their parameters.
The list of serve event listeners
change-state
The operation to perform. * SET
- set the value of a state item in the state cache. * DELETE
- delete a state item from the state cache. * REQUEST_VAR
- set a variable that will be available for the lifetime of the request.
SET
, DELETE
, REQUEST_VAR
The context of the item to perform the operation on. Relevant only when operation
is SET
or DELETE
. Can be templated.
The key of the item to perform the operation on. Cannot be templated.
The value to set the item to. Relevant only when operation
is SET
or REQUEST_VAR
. Can be templated.
Arbitrary metadata to be used for e.g. tagging, documentation. Can also be used to find and remove stubs.
curl --request POST \
--url https://wmc.wiremockapi.cloud/v1/mock-apis/{mockApiId}/mappings \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '{
"request": {
"method": "GET",
"url": "/some/thing"
},
"response": {
"body": "Hello world!",
"headers": {
"Content-Type": "text/plain"
},
"status": 200
}
}'
{
"id": "76ada7b0-49ae-4229-91c4-396a36f18e09",
"priority": 3,
"request": {
"headers": {
"Accept": {
"equalTo": "text/plain"
}
},
"method": "GET",
"url": "/some/thing"
},
"response": {
"body": "Hello world!",
"headers": {
"Content-Type": "text/plain"
},
"status": 200
}
}