Stay organized with collections Save and categorize content based on your preferences.
Passing data to and from the backend serviceWhen an API client makes a request to your API deployed on API Gateway, the client can pass any or all of the following information as part of the request:
In building its response to the API request, the backend service can return data to the API client, including:
This document describes how this data is passed to and from the backend service.
How is request data passed to the backend service?All data in the request from the API client is passed unchanged to the backend service. It is then up to the backend service to parse the request data as part of handling the request.
How is response data returned to the API client?All data received in the response from the backend service is passed unchanged to the API client. It is then up to the API client to process any returned data in the response.
How is the request URL passed to the backend service?The URL used to make a request to the backend service is controlled by the x-google-backend
extension. This section describes the options for configuring the backend service URL.
In the OpenAPI spec that you use to create an API config, you use the x-google-backend
extension to specify the URL of the backend service. For example, you specify the backend service in the form:
x-google-backend: address: https://GCP_REGION-PROJECT_ID.cloudfunctions.net/helloCloud Run
x-google-backend: address: https://hello-HASH.a.run.appApp Engine standard environment
x-google-backend: address: https://PROJECT_ID.appspot.com
In these examples:
In addition, the path
parameter in the OpenAPI spec specifies the endpoint, or resource, supported by your API. You can specify an absolute path or one that uses path parameters:
paths: /hello:
paths: /hello/{name}:Generating the backend service URL from an API request
As API Gateway handles a request from the API client, it takes the request URL sent by the API client and translates it into the URL used to make the request to the backend service. Exactly how this translation occurs depends on which path translation strategy you are using.
The path_translation
option to the x-google-backend
extension supports two path translation strategies:
APPEND_PATH_TO_ADDRESS
: The backend service URL is generated by appending the resource path from the client request to the address
URL of the x-google-backend
extension.
Most backend services use APPEND_PATH_TO_ADDRESS
because it means the backend receives the same resource path as specified by the API client.
CONSTANT_ADDRESS
: The backend service URL is constant, as defined by the address
URL of the x-google-backend
extension. If the client request contains a resource path, the resource path is added to the backend service URL by using query parameters.
This method is typically used by Cloud Run functions.
For example:
APPEND_PATH_TO_ADDRESS
address
: https://PROJECT_ID.appspot.com
/hello
/hello
https://PROJECT_ID.appspot.com/hello
/hello/{name}
/hello/Dave
https://PROJECT_ID.appspot.com/hello/Dave
CONSTANT_ADDRESS
address
: https://GCP_REGION-PROJECT_ID.cloudfunctions.net/hello
/hello
/hello
https://GCP_REGION-PROJECT_ID.cloudfunctions.net/hello
/hello/{name}
/hello/Dave
https://GCP_REGION-PROJECT_ID.cloudfunctions.net/hello?name=Dave
path_translation
Set path_translation
as part of setting x-google-backend
:
x-google-backend: address: https://GCP_REGION-PROJECT_ID.cloudfunctions.net/hello path_translation: [ APPEND_PATH_TO_ADDRESS | CONSTANT_ADDRESS ]`
The default value of path_translation
depends on where you set x-google-backend
in your OpenAPI spec:
When x-google-backend
is used at the top level of the OpenAPI specification, path_translation
defaults to APPEND_PATH_TO_ADDRESS
.
When x-google-backend
is used at the operation level of the OpenAPI specification, path_translation
defaults to CONSTANT_ADDRESS
.
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."],[[["API clients can pass request headers, query parameters, form data, XML/JSON payloads, and request paths to the API Gateway."],["Backend services return response headers and XML/JSON payloads to the API client."],["The `x-google-backend` extension in the OpenAPI spec defines the backend service URL, with options to specify the address and path."],["API Gateway uses path translation strategies, either `APPEND_PATH_TO_ADDRESS` or `CONSTANT_ADDRESS`, to translate client request URLs into backend service URLs."],["The `path_translation` default value depends on where `x-google-backend` is used in the OpenAPI specification, being `APPEND_PATH_TO_ADDRESS` at the top level and `CONSTANT_ADDRESS` at the operation level."]]],[]]
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