NAME DISPLAY_NAME MANAGED_SERVICE STATE
projects/PROJECT_ID/locations/global/apis/API_IDAPI_IDMANAGED_SERVICE_NAME.apigateway.PROJECT_ID.cloud.goog ACTIVE
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-09-03 (世界標準時間)。"],[[["\u003cp\u003eBefore 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.\u003c/p\u003e\n"],["\u003cp\u003eUse the \u003ccode\u003egcloud api-gateway apis create API_ID --project=PROJECT_ID\u003c/code\u003e command to create a new API, where you specify the desired API ID and the Google Cloud project ID.\u003c/p\u003e\n"],["\u003cp\u003eAfter creation, the API's display name and labels can be updated using the \u003ccode\u003egcloud api-gateway apis update\u003c/code\u003e command with options like \u003ccode\u003e--display-name\u003c/code\u003e, \u003ccode\u003e--update-labels\u003c/code\u003e, \u003ccode\u003e--clear-labels\u003c/code\u003e, and \u003ccode\u003e--remove-labels\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eTo delete an API, you must first delete all associated API configs using \u003ccode\u003egcloud api-gateway api-configs delete\u003c/code\u003e, and then delete the API itself with \u003ccode\u003egcloud api-gateway apis delete\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eListing all the existing APIs within a project can be done with the following command \u003ccode\u003egcloud api-gateway apis list --project=PROJECT_ID\u003c/code\u003e.\u003c/p\u003e\n"]]],[],null,["# Creating an API\n===============\n\nPrerequisites\n-------------\n\nBefore you can create an API on API Gateway, ensure that you have:\n\n- Prepared your development environment as described in [Configuring your development environment](/api-gateway/docs/configure-dev-env).\n\nAPI ID requirements\n-------------------\n\nMany of the `gcloud` commands shown require you to specify the ID of the API, in the form: \u003cvar translate=\"no\"\u003eAPI_ID\u003c/var\u003e.\nAPI Gateway enforces the following requirements for the API ID:\n\n- Must have a maximum length of 63 characters.\n- Must contain only lowercase letters, numbers, or dashes.\n- Must not start with a dash.\n- Must not contain an underscore.\n\nCreating an API\n---------------\n\nTo create an API:\n\n1. Validate the project ID returned from the following command to make sure that\n the service isn't created in the wrong project.\n\n ```\n gcloud config list project\n ```\n\n If you need to change the default project, run the following command\n and replace \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e with the Google Cloud project ID\n in which you want to create the service:: \n\n ```\n gcloud config set project PROJECT_ID\n ```\n\n If your project ID contains a colon (`:`), see\n [Domain-scoped projects](#domain) for additional details about creating an\n API in your project.\n2. View help for the `apis create` command:\n\n ```\n gcloud api-gateway apis create --help\n ```\n3. Run the following command to create the API:\n\n ```\n gcloud api-gateway apis create API_ID --project=PROJECT_ID\n ```\n\n where:\n - \u003cvar translate=\"no\"\u003eAPI_ID\u003c/var\u003e specifies the ID of the new API. See [API ID requirements](#api-id-requirements) for API naming guidelines.\n - \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e specifies the Google Cloud project ID.\n\n As it is creating the API, API Gateway outputs information to the terminal.\n4. On successful completion, you can use the following command to view details about the new API:\n\n ```\n gcloud api-gateway apis describe API_ID --project=PROJECT_ID\n ```\n\n This command returns the following: \n\n ```scdoc\n createTime: '2020-02-29T21:52:20.297426875Z'\n displayName: API_ID\n managedService: MANAGED_SERVICE_NAME.apigateway.PROJECT_ID.cloud.goog\n name: projects/PROJECT_ID/locations/global/apis/API_ID\n state: ACTIVE\n updateTime: '2020-02-29T21:52:20.647923711Z'\n ```\n\n### gcloud options\n\nThe Google Cloud CLI takes many options, including those described in the\n[gcloud Reference](/sdk/gcloud/reference). In addition,\nfor API Gateway, you can set the following options when creating an API:\n\n- `--async`: Return control to the terminal immediately, without waiting for the operation to complete.\n- `--display-name=`\u003cvar translate=\"no\"\u003eNAME\u003c/var\u003e: 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 \u003cvar translate=\"no\"\u003eAPI_ID\u003c/var\u003e.\n- `--labels=`\u003cvar translate=\"no\"\u003eKEY1\u003c/var\u003e`=`\u003cvar translate=\"no\"\u003eVALUE1\u003c/var\u003e`,`\u003cvar translate=\"no\"\u003eKEY2\u003c/var\u003e`=`\u003cvar translate=\"no\"\u003eVALUE2\u003c/var\u003e`,...`: Specifies labels associated with the API config.\n- `--managed-service`: Specifies a pre-existing managed service (for example, an existing Endpoints service) for the API.\n\n### Domain-scoped projects\n\nIf your project is scoped to your domain, the project ID includes the name of\nthe domain followed by a colon (`:`), for example, `example.com:my-project`. You\nmust provide a valid managed service when creating an API in a domain-scoped\nproject.\n\nIf using `gcloud`, provide the managed service name using the\n`--managed-service` flag, as described in\n[gcloud options](#gcloud-options).\n| **Note:** Scoping projects to a domain is a legacy feature. You cannot create new domain-scoped projects.\n\nListing APIs\n------------\n\nTo list all APIs in a project: \n\n```\ngcloud api-gateway apis list --project=PROJECT_ID\n```\n\nThis command returns output in the form: \n\n```scdoc\nNAME DISPLAY_NAME MANAGED_SERVICE STATE\nprojects/PROJECT_ID/locations/global/apis/API_ID API_ID MANAGED_SERVICE_NAME.apigateway.PROJECT_ID.cloud.goog ACTIVE\n```\n\nUse the project ID and API ID to obtain detailed information about the API: \n\n```\ngcloud api-gateway apis describe API_ID --project=PROJECT_ID\n```\n\nUpdating an API\n---------------\n\nAfter creation, you can update the labels and display name of an existing API.\nUse the following `gcloud` options to update an existing API:\n\n- `--display-name`\n- `--update-labels`\n- `--clear-labels`\n- `--remove-labels`\n\nFor example: \n\n```\ngcloud api-gateway apis update API_ID --project=PROJECT_ID \\\n --update-labels=a=1,b=2\n```\n\nUse the following command to view all update options: \n\n```\ngcloud api-gateway apis update --help\n```\n\nDeleting an API\n---------------\n\nTo delete an API you must:\n\n- Delete the API configs associated with the API.\n- Delete the API.\n\n| **Note:** If you deployed an API config to a gateway, then deleting the API causes the gateway to stop serving traffic. However, you are not required to delete the gateway. Instead, you can deploy an API config from a different API to the gateway.\n\nTo delete an API:\n\n1. Determine the list of API configs associated with the API:\n\n ```\n gcloud api-gateway api-configs list --api=API_ID --project=PROJECT_ID\n ```\n2. Delete each API config associated with the API:\n\n ```\n gcloud api-gateway api-configs delete CONFIG_ID --api=API_ID --project=PROJECT_ID\n ```\n3. Delete the API:\n\n ```\n gcloud api-gateway apis delete API_ID --project=PROJECT_ID\n ```\n\nWhat's next\n-----------\n\n- [Creating an API config](/api-gateway/docs/creating-api-config)"]]