Skip to content

Adding a New Endpoint to GCP API Gateway

This guide explains how to add a new endpoint to an existing API Gateway on Google Cloud Platform (GCP), using OpenAPI and Cloud Endpoints.

Step-by-Step Instructions

1. Edit the OpenAPI Spec

Locate your existing OpenAPI specification file (usually openapi.yaml or openapi.json).

Add the new endpoint under the paths section. Example:

paths:
  /new-endpoint:
    get:
      summary: New GET endpoint
      operationId: getNewEndpoint
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object

You can also add other methods (post, put, etc.) as needed.

If you want to enable CORS for a specific endpoint, please add this section before specifying the method of the endpoint:

options:
      summary: CORS pre-flight
      operationId: corsAuth
      x-google-backend:
        address: "${CLOUD_RUN_SERVICE_URL}"
      responses:
        '200':
          description: A successful response