> For the complete documentation index, see [llms.txt](https://docs.planetcrust.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.planetcrust.com/human-connections/google/google-tasks-individual/query-find-or-create-task.md).

# Query: Find or Create Task

<p align="center"><a class="button primary" data-icon="circle-caret-right">Try @Human</a><a class="button primary" data-icon="check">Buy @Human Subscriptions</a><a class="button primary" data-icon="comments">Join @Human Community</a></p>

<figure><img src="/files/xtBRH49mqXsj1Nocn49x" alt="" width="188"><figcaption></figcaption></figure>

<p align="center">The Find or Create Task query locates an existing task or creates a new one if it doesn't exist.</p>

{% embed url="<https://www.youtube.com/watch?v=CyuUuaBSZzA>" %}

#### Example User Story

I want to find an existing task by its title or create a new one if it doesn't exist, so that I can manage my tasks efficiently.

#### Fields

| Field Name | Field Type | Required |
| ---------- | ---------- | -------- |
| title      | String     | Yes      |
| taskList   | String     | Yes      |
| notes      | String     | No       |
| due        | String     | No       |

### Related Connections

[Google Tasks](/human-connections/google/google-tasks-individual.md)

### Related Automations

Example link

### Code (Apache v2.0): Operation

```
{
  "handle": "find-or-create-task",
  "state": "inDev",
  "meta": {
    "short": "Find or Create Task",
    "description": "Finds an existing task by title or creates a new one if it doesn't exist."
  },
  "input": [
    {
      "name": "title",
      "type": "String",
      "required": true,
      "meta": {
        "description": "Title of the task to find or create."
      }
    },
    {
      "name": "taskList",
      "type": "String",
      "required": true,
      "meta": {
        "description": "ID of the task list where the task should be found or created."
      }
    },
    {
      "name": "notes",
      "type": "String",
      "required": false,
      "meta": {
        "description": "Additional notes for the task."
      }
    },
    {
      "name": "due",
      "type": "String",
      "required": false,
      "meta": {
        "description": "Due date for the task in RFC 3339 format."
      }
    }
  ],
  "output": [
    {
      "name": "taskId",
      "type": "String",
      "selector": ["id"],
      "meta": {
        "description": "ID of the found or created task."
      }
    },
    {
      "name": "taskStatus",
      "type": "String",
      "selector": ["status"],
      "meta": {
        "description": "Status of the task (e.g., 'needsAction', 'completed')."
      }
    }
  ],
  "steps": [
    {
      "type": "http",
      "http": {
        "method": "GET",
        "path": "/tasks",
        "queryParams": {
          "tasklist": "{{taskList}}",
          "showCompleted": "false",
          "showHidden": "false"
        }
      }
    },
    {
      "type": "taq",
      "taq": {
        "action": "if",
        "condition": "{{#if (eq (len .response.tasks) 0)}}",
        "steps": [
          {
            "type": "http",
            "http": {
              "method": "POST",
              "path": "/tasks",
              "queryParams": {
                "tasklist": "{{taskList}}"
              },
              "bodyTemplate": {
                "value": "{\"title\": \"{{title}}\", \"notes\": \"{{notes}}\", \"due\": \"{{due}}\"}",
                "placeholders": [
                  {
                    "name": "title",
                    "type": "String",
                    "description": "Title of the task.",
                    "required": true
                  },
                  {
                    "name": "notes",
                    "type": "String",
                    "description": "Additional notes for the task.",
                    "required": false
                  },
                  {
                    "name": "due",
                    "type": "String",
                    "description": "Due date for the task in RFC 3339 format.",
                    "required": false
                  }
                ]
              }
            }
          }
        ]
      }
    }
  ]
}

```

<p align="center"><a class="button primary" data-icon="square-caret-right">Try @Human</a><a class="button primary" data-icon="check">Buy @Human Subscription</a><a class="button primary" data-icon="comments">Join @Human Community</a></p>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.planetcrust.com/human-connections/google/google-tasks-individual/query-find-or-create-task.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
