Skip to content

Edit a project's configuration in the browser

Before you begin

Plan
Included in Free, Pro and Team. How plans and limits work
Role
Viewer or higher to export the configuration, Editor or higher to apply a document and Admin or higher to apply changes to settings, chaos profiles or webhooks.

The Config as code page shows a project’s settings, scenarios, mocks, chaos profiles and webhooks as one configuration document in JSON. Edit a copy, see exactly what applying it would change, and apply it in one step: a quick way to change many mocks at once. Configuration document describes every field.

  1. Open the project’s Settings tab.

  2. Under Config as code, select Open config. The page shows This project’s config: the document, and how many scenarios, mocks, chaos profiles and webhooks it holds.

  3. Select Edit a copy below. If Config document (JSON) already holds text, confirm with Replace it.

  4. Edit the document in Config document (JSON). Each mock, scenario, chaos profile and webhook is identified by its name.

  5. Select Preview changes.

  6. Read the preview. Its heading says how many changes applying would make, and each section lists what would be created (Create), changed (Update, with the fields) and deleted (Delete). A tag such as 2 deletions marks a preview that deletes something.

  7. Select Apply. If the document deletes anything, a dialog names each deletion; select Apply and delete to go ahead.

The page says Applied., and This project’s config shows the project as it now is. The project’s address answers with the new mocks from the next request. If the page warns Applied, but not live yet, the change is saved, and requests may get the old answers for a moment.

A preview headed No changes means the project already looks exactly like the document, and Apply is dimmed: selecting it goes back to that heading.

  • The document is the whole truth. A mock, scenario, chaos profile or webhook the document does not mention is deleted, and a section left out counts as empty. A setting left out goes back to its default.
  • Apply is bound to the preview. Apply works only after a preview of the exact text in the box, and any edit clears the preview. If the project changes in between, nothing is applied; see Applying a configuration says the project changed.
  • All or nothing. If any part of an apply fails, the project stays exactly as it was.
  • A rename is a delete and a create. Names are identity, so a renamed resource starts afresh: a mock loses its version history, a webhook gets a new signing secret and loses its delivery records, a scenario starts again from the beginning, and a chaos profile is no longer active.
  • Some sections need Admin. An Editor can apply scenarios and mocks. Changes to settings, chaos profiles or webhooks need the Admin role, and the page names those sections; until they are taken out of the document Apply is dimmed, and selecting it goes to that list. Leaving out settings changes the settings too, when the project’s differ from the defaults.
  • Secrets stay out. Webhook signing secrets are never in the document, and an existing webhook keeps its secret when the document changes it.
  • The document is version 3. Each mock lists its named responses, each with a key, a name and its response, and a responseSelection saying which answers: the default, or a sequence over keys. The contract is under openapi, which is always there: the contract, or null for none. Each mock may also carry responseTemplating, openapiOperation and openapiGeneration. The preview lists the contract under OpenAPI contract. The selector a mock shows for each response, which is derived from the mock’s identifier, is never in the document, so a document applied to another project works there. "openapi": null removes the contract, its revisions and every mock’s link to it, and counts as a deletion. Changing the contract needs no more than Editor. See Configuration document.
  • Header values stay out too. A webhook’s static header values read [REDACTED] in the document, and leaving one as [REDACTED] keeps the saved value, so applying the document as it is changes nothing. Write a new value to replace one. [REDACTED] for a header the webhook does not have yet, such as one you renamed, is refused by the preview with Webhook "Order created": The "X-Api-Key" header has no stored value to keep; send its value.
The page shows What to do
That is not valid JSON. followed by the position Fix the JSON there. A YAML document is refused the same way.
The config document is invalid. followed by paths such as mocks[2].request.method Fix each field named. Unknown key., or Unknown setting. under settings, means a misspelt name, which is refused rather than ignored, such as a mock’s old response beside its new responses. A default or a sequence step that names a response the mock does not have, a key used twice, or a mock with no response is refused with a path such as mocks[0].responseSelection.defaultResponseKey.
This document changes things your role cannot apply from here. Take out the changes to the sections it names, or ask an Admin to apply the document.
The project configuration changed since this plan was computed (expected revision …, current …). Re-run diff and push again., or another message ending Re-run diff and push again. Select Preview changes again, check the new preview, and apply.
Your workspace allows … configuration bytes including version history. Remove or reduce existing resources, or upgrade. The workspace has reached its Configuration and versions per workspace limit. Delete mocks it no longer needs, or upgrade.
The page shows What to do
The document must declare "version": 3. Keep the version the export gave you.
Config version 2 is no longer read: a mock now lists named "responses" and a "responseSelection". Run mockhub pull to write version 3, and edit that file. The document is an older one, written before a mock held several responses. Select Edit a copy below to start from the project’s version 3 document, or run mockhub pull.
Required: the project's OpenAPI contract, or null when it has none. Put back the openapi from the export, or write "openapi": null to remove the contract.
The config document is … MiB, past the 48.0 MiB a config document may be. Its largest parts are … Shrink or remove the parts it names, such as a mock with a very large body, then preview again.
Too many OpenAPI contract checks for this workspace; … A document with an OpenAPI contract counts against the workspace’s OpenAPI imports, 30 a minute. Wait a minute and preview again.
The page shows What to do
This would make 2 active mocks in this project; your plan allows 1., or the same for active mocks, chaos profiles or webhooks in this workspace, or scenarios in this project The document asks for more than the plan allows, counting the workspace’s other projects. Remove some from the document or elsewhere, or upgrade.

The preview shows it under the section it concerns; an apply that would go over shows the same sentence.

  • The document leaves out the project’s name, description and address, its alert rules, request logs, captures, version history and delivery records, which chaos profile is active and where each scenario stands.
  • The preview checks what applying would: the document’s structure, the names it refers to, the settings, the plan’s numbers of active mocks, scenarios, chaos profiles and webhooks counted with the workspace’s other projects, each webhook’s address and templates, and each chaos profile’s path pattern. Only the limit on configuration storage, and the Owner with a confirmed email address that external webhooks need, are checked by the apply alone. An apply that fails changes nothing.
  • Renaming a mock or a scenario at the plan’s limit applies: the limits are measured once the whole document is applied.
  • A document of an older version is refused, whatever the project holds, with the message above; there is no conversion. Select Edit a copy below, or run mockhub pull, to write the current version.
  • A mock matching on a header named X-MockHub-Response is refused: that header selects among a mock’s responses, so a matcher cannot claim it. A key starting with oa- is one an import derived; keep the ones the export has, and do not invent new ones.
  • On a plan without config as code, project settings have no Config as code section, and the page says Config as code is not part of this workspace's plan.

Report a problem with this page