<commit_before>---
title: "Using gRPC mock servers"
updated: 2022-08-31
contextual_links:
  - type: section
    name: "Prerequisites"
  - type: link
    name: "Invoke your first gRPC request"
    url: "/docs/sending-requests/grpc/first-grpc-request/"
---

In an API-first design lifecycle, you may be designing a new feature that depends on new API endpoints, but another team is responsible for implementing those endpoints, and aren't finished yet. Instead of being blocked by this, you can use a mock server, which will return sample data for requests to the API's endpoints, simulating the behavior of a real API. You can then use the mock server to test your API, before it's even implemented by the other team.

## Contents

* [Using a gRPC mock server](#using-a-grpc-mock-server)
* [Reusing mock server responses](#reusing-mock-server-responses)
* [Next steps](#next-steps)

## Using a gRPC mock server

Before creating a gRPC mock server, you must have an API definition. This can either be an API in your workspace, a `.proto` file you want to import, or you can create a new API using the Postman API Builder.

To create the gRPC mock server:

1. Create a new gRPC request. See [Creating a new request](/docs/sending-requests/grpc/grpc-request-interface/#creating-a-new-request) for more information.
1. Select **Enter server URL**.
1. Select **Select a Protobuf API**.
1. Enter the protobuf API to use in one of the following ways:
    * **Use an API from this workspace** - Select an existing protobuf API in the current workspace.
    * **Import a .proto file** - Add a new protobuf API from a `.proto` file.
    * **Create a new API** - Open the Postman API Builder and create a new protobuf API.
1. After you have selected an API, select **Enter server URL** again, and select **Use Mock URL**.

The request URL will be a server name beginning with a random name and ending in `.srv.pstmn.io`. Select methods, then select **Invoke**, and your request will receive responses with random values.

The mock server will dynamically update based on changes to your protobuf API. If changes are made in API Builder to the protobuf API, requests to the mock server will automatically implement the changes.

## Reusing mock server responses
<commit_msg>review edit<commit_after>---
title: "Using gRPC mock servers"
updated: 2022-08-31
contextual_links:
  - type: section
    name: "Prerequisites"
  - type: link
    name: "Invoke your first gRPC request"
    url: "/docs/sending-requests/grpc/first-grpc-request/"
---

In an API-first design lifecycle, you may be designing a new feature that depends on new API endpoints, but another team is responsible for implementing those endpoints, and aren't finished yet. Instead of being blocked by this, you can use a mock server, which will return sample data for requests to the API's endpoints, simulating the behavior of a real API. You can then use the mock server to test your API, before it's even implemented by the other team.

## Contents

* [Using a gRPC mock server](#using-a-grpc-mock-server)
* [Reusing mock server responses](#reusing-mock-server-responses)
* [Next steps](#next-steps)

## Using a gRPC mock server

Before creating a gRPC mock server, you must have an API definition. This can either be an API in your workspace, a `.proto` file you want to import, or you can create a new API using the Postman API Builder.

To create the gRPC mock server:

1. Create a new gRPC request. See [Creating a new request](/docs/sending-requests/grpc/grpc-request-interface/#creating-a-new-request) for more information.
1. Select **Enter server URL**.
1. Select **Select a Protobuf API**.
1. Enter the protobuf API to use in one of the following ways:
    * **Use an API from this workspace** - Select an existing protobuf API in the current workspace.
    * **Import a .proto file** - Add a new protobuf API from a `.proto` file.
    * **Create a new API** - Open the Postman API Builder and create a new protobuf API.
1. After you have selected an API, select **Enter server URL** again, and select **Use Mock URL**.

The mock server will be automatically generated, and ready for use. The request URL will be a server name beginning with a random name and ending in `.srv.pstmn.io`. Select methods, then select **Invoke**, and your request will receive responses with random values.

The mock server will dynamically update based on changes to your protobuf API. If changes are made in API Builder to the protobuf API, requests to the mock server will automatically implement the changes.

## Reusing mock server responses

{'fraction_non_alphanumeric': 0.07802964254577158, 'fraction_numerical': 0.005666957279860506, 'mean_word_length': 3.9664502164502164, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '527602', 'n_tokens_mistral': 1235, 'n_tokens_neox': 1206, 'n_words': 678}