Skip to main content
A mock API’s stubs can be exported in bulk via the admin API. This can be useful for backing up your API to source control, or cloning the contents of one API into another.

Importing

To import any of the supported formats (Swagger, OpenAPI, WireMock Cloud WireMock JSON), execute a POST request to the stub import URL e.g.:
More detail can be found in our API reference.

Asynchronous imports

Larger imports can take a while to process, so every import runs as a background job. When you call the import endpoint it will wait up to a configurable sync timeout (3 seconds by default) for the import to finish:
  • If the import finishes within the timeout, a 200 is returned containing the import result directly i.e. the IDs of the stub mappings created.
  • If the import is still running when the timeout elapses, a 202 Accepted response is returned containing details of the running job:
You can poll the job by sending a GET request to the URL in the job’s links.self:
When the import finishes, the job’s status will become COMPLETE, and its outcome will contain the import result:
If the import fails, the job’s status will become ERROR, and its outcome will contain the errors. Note that if you’re using the api.wiremock.cloud endpoint instead of your mock API’s own domain, the returned links.self URL will be of the form /v1/mock-apis/{mockApiId}/jobs/{jobId}, but the behaviour is otherwise identical.

Setting the sync timeout

The sync timeout can be changed - or disabled entirely - by supplying an import config in a config part of a multipart request, with the syncTimeout set to an ISO 8601 duration:
Setting syncTimeout to PT0S will disable waiting entirely - the endpoint will return a 202 immediately, and you can poll the job for the result. Other import config options such as duplicatePolicy can be supplied in the same config part. More detail can be found in our API reference and the job status API reference.

Exporting in WireMock Cloud/WireMock JSON format

To export an API’s stubs, execute a GET request to the stub mappings admin URL e.g.:
You can find your API token at https://app.wiremock.cloud/account/security.