---
agentTools:
  projectIndex: https://docs.ninepay.com.br/llms.txt
  projectSearch: https://docs.ninepay.com.br/agentSearch?query=term1%20term2
---

# 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

- Install [Insomnia](https://insomnia.rest/download).
- Have an API token for the environment you are going to test (see [Authentication](/docs/authentication) and [Test Environment](/docs/sandbox-en)).

> ⚠️ 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 API — arquivo do Insomnia](https://docs.ninepay.com.br/insomnia/ninepay-api.insomnia.json)

## 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](/docs/postman-en) (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 environment | Base 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:

| Variable | Use | Reference |
| --- | --- | --- |
| `token` | Access 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

| Problem | What to check |
| --- | --- |
| The import finds no requests | Whether you picked the `.insomnia.json` file from this page (or its full URL) and it downloaded completely. |
| `401` or `403` | Whether 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 `_.baseUrl` | Whether a sub environment is selected or the base environment has `baseUrl` set. |
| `400` or `422` | Whether 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

- [Browse the API Reference](/reference/criar-novo-pagamento)
- [Use the Postman collection](/docs/postman-en)
- [See all collections](/docs/collections-en)
