Stay organized with collections Save and categorize content based on your preferences.
Creating an API PrerequisitesBefore you can create an API on API Gateway, ensure that you have:
Many of the gcloud
commands shown require you to specify the ID of the API, in the form: API_ID. API Gateway enforces the following requirements for the API ID:
To create an API:
Validate the project ID returned from the following command to make sure that the service isn't created in the wrong project.
gcloud config list project
If you need to change the default project, run the following command and replace PROJECT_ID with the Google Cloud project ID in which you want to create the service::
gcloud config set project PROJECT_ID
If your project ID contains a colon (:
), see Domain-scoped projects for additional details about creating an API in your project.
View help for the apis create
command:
gcloud api-gateway apis create --help
Run the following command to create the API:
gcloud api-gateway apis create API_ID --project=PROJECT_ID
where:
As it is creating the API, API Gateway outputs information to the terminal.
On successful completion, you can use the following command to view details about the new API:
gcloud api-gateway apis describe API_ID --project=PROJECT_ID
This command returns the following:
createTime: '2020-02-29T21:52:20.297426875Z' displayName: API_ID managedService: MANAGED_SERVICE_NAME.apigateway.PROJECT_ID.cloud.goog name: projects/PROJECT_ID/locations/global/apis/API_ID state: ACTIVE updateTime: '2020-02-29T21:52:20.647923711Z'
The Google Cloud CLI takes many options, including those described in the gcloud Reference. In addition, for API Gateway, you can set the following options when creating an API:
--async
: Return control to the terminal immediately, without waiting for the operation to complete.--display-name=NAME
: Specifies the display name of the API, meaning the name shown in the UI. Do not use spaces in the name. Use hyphens and underscores instead. The default value is API_ID.--labels=KEY1=VALUE1,KEY2=VALUE2,...
: Specifies labels associated with the API config.--managed-service
: Specifies a pre-existing managed service (for example, an existing Endpoints service) for the API.If your project is scoped to your domain, the project ID includes the name of the domain followed by a colon (:
), for example, example.com:my-project
. You must provide a valid managed service when creating an API in a domain-scoped project.
If using gcloud
, provide the managed service name using the --managed-service
flag, as described in gcloud options.
To list all APIs in a project:
gcloud api-gateway apis list --project=PROJECT_ID
This command returns output in the form:
NAME DISPLAY_NAME MANAGED_SERVICE STATE projects/PROJECT_ID/locations/global/apis/API_ID API_ID MANAGED_SERVICE_NAME.apigateway.PROJECT_ID.cloud.goog ACTIVE
Use the project ID and API ID to obtain detailed information about the API:
gcloud api-gateway apis describe API_ID --project=PROJECT_IDUpdating an API
After creation, you can update the labels and display name of an existing API. Use the following gcloud
options to update an existing API:
--display-name
--update-labels
--clear-labels
--remove-labels
For example:
gcloud api-gateway apis update API_ID --project=PROJECT_ID \ --update-labels=a=1,b=2
Use the following command to view all update options:
gcloud api-gateway apis update --helpDeleting an API
To delete an API you must:
To delete an API:
Determine the list of API configs associated with the API:
gcloud api-gateway api-configs list --api=API_ID --project=PROJECT_ID
Delete each API config associated with the API:
gcloud api-gateway api-configs delete CONFIG_ID --api=API_ID --project=PROJECT_ID
Delete the API:
gcloud api-gateway apis delete API_ID --project=PROJECT_ID
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-07 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["Before creating an API, ensure your development environment is properly configured and meets the API ID requirements, which include a maximum length of 63 characters, lowercase letters, numbers, or dashes, and no starting dashes or underscores."],["Use the `gcloud api-gateway apis create API_ID --project=PROJECT_ID` command to create a new API, where you specify the desired API ID and the Google Cloud project ID."],["After creation, the API's display name and labels can be updated using the `gcloud api-gateway apis update` command with options like `--display-name`, `--update-labels`, `--clear-labels`, and `--remove-labels`."],["To delete an API, you must first delete all associated API configs using `gcloud api-gateway api-configs delete`, and then delete the API itself with `gcloud api-gateway apis delete`."],["Listing all the existing APIs within a project can be done with the following command `gcloud api-gateway apis list --project=PROJECT_ID`."]]],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4