Deletar unidade operacional

Este endpoint exclui uma unidade operacional identificada pelo externalCode.

Rota: DELETE /os/v1/operation-units/external/{externalCode}

Regras de negócio e restrições

A exclusão não é permitida se:

  • Houver posições vinculadas à unidade.
  • Houver unidades filhas (filhas na hierarquia).

Resposta de sucesso (200)

HTTP 200 sem payload no corpo (exclusão concluída).

Exemplo de requisição (cURL)

curl --request DELETE \
     --url 'https://api.gupy.io/os/v1/operation-units/external/SP-001' \
     --header 'accept: application/json' \
     --header 'Authorization: Bearer bearer_token_value_here'

Atenção: Substitua SP-001 pelo código externo.

Possíveis erros

Unidade não encontrada (404)

{
  "statusCode": 404,
  "message": "Operation unit with external code OU-MISSING was not found",
  "errors": [
    {
      "code": "NOT_FOUND",
      "message": "Operation unit with external code OU-MISSING was not found"
    }
  ]
}

Unidade com dependências (422)

Posições ou unidades filhas vinculadas:

{
  "statusCode": 422,
  "message": "The operation unit cannot be deleted: active relationships with 1 position(s)",
  "errors": [
    {
      "code": "OPERATION_UNIT_HAS_ACTIVE_DEPENDENCIES",
      "message": "The operation unit cannot be deleted: active relationships with 1 position(s)"
    }
  ]
}

Não autenticado (401)

Token ausente ou inválido.