In Cloud Functions, an HTTP trigger enables a function to run in response to
HTTP(S) requests. When you specify an HTTP trigger for a function, the function
is assigned a URL at which it can receive requests. HTTP triggers support the
OPTIONS request methods.
In Cloud Functions (2nd gen), requests to a function URL always require HTTPS. In Cloud Functions (1st gen), you can choose whether HTTPS is required during deployment.
By default, requests to a function with an HTTP trigger require authentication. You can choose to allow unauthenticated calls during deployment. See Allowing unauthenticated HTTP function invocation for more information.
You use HTTP functions to implement Cloud Functions that can handle general HTTP(S) requests.
You can specify an HTTP trigger when you deploy a function. See Deploy a Cloud Function for general instructions on how to deploy a function, and see below for additional information specific to configuring HTTP triggers during deployment.
If you are deploying using the gcloud CLI, the flags shown below are used to configure HTTP triggers:
gcloud functions deploy YOUR_FUNCTION_NAME \ --trigger-http \ [--allow-unauthenticated] \ [--security-level=SECURITY_LEVEL] \ ...
--trigger-httpflag specifies that the function uses an HTTP trigger.
--allow-unauthenticatedflag specifies that the function can be called without authentication. Omitting this flag means that calls to the function require authentication, which is the default. See Authenticating for invocation for more information.
- (1st gen) The
--security-levelflag controls whether the function endpoint requires HTTPS. The value
secure-alwaysmeans HTTPS is required and non-SSL HTTP requests are not supported. The value
secure-optionalmeans both HTTP and HTTPS are supported. The default is
If you are deploying using the Google Cloud console, you can configure an HTTP trigger in the Trigger section.
- For Cloud Functions (2nd gen):
- Under HTTPS, in the Authentication field, select an option depending on whether you want to allow unauthenticated invocations of your function. By default, authentication is required. See Authenticating for invocation for more information.
- For Cloud Functions (1st gen):
- In the Trigger type field, select HTTP.
- In the Authentication field, select an option depending on whether you want to allow unauthenticated invocations of your function. By default, authentication is required. See Authenticating for invocation for more information.
- Select or deselect the Require HTTPS checkbox to control whether the function endpoint requires HTTPS. If deselected, both HTTP and HTTPS are supported.
After your function is deployed with an HTTP trigger, you can retrieve its assigned URL.
For Cloud Functions (2nd gen):
gcloud functions describe YOUR_FUNCTION_NAME \ --gen2 \ --region=YOUR_FUNCTION_REGION \ --format="value(serviceConfig.uri)"
For Cloud Functions (1st gen):
gcloud functions describe YOUR_FUNCTION_NAME \ --format="value(httpsTrigger.url)"
Go to the Cloud Functions overview page in the console:
Click the name of the function whose URL you want to retrieve.
Click the Trigger tab. The function's assigned URL is shown.
- Learn how to write HTTP functions.
- Learn how to deploy a Cloud Function.
- See the HTTP function tutorial for an example of writing, deploying, and calling an HTTP function.