# crm.task_done

Concluir ou reabrir tarefa. `done: true` conclui; `false` reabre. `outcome` (só ao concluir) é o resultado da próxima ação, como no original: `true` = deu certo, `false` = não deu certo, omitido ou `null` = sem resultado. Se a tarefa é a próxima ação de uma cadência de follow-up, o resultado decide o passo seguinte (deu certo pula de fase; os outros seguem o próximo passo).

- Endpoint: `POST https://app.atomiks.com.br/api/v1/crm.task_done` (corpo JSON)
- Quem pode chamar: membro da conta
- Escopo da chave: `crm:write`
- Grava dados: sim
- Pela chave de API: sim
- Ferramenta MCP: `crm_task_done`
- Ficha em JSON: `https://app.atomiks.com.br/api/v1/openapi.json` (operationId `crm.task_done`)

## Entrada

| Campo | Tipo | Obrigatório | Nota |
|---|---|---|---|
| `id` | string (uuid) | sim |  |
| `done` | boolean | sim |  |
| `outcome` | boolean \| null | não |  |

<details><summary>JSON Schema</summary>

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid",
      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
    },
    "done": {
      "type": "boolean"
    },
    "outcome": {
      "type": [
        "boolean",
        "null"
      ]
    }
  },
  "required": [
    "id",
    "done"
  ]
}
```

</details>

## Exemplo

```bash
curl -X POST https://app.atomiks.com.br/api/v1/crm.task_done \
  -H "Authorization: Bearer $ATOMIKS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"id":"00000000-0000-0000-0000-000000000000","done":true}'
```

CLI:

```bash
node cli/atomiks.mjs crm.task_done --json '{"id":"00000000-0000-0000-0000-000000000000","done":true}'
```

MCP: ferramenta `crm_task_done` com a mesma entrada.

## Saída

Sucesso: `{"data": ...}` com o formato abaixo.

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "task": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "title": {
          "type": "string"
        },
        "kind": {
          "type": "string",
          "enum": [
            "todo",
            "call",
            "message",
            "meeting"
          ]
        },
        "dueAt": {
          "type": [
            "string",
            "null"
          ]
        },
        "done": {
          "type": "boolean"
        },
        "doneAt": {
          "type": [
            "string",
            "null"
          ]
        },
        "contact": {
          "type": "object",
          "properties": {
            "id": {
              "type": "string"
            },
            "name": {
              "type": [
                "string",
                "null"
              ]
            }
          },
          "required": [
            "id",
            "name"
          ],
          "additionalProperties": false
        },
        "conversationId": {
          "type": [
            "string",
            "null"
          ]
        },
        "opportunityId": {
          "type": [
            "string",
            "null"
          ]
        },
        "assignee": {
          "anyOf": [
            {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "name": {
                  "type": [
                    "string",
                    "null"
                  ]
                }
              },
              "required": [
                "id",
                "name"
              ],
              "additionalProperties": false
            },
            {
              "type": "null"
            }
          ]
        },
        "bucket": {
          "type": "string",
          "enum": [
            "overdue",
            "today",
            "upcoming",
            "no_date",
            "done"
          ]
        },
        "durationMinutes": {
          "type": [
            "number",
            "null"
          ]
        },
        "allDay": {
          "type": "boolean"
        },
        "notes": {
          "type": [
            "string",
            "null"
          ]
        },
        "meetingUrl": {
          "type": [
            "string",
            "null"
          ]
        },
        "guests": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "required": [
        "id",
        "title",
        "kind",
        "dueAt",
        "done",
        "doneAt",
        "contact",
        "conversationId",
        "opportunityId",
        "assignee",
        "bucket",
        "durationMinutes",
        "allDay",
        "notes",
        "meetingUrl",
        "guests"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "task"
  ],
  "additionalProperties": false
}
```

## Erros

`{"error": {"code", "message", "requestId"}}`. Códigos: `invalid_input` (400), `unauthorized` (401), `forbidden` / `account_pending` / `scope_missing` (403), `not_found` (404), `limit_reached` (409), `internal` (500).
