> ## Documentation Index
> Fetch the complete documentation index at: https://docs.swisstools.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Create and Configure a Mock Endpoint

> Add a mock HTTP endpoint to your project, set the method, path, status code, response body, and headers, then start sending requests immediately.

Each mock endpoint belongs to a project and is live as soon as you save it. You can create as many mocks as your project needs — one per route, or one per scenario.

<Steps>
  <Step title="Open API Mocks">
    Go to your project dashboard and click **API Mocks** in the sidebar.
  </Step>

  <Step title="Create a new mock">
    Click **New Mock** in the top-right corner. A dialog opens with the mock configuration form.
  </Step>

  <Step title="Give it a name">
    Enter a **Name** for the mock. This is for your reference only — it appears in the mock list but is not part of the URL.

    You can also add an optional **Description** to document its purpose.
  </Step>

  <Step title="Set the method and path">
    Choose the **HTTP method** from the dropdown: `GET`, `POST`, `PUT`, `PATCH`, or `DELETE`.

    Enter the **endpoint path** in the path field. The path must start with `/`, for example `/users` or `/orders/123`. This value becomes the last segment of your mock URL.
  </Step>

  <Step title="Configure the response">
    * **Status code** — The HTTP status code to return. Defaults to `200`. Use `201` for successful creations, `404` for not-found scenarios, and so on.
    * **Response body** — The body returned with every response. Accepts any text or JSON. Defaults to `{"message": "Hello World"}`.
    * **Response headers** — A JSON object of headers to include. Defaults to `{"Content-Type": "application/json"}`. You can add any headers your integration expects.
  </Step>

  <Step title="Save the mock">
    Click **Create Mock**. The mock is immediately live — you can start sending requests to its URL right away.
  </Step>
</Steps>

## Example: GET /users

Here is a complete example of a mock that returns a list of users:

| Field            | Value                                                    |
| ---------------- | -------------------------------------------------------- |
| Name             | `List users`                                             |
| Method           | `GET`                                                    |
| Path             | `/users`                                                 |
| Status code      | `200`                                                    |
| Response body    | `[{"id": 1, "name": "Alice"}, {"id": 2, "name": "Bob"}]` |
| Response headers | `{"Content-Type": "application/json"}`                   |

Once saved, you can call it with curl:

```bash theme={null}
curl https://abc12345-my-api.swisstools.dev/api/mock/users
# Returns: [{"id": 1, "name": "Alice"}, {"id": 2, "name": "Bob"}]
```

## Edit a mock

To update an existing mock, click the edit icon next to it in the mock list. The same form opens pre-filled with the current values. Change any field and click **Update Mock** — the change takes effect immediately.

## Delete a mock

To remove a mock, click the delete icon next to it in the mock list. Deleting a mock is permanent; any requests to its URL will no longer match and will return a not-found response.
