Pular para o conteúdo

Insomnia

Import the API into Insomnia with environments and authentication ready, and send your first request.

Import the API into Insomnia to get every endpoint in one collection, organised in folders, with environments and authentication ready.

By the end of this guide

You will have the collection imported into Insomnia, an environment selected, your token set and a request sent.

Before you start

Keep your token safe

Do not publish your token in public workspaces, screenshots, repositories or chats. Use sandbox tokens (sk_hmlg_) while testing.

1. Download the file

A single file holds the collection and every environment.

NinePay APIExportação do Insomnia (formato v4) · 1 ambiente

2. Import into Insomnia

  1. In Insomnia, open the project that will hold the collection and click Import.
  2. Choose File and pick the downloaded file, or choose URL and paste the file address (below).
  3. Click Scan, review the summary and confirm with Import. A collection named after the API is created, with one folder per API Reference group.

Address for importing from a URL:

Text
https://docs.ninepay.com.br/insomnia/ninepay-api.insomnia.json

Alternative: the Postman collection

Insomnia also imports the Postman collection (format v2.1). Use it if your team already works with it.

3. Pick the environment

The collection has a base environment and one sub environment per API server, each with the baseUrl variable:

Sub environmentBase URL (baseUrl)
Servidor de Testes (sandbox)https://api.sandbox.cefispay.com.br/api/v1
Servidor de Produção (production)https://payments.cefis.com.br/api/v1

In the environment selector above the request list, pick the sub environment. Without one, the base environment applies (the first server, the sandbox).

4. Enter your token

Every request already has authentication set on its Auth tab, using the variable below, which starts empty:

VariableUseReference
tokenAccess token, sent as Authorization: Bearer <token>{{ _.token }}

Open Manage Environments (in the environment selector), select the sub environment in use and fill in the variable value. Changes are saved automatically.

5. Send a request

  1. Open a folder of the collection and select an endpoint.
  2. Check the URL and the Params (path variables and optional parameters, which start disabled) and Headers tabs.
  3. Adjust the example body on the Body tab, when there is one.
  4. Click Send and check the status and the response body.

A 2xx status means success. The exact code and response format are on the endpoint page in the API Reference.

Common errors

ProblemWhat to check
The import finds no requestsWhether you picked the .insomnia.json file from this page (or its full URL) and it downloaded completely.
401 or 403Whether the token variable is filled in on the selected sub environment and the token belongs to the same environment as the URL.
URL with an empty _.baseUrlWhether a sub environment is selected or the base environment has baseUrl set.
400 or 422Whether the body is valid JSON and follows the fields described on the endpoint page.

Updates

To get new or changed endpoints, import the file again. To compare with the previous version before replacing it, import it into a separate project.

Next steps