# iMock

Use [iMock](https://developers.alipayplus.com/open/console/developer/aps/app/iMock) to simulate different API results and return specified responses for integration testing.

> **Note**:
>
> -   Use iTest to send API requests, so as to receive the responses that you specify in iMock. For how to use iTest, see [iTest](itest).
> -   If you use other tools such as Postman to send API requests, you need to add the following parameters in the request headers: `loadmode: 2`, `markuid: 0A`, and `instmock: O`.

On the **Sandbox** > **Tools** > **iMock** page, follow these steps:

1.  Click **Specify** on the right side of each API.

![image.png](https://idocs-assets.marmot-cloud.com/storage/idocs87c36dc8dac653c1/yuque/idocs/2025/png/7d68bbeb-ffe9-4c0d-aa46-436b7c5f6fbb.png)

2.  In the pop-up window, you can complete the **Basic Settings** or **Advance Settings** to set the API response.

-   **Basic Settings**: Select a value for the _resultCode_ parameter from the drop-down list beside the **Response: resultCode** field.![image](https://idocs-assets.marmot-cloud.com/storage/idocs87c36dc8dac653c1/1676367186830-c684aa0c-3184-4c8c-910f-1caf8061172f.png)
-   **Advanced Settings**:

1.  Turn on **Advanced Settings** by switching the **Off** button to **On**.
    Note that **Basic Settings** is automatically cleared when **Advanced Settings** is turned on.![image](https://idocs-assets.marmot-cloud.com/storage/idocs87c36dc8dac653c1/1676368639607-b1da361c-3ab2-4ada-8290-006c6817a27e.png)
2.  Click **Add Response**.
3.  Specify values for the following fields:
    ![image](https://idocs-assets.marmot-cloud.com/storage/idocs87c36dc8dac653c1/1676367654274-50e4b87d-8ea8-4696-9b71-f5f4d1448b02.png)

-   **Response: resultCode**: indicates the value of _resultCode_ parameter that you expect to return in the API response.
-   **Request: {parameter}**: indicates the value of the request parameter that triggers the specified value of _resultCode_ in the API response.

4.  Click **Save** to make your settings valid.If you want to delete a record, click **Delete** in the **Action** column.

3.  Set the **API Mocking duration** on the **iMock** page. The duration can be 30 mins, 60 mins, 90 mins, or 120 mins. iMock is turned off automatically when the time is up.
    ![image](https://idocs-assets.marmot-cloud.com/storage/idocs87c36dc8dac653c1/1676368474420-f59f47a5-586a-4265-9875-9a2c50634d16.png)
4.  Turn on iMock by switching the **Off** button to **On**.
    ![image](https://idocs-assets.marmot-cloud.com/storage/idocs87c36dc8dac653c1/1676368463339-8a72cf7f-ff60-4afc-b395-4a17e6fe9632.png)