---
updatedAt: 2026-05-28T19:21:10.000Z
agentTools:
  projectIndex: https://docs.notagateway.com.br/llms.txt
---

# Cancelar (IdExterno)

Cancela uma nota fiscal identificada pelo seu Id Externo (paramêtro {idExterno})

# OpenAPI definition

```json
{
  "openapi": "3.1.0",
  "info": {
    "title": "visão-geral",
    "version": "1"
  },
  "servers": [
    {
      "url": "https://api.notagateway.com.br"
    }
  ],
  "components": {
    "securitySchemes": {
      "sec0": {
        "type": "apiKey",
        "in": "header",
        "name": "Authorization",
        "x-bearer-format": "basic"
      }
    }
  },
  "security": [
    {
      "sec0": []
    }
  ],
  "paths": {
    "/v1/empresas/{empresaId}/nfes/porIdExterno/{idExterno}": {
      "delete": {
        "summary": "Cancelar (IdExterno)",
        "description": "Cancela uma nota fiscal identificada pelo seu Id Externo (paramêtro {idExterno})",
        "operationId": "cancelar-nota-fiscal-por-id-externo",
        "parameters": [
          {
            "name": "empresaId",
            "in": "path",
            "description": "Identificador único da Empresa relacionada a Nota Fiscal que deseja requisitar",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "name": "idExterno",
            "in": "path",
            "description": "Identificador externo único da Nota Fiscal que deseja cancelar",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "name": "Accept",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "default": "application/json"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "200",
            "content": {
              "application/json": {
                "examples": {
                  "Result": {
                    "value": "{\n  \"nfeId\": \"string\"\n}"
                  }
                },
                "schema": {
                  "type": "object",
                  "properties": {
                    "nfeId": {
                      "type": "string",
                      "example": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "400",
            "content": {
              "application/json": {
                "examples": {
                  "Result": {
                    "value": "{\n    \"Message\": \"The request is invalid.\"\n}"
                  }
                },
                "schema": {
                  "type": "object",
                  "properties": {
                    "Message": {
                      "type": "string",
                      "example": "The request is invalid."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "401",
            "content": {
              "application/json": {
                "examples": {
                  "Result": {
                    "value": "[\n    {\n        \"codigo\": \"AUT002\",\n        \"mensagem\": \"Acesso negado. APIKey invalida, por favor verifique se setou o header do request corretamente com uma APIKey válida, por exemplo: \\\"Authorization: Basic {your-APIKey-here}\\\".\"\n    }\n]"
                  }
                },
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "codigo": {
                        "type": "string",
                        "example": "AUT002"
                      },
                      "mensagem": {
                        "type": "string",
                        "example": "Acesso negado. APIKey invalida, por favor verifique se setou o header do request corretamente com uma APIKey válida, por exemplo: \"Authorization: Basic {your-APIKey-here}\"."
                      }
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "403",
            "content": {
              "application/json": {
                "examples": {
                  "Result": {
                    "value": "[\n    {\n        \"codigo\": \"AUT001\",\n        \"mensagem\": \"Acesso negado. APIKey invalida, por favor verifique se ela está correta.\"\n    }\n]"
                  }
                },
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "codigo": {
                        "type": "string",
                        "example": "AUT001"
                      },
                      "mensagem": {
                        "type": "string",
                        "example": "Acesso negado. APIKey invalida, por favor verifique se ela está correta."
                      }
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "500",
            "content": {
              "text/plain": {
                "examples": {
                  "Result": {
                    "value": "Erro interno do servidor"
                  }
                }
              }
            }
          }
        },
        "deprecated": false,
        "x-readme": {
          "code-samples": [
            {
              "language": "csharp",
              "code": "public string CancelarNFporIdExternoAsync(Guid empresaId, string idExterno)\n{\n  try\n  {\n    using (var httpClient = new HttpClient())\n    {\n      httpClient.DefaultRequestHeaders.Clear();\n      httpClient.DefaultRequestHeaders.Add(\"Authorization\", \"Basic {Sua-ApiKey-Aqui}\");\n      httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(\"application/json\"));\n\n      using (var request = new HttpRequestMessage(HttpMethod.Delete, string.Format(\"https://api.enotasgw.com.br/v1/empresas/{0}/nfes/porIdExterno/{1}\", empresaId, idExterno)))\n      {\n        using (var response = httpClient.SendAsync(request).Result)\n        {\n          var resultContent = response.Content.ReadAsStringAsync().Result;\n\n          if (response.IsSuccessStatusCode)\n          {\n            return resultContent;\n          }\n          else\n          {\n            throw new Exception(((int)response.StatusCode) + \" - \" + response.ReasonPhrase);\n          }\n        }\n      }\n    }\n  }\n  catch (Exception)\n  {\n    throw;\n  }\n}",
              "name": "Exemplo C#"
            },
            {
              "language": "php",
              "code": "<?php\n\theader('Content-Type: text/html; charset=utf-8');\n\t\n\trequire('../src/eNotasGW.php');\n\t\n\tuse eNotasGW\\Api\\Exceptions as Exceptions;\n\n\teNotasGW::configure(array(\n\t\t'apiKey' => '<api key>'\n\t));\n\t\n\t$empresaId = 'a9f9d282-fdb9-4259-a7b8-2f19be4da06d';\n\t\n\ttry\n\t{\t\t\n\t\t$idExterno = '1';\n\t\teNotasGW::$NFeApi->cancelarPorIdExterno($empresaId, $idExterno);\n\t\t\n\t\techo 'Cancelamento solicitado com sucesso!';\n\t}\n\tcatch(Exceptions\\invalidApiKeyException $ex) {\n\t\techo 'Erro de autenticação: </br></br>';\n\t\techo $ex->getMessage();\n\t}\n\tcatch(Exceptions\\unauthorizedException $ex) {\n\t\techo 'Acesso negado: </br></br>';\n\t\techo $ex->getMessage();\n\t}\n\tcatch(Exceptions\\apiException $ex) {\n\t\techo 'Erro de validação: </br></br>';\n\t\techo $ex->getMessage();\n\t}\n\tcatch(Exceptions\\requestException $ex) {\n\t\techo 'Erro na requisição web: </br></br>';\n\t\t\n\t\techo 'Requested url: ' . $ex->requestedUrl;\n\t\techo '</br>';\n\t\techo 'Response Code: ' . $ex->getCode();\n\t\techo '</br>';\n\t\techo 'Message: ' . $ex->getMessage();\n\t\techo '</br>';\n\t\techo 'Response Body: ' . $ex->responseBody;\n\t}\n?>",
              "name": "Exemplo PHP"
            }
          ],
          "samples-languages": [
            "csharp",
            "php"
          ]
        }
      }
    }
  },
  "x-readme": {
    "headers": [],
    "explorer-enabled": true,
    "proxy-enabled": true
  },
  "x-readme-fauxas": true
}
```