{
  "openapi": "3.1.1",
  "info": {
    "title": "Nexus · API de integração",
    "description": "Crie e acompanhe tarefas de um workspace a partir de um ERP ou de qualquer outro sistema. Autentique com \"Authorization: Bearer <chave>\"; as chaves são geradas nas configurações do workspace, em Integrações.",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://nexus.aamora.com.br/"
    }
  ],
  "paths": {
    "/api/v1/workspace": {
      "get": {
        "tags": [
          "Workspace"
        ],
        "summary": "Workspace da chave",
        "description": "Identifica o workspace ao qual a chave de API dá acesso.",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkspaceResponse"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          }
        }
      }
    },
    "/api/v1/lists": {
      "get": {
        "tags": [
          "Workspace"
        ],
        "summary": "Spaces, listas e status",
        "description": "Ids necessários para criar tarefas: a lista de destino e, se quiser escolher, o status inicial.",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/SpaceResponse"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/members": {
      "get": {
        "tags": [
          "Workspace"
        ],
        "summary": "Membros do workspace",
        "description": "Ids aceitos em assigneeId ao criar ou atualizar uma tarefa.",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/MemberResponse"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tasks": {
      "get": {
        "tags": [
          "Tarefas"
        ],
        "summary": "Lista tarefas",
        "description": "Paginada (pageSize até 100). updatedSince traz só o que mudou desde a data informada, para sincronizações incrementais.",
        "parameters": [
          {
            "name": "ListId",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "StatusId",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "AssigneeId",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "UpdatedSince",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "Page",
            "in": "query",
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "type": [
                "integer",
                "string"
              ],
              "format": "int32"
            }
          },
          {
            "name": "PageSize",
            "in": "query",
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "type": [
                "integer",
                "string"
              ],
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskPageResponse"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Tarefas"
        ],
        "summary": "Cria uma tarefa",
        "description": "Informe externalReference com o id da tarefa no sistema de origem: uma segunda chamada com a mesma referência responde 409 com a tarefa já criada, em vez de duplicar.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateWorkItemRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskConflictResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tasks/{idOrCode}": {
      "get": {
        "tags": [
          "Tarefas"
        ],
        "summary": "Busca uma tarefa",
        "description": "Pelo id ou pelo código mostrado na tela (TASK-12).",
        "parameters": [
          {
            "name": "idOrCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskResponse"
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Tarefas"
        ],
        "summary": "Atualiza uma tarefa",
        "description": "Atualização parcial: campo ausente não muda. String vazia limpa description, assigneeId ou externalReference. Mudança de status respeita o fluxo de trabalho da lista.",
        "parameters": [
          {
            "name": "idOrCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateWorkItemRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskConflictResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/checkins": {
      "get": {
        "tags": [
          "Check-in"
        ],
        "summary": "Lista os check-ins semanais",
        "description": "Do mais recente para o mais antigo, até 26 semanas.",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/CheckinResponse"
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Check-in"
        ],
        "summary": "Registra ou atualiza o check-in de uma semana",
        "description": "Exige chave de leitura e escrita. perception: OnTrack, Frozen, OffTrack ou AtRisk. Pelo menos um de finished, inProgress ou nextSteps.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CheckinRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CheckinResponse"
                }
              }
            }
          },
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CheckinResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/time-entries": {
      "get": {
        "tags": [
          "Horas"
        ],
        "summary": "Lista lançamentos de horas",
        "description": "Por período (from/to, padrão: mês atual), pessoa, tarefa e contrato.",
        "parameters": [
          {
            "name": "From",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "To",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "UserId",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "TaskId",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "ContractId",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/TimeEntryResponse"
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Horas"
        ],
        "summary": "Registra horas de um membro",
        "description": "userId é obrigatório (veja GET /members). Contrato: sem informar, segue a regra do workspace (um ativo vincula sozinho; dois ou mais exigem contractId).",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TimeEntryRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TimeEntryResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "CheckinPerception": {
        "enum": [
          "OnTrack",
          "Frozen",
          "OffTrack",
          "AtRisk"
        ]
      },
      "CheckinRequest": {
        "required": [
          "weekDate",
          "perception",
          "finished",
          "inProgress",
          "nextSteps",
          "observations"
        ],
        "type": "object",
        "properties": {
          "weekDate": {
            "type": "string",
            "format": "date-time"
          },
          "perception": {
            "$ref": "#/components/schemas/CheckinPerception"
          },
          "finished": {
            "type": [
              "null",
              "string"
            ]
          },
          "inProgress": {
            "type": [
              "null",
              "string"
            ]
          },
          "nextSteps": {
            "type": [
              "null",
              "string"
            ]
          },
          "observations": {
            "type": [
              "null",
              "string"
            ]
          }
        }
      },
      "CheckinResponse": {
        "required": [
          "id",
          "weekStartUtc",
          "perception",
          "finished",
          "inProgress",
          "nextSteps",
          "observations",
          "authorName",
          "createdAtUtc",
          "updatedAtUtc"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "weekStartUtc": {
            "type": "string",
            "format": "date-time"
          },
          "perception": {
            "$ref": "#/components/schemas/CheckinPerception"
          },
          "finished": {
            "type": "string"
          },
          "inProgress": {
            "type": "string"
          },
          "nextSteps": {
            "type": "string"
          },
          "observations": {
            "type": "string"
          },
          "authorName": {
            "type": [
              "null",
              "string"
            ]
          },
          "createdAtUtc": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAtUtc": {
            "type": [
              "null",
              "string"
            ],
            "format": "date-time"
          }
        }
      },
      "CreateWorkItemRequest": {
        "required": [
          "taskListId",
          "title"
        ],
        "type": "object",
        "properties": {
          "taskListId": {
            "type": "string",
            "format": "uuid"
          },
          "title": {
            "type": [
              "null",
              "string"
            ]
          },
          "description": {
            "type": [
              "null",
              "string"
            ]
          },
          "type": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/WorkItemType"
              }
            ]
          },
          "priority": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/WorkItemPriority"
              }
            ]
          },
          "statusId": {
            "type": [
              "null",
              "string"
            ],
            "format": "uuid"
          },
          "assigneeId": {
            "type": [
              "null",
              "string"
            ]
          },
          "startDateUtc": {
            "type": [
              "null",
              "string"
            ],
            "format": "date-time"
          },
          "dueDateUtc": {
            "type": [
              "null",
              "string"
            ],
            "format": "date-time"
          },
          "externalReference": {
            "type": [
              "null",
              "string"
            ]
          }
        }
      },
      "HttpValidationProblemDetails": {
        "type": "object",
        "properties": {
          "type": {
            "type": [
              "null",
              "string"
            ]
          },
          "title": {
            "type": [
              "null",
              "string"
            ]
          },
          "status": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "null",
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "detail": {
            "type": [
              "null",
              "string"
            ]
          },
          "instance": {
            "type": [
              "null",
              "string"
            ]
          },
          "errors": {
            "type": "object",
            "additionalProperties": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        }
      },
      "ListResponse": {
        "required": [
          "id",
          "name",
          "statuses"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "statuses": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StatusResponse"
            }
          }
        }
      },
      "MemberResponse": {
        "required": [
          "id",
          "name",
          "email",
          "role"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "email": {
            "type": [
              "null",
              "string"
            ]
          },
          "role": {
            "$ref": "#/components/schemas/WorkspaceRole"
          }
        }
      },
      "PersonResponse": {
        "required": [
          "id",
          "name",
          "email"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "email": {
            "type": [
              "null",
              "string"
            ]
          }
        }
      },
      "SpaceResponse": {
        "required": [
          "id",
          "name",
          "lists"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "lists": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ListResponse"
            }
          }
        }
      },
      "StatusCategory": {
        "enum": [
          "ToDo",
          "InProgress",
          "Done"
        ]
      },
      "StatusResponse": {
        "required": [
          "id",
          "name",
          "category",
          "isDefault"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "category": {
            "$ref": "#/components/schemas/StatusCategory"
          },
          "isDefault": {
            "type": "boolean"
          }
        }
      },
      "TaskConflictResponse": {
        "required": [
          "message",
          "task"
        ],
        "type": "object",
        "properties": {
          "message": {
            "type": "string"
          },
          "task": {
            "$ref": "#/components/schemas/TaskResponse"
          }
        }
      },
      "TaskListRef": {
        "required": [
          "id",
          "name"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          }
        }
      },
      "TaskPageResponse": {
        "required": [
          "items",
          "page",
          "pageSize",
          "total"
        ],
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TaskResponse"
            }
          },
          "page": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "pageSize": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "total": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          }
        }
      },
      "TaskResponse": {
        "required": [
          "id",
          "code",
          "number",
          "title",
          "description",
          "type",
          "priority",
          "status",
          "list",
          "assignee",
          "startDateUtc",
          "dueDateUtc",
          "externalReference",
          "createdAtUtc",
          "updatedAtUtc",
          "url"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "code": {
            "type": "string"
          },
          "number": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "title": {
            "type": "string"
          },
          "description": {
            "type": [
              "null",
              "string"
            ]
          },
          "type": {
            "$ref": "#/components/schemas/WorkItemType"
          },
          "priority": {
            "$ref": "#/components/schemas/WorkItemPriority"
          },
          "status": {
            "$ref": "#/components/schemas/StatusResponse"
          },
          "list": {
            "$ref": "#/components/schemas/TaskListRef"
          },
          "assignee": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/PersonResponse"
              }
            ]
          },
          "startDateUtc": {
            "type": [
              "null",
              "string"
            ],
            "format": "date-time"
          },
          "dueDateUtc": {
            "type": [
              "null",
              "string"
            ],
            "format": "date-time"
          },
          "externalReference": {
            "type": [
              "null",
              "string"
            ]
          },
          "createdAtUtc": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAtUtc": {
            "type": [
              "null",
              "string"
            ],
            "format": "date-time"
          },
          "url": {
            "type": [
              "null",
              "string"
            ]
          }
        }
      },
      "TimeEntryRequest": {
        "required": [
          "userId",
          "date",
          "hours"
        ],
        "type": "object",
        "properties": {
          "userId": {
            "type": [
              "null",
              "string"
            ]
          },
          "date": {
            "type": "string",
            "format": "date-time"
          },
          "hours": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
            "type": [
              "number",
              "string"
            ],
            "format": "double"
          },
          "taskId": {
            "type": [
              "null",
              "string"
            ],
            "format": "uuid"
          },
          "activityId": {
            "type": [
              "null",
              "string"
            ],
            "format": "uuid"
          },
          "contractId": {
            "type": [
              "null",
              "string"
            ],
            "format": "uuid"
          },
          "comment": {
            "type": [
              "null",
              "string"
            ]
          }
        }
      },
      "TimeEntryResponse": {
        "required": [
          "id",
          "userId",
          "userName",
          "taskId",
          "taskCode",
          "contractId",
          "contractName",
          "activityId",
          "activityName",
          "date",
          "hours",
          "comment",
          "source",
          "createdAtUtc"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "userId": {
            "type": "string"
          },
          "userName": {
            "type": "string"
          },
          "taskId": {
            "type": [
              "null",
              "string"
            ],
            "format": "uuid"
          },
          "taskCode": {
            "type": [
              "null",
              "string"
            ]
          },
          "contractId": {
            "type": [
              "null",
              "string"
            ],
            "format": "uuid"
          },
          "contractName": {
            "type": [
              "null",
              "string"
            ]
          },
          "activityId": {
            "type": [
              "null",
              "string"
            ],
            "format": "uuid"
          },
          "activityName": {
            "type": [
              "null",
              "string"
            ]
          },
          "date": {
            "type": "string",
            "format": "date-time"
          },
          "hours": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
            "type": [
              "number",
              "string"
            ],
            "format": "double"
          },
          "comment": {
            "type": [
              "null",
              "string"
            ]
          },
          "source": {
            "$ref": "#/components/schemas/TimeEntrySource"
          },
          "createdAtUtc": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "TimeEntrySource": {
        "enum": [
          "Manual",
          "Timer"
        ]
      },
      "UpdateWorkItemRequest": {
        "type": "object",
        "properties": {
          "title": {
            "type": [
              "null",
              "string"
            ]
          },
          "description": {
            "type": [
              "null",
              "string"
            ]
          },
          "type": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/WorkItemType"
              }
            ]
          },
          "priority": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/WorkItemPriority"
              }
            ]
          },
          "statusId": {
            "type": [
              "null",
              "string"
            ],
            "format": "uuid"
          },
          "assigneeId": {
            "type": [
              "null",
              "string"
            ]
          },
          "startDateUtc": {
            "type": [
              "null",
              "string"
            ],
            "format": "date-time"
          },
          "dueDateUtc": {
            "type": [
              "null",
              "string"
            ],
            "format": "date-time"
          },
          "externalReference": {
            "type": [
              "null",
              "string"
            ]
          }
        }
      },
      "WorkItemPriority": {
        "enum": [
          "Lowest",
          "Low",
          "Medium",
          "High",
          "Highest"
        ]
      },
      "WorkItemType": {
        "enum": [
          "Task",
          "Bug",
          "Story",
          "Epic"
        ]
      },
      "WorkspaceResponse": {
        "required": [
          "id",
          "name",
          "slug",
          "isArchived"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "slug": {
            "type": "string"
          },
          "isArchived": {
            "type": "boolean"
          }
        }
      },
      "WorkspaceRole": {
        "enum": [
          "Owner",
          "Admin",
          "Member"
        ]
      }
    }
  },
  "tags": [
    {
      "name": "Workspace"
    },
    {
      "name": "Tarefas"
    },
    {
      "name": "Check-in"
    },
    {
      "name": "Horas"
    }
  ]
}