All Products
Document Center

Switch an API

Last Updated: Feb 18, 2019


For switching the API definition running in the specified stage to a specified historical definition, that is, replacing the running definition with a historical definition.

  • This function is intended for API activators.
  • The historical version number can be obtained through the DescribeHistoryApis interface.
  • Only definitions of APIs released more than once can be switched.
  • The definition switch can only be operated on running APIs. You must be cautious when performing this operation because the operation is reversible and takes effect immediately. The switch delay is no more than 5 seconds.
  • In essence, the switch operation is a release operation, and the reason for switch must be provided.

Request parameters

Name Type Required? Description
Action String Yes Operation interface, which is a required parameter; value: SwitchApi.
GroupId String No ID of the group.
ApiId String Yes ID of the API.
StageName String Yes Name of the running stage; values:
  • RELEASE: Online
  • TEST: Test
HistoryVersion String Yes Specifies the historical version number you want to switch to.
Description String Yes Switch the notes.

Return parameters

Name Type Description
RequestId String ID of the current request.


Request example

  2. &ApiId=d6f679aeb3be4b91b3688e887ca1fe16
  3. &StageName=release
  4. &HistoryVersion=20160705104552292
  5. &Description=for_demo
  6. &<Public request parameters>

Response example

XML format

  1. <SwitchApiResponse>
  2. <RequestId>CEF72CEB-54B6-4AE8-B225-F876FF7BZ001</RequestId>
  3. </SwitchApiResponse>

JSON format

  1. {
  2. "RequestId":"CEF72CEB-54B6-4AE8-B225-F876FF7BZ001"
  3. }