Reference documentation and code samples for the Cloud Scheduler V1 Client class HttpTarget.
Http target. The job will be pushed to the job handler by means of
an HTTP request via an
http_method such as HTTP
POST, HTTP GET, etc. The job is acknowledged by means of an HTTP
response code in the range [200 - 299]. A failure to receive a response
constitutes a failed execution. For a redirected request, the response
returned by the redirected request is considered.
Generated from protobuf message google.cloud.scheduler.v1.HttpTarget
Namespace
Google \ Cloud \ Scheduler \ V1
Methods
__construct
Constructor.
Parameters
Name
Description
data
array
Optional. Data for populating the Message object.
↳ uri
string
Required. The full URI path that the request will be sent to. This string must begin with either "http://" or "https://". Some examples of valid values for uri are: http://acme.com and https://acme.com/sales:8080. Cloud Scheduler will encode some characters for safety and compatibility. The maximum allowed URL length is 2083 characters after encoding.
HTTP request headers. This map contains the header field names and values. The user can specify HTTP request headers to send with the job's HTTP request. Repeated headers are not supported, but a header value can contain commas. The following headers represent a subset of the headers that accompany the job's HTTP request. Some HTTP request headers are ignored or replaced. A partial list of headers that are ignored or replaced is below: * * Host: This will be computed by Cloud Scheduler and derived from uri. * * Content-Length: This will be computed by Cloud Scheduler. * * User-Agent: This will be set to "Google-Cloud-Scheduler". * * X-Google-*: Google internal use only. * * X-AppEngine-*: Google internal use only. * * X-CloudScheduler: This header will be set to true. * * X-CloudScheduler-JobName: This header will contain the job name. * * X-CloudScheduler-ScheduleTime: For Cloud Scheduler jobs specified in the unix-cron format, this header will contain the job schedule as an offset of UTC parsed according to RFC3339. If the job has a body and the following headers are not set by the user, Cloud Scheduler sets default values: * * Content-Type: This will be set to "application/octet-stream". You can override this default by explicitly setting Content-Type to a particular media type when creating the job. For example, you can set Content-Type to "application/json". The total size of headers must be less than 80KB.
↳ body
string
HTTP request body. A request body is allowed only if the HTTP method is POST, PUT, or PATCH. It is an error to set body on a job with an incompatible HttpMethod.
If specified, an OAuth token will be generated and attached as an Authorization header in the HTTP request. This type of authorization should generally only be used when calling Google APIs hosted on *.googleapis.com.
If specified, an OIDC token will be generated and attached as an Authorization header in the HTTP request. This type of authorization can be used for many scenarios, including calling Cloud Run, or endpoints where you intend to validate the token yourself.
getUri
Required. The full URI path that the request will be sent to. This string
must begin with either "http://" or "https://". Some examples of
valid values for uri are:
http://acme.com and https://acme.com/sales:8080. Cloud Scheduler will
encode some characters for safety and compatibility. The maximum allowed
URL length is 2083 characters after encoding.
Returns
Type
Description
string
setUri
Required. The full URI path that the request will be sent to. This string
must begin with either "http://" or "https://". Some examples of
valid values for uri are:
http://acme.com and https://acme.com/sales:8080. Cloud Scheduler will
encode some characters for safety and compatibility. The maximum allowed
URL length is 2083 characters after encoding.
Parameter
Name
Description
var
string
Returns
Type
Description
$this
getHttpMethod
Which HTTP method to use for the request.
Returns
Type
Description
int
setHttpMethod
Which HTTP method to use for the request.
Parameter
Name
Description
var
int
Returns
Type
Description
$this
getHeaders
HTTP request headers.
This map contains the header field names and values.
The user can specify HTTP request headers to send with the job's
HTTP request. Repeated headers are not supported, but a header value can
contain commas.
The following headers represent a subset of the headers
that accompany the job's HTTP request. Some HTTP request
headers are ignored or replaced. A partial list of headers that
are ignored or replaced is below:
Host: This will be computed by Cloud Scheduler and derived from
uri.
Content-Length: This will be computed by Cloud Scheduler.
User-Agent: This will be set to "Google-Cloud-Scheduler".
X-Google-*: Google internal use only.
X-AppEngine-*: Google internal use only.
X-CloudScheduler: This header will be set to true.
X-CloudScheduler-JobName: This header will contain the job name.
X-CloudScheduler-ScheduleTime: For Cloud Scheduler jobs specified in
the unix-cron format, this header will contain the job schedule as an
offset of UTC parsed according to RFC3339.
If the job has a body and the
following headers are not set by the user, Cloud Scheduler sets default
values:
Content-Type: This will be set to "application/octet-stream". You
can override this default by explicitly setting Content-Type to a
particular media type when creating the job. For example, you can set
Content-Type to "application/json".
The total size of headers must be less than 80KB.
This map contains the header field names and values.
The user can specify HTTP request headers to send with the job's
HTTP request. Repeated headers are not supported, but a header value can
contain commas.
The following headers represent a subset of the headers
that accompany the job's HTTP request. Some HTTP request
headers are ignored or replaced. A partial list of headers that
are ignored or replaced is below:
Host: This will be computed by Cloud Scheduler and derived from
uri.
Content-Length: This will be computed by Cloud Scheduler.
User-Agent: This will be set to "Google-Cloud-Scheduler".
X-Google-*: Google internal use only.
X-AppEngine-*: Google internal use only.
X-CloudScheduler: This header will be set to true.
X-CloudScheduler-JobName: This header will contain the job name.
X-CloudScheduler-ScheduleTime: For Cloud Scheduler jobs specified in
the unix-cron format, this header will contain the job schedule as an
offset of UTC parsed according to RFC3339.
If the job has a body and the
following headers are not set by the user, Cloud Scheduler sets default
values:
Content-Type: This will be set to "application/octet-stream". You
can override this default by explicitly setting Content-Type to a
particular media type when creating the job. For example, you can set
Content-Type to "application/json".
The total size of headers must be less than 80KB.
HTTP request body. A request body is allowed only if the HTTP
method is POST, PUT, or PATCH. It is an error to set body on a job with an
incompatible HttpMethod.
Returns
Type
Description
string
setBody
HTTP request body. A request body is allowed only if the HTTP
method is POST, PUT, or PATCH. It is an error to set body on a job with an
incompatible HttpMethod.
Parameter
Name
Description
var
string
Returns
Type
Description
$this
getOauthToken
If specified, an
OAuth token
will be generated and attached as an Authorization header in the HTTP
request.
This type of authorization should generally only be used when calling
Google APIs hosted on *.googleapis.com.
[[["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-09-04 UTC."],[],[],null,["# Cloud Scheduler V1 Client - Class HttpTarget (2.0.5)\n\nVersion latestkeyboard_arrow_down\n\n- [2.0.5 (latest)](/php/docs/reference/cloud-scheduler/latest/V1.HttpTarget)\n- [2.0.4](/php/docs/reference/cloud-scheduler/2.0.4/V1.HttpTarget)\n- [1.10.5](/php/docs/reference/cloud-scheduler/1.10.5/V1.HttpTarget)\n- [1.9.4](/php/docs/reference/cloud-scheduler/1.9.4/V1.HttpTarget)\n- [1.8.3](/php/docs/reference/cloud-scheduler/1.8.3/V1.HttpTarget)\n- [1.7.1](/php/docs/reference/cloud-scheduler/1.7.1/V1.HttpTarget)\n- [1.6.8](/php/docs/reference/cloud-scheduler/1.6.8/V1.HttpTarget) \nReference documentation and code samples for the Cloud Scheduler V1 Client class HttpTarget.\n\nHttp target. The job will be pushed to the job handler by means of\nan HTTP request via an\n[http_method](/php/docs/reference/cloud-scheduler/latest/V1.HttpTarget#_Google_Cloud_Scheduler_V1_HttpTarget__getHttpMethod__) such as HTTP\nPOST, HTTP GET, etc. The job is acknowledged by means of an HTTP\nresponse code in the range \\[200 - 299\\]. A failure to receive a response\nconstitutes a failed execution. For a redirected request, the response\nreturned by the redirected request is considered.\n\nGenerated from protobuf message `google.cloud.scheduler.v1.HttpTarget`\n\nNamespace\n---------\n\nGoogle \\\\ Cloud \\\\ Scheduler \\\\ V1\n\nMethods\n-------\n\n### __construct\n\nConstructor.\n\n### getUri\n\nRequired. The full URI path that the request will be sent to. This string\nmust begin with either \"http://\" or \"https://\". Some examples of\nvalid values for [uri](/php/docs/reference/cloud-scheduler/latest/V1.HttpTarget#_Google_Cloud_Scheduler_V1_HttpTarget__getUri__) are:\n`http://acme.com` and `https://acme.com/sales:8080`. Cloud Scheduler will\nencode some characters for safety and compatibility. The maximum allowed\nURL length is 2083 characters after encoding.\n\n### setUri\n\nRequired. The full URI path that the request will be sent to. This string\nmust begin with either \"http://\" or \"https://\". Some examples of\nvalid values for [uri](/php/docs/reference/cloud-scheduler/latest/V1.HttpTarget#_Google_Cloud_Scheduler_V1_HttpTarget__getUri__) are:\n`http://acme.com` and `https://acme.com/sales:8080`. Cloud Scheduler will\nencode some characters for safety and compatibility. The maximum allowed\nURL length is 2083 characters after encoding.\n\n### getHttpMethod\n\nWhich HTTP method to use for the request.\n\n### setHttpMethod\n\nWhich HTTP method to use for the request.\n\n### getHeaders\n\nHTTP request headers.\n\nThis map contains the header field names and values.\nThe user can specify HTTP request headers to send with the job's\nHTTP request. Repeated headers are not supported, but a header value can\ncontain commas.\nThe following headers represent a subset of the headers\nthat accompany the job's HTTP request. Some HTTP request\nheaders are ignored or replaced. A partial list of headers that\nare ignored or replaced is below:\n\n- Host: This will be computed by Cloud Scheduler and derived from [uri](/php/docs/reference/cloud-scheduler/latest/V1.HttpTarget#_Google_Cloud_Scheduler_V1_HttpTarget__getUri__).\n- `Content-Length`: This will be computed by Cloud Scheduler.\n- `User-Agent`: This will be set to `\"Google-Cloud-Scheduler\"`.\n- `X-Google-*`: Google internal use only.\n- `X-AppEngine-*`: Google internal use only.\n- `X-CloudScheduler`: This header will be set to true.\n- `X-CloudScheduler-JobName`: This header will contain the job name.\n- `X-CloudScheduler-ScheduleTime`: For Cloud Scheduler jobs specified in the unix-cron format, this header will contain the job schedule as an offset of UTC parsed according to RFC3339. If the job has a [body](/php/docs/reference/cloud-scheduler/latest/V1.HttpTarget#_Google_Cloud_Scheduler_V1_HttpTarget__getBody__) and the following headers are not set by the user, Cloud Scheduler sets default values:\n- `Content-Type`: This will be set to `\"application/octet-stream\"`. You can override this default by explicitly setting `Content-Type` to a particular media type when creating the job. For example, you can set `Content-Type` to `\"application/json\"`. The total size of headers must be less than 80KB.\n\n### setHeaders\n\nHTTP request headers.\n\nThis map contains the header field names and values.\nThe user can specify HTTP request headers to send with the job's\nHTTP request. Repeated headers are not supported, but a header value can\ncontain commas.\nThe following headers represent a subset of the headers\nthat accompany the job's HTTP request. Some HTTP request\nheaders are ignored or replaced. A partial list of headers that\nare ignored or replaced is below:\n\n- Host: This will be computed by Cloud Scheduler and derived from [uri](/php/docs/reference/cloud-scheduler/latest/V1.HttpTarget#_Google_Cloud_Scheduler_V1_HttpTarget__getUri__).\n- `Content-Length`: This will be computed by Cloud Scheduler.\n- `User-Agent`: This will be set to `\"Google-Cloud-Scheduler\"`.\n- `X-Google-*`: Google internal use only.\n- `X-AppEngine-*`: Google internal use only.\n- `X-CloudScheduler`: This header will be set to true.\n- `X-CloudScheduler-JobName`: This header will contain the job name.\n- `X-CloudScheduler-ScheduleTime`: For Cloud Scheduler jobs specified in the unix-cron format, this header will contain the job schedule as an offset of UTC parsed according to RFC3339. If the job has a [body](/php/docs/reference/cloud-scheduler/latest/V1.HttpTarget#_Google_Cloud_Scheduler_V1_HttpTarget__getBody__) and the following headers are not set by the user, Cloud Scheduler sets default values:\n- `Content-Type`: This will be set to `\"application/octet-stream\"`. You can override this default by explicitly setting `Content-Type` to a particular media type when creating the job. For example, you can set `Content-Type` to `\"application/json\"`. The total size of headers must be less than 80KB.\n\n### getBody\n\nHTTP request body. A request body is allowed only if the HTTP\nmethod is POST, PUT, or PATCH. It is an error to set body on a job with an\nincompatible [HttpMethod](/php/docs/reference/cloud-scheduler/latest/V1.HttpMethod).\n\n### setBody\n\nHTTP request body. A request body is allowed only if the HTTP\nmethod is POST, PUT, or PATCH. It is an error to set body on a job with an\nincompatible [HttpMethod](/php/docs/reference/cloud-scheduler/latest/V1.HttpMethod).\n\n### getOauthToken\n\nIf specified, an\n[OAuth token](https://developers.google.com/identity/protocols/OAuth2)\nwill be generated and attached as an `Authorization` header in the HTTP\nrequest.\n\nThis type of authorization should generally only be used when calling\nGoogle APIs hosted on \\*.googleapis.com.\n\n### hasOauthToken\n\n### setOauthToken\n\nIf specified, an\n[OAuth token](https://developers.google.com/identity/protocols/OAuth2)\nwill be generated and attached as an `Authorization` header in the HTTP\nrequest.\n\nThis type of authorization should generally only be used when calling\nGoogle APIs hosted on \\*.googleapis.com.\n\n### getOidcToken\n\nIf specified, an\n[OIDC](https://developers.google.com/identity/protocols/OpenIDConnect)\ntoken will be generated and attached as an `Authorization` header in the\nHTTP request.\n\nThis type of authorization can be used for many scenarios, including\ncalling Cloud Run, or endpoints where you intend to validate the token\nyourself.\n\n### hasOidcToken\n\n### setOidcToken\n\nIf specified, an\n[OIDC](https://developers.google.com/identity/protocols/OpenIDConnect)\ntoken will be generated and attached as an `Authorization` header in the\nHTTP request.\n\nThis type of authorization can be used for many scenarios, including\ncalling Cloud Run, or endpoints where you intend to validate the token\nyourself.\n\n### getAuthorizationHeader"]]