# 使用範例

在整個 API 的範例欄位中新增樣本資料。

在 API 合約中，您可以為 API 的各種元素新增範例值。定義範例後，在對您的 mock 進行 API 呼叫時便會使用該範例。

在下列範例中，使用範例建立了一個資料類型。

![從 JSON 範例產生的 Character 資料類型螢幕截圖。](https://help.qlik.com/zh-TW/cloud-services/Subsystems/Hub/Content/Resources/Images/ApiDesigner/shows_a_example_used_in_a_data_type.png)

此資料類型接著會用作作業的回應本文。

![名為 Get a Star Wars character by ID 的方法會傳回 Character 資料類型。](https://help.qlik.com/zh-TW/cloud-services/Subsystems/Hub/Content/Resources/Images/ApiDesigner/shows_a_data_type_used_in_an_operation_response.png)

您可以在 API 的不同部分定義範例，而在呼叫您的 Mock 時，某些範例可能會覆寫其他範例。此處使用的是資料類型的範例，但您也可以 為作業的回應定義範例。

![已為該回應定義新範例。這裡的角色是莉亞·歐嘉納。](https://help.qlik.com/zh-TW/cloud-services/Subsystems/Hub/Content/Resources/Images/ApiDesigner/shows_an_operation_response_using_a_data_type_and_an_added_example.png)

不支援外部範例。