---
title: WireMock Hosting
description: Host WireMock Cloud stubs locally through your Aspire AppHost.
moved_from:
  - guides/development/mocking/host-wiremock-cli.md
---

# WireMock Hosting

This guide provides step-by-step instructions for configuring Wiremock hosting in your Aspire AppHost using Wiremock CLI. This will allow you to automatically pull down Wiremock cloud project stubs and run a mock server locally using the CLI.

[TOC]

## 📚 Useful Resources

- [Wiremock CLI Documentation](https://docs.wiremock.io/cli/overview)
- [Wiremock Cloud](https://docs.wiremock.io/overview)
- [Wiremock CLI - Recording Mocks](wiremock-cli-record.md)
- [WireMock CLI Example](../../examples/aspire-wiremockcli.md) - Working example of API mocking with Kiota client generation

## 📋 Prerequisites

Complete the [shared mocking prerequisites](index.md#shared-prerequisites), then make sure you have:

- ✅ Wiremock CLI installed (`npm install -g @wiremock/cli`)
- ✅ Wiremock Cloud project(s) with mocks defined (optional, for auto-update feature)

---

## 🛠️ Configure WireMock CLI Hosting

The `SAIF.Platform.Aspire.Hosting.WiremockCli` namespace runs each mock through the WireMock CLI executable and can pull its definitions from WireMock Cloud. See the [`SAIF.Platform.Aspire.Hosting` WireMock reference](../../../reference/dotnet/SAIF.Platform.Aspire.Hosting/index.md#wiremock) for how it compares with the package's other WireMock integrations, and the [WiremockCli README](https://github.com/saif-corp/forge/blob/main/src/dotnet/SAIF.Platform.Aspire.Hosting/WiremockCli/README.md) for its features, `AddMock` parameters, and default storage directory.

### Usage Example

```csharp
// Create the WireMock CLI resource
var wiremock = builder
    .AddWiremockCli("wiremock");

// Add a mock service that pulls definitions from WireMock Cloud
var mockApi = wiremock.AddMock(
    name: "external-api",
    port: 8080,
    wiremockProjectId: "abc123xyz",  // Your WireMock Cloud mock API ID
    autoUpdate: true
);

// Wire your application to reference the mock service
builder
    .AddProject<Projects.MyApiService>("my-api-service")
    .WithReference(mockApi)
    .WaitFor(mockApi);
```

To get the `wiremockProjectId`, follow [Find your mock API ID](index.md#find-your-mock-api-id).

### Feedback

Please provide feedback on these APIs through:

- 🐛 **Issues** for bugs or problems
- 💡 **Feature requests** for improvements
- 📝 **Discussions** for general feedback
