# Informações gerais

### Ambientes / Hosts

A Blue Fleet possui infraestrutura completamente separada para os ambientes de Sandbox e Produção.

O ambiente de Sandbox foi criado para os desenvolvedores realizarem seus testes, validações e integração. Quando tudo estiver pronto e homologado, apenas as variáveis de Host e Access Token precisarão ser atualizadas para o ambiente de produção.

Os ambientes estão sempre na mesma versão, portanto quando ocorre uma atualização em Produção, a mesma atualização ocorre no ambiente Sandbox.

| AMBIENTE | HOST                                                                |
| -------- | ------------------------------------------------------------------- |
| Produção | [https://api.bluefleet.com.br](https://api.bluefleet.com.br/)       |
| Sandbox  | [https://api.qa.bluefleet.com.br](https://api.qa.bluefleet.com.br/) |

### Autenticação <a href="#autenticacao" id="autenticacao"></a>

A API da Blue Fleet utiliza o padrão de autenticação OAuth2.0 com Client Credentials.

É desejável que você possua conhecimento prévio do protocolo de autenticação OAuth2.0 com Cliente Credentials: <https://www.oauth.com/oauth2-servers/access-tokens/client-credentials>

Para realizar a autenticação você deve obter previamente o `client_id` e `client_secret` para utilização da API. Caso não possua estes dados, solicite para equipe de suporte através do e-mail <suporte@bluefleet.com.br>.

A geração do token deve ser inicialmente autenticada com Basic Access Authentication [Basic access authentication](https://en.wikipedia.org/wiki/Basic_access_authentication), e feita a partir de uma requisição https via método POST no endereço abaixo:

| AMBIENTE | URL                                              |
| -------- | ------------------------------------------------ |
| Produção | <https://auth.bluefleet.com.br/connect/token>    |
| Sandbox  | <https://auth.qa.bluefleet.com.br/connect/token> |

### **Geração do Basic Authentication Token**

Para gerar um token de autenticação, é necessário codificar o `client_id` e o `client_secret` em `BASE64`, seguindo o formato abaixo:

token = base64\_encode(client\_id + ':' + client\_secret)

#### **Exemplo de obtenção de token**

POST <https://auth.bluefleet.com.br/connect/tokenHeaders:Accept>: application/jsonAuthorization: Basic \<BASE64\_ENCODED\_TOKEN>Content-Type: application/x-www-form-urlencodedBody:grant\_type=client\_credentials

Abaixo um exemplo de um request em cURL:

```bash
curl -X POST --location 'https://auth.bluefleet.com.br/connect/token' \
--header 'Authorization: Basic <BASE64_ENCODED_TOKEN>' \
--header 'Accept: application/json' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'grant_type=client_credentials'
```

> Obtenha um `client_id` e `client_secret` válidos enviando um e-mail para <suporte@bluefleet.com.br>

O resultado desta requisição será um JWT Access Token que deverá ser utilizado nas chamadas da API.

{% code overflow="wrap" fullWidth="false" %}

```json
{
    "access_token": "eyJhbGciOiJSUzI1NiIsImtpZCI6IjMyMUUzMzk1MTc3RkY4REU4RTg4NkU0Qzk3MUM4RDZFIiwidHlwIjoiYXQrand0In0.eyJuYmYiOjE2ODQxNjI5OTUsImV4cCI6MTY4NDE2NjU5NSwiaXNzIjoiaHR0cHM6Ly9hdXRoLnFhLmJsdWVmbGVldC5jb20uYnIiLCJhdWQiOiJiZi1wdWJsaWMtYXBpIiwiY2xpZW50X2lkIjoiNGRlY2IwNmYtNmNmMi00NTdmLWIwZGUtMGI1OTI3ZDZjYzZlIiwiY2xpZW50X3VzZXJfaWQiOiIxMjYzNyIsImp0aSI6Ijc2RjVBRUNGQjE2OTZGQTBGNDA2RTIzQzIwQ0U0QjhCIiwiaWF0IjoxNjg0MTYyOTk1LCJzY29wZSI6WyJiZi1wdWJsaWMtYXBpIl19.msx5wAT7KS1Q2WWh3NDwN_caBc7FBX_0waQdRfbLW4_5YRmic4ZfRShCJaIbmPGcMzKG8FK0tbRBFInZrAXBxtcIzI-fere5Ns7yvfCnhXN_4Bv_7-5qz9ovWFqIkqo3rn1gIQGhUR8mpawTl1QzBIQ3J64SRoUTiE5JTjpmfx3HlOgBCSz9Ucw04v3wIYMEdCrH_uryy3flUR6gjKeWlZumEiw4VHeBQDTDnOzH49qBNd4ycu9S0bfFWr-kwGCvBoPswKnHqqcb7p7tFoz51QIfWlYV3PdyWDWkxWg4LFoLFF-ZIDUdwZzt1D7HYdFvhcY_j7anYJ8zlYocXKZHXA",
    "expires_in": 3600,
    "token_type": "Bearer",
    "scope": "bf-public-api"
}
```

{% endcode %}

Por padrão o Access Token expira em uma hora. Após este período um novo Access Token deve ser gerado.

#### Formatação de datas <a href="#formatacao-de-datas" id="formatacao-de-datas"></a>

Para padronização, todas as datas devem ser formatadas de acordo com a norma [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601), por exemplo:

`2022-09-10T18:32:10.335-03:00`

As respostas das requisições sempre estarão no fuso horário UTC.


---

# Agent Instructions: 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:

```
GET https://developers.bluefleet.com.br/home/api-rest/informacoes-gerais.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
