Manage deployments using the API

The following sections step through a sample scenario that demonstrates how you can manage the deployment of an API proxy using the API. For a complete list of the Apigee APIs supported, see the Apigee API reference.

Deploy an API proxy using the API

You cannot invoke an API proxy until it has been deployed.

When you create a new revision of an API proxy without changing its base path, then deploy it to an environment in which it's already deployed, the previous version is undeployed and the new revision is deployed in its place.

Deploy an API proxy to a specific environment in your Apigee organization by issuing a POST request to the following resource:

https://apigee.googleapis.com/v1/organizations/org_name/environments/environment_name/apis/api_proxy_name/revisions/revision_number/deployments

Where:

  • org_name is the name of your Apigee organization.
  • environment_name is the environment name.
  • api_proxy_name is the name of your API proxy.
  • revision_number is the revision number. The revision must exist.

If an existing API proxy revision is deployed, to ensure seamless deployment with zero downtime set the override query parameter to true. In this case, hybrid deploys the new revision fully before undeploying the existing revision.

The following example demonstrates how to deploy revision 1 of the helloworld API proxy to the test environment. (To create an API proxy, see Create an API proxy using the API.)

curl "https://apigee.googleapis.com/v1/organizations/myorg/environments/test/apis/helloworld/revisions/1/deployments" \
  -X POST \
  -H "Content-type:application/x-www-form-urlencoded" \
  -H "Authorization: Bearer $TOKEN"

Where $TOKEN is set to your OAuth 2.0 access token, as described in Obtain an OAuth 2.0 access token. For information about the curl options used in this example, see Use curl.

The following shows an example of the response output:

{
  "environment": "test",
  "apiProxy": "helloworld",
  "revision": "1",
  "deployStartTime": "1559149080457",
  "basePath": "/"
}

For more information, see the API Proxy Revision Environment Deployments API.

View all deployments in your Apigee organization using the API

View all deployments of API proxies and shared flows in your Apigee organization by issuing a GET request to the following resource:

https://apigee.googleapis.com/v1/organizations/org_name/deployments

Where org_name is the name of your Apigee organization.

The following example shows how to view all API proxy and shared flow deployments for myorg organization:

curl "https://apigee.googleapis.com/v1/organizations/myorg/deployments" \
  -X GET
  -H "Authorization: Bearer $TOKEN"

Where $TOKEN is set to your OAuth 2.0 access token, as described in Obtain an OAuth 2.0 access token. For information about the curl options used in this example, see Use curl.

The following provides an example of the response. In this example, there are three API proxies deployed, including helloworld which was deployed in the previous section.

{
  "deployments": [
    {
      "environment": "test",
      "apiProxy": "helloworld",
      "revision": "1",
      "deployStartTime": "1559149080457",
      "basePath": "/"
    },
    {
      "environment": "test",
      "apiProxy": "weather",
      "revision": "1",
      "deployStartTime": "1558620435217",
      "basePath": "/"
    },
    {
      "environment": "test",
      "apiProxy": "testproxy",
      "revision": "2",
      "deployStartTime": "1558635113086",
      "basePath": "/"
    }
  ]
}

For more information, see the Deployments API.

Check the deployment status of an API proxy revision using the API

Check the deployment status of your API proxy revision in an environment by issuing a GET request to the following resource:

https://apigee.googleapis.com/v1/organizations/org_name/environments/environment_name/apis/api_proxy_name/revisions/revision_number/deployments

Where:

  • org_name is the name of your Apigee organization.
  • environment_name is the environment name.
  • api_proxy_name is the name of your API proxy.
  • revision_number is the revision number.

For example:

curl "https://apigee.googleapis.com/v1/organizations/myorg/environments/test/apis/helloworld/revisions/1/deployments" \
  -X GET \
  -H "Authorization: Bearer $TOKEN"

Where $TOKEN is set to your OAuth 2.0 access token, as described in Obtain an OAuth 2.0 access token. For information about the curl options used in this example, see Use curl.

The following provides an example of the response:

{
  "environment": "test",
  "apiProxy": "helloworld",
  "revision": "1",
  "deployStartTime": "1559149080457",
  "pods": [
    {
      "podName": "apigee-runtime-myorg-test-f8bdf9d-2s72w",
      "appVersion": "self",
      "deploymentStatusTime": "1559164511972",
      "deploymentStatus": "deployed",
      "statusCode": "200",
      "statusCodeDetails": "Deployment Success",
      "deploymentTime": "1559149659417"
    }
  ],
  "basePath": "/"
}

For more information, see the API Proxy Revision Environment Deployments API.

Undeploy an API proxy using the API

Undeploy an API proxy in your Apigee organization by issuing a DELETE request to the following resource:

https://apigee.googleapis.com/v1/organizations/org_name/environments/environment_name/apis/api_proxy_name/revisions/revision_number/deployments

Where:

  • org_name is the name of your Apigee organization.
  • environment_name is the environment name.
  • api_proxy_name is the name of your API proxy.
  • revision_number is the revision number.

For example:

curl "https://apigee.googleapis.com/v1/organizations/myorg/environments/test/apis/helloworld/revisions/1/deployments" \
  -X DELETE \
  -H "Authorization: Bearer $TOKEN"

Where $TOKEN is set to your OAuth 2.0 access token, as described in Obtain an OAuth 2.0 access token. For information about the curl options used in this example, see Use curl.

The following provides an example of the response output (an empty response):

{}

For more information, see the API Proxy Revision Environment Deployments API.