> For the complete documentation index, see [llms.txt](https://kb.stoque.com.br/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kb.stoque.com.br/zeev/apis/all/access/roles/consult.md).

# Consultar função

## Como obter uma função específica utilizando API?

É possível obter os dados de uma função específica utilizando API através de dois endpoints diferentes:

* **Autenticação**: Primeiro obtenha um [token de autenticação](https://kb.zeev.it/apis/como-gerar-tokens-para-autenticar-nas-apis) com permissão de realizar essa operação;
* Utilize:
  * [#api-2-positions-positionid](#api-2-positions-positionid "mention") se desejar obter a função utilizando como filtro o parâmetro positionid que é o código identificaor da função;
  * [#api-2-positions-code-positioncode](#api-2-positions-code-positioncode "mention") se desejar obter a função utilizando como filtro o parâmetro postioncode que é o código original/integração da função;
* **oData**: opcionalmente, utilize [regras oData](https://kb.stoque.com.br/zeev/apis/como-utilizar-as-apis-do-zeev/como-realizar-filtros-e-manipulacoes-adicionais-nas-apis-com-odata.md) para manipular o resultado da API. Essa API aceita `$select.`

Tanto o código identificador quanto o código original podem ser obtidos na página Acesso > Funções ou através de consultas de API como em [#como-listar-as-funcoes-utilizando-api](#como-listar-as-funcoes-utilizando-api "mention")

{% openapi src="/files/DYIxvabeLXa2mL6uE2si" path="/api/2/positions/{positionid}" method="get" %}
[ZeevApi's\_new.json](https://3371003943-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MD66pBdRalAQgnhNstG%2Fuploads%2Ff5huLIsAqm88oSjkTavv%2FZeevApi's_new.json?alt=media\&token=aae47f9f-90ca-48d0-b250-fc38fe74e6c0)
{% endopenapi %}

{% openapi src="/files/DYIxvabeLXa2mL6uE2si" path="/api/2/positions/code/{positioncode}" method="get" %}
[ZeevApi's\_new.json](https://3371003943-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MD66pBdRalAQgnhNstG%2Fuploads%2Ff5huLIsAqm88oSjkTavv%2FZeevApi's_new.json?alt=media\&token=aae47f9f-90ca-48d0-b250-fc38fe74e6c0)
{% endopenapi %}

Exemplos de requisição para obter dados de uma função específica

{% tabs %}
{% tab title="Node.js (Utilizando positionId)" %}

```javascript
let positionId = 573;

const myHeaders = new Headers();
myHeaders.append("Accept", "application/json");
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", "Bearer TOKEN_DO_USUARIO");

const requestOptions = {
  method: "GET",
  headers: myHeaders
};

try {
  const response = await fetch(`https://seu_endereco.do.zeev/api/2/positions/code/${positionId}/users`, requestOptions);
  const result = await response.json();
  console.log(result)
} catch (error) {
  console.error(error);
};
```

{% endtab %}

{% tab title="Node.js (Utilizando positionCode)" %}

```javascript
let positionCode = "p0s1Tion";

const myHeaders = new Headers();
myHeaders.append("Accept", "application/json");
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", "Bearer TOKEN_DO_USUARIO");

const requestOptions = {
  method: "GET",
  headers: myHeaders
};

try {
  const response = await fetch(`https://seu_endereco.do.zeev/api/2/positions/code/${positionCode}/users`, requestOptions);
  const result = await response.json();
  console.log(result)
} catch (error) {
  console.error(error);
};
```

{% endtab %}
{% endtabs %}

***


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://kb.stoque.com.br/zeev/apis/all/access/roles/consult.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
