> ## Documentation Index
> Fetch the complete documentation index at: https://docs.carbn.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Authentication

> Learn how to authenticate with the Carbn Connect API

Carbn uses API keys to authenticate your requests. You can generate them from the [dashboard](https://dashboard.carbnconnect.com/app/keys).

<Warning>
  API keys are shown only once at the time of creation. Be sure to copy and store them securely, they cannot be retrieved later.
</Warning>

### How Authentication Works

* Pass your API key in the `x-api-key` header using HTTP Basic Auth.
* No username or password is required, just the API key.
* All requests must be made over HTTPS; requests over plain HTTP are rejected.
* Invalid or missing keys will return a 401 Unauthorized.

<Danger>
  Keep your API keys secure. They grant full access to your account and should never be shared publicly or within internal tools like Slack or Dashboards.
</Danger>

### Sample Request

<CodeGroup>
  ```bash cURL theme={null}
  curl --location --request GET 'https://api.carbnconnect.com/onboarding/api/v1/users/all' \
  --header 'Content-Type: application/json' \
  --header 'x-api-key: <api-key>'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://api.carbnconnect.com/onboarding/api/v1/users/all', {
    headers: {
      'Content-Type': 'application/json',
      'x-api-key': '<api-key>'
    }
  });
  ```

  ```python Python theme={null}
  import requests

  headers = {
      'Content-Type': 'application/json',
      'x-api-key': '<api-key>'
  }

  response = requests.get(
      'https://api.carbnconnect.com/onboarding/api/v1/users/all',
      headers=headers
  )
  ```

  ```java Java theme={null}
  import java.net.http.HttpClient;
  import java.net.http.HttpRequest;
  import java.net.http.HttpResponse;
  import java.net.URI;

  HttpClient client = HttpClient.newHttpClient();
  HttpRequest request = HttpRequest.newBuilder()
      .uri(URI.create("https://api.carbnconnect.com/onboarding/api/v1/users/all"))
      .header("Content-Type", "application/json")
      .header("x-api-key", "<api-key>")
      .GET()
      .build();

  HttpResponse<String> response = client.send(request, 
      HttpResponse.BodyHandlers.ofString());
  ```
</CodeGroup>
