> This page is for Postman Docs, version Latest (v12) (default).
> For other versions, use one of these documentation indexes:
> - Latest (v12) (default): https://learning.postman.com/latest-v-12/llms.txt
> - v11: https://learning.postman.com/v11/llms.txt

> For clean Markdown content of this page, append .md to this URL. For the complete documentation index, see https://learning.postman.com/llms.txt.

# Deploy a mock as a mock server in Postman

> Deploy a code mock to the Postman Cloud as an always-available mock server, call its hosted URL, use state sessions, and inspect its logs.

Deploy a [mock](/docs/design-apis/mock-apis/mocks/overview) as a mock server to run its JavaScript request handlers in the Postman Cloud. Unlike a local mock that you [start and stop manually](/docs/design-apis/mock-apis/mocks/run-a-mock), a deployed mock server is always running, so anyone with access can send requests to it at any time.

> **Info**
>
> Deploying a mock as a mock server is supported in Cloud View for Solo, Team, and Enterprise plans only. For more information, see the [pricing page](https://www.postman.com/pricing/).

## Deploy a mock as a mock server \[#deploy-a-mock-as-a-mock-server]

1. Click the ![Items icon](https://assets.postman.com/postman-docs/aether-icons/v12/descriptive-items-stroke.svg#icon) **Items** tab in the sidebar.
2. Click **Mocks**.
3. Select the mock.
4. In the upper right, click **Deploy**. You can also select ![Options icon](https://assets.postman.com/postman-docs/aether-icons/v12/action-options-stroke.svg#icon) **View more actions > Deploy** next to a mock in the sidebar.
5. (Optional) Customize the URL for your mock server. The customized URL must be unique and can only have lowercase letters, numbers, and hyphens.
6. (Optional) Select the **Allow public access** checkbox to allow anyone with the mock server URL to send requests to it. To learn more, see [Make a mock server public](#make-a-mock-server-public).
7. (Optional) By default, mock servers maintain separate state for each session. To share a single state store across all requests, clear the **Enable sessions** checkbox. To learn more, see [State sessions](#state-sessions).
8. (Optional) Select **Auto deploy when mock changes** to automatically redeploy the mock server when you make changes to the mock.
9. Click **Deploy**.

The mock server is automatically running once it's deployed.

You can also deploy a mock from the Postman CLI: [`postman mock push`](/docs/postman-cli/postman-cli-mock#postman-mock-push) uploads the mock to the Postman Cloud, and [`postman mock deploy`](/docs/postman-cli/postman-cli-mock#postman-mock-deploy) publishes it as a mock server.

> **Info**
>
> To serve several mocks together behind one address, add them to a [simulation](/docs/design-apis/simulate-conditions/overview) instead.

### Make a mock server public \[#make-a-mock-server-public]

Mock servers deployed from a mock are private by default. Private mock servers can only be accessed by workspace members or callers that include a valid `x-api-key` header with a [Postman API key](/docs/reference/postman-api/authentication#generate-a-postman-api-key).

To allow anyone with the mock server URL to send requests to it, select **Allow public access** when deploying or editing the mock server. On Team and Enterprise plans, your team may require Team Admin approval before a mock server can be made public.

### State sessions \[#state-sessions]

By default, mock servers maintain a separate state store for each session when using `pm.state`. When you clear **Enable sessions**, all requests share a single state store instead.

Use state sessions to simulate multiple users, run parallel tests, or test stateful workflows without requests affecting each other's data. Identify a session using the `x-mock-session` header. Postman can also use a `pm_mock_session` cookie to maintain a session across requests automatically.

### Configure a deployed mock server \[#configure-a-deployed-mock-server]

You can change a deployed mock server's settings at any time.

1. Click the ![Services icon](https://assets.postman.com/postman-docs/aether-icons/v12/descriptive-services-stroke.svg#icon) **Services** tab in the sidebar.

2. Click **Mock Servers**.

3. Select the mock server you want to configure.

4. In the upper right, select ![Options icon](https://assets.postman.com/postman-docs/aether-icons/v12/action-options-stroke.svg#icon) **View more actions > Edit**.

5. Update the mock server's settings:

   * **URL** — The unique URL for the mock server. It can only have lowercase letters, numbers, and hyphens.
   * **Allow public access** — Allow anyone with the mock server URL to send requests to it. On Team and Enterprise plans, this may require Team Admin approval.
   * **Enable sessions** — When turned on, each session gets its own isolated copy of state. When turned off, all requests share a single state store.
   * **Auto deploy when mock changes** — Automatically redeploy the mock server when you make changes to the mock.

6. Click **Save**.

## Call a deployed mock server \[#call-a-deployed-mock-server]

After you deploy a mock as a mock server, send requests to the mock server URL to validate that it behaves as expected. The mock server listens for incoming requests and returns responses based on the logic you defined in the mock.

1. Click the ![Services icon](https://assets.postman.com/postman-docs/aether-icons/v12/descriptive-services-stroke.svg#icon) **Services** tab in the sidebar.
2. Click **Mock Servers**.
3. Select the mock server.
4. In the upper right, click ![Open in Postman icon](https://assets.postman.com/postman-docs/aether-icons/v12/icon-action-openInPostman-stroke.svg#icon) **Open in a new request** to open a new request with the URL auto-filled. You can also click ![Copy icon](https://assets.postman.com/postman-docs/aether-icons/v12/icon-action-copy-stroke.svg#icon) **Copy URL** to copy the URL and use it in an HTTP request.
5. Send requests to the URL and observe the responses.

   * If the mock server is private, you must either be signed in to Postman with access to the workspace, or include a valid `x-api-key` header with a [Postman API key](/docs/reference/postman-api/authentication#generate-a-postman-api-key).
   * If the mock server is public, anyone with the mock server URL can send requests to it.

## Inspect a deployed mock server \[#inspect-a-deployed-mock-server]

View the requests, responses, and state for a deployed mock server in the **Logs** and **State** tabs, the same way you [inspect a local mock](/docs/design-apis/mock-apis/mocks/run-a-mock#inspect-a-running-mock).

1. Click the ![Services icon](https://assets.postman.com/postman-docs/aether-icons/v12/descriptive-services-stroke.svg#icon) **Services** tab in the sidebar, click **Mock Servers**, then select the mock server.
2. Use the **Session** dropdown list to inspect a specific state session.
3. Use the **Logs** and **State** tabs to inspect requests, responses, and state information.

You can also browse a deployed mock server's request history from the Postman CLI with the [`postman mock log`](/docs/postman-cli/postman-cli-mock#postman-mock-log) command.