> For the complete documentation index, see [llms.txt](https://docs.tnid.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tnid.com/api-reference/001_user/012_documents/027__create_user_ai_task.md).

# Create A User AI Task

GraphQL endpoint: `/user`

Creates a task the calling user runs against their documents. Naming folders in `folderIds` covers each of them and everything beneath it; `runOnRoot` covers the whole repository instead. A task given neither runs against the documents a run names. Creating a task stores it — use `runUserAiTask` to run it. Documents uploaded afterwards are run against it as they become readable.

## Query

```graphql
mutation ($name: String!, $prompt: String!, $runOnRoot: Boolean, $folderIds: [ID!], $outputShape: JSON!) {
  createUserAiTask(name: $name, prompt: $prompt, runOnRoot: $runOnRoot, folderIds: $folderIds, outputShape: $outputShape) {
    id
    name
    prompt
    runOnRoot
    folders { id name }
    outputShape
    documentCount
    inFlightCount
  }
}

```

## Variables

```json
{
  "name": "Invoice details",
  "outputShape": {
    "total": "number"
  },
  "prompt": "Extract the total."
}
```

## Response

```json
{
  "data": {
    "createUserAiTask": {
      "documentCount": 0,
      "folders": [],
      "id": "00000000-0000-4000-8000-000000000001",
      "inFlightCount": 0,
      "name": "Invoice details",
      "outputShape": {
        "total": "number"
      },
      "prompt": "Extract the total.",
      "runOnRoot": false
    }
  }
}
```
