Task names have the following format:projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID. The user can optionally specify a taskname. If a name is not specified then the system will generate a random unique task id, which will be set in the task returned in theresponse.
IfscheduleTimeis not set or is in the past then Cloud Tasks will set it to the current time.
Task De-duplication:
Explicitly specifying a task ID enables task de-duplication. If a task's ID is identical to that of an existing task or a task that was deleted or executed recently then the call will fail withgoogle.rpc.Code.ALREADY_EXISTS. The IDs of deleted tasks are not immediately available for reuse. It can take up to 24 hours (or 9 days if the task's queue was created using a queue.yaml or queue.xml) for the task ID to be released and made available again.
Because there is an extra lookup cost to identify duplicate task names, thesetasks.createcalls have significantly increased latency. Using hashed strings for the task id or for the prefix of the task id is recommended. Choosing task ids that are sequential or have sequential prefixes, for example using a timestamp, causes an increase in latency and error rates in all task commands. The infrastructure relies on an approximately uniform distribution of task ids to store and serve tasks efficiently.
The responseView specifies which subset of theTaskwill be returned.
By default responseView isBASIC; not all information is retrieved by default because some data, such as payloads, might be desirable to return only when needed because of its large size or because of the sensitivity of data that it contains.
Authorization forFULLrequirescloudtasks.tasks.fullViewGoogle IAMpermission on theTaskresource.
Response body
If successful, the response body contains a newly created instance ofTask.
[[["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-21 UTC."],[],[],null,["# Method: projects.locations.queues.tasks.create\n\n- [HTTP request](#body.HTTP_TEMPLATE)\n- [Path parameters](#body.PATH_PARAMETERS)\n- [Request body](#body.request_body)\n - [JSON representation](#body.request_body.SCHEMA_REPRESENTATION)\n- [Response body](#body.response_body)\n- [Authorization scopes](#body.aspect)\n- [Try it!](#try-it)\n\nCreates a task and adds it to a queue.\n\nTasks cannot be updated after creation; there is no UpdateTask command.\n\n- The maximum task size is 100KB.\n\n### HTTP request\n\n`POST https://cloudtasks.googleapis.com/v2/{parent=projects/*/locations/*/queues/*}/tasks`\n\nThe URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.\n\n### Path parameters\n\n### Request body\n\nThe request body contains data with the following structure:\n\n### Response body\n\nIf successful, the response body contains a newly created instance of [Task](/tasks/docs/reference/rest/v2/projects.locations.queues.tasks#Task).\n\n### Authorization scopes\n\nRequires one of the following OAuth scopes:\n\n- `https://www.googleapis.com/auth/cloud-platform`\n- `https://www.googleapis.com/auth/cloud-tasks`\n\nFor more information, see the [Authentication Overview](/docs/authentication#authorization-gcp)."]]