> For the complete documentation index, see [llms.txt](https://developers.make.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.make.com/custom-apps-documentation/best-practices/connections.md).

# Connections

Every connection should have a way to check if the used API key (token) is valid (a validation endpoint).

This means that each connection should have a part that uses the API key (token) against an endpoint that requires **only** the API key to run. For example, a user info endpoint, or any endpoint that is used to list data.

The validation endpoint is located:

* OAuth1 and OAuth2 - in the `info` directive
* API key, basic auth, digest auth, other - in the `url` in the Communication tab

{% hint style="info" %}
There are APIs that don't have a validation endpoint. In this case, it is recommended to call an endpoint that will work in every case and, if possible, will return the account's data, e. g. an endpoint `/about` or `/me`, etc.
{% endhint %}

{% tabs %}
{% tab title="Correct API Key" %}

<div align="left"><figure><img src="https://1562974717-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNS0mCBwODiYtOVXjc6qf%2Fuploads%2Fgit-blob-f8dff6d7f7fb95baba745f547f6a94ff0957cd7b%2Fconnection_correctAPIkey.png?alt=media" alt="" width="563"><figcaption></figcaption></figure></div>

{% hint style="info" %}
The API key is checked against the `/whoami` endpoint. If the API key is incorrect, this returns an error and the connection won't be created.
{% endhint %}
{% endtab %}

{% tab title="Correct OAuth 2.0" %}

```json
{
    "authorize": {
        ...
    },
    "token": {
        ...
    },
    "info": {
        "url": "https://api.dropboxapi.com/2/users/get_current_account",
        "method": "POST",
        "headers": {
            "authorization": "Bearer {{connection.accessToken}}"
        },
        "body": "{{null}}",
        "response": {
            "uid": "{{body.account_id}}",
            "metadata": {
                "type": "email",
                "value": "{{body.email}}"
            },
            "error": {
                "message": "[{{statusCode}}] {{if(body.error_summary, body.error_summary, body)}}"
            },
            "data": {
                "root_namespace_id": "{{body.root_info.root_namespace_id}}"
            }
        },
        "log": {
            "sanitize": [
                "request.headers.authorization"
            ]
        }
    },
    "invalidate": {
        ...
    }
}
```

{% hint style="info" %}
The `info` directive of the Dropbox OAuth 2.0 connection validates the access token against the endpoint that returns the current account.
{% endhint %}
{% endtab %}
{% endtabs %}

## Error handling

Error handling in connections follows the same rules as [error handling in the base](/custom-apps-documentation/best-practices/base/error-handling.md).

The only difference is where you define it. For example, in OAuth 2.0 connections, define the `error` directive in the `response` of the `info` directive, and of other requests such as `token`, if needed.


---

# 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://developers.make.com/custom-apps-documentation/best-practices/connections.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.
