{
  "openapi": "3.1.0",
  "info": {
    "title": "NooriACS API de integração de equipamentos",
    "version": "1.0.0",
    "description": "Funções sobre ONT/ONU para qualquer sistema integrador. O tenant vem sempre da chave. Reinício, Wi-Fi e leitura reaproveitam as regras do painel. Toda ação é assíncrona: aceite não é aplicação; consulte GET /integrations/v1/tasks/{taskId}. A chave é emitida, girada e revogada no painel (Integrações > Chaves de integração), com o segredo mostrado uma vez. Webhook de conclusão ainda não existe: a consulta da tarefa é o caminho oficial."
  },
  "servers": [
    {
      "url": "/"
    }
  ],
  "security": [
    {
      "integrationKey": []
    }
  ],
  "tags": [
    {
      "name": "Credencial"
    },
    {
      "name": "Localização"
    },
    {
      "name": "Leitura"
    },
    {
      "name": "Ações"
    },
    {
      "name": "Tarefas"
    },
    {
      "name": "Webhooks",
      "description": "Assinatura de eventos. Em vez de perguntar pelo resultado, o sistema integrador e avisado."
    }
  ],
  "paths": {
    "/integrations/v1/me": {
      "get": {
        "tags": [
          "Credencial"
        ],
        "summary": "Confere a chave",
        "description": "Serve de teste de conexão. Vale para qualquer chave válida.",
        "operationId": "integrationMe",
        "security": [
          {
            "integrationKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Chave válida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntegrationMe"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/integrations/v1/devices/lookup": {
      "post": {
        "tags": [
          "Localização"
        ],
        "summary": "Localiza o equipamento por serviço, serial ou MAC",
        "description": "Escopo devices:read. Os identificadores vão no corpo para não ficarem em log de acesso. O serial GPON aceita as duas codificações (54504C475136E0B0 e TPLG5136e0b0). MAC e PPPoE ajudam a achar o candidato, mas sozinhos não liberam ação remota. Nunca há busca por nome.",
        "operationId": "lookupDevice",
        "security": [
          {
            "integrationKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/IntegrationTarget"
              },
              "example": {
                "provider": "HUBSOFT",
                "serviceExternalId": "12345",
                "physicalIdentifier": "TPLG5136e0b0"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Resultado da localização. Sem vínculo também responde 200, com link.state",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntegrationLookupResult"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/integrations/v1/device-links": {
      "post": {
        "tags": [
          "Localização"
        ],
        "summary": "Confirma o vínculo por uma pessoa autorizada",
        "description": "Escopo devices:link, que nenhuma chave deve receber sem necessidade. Só promove candidato devolvido pela localização (UNCONFIRMED ou AMBIGUOUS). Divergência entre ERP e ACS nunca é resolvida aqui: responde 409 e pede revisão no painel.",
        "operationId": "confirmDeviceLink",
        "security": [
          {
            "integrationKey": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/IntegrationLinkRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Vínculo confirmado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntegrationLinkResult"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/integrations/v1/devices/{deviceId}/summary": {
      "get": {
        "tags": [
          "Leitura"
        ],
        "summary": "Resumo operacional",
        "description": "Escopo devices:read. Devolve a última leitura guardada no ACS, sem abrir sessão com o equipamento. live é sempre false e stale indica leitura obsoleta. Sem senha, sem IP e sem caminho de parâmetro.",
        "operationId": "deviceSummary",
        "security": [
          {
            "integrationKey": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/DeviceId"
          }
        ],
        "responses": {
          "200": {
            "description": "Resumo",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntegrationSummary"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/integrations/v1/devices/{deviceId}/connected-devices": {
      "get": {
        "tags": [
          "Leitura"
        ],
        "summary": "Dispositivos conectados",
        "description": "Escopo devices:read. MAC mascarado, sem nome de host nem IP do cliente.",
        "operationId": "deviceConnectedDevices",
        "security": [
          {
            "integrationKey": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/DeviceId"
          },
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Lista",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntegrationConnectedDevices"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/integrations/v1/devices/{deviceId}/reboot": {
      "post": {
        "tags": [
          "Ações"
        ],
        "summary": "Reinicia o equipamento",
        "description": "Escopo devices:reboot. Exige vínculo confirmado no momento do pedido. Sucesso da tarefa só com Inform de boot. Há intervalo mínimo entre reinícios (padrão 10 min), que conta tarefa de qualquer origem e boot sem tarefa. Derruba a internet do cliente por alguns minutos.",
        "operationId": "rebootDevice",
        "security": [
          {
            "integrationKey": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/DeviceId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/IntegrationActionRequest"
              },
              "example": {
                "target": {
                  "provider": "HUBSOFT",
                  "serviceExternalId": "12345",
                  "physicalIdentifier": "TPLG5136e0b0"
                },
                "actor": {
                  "type": "USER",
                  "id": "42",
                  "name": "Atendente"
                },
                "externalRef": "ticket:1001"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Repetição com a mesma Idempotency-Key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntegrationTask"
                }
              }
            }
          },
          "202": {
            "description": "Aceito. Ainda não aplicado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntegrationTask"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/integrations/v1/devices/{deviceId}/wifi": {
      "post": {
        "tags": [
          "Ações"
        ],
        "summary": "Troca senha ou nome da rede",
        "description": "Escopo wifi:write. Exige vínculo confirmado e perfil homologado. A senha nunca volta na resposta nem fica em auditoria. Em alguns modelos a alteração só vale depois de reiniciar (AWAITING_REBOOT) e a senha não pode ser relida (UNCONFIRMED com reason PASSWORD_NOT_READABLE): isso não é falha.\n\nDesde 2026-11-09 a entrega não exige mais que o ACS alcance o equipamento agora. `delivery` diz como a alteração vai chegar: `IMMEDIATE` quando o Connection Request foi aceito, `NEXT_INFORM` quando o aparelho está inalcançável de fora e a tarefa ficou na fila do próximo contato dele (o caso típico de CGNAT). Antes dessa data o mesmo cenário respondia 409 IMMEDIATE_DELIVERY_FAILED e a tarefa era encerrada sem nada chegar ao equipamento. Acompanhe por GET /integrations/v1/tasks/{taskId} nos dois casos.\n\nO template homologado trata uma rede por banda. Aparelho que anuncia outras redes mantém o nome antigo nelas, e isso não é falha da troca.",
        "operationId": "changeDeviceWifi",
        "security": [
          {
            "integrationKey": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/DeviceId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/IntegrationWifiRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Repetição com a mesma Idempotency-Key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntegrationTask"
                }
              }
            }
          },
          "202": {
            "description": "Aceito. Ainda não aplicado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntegrationTask"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/integrations/v1/devices/{deviceId}/refresh": {
      "post": {
        "tags": [
          "Ações"
        ],
        "summary": "Pede uma leitura nova",
        "description": "Escopo devices:refresh. Abre sessão com o equipamento, por isso tem limite: tarefa ativa é reaproveitada e a leitura repete no máximo a cada 15 min (skipped informa o motivo).",
        "operationId": "refreshDeviceReading",
        "security": [
          {
            "integrationKey": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/DeviceId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/IntegrationRefreshRequest"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Pedido aceito ou reaproveitado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntegrationRefreshResult"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/integrations/v1/tasks/{taskId}": {
      "get": {
        "tags": [
          "Tarefas"
        ],
        "summary": "Consulta o estado de uma ação",
        "description": "Escopo tasks:read. Só tarefas criadas por esta API. ACCEPTED: aceita pelo ACS. SENT: enviada ao equipamento. AWAITING_REBOOT: equipamento aceitou e só aplica depois de reiniciar. CONFIRMED: confirmada pelo equipamento. UNCONFIRMED: sem confirmação, veja reason. FAILED: falhou. EXPIRED: expirou sem chegar ao equipamento.",
        "operationId": "integrationTask",
        "security": [
          {
            "integrationKey": []
          }
        ],
        "parameters": [
          {
            "name": "taskId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Estado atual",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntegrationTask"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/integrations/v1/devices/{deviceId}/wifi-channels": {
      "get": {
        "tags": [
          "Leitura"
        ],
        "summary": "Análise de canais por banda",
        "operationId": "getDeviceWifiChannels",
        "security": [
          {
            "integrationKey": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/DeviceId"
          }
        ],
        "description": "Escopo devices:read. Última análise, sem nome de redes de terceiros. Modelo sem varredura responde scan.code CHANNEL_SCAN_UNSUPPORTED.",
        "responses": {
          "200": {
            "description": "Análise",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntegrationChannelView"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/integrations/v1/devices/{deviceId}/wifi-channels/scan": {
      "post": {
        "tags": [
          "Ações"
        ],
        "summary": "Pede uma varredura de canais",
        "operationId": "scanDeviceWifiChannels",
        "security": [
          {
            "integrationKey": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/DeviceId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "description": "Escopo wifi:scan. Assíncrono. Uma varredura por vez. PREPARING significa que o pedido precisa ser repetido.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "actor",
                  "externalRef"
                ],
                "properties": {
                  "actor": {
                    "type": "object"
                  },
                  "externalRef": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Aceito",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntegrationChannelScan"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/integrations/v1/devices/{deviceId}/wifi-channel": {
      "post": {
        "tags": [
          "Ações"
        ],
        "summary": "Troca o canal, liga o automático ou reverte",
        "operationId": "changeDeviceWifiChannel",
        "security": [
          {
            "integrationKey": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/DeviceId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "description": "Escopo wifi:channel. Exige vínculo confirmado, análise recente, homologação do canal para firmware e equipamento, canal permitido na banda e no Brasil. A troca desconecta os aparelhos: avise o cliente antes. Repetição com a mesma Idempotency-Key devolve a tarefa original. Uma reversão por troca: revert sobre reversão responde CHANNEL_REVERT_UNAVAILABLE. Erros: CHANNEL_SCAN_UNSUPPORTED, CHANNEL_CHANGE_TOO_SOON, CHANNEL_REVERT_UNAVAILABLE, WIFI_CHANNEL_NOT_ALLOWED, WIFI_CHANNEL_NOT_HOMOLOGATED, WIFI_CHANNEL_EVIDENCE_STALE.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/IntegrationChannelRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Repetição com a mesma Idempotency-Key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntegrationChannelChange"
                }
              }
            }
          },
          "202": {
            "description": "Aceito. Ainda não aplicado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntegrationChannelChange"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/integrations/v1/webhooks": {
      "get": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Lista as assinaturas desta chave",
        "description": "Mostra apenas as assinaturas da propria chave. Um integrador nao enxerga a do outro, mesmo na mesma empresa. O segredo nunca volta aqui.",
        "operationId": "listIntegrationWebhooks",
        "security": [
          {
            "integrationKey": [
              "webhooks:manage"
            ]
          }
        ],
        "responses": {
          "200": {
            "description": "Assinaturas",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "webhooks": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/WebhookSubscription"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          }
        }
      },
      "post": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Assina eventos",
        "description": "Cadastra um destino HTTPS. O segredo de assinatura e devolvido UMA unica vez, nesta resposta, e nao aparece em listagem, log, auditoria nem neste contrato. Repetir o mesmo URL na mesma chave atualiza a assinatura e gera segredo novo: e o caminho de rotacao.\n\nCada entrega leva `X-Noori-Signature: t=<unix>,v1=<hmac-sha256 hex>`, calculado sobre a cadeia `<t>.<corpo>` com o segredo. O carimbo entra no que e assinado para que uma entrega antiga reapresentada nao passe; recuse `t` fora de 300 s.\n\nEntrega repetida e possivel. Trate `id` do corpo (igual a `X-Noori-Delivery`) como chave de idempotencia.\n\nResponda 2xx para confirmar. 4xx que nao seja 408 ou 429 e tratado como recusa definitiva e nao e repetido. Falha de rede e 5xx sao repetidos com recuo de 1, 2, 4, 8, 16 e 30 minutos, ate 6 tentativas. Vinte falhas seguidas desligam a assinatura.",
        "operationId": "createIntegrationWebhook",
        "security": [
          {
            "integrationKey": [
              "webhooks:manage"
            ]
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "url",
                  "events"
                ],
                "properties": {
                  "url": {
                    "type": "string",
                    "format": "uri",
                    "example": "https://chat.example.com/noori/acs"
                  },
                  "events": {
                    "type": "array",
                    "minItems": 1,
                    "items": {
                      "type": "string",
                      "enum": [
                        "task.completed",
                        "device.online",
                        "device.offline"
                      ]
                    }
                  },
                  "description": {
                    "type": "string",
                    "maxLength": 200,
                    "nullable": true
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Assinada. O segredo aparece so agora.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "webhook": {
                      "$ref": "#/components/schemas/WebhookSubscription"
                    },
                    "secret": {
                      "type": "string",
                      "description": "Guarde: nao e possivel recuperar depois."
                    },
                    "signature": {
                      "type": "object",
                      "properties": {
                        "header": {
                          "type": "string"
                        },
                        "format": {
                          "type": "string"
                        },
                        "toleranceSeconds": {
                          "type": "integer"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/integrations/v1/webhooks/{webhookId}": {
      "delete": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Cancela a assinatura",
        "description": "Remove a assinatura e a fila pendente dela. So alcanca assinatura da propria chave.",
        "operationId": "deleteIntegrationWebhook",
        "security": [
          {
            "integrationKey": [
              "webhooks:manage"
            ]
          }
        ],
        "parameters": [
          {
            "name": "webhookId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Cancelada",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "removed": {
                      "type": "boolean"
                    },
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "integrationKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "Chave de sistema integrador. Escopos: devices:read, devices:link, devices:reboot, devices:refresh, wifi:write, tasks:read, webhooks:manage. Reset de fábrica e firmware não existem nesta API."
      }
    },
    "parameters": {
      "DeviceId": {
        "name": "deviceId",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string",
          "format": "uuid"
        }
      },
      "IdempotencyKey": {
        "name": "Idempotency-Key",
        "in": "header",
        "required": true,
        "description": "Obrigatória em toda ação. Repetir a mesma chave devolve a mesma tarefa, sem novo comando.",
        "schema": {
          "type": "string",
          "minLength": 8,
          "maxLength": 100,
          "pattern": "^[A-Za-z0-9._:-]+$"
        }
      }
    },
    "responses": {
      "Error": {
        "description": "Erro padronizado",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/IntegrationError"
            },
            "example": {
              "error": "DEVICE_LINK_NOT_CONFIRMED",
              "message": "O equipamento não está confirmado para este serviço. Nenhum comando foi enviado.",
              "requestId": "a1b2c3"
            }
          }
        }
      }
    },
    "schemas": {
      "IntegrationError": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string",
            "description": "UNAUTHENTICATED, INSUFFICIENT_SCOPE, DEVICE_NOT_FOUND, TASK_NOT_FOUND, DEVICE_OFFLINE, DEVICE_LINK_NOT_CONFIRMED, DEVICE_LINK_CONFLICT, WIFI_PROFILE_NOT_FOUND, WIFI_PASSWORD_INVALID, REBOOT_TASK_ALREADY_ACTIVE, REBOOT_TOO_SOON, RATE_LIMITED, IDEMPOTENCY_KEY_INVALID, IDEMPOTENCY_KEY_REUSED, WIFI_CHANNEL_IDEMPOTENCY_CONFLICT, INTEGRATION_BUSY, IMMEDIATE_DELIVERY_FAILED, INTEGRATION_ACTOR_INVALID, INTEGRATION_EXTERNAL_REF_INVALID, INTEGRATION_LOOKUP_INVALID, INTEGRATION_LOOKUP_EMPTY, INTEGRATION_LOOKUP_PROVIDER_REQUIRED, CAPABILITY_DISCOVERY_REQUIRED, CPE_RPC_NOT_SUPPORTED, WAN_NOT_DISCOVERED, WIFI_DEVICE_AMBIGUOUS, CENTRAL_LIMIT_API_REQUESTS"
          },
          "message": {
            "type": "string"
          },
          "requestId": {
            "type": "string"
          },
          "requiredScope": {
            "type": "string"
          },
          "retryAfterSeconds": {
            "type": "integer"
          },
          "taskId": {
            "type": "string"
          },
          "deliveryCode": {
            "type": "string"
          },
          "link": {
            "$ref": "#/components/schemas/IntegrationLink"
          }
        }
      },
      "IntegrationMe": {
        "type": "object",
        "required": [
          "integrator",
          "tenant",
          "scopes",
          "apiVersion",
          "product"
        ],
        "properties": {
          "integrator": {
            "type": "string"
          },
          "tenant": {
            "type": "string"
          },
          "scopes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "expiresAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "apiVersion": {
            "type": "string",
            "enum": [
              "v1"
            ]
          },
          "product": {
            "type": "string",
            "enum": [
              "NOORI_ACS"
            ]
          }
        }
      },
      "IntegrationTarget": {
        "type": "object",
        "description": "Ao menos um identificador. provider é obrigatório com serviceExternalId, serviceNumber ou pppoeLogin.",
        "properties": {
          "provider": {
            "type": "string",
            "enum": [
              "HUBSOFT",
              "SGP"
            ]
          },
          "serviceExternalId": {
            "type": "string",
            "description": "Identificador do serviço no ERP (id_cliente_servico no HubSoft)"
          },
          "serviceNumber": {
            "type": "string"
          },
          "pppoeLogin": {
            "type": "string"
          },
          "physicalIdentifier": {
            "type": "string",
            "description": "Serial GPON em qualquer codificação, serial do equipamento ou MAC, como o ERP informa"
          },
          "macAddress": {
            "type": "string"
          }
        }
      },
      "IntegrationLink": {
        "type": "object",
        "required": [
          "state",
          "reason",
          "actionAllowed"
        ],
        "properties": {
          "state": {
            "type": "string",
            "enum": [
              "CONFIRMED",
              "UNCONFIRMED",
              "NOT_LINKED",
              "AMBIGUOUS",
              "CONFLICT"
            ],
            "description": "Só CONFIRMED libera ação remota"
          },
          "reason": {
            "type": "string",
            "enum": [
              "SERIAL_MATCH",
              "ASSIGNMENT_SERIAL",
              "HUMAN_CONFIRMED",
              "MAC_ONLY",
              "SERVICE_NOT_MIRRORED",
              "SERVICE_INACTIVE",
              "MULTIPLE_SERVICES",
              "NO_DEVICE",
              "MULTIPLE_DEVICES",
              "ERP_POINTS_TO_OTHER_DEVICE",
              "ERP_IDENTITY_CHANGED",
              "DEVICE_LINKED_TO_OTHER_SERVICE"
            ]
          },
          "actionAllowed": {
            "type": "boolean"
          },
          "serviceExternalId": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "IntegrationDevice": {
        "type": "object",
        "required": [
          "id",
          "serialNumber",
          "online"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "serialNumber": {
            "type": "string"
          },
          "oui": {
            "type": "string"
          },
          "manufacturer": {
            "type": [
              "string",
              "null"
            ]
          },
          "model": {
            "type": [
              "string",
              "null"
            ]
          },
          "firmwareVersion": {
            "type": [
              "string",
              "null"
            ]
          },
          "online": {
            "type": "boolean"
          },
          "lastInformAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      },
      "IntegrationActionAvailability": {
        "type": "object",
        "required": [
          "allowed",
          "blockedBy"
        ],
        "properties": {
          "allowed": {
            "type": "boolean"
          },
          "blockedBy": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "IntegrationLookupResult": {
        "type": "object",
        "required": [
          "source",
          "observedAt",
          "link",
          "device",
          "candidates",
          "actions",
          "mirror"
        ],
        "properties": {
          "source": {
            "type": "string",
            "enum": [
              "NOORIACS"
            ]
          },
          "observedAt": {
            "type": "string",
            "format": "date-time"
          },
          "link": {
            "$ref": "#/components/schemas/IntegrationLink"
          },
          "device": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/IntegrationDevice"
              },
              {
                "type": "null"
              }
            ]
          },
          "candidates": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/IntegrationDevice"
            }
          },
          "actions": {
            "type": "object",
            "required": [
              "reboot",
              "wifi"
            ],
            "properties": {
              "reboot": {
                "$ref": "#/components/schemas/IntegrationActionAvailability"
              },
              "wifi": {
                "$ref": "#/components/schemas/IntegrationActionAvailability"
              }
            }
          },
          "mirror": {
            "type": "object",
            "description": "Atualidade do espelho do ERP. O espelho é sincronizado sob demanda",
            "required": [
              "serviceFound"
            ],
            "properties": {
              "serviceFound": {
                "type": "boolean"
              },
              "serviceLastSeenAt": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              },
              "lastSyncAt": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              }
            }
          }
        }
      },
      "IntegrationActor": {
        "type": "object",
        "required": [
          "type",
          "id"
        ],
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "USER",
              "AUTOMATION",
              "SYSTEM"
            ]
          },
          "id": {
            "type": "string",
            "maxLength": 64
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 80
          }
        }
      },
      "IntegrationActionRequest": {
        "type": "object",
        "required": [
          "target",
          "actor",
          "externalRef"
        ],
        "properties": {
          "target": {
            "$ref": "#/components/schemas/IntegrationTarget"
          },
          "actor": {
            "$ref": "#/components/schemas/IntegrationActor"
          },
          "externalRef": {
            "type": "string",
            "maxLength": 128,
            "description": "Referência do sistema chamador, por exemplo ticket:1001"
          }
        }
      },
      "IntegrationWifiRequest": {
        "allOf": [
          {
            "$ref": "#/components/schemas/IntegrationActionRequest"
          }
        ],
        "type": "object",
        "properties": {
          "band": {
            "type": "string",
            "enum": [
              "2.4GHZ",
              "5GHZ",
              "BOTH"
            ]
          },
          "password": {
            "type": "string",
            "minLength": 8,
            "maxLength": 63,
            "writeOnly": true
          },
          "ssid": {
            "type": "string",
            "maxLength": 32
          }
        }
      },
      "IntegrationLinkRequest": {
        "allOf": [
          {
            "$ref": "#/components/schemas/IntegrationActionRequest"
          }
        ],
        "type": "object",
        "required": [
          "deviceId"
        ],
        "properties": {
          "deviceId": {
            "type": "string",
            "format": "uuid"
          }
        }
      },
      "IntegrationLinkResult": {
        "type": "object",
        "required": [
          "link",
          "deviceId",
          "changed"
        ],
        "properties": {
          "link": {
            "$ref": "#/components/schemas/IntegrationLink"
          },
          "deviceId": {
            "type": "string"
          },
          "changed": {
            "type": "boolean"
          }
        }
      },
      "IntegrationRefreshRequest": {
        "type": "object",
        "required": [
          "actor",
          "externalRef"
        ],
        "properties": {
          "actor": {
            "$ref": "#/components/schemas/IntegrationActor"
          },
          "externalRef": {
            "type": "string"
          },
          "what": {
            "type": "string",
            "enum": [
              "telemetry",
              "connected-devices"
            ]
          }
        }
      },
      "IntegrationRefreshResult": {
        "type": "object",
        "required": [
          "accepted",
          "what",
          "reused"
        ],
        "properties": {
          "accepted": {
            "type": "boolean"
          },
          "what": {
            "type": "string"
          },
          "taskId": {
            "type": [
              "string",
              "null"
            ]
          },
          "reused": {
            "type": "boolean"
          },
          "skipped": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "DEVICE_BUSY",
              "RECENT_COLLECTION",
              "CURRENT_READING",
              null
            ]
          }
        }
      },
      "IntegrationTaskState": {
        "type": "string",
        "enum": [
          "ACCEPTED",
          "SENT",
          "AWAITING_REBOOT",
          "CONFIRMED",
          "UNCONFIRMED",
          "FAILED",
          "EXPIRED"
        ]
      },
      "IntegrationTask": {
        "type": "object",
        "required": [
          "taskId",
          "deviceId",
          "action",
          "state",
          "reason",
          "delivered",
          "terminal",
          "acknowledged",
          "awaitingReboot"
        ],
        "properties": {
          "taskId": {
            "type": "string",
            "format": "uuid"
          },
          "deviceId": {
            "type": "string",
            "format": "uuid"
          },
          "action": {
            "type": "string",
            "enum": [
              "REBOOT",
              "WIFI_CHANGE",
              "WIFI_CHANNEL",
              "READ_REFRESH"
            ]
          },
          "state": {
            "$ref": "#/components/schemas/IntegrationTaskState"
          },
          "reason": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "PASSWORD_NOT_READABLE",
              "CONFIRMATION_WINDOW_ELAPSED",
              "REBOOT_NOT_CONFIRMED",
              "NOT_DELIVERED",
              "VALUE_DIVERGED",
              "CANCELED",
              "DEVICE_FAULT",
              null
            ]
          },
          "delivered": {
            "type": "boolean",
            "description": "false quando o comando não chegou ao equipamento"
          },
          "terminal": {
            "type": "boolean"
          },
          "acknowledged": {
            "type": "boolean",
            "description": "O equipamento respondeu ao comando. Não significa aplicado"
          },
          "awaitingReboot": {
            "type": "boolean"
          },
          "errorCode": {
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "type": "string"
          },
          "dispatchedAt": {
            "type": [
              "string",
              "null"
            ]
          },
          "finishedAt": {
            "type": [
              "string",
              "null"
            ]
          },
          "updatedAt": {
            "type": "string"
          },
          "replayed": {
            "type": "boolean"
          },
          "connectionRequest": {
            "type": [
              "string",
              "null"
            ]
          },
          "delivery": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "IMMEDIATE",
              "NEXT_INFORM",
              null
            ],
            "description": "Só na troca de Wi-Fi. IMMEDIATE: o Connection Request foi aceito e a sessão CWMP já começou. NEXT_INFORM: o ACS não alcança o equipamento de fora (CGNAT, firewall, rota) e a alteração ficou na fila do próximo contato dele. Nulo em repetição por Idempotency-Key e nas outras ações."
          },
          "deliveryMessage": {
            "type": [
              "string",
              "null"
            ],
            "description": "Explicação em português do que aconteceu com a entrega. Nunca contém endereço, credencial nem segredo."
          },
          "bands": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "IntegrationMetric": {
        "oneOf": [
          {
            "type": "null"
          },
          {
            "type": "object",
            "properties": {
              "value": {},
              "unit": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "observedAt": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          }
        ]
      },
      "IntegrationSummary": {
        "type": "object",
        "required": [
          "source",
          "readAt",
          "live",
          "stale",
          "staleAfterSeconds",
          "device",
          "optical",
          "wifi",
          "connectedDevices"
        ],
        "properties": {
          "source": {
            "type": "string",
            "enum": [
              "NOORIACS"
            ]
          },
          "readAt": {
            "type": "string",
            "format": "date-time"
          },
          "lastInformAt": {
            "type": [
              "string",
              "null"
            ]
          },
          "staleAfterSeconds": {
            "type": "integer"
          },
          "stale": {
            "type": "boolean"
          },
          "live": {
            "type": "boolean",
            "enum": [
              false
            ],
            "description": "Sempre false: é a última leitura, não uma consulta ao vivo"
          },
          "device": {
            "$ref": "#/components/schemas/IntegrationDevice"
          },
          "optical": {
            "type": "object",
            "properties": {
              "rx": {
                "$ref": "#/components/schemas/IntegrationMetric"
              },
              "tx": {
                "$ref": "#/components/schemas/IntegrationMetric"
              },
              "temperature": {
                "$ref": "#/components/schemas/IntegrationMetric"
              },
              "ponStatus": {
                "$ref": "#/components/schemas/IntegrationMetric"
              }
            }
          },
          "wan": {
            "type": "object",
            "properties": {
              "status": {
                "$ref": "#/components/schemas/IntegrationMetric"
              },
              "uptime": {
                "$ref": "#/components/schemas/IntegrationMetric"
              }
            }
          },
          "wifi": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "band": {
                  "type": "string"
                },
                "ssid": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "observedAt": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "current": {
                  "type": "boolean"
                }
              }
            }
          },
          "connectedDevices": {
            "type": "object",
            "properties": {
              "available": {
                "type": "boolean"
              },
              "state": {
                "type": "string"
              },
              "observedAt": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "current": {
                "type": "integer"
              },
              "wifi24": {
                "type": "integer"
              },
              "wifi5": {
                "type": "integer"
              },
              "ethernet": {
                "type": "integer"
              }
            }
          },
          "profile": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "homologated": {
                    "type": "boolean"
                  }
                }
              }
            ]
          },
          "alerts": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "lastBootAt": {
            "type": [
              "string",
              "null"
            ]
          },
          "lastReboot": {
            "type": [
              "object",
              "null"
            ]
          },
          "opticalHealthy": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "Sinal óptico dentro da faixa. null sem leitura"
          }
        }
      },
      "IntegrationConnectedDevices": {
        "type": "object",
        "required": [
          "source",
          "readAt",
          "live",
          "available",
          "items"
        ],
        "properties": {
          "source": {
            "type": "string",
            "enum": [
              "NOORIACS"
            ]
          },
          "readAt": {
            "type": "string"
          },
          "live": {
            "type": "boolean"
          },
          "available": {
            "type": "boolean"
          },
          "state": {
            "type": "string"
          },
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "macMasked": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "connection": {
                  "type": "string"
                },
                "band": {
                  "type": "string"
                },
                "ssid": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "signalDbm": {
                  "type": [
                    "number",
                    "null"
                  ]
                },
                "state": {
                  "type": "string"
                },
                "lastSeenAt": {
                  "type": [
                    "string",
                    "null"
                  ]
                }
              }
            }
          },
          "summary": {
            "type": "object"
          },
          "pagination": {
            "type": "object"
          }
        }
      },
      "IntegrationChannelImpact": {
        "type": "object",
        "required": [
          "disconnectsClients",
          "approximateSeconds",
          "message"
        ],
        "properties": {
          "disconnectsClients": {
            "type": "boolean"
          },
          "approximateSeconds": {
            "type": "integer"
          },
          "message": {
            "type": "string",
            "description": "Texto para avisar o cliente antes da troca"
          }
        }
      },
      "IntegrationChannelBand": {
        "type": "object",
        "required": [
          "band",
          "currentChannel",
          "interference",
          "recommendedChannel",
          "conclusive",
          "reason",
          "allowedChannels",
          "channels",
          "canApply",
          "blockedBy"
        ],
        "properties": {
          "band": {
            "type": "string",
            "enum": [
              "2.4GHZ",
              "5GHZ",
              "6GHZ"
            ]
          },
          "currentChannel": {
            "type": "integer"
          },
          "auto": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "widthMHz": {
            "type": [
              "integer",
              "null"
            ]
          },
          "interference": {
            "type": "object",
            "properties": {
              "score": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "level": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "neighbors": {
                "type": "integer",
                "description": "Quantidade de redes vizinhas, sem nomes de terceiros"
              }
            }
          },
          "recommendedChannel": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Só recomendação. Nunca aplica sozinha"
          },
          "conclusive": {
            "type": "boolean"
          },
          "reason": {
            "type": "string"
          },
          "allowedChannels": {
            "type": "array",
            "items": {
              "type": "integer"
            },
            "description": "Permitidos no equipamento e no Brasil"
          },
          "channels": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "channel": {
                  "type": "integer"
                },
                "networks": {
                  "type": "integer"
                },
                "score": {
                  "type": [
                    "number",
                    "null"
                  ]
                },
                "dfs": {
                  "type": "boolean"
                }
              }
            }
          },
          "canApply": {
            "type": "boolean"
          },
          "blockedBy": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "WIFI_CHANNEL_EVIDENCE_STALE",
                "WIFI_CHANNEL_NOT_HOMOLOGATED"
              ]
            }
          }
        }
      },
      "IntegrationChannelView": {
        "type": "object",
        "required": [
          "source",
          "readAt",
          "live",
          "scan",
          "bands",
          "lastChange",
          "impact"
        ],
        "properties": {
          "source": {
            "type": "string",
            "enum": [
              "NOORIACS"
            ]
          },
          "readAt": {
            "type": "string",
            "format": "date-time"
          },
          "live": {
            "type": "boolean",
            "enum": [
              false
            ]
          },
          "scan": {
            "type": "object",
            "required": [
              "supported",
              "code",
              "state"
            ],
            "properties": {
              "supported": {
                "type": "boolean"
              },
              "code": {
                "type": [
                  "string",
                  "null"
                ],
                "enum": [
                  "CHANNEL_SCAN_UNSUPPORTED",
                  null
                ]
              },
              "state": {
                "type": "string"
              },
              "surveyId": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "collectedAt": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          },
          "bands": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/IntegrationChannelBand"
            }
          },
          "lastChange": {
            "type": [
              "object",
              "null"
            ],
            "description": "Última troca, com canal anterior para reverter"
          },
          "impact": {
            "$ref": "#/components/schemas/IntegrationChannelImpact"
          }
        }
      },
      "IntegrationChannelScan": {
        "type": "object",
        "required": [
          "state",
          "surveyId"
        ],
        "properties": {
          "state": {
            "type": "string",
            "enum": [
              "PREPARING",
              "SCANNING"
            ],
            "description": "PREPARING: repita o pedido até SCANNING"
          },
          "surveyId": {
            "type": [
              "string",
              "null"
            ]
          },
          "reused": {
            "type": "boolean"
          }
        }
      },
      "IntegrationChannelRequest": {
        "type": "object",
        "required": [
          "target",
          "actor",
          "externalRef",
          "band"
        ],
        "description": "Informe channel, auto=true ou revert=true.",
        "properties": {
          "target": {
            "$ref": "#/components/schemas/IntegrationLookupRequest"
          },
          "actor": {
            "type": "object"
          },
          "externalRef": {
            "type": "string"
          },
          "band": {
            "type": "string",
            "enum": [
              "2.4GHZ",
              "5GHZ",
              "6GHZ"
            ]
          },
          "channel": {
            "type": "integer"
          },
          "auto": {
            "type": "boolean"
          },
          "revert": {
            "type": "boolean"
          }
        }
      },
      "IntegrationChannelChange": {
        "type": "object",
        "required": [
          "taskId",
          "deviceId",
          "action",
          "state",
          "previous",
          "impact"
        ],
        "properties": {
          "taskId": {
            "type": "string",
            "format": "uuid"
          },
          "deviceId": {
            "type": "string",
            "format": "uuid"
          },
          "action": {
            "type": "string",
            "enum": [
              "REBOOT",
              "WIFI_CHANGE",
              "WIFI_CHANNEL",
              "READ_REFRESH"
            ]
          },
          "state": {
            "$ref": "#/components/schemas/IntegrationTaskState"
          },
          "reason": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "PASSWORD_NOT_READABLE",
              "CONFIRMATION_WINDOW_ELAPSED",
              "REBOOT_NOT_CONFIRMED",
              "NOT_DELIVERED",
              "VALUE_DIVERGED",
              "CANCELED",
              "DEVICE_FAULT",
              null
            ]
          },
          "delivered": {
            "type": "boolean",
            "description": "false quando o comando não chegou ao equipamento"
          },
          "terminal": {
            "type": "boolean"
          },
          "acknowledged": {
            "type": "boolean",
            "description": "O equipamento respondeu ao comando. Não significa aplicado"
          },
          "awaitingReboot": {
            "type": "boolean"
          },
          "errorCode": {
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "type": "string"
          },
          "dispatchedAt": {
            "type": [
              "string",
              "null"
            ]
          },
          "finishedAt": {
            "type": [
              "string",
              "null"
            ]
          },
          "updatedAt": {
            "type": "string"
          },
          "replayed": {
            "type": "boolean"
          },
          "connectionRequest": {
            "type": [
              "string",
              "null"
            ]
          },
          "bands": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "previous": {
            "type": "object",
            "properties": {
              "channel": {
                "type": "integer"
              },
              "auto": {
                "type": "boolean"
              }
            }
          },
          "impact": {
            "$ref": "#/components/schemas/IntegrationChannelImpact"
          }
        }
      },
      "WebhookSubscription": {
        "type": "object",
        "required": [
          "id",
          "url",
          "events",
          "enabled"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "url": {
            "type": "string",
            "format": "uri",
            "description": "Destino HTTPS. Endereco nao publico e recusado no cadastro."
          },
          "events": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "task.completed",
                "device.online",
                "device.offline"
              ]
            }
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "enabled": {
            "type": "boolean",
            "description": "Desligada automaticamente apos 20 falhas seguidas."
          },
          "disabledReason": {
            "type": "string",
            "nullable": true,
            "enum": [
              "TOO_MANY_FAILURES",
              null
            ]
          },
          "consecutiveFailures": {
            "type": "integer"
          },
          "lastDeliveryAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "lastStatus": {
            "type": "string",
            "nullable": true,
            "enum": [
              "SENT",
              "FAILED",
              "PENDING",
              "UNKNOWN",
              null
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "WebhookEnvelope": {
        "type": "object",
        "description": "Corpo entregue no POST. Repeticao e possivel: use `id` para descartar o que ja tratou.",
        "required": [
          "id",
          "event",
          "occurredAt",
          "data"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Identificador do FATO. Igual ao cabecalho X-Noori-Delivery."
          },
          "event": {
            "type": "string",
            "enum": [
              "task.completed",
              "device.online",
              "device.offline"
            ]
          },
          "occurredAt": {
            "type": "string",
            "format": "date-time"
          },
          "apiVersion": {
            "type": "string",
            "example": "v1"
          },
          "product": {
            "type": "string",
            "example": "NOORI_ACS"
          },
          "data": {
            "type": "object",
            "additionalProperties": true
          }
        }
      }
    }
  }
}
