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

# Authentication

> Documentation for the Fasten Connect API

## Authentication

All sensitive API endpoints require authentication using the Public ID & Private Key generated in the Fasten Connect dashboard.

This is done using [Basic Authentication](https://en.wikipedia.org/wiki/Basic_access_authentication), where the Public ID is the username and the Private Key is the password.

<Warning>
  Remember, when generating the Basic Auth header manually, the Public Id and Private Key must be concatenated with a colon `:` and then base64 encoded.
  The resulting string should be prefixed with `Basic ` and included in the `Authorization` header of the request.

  For example, if your Public ID is `public_test_123456324234234` and your Private Key is `private_test_9u2orjsd02lk3)i03423`,
  then the field's value is the Base64 encoding of `public_test_123456324234234:private_test_9u2orjsd02lk3)i03423`.

  Then the Authorization header field will appear as:

  ```http theme={null}
  Authorization: Basic cHVibGljX3Rlc3RfMTIzNDU2MzI0MjM0MjM0OnByaXZhdGVfdGVzdF85dTJvcmpzZDAybGszKWkwMzQyMwo=
  ```
</Warning>

<CodeGroup>
  ```bash cURL theme={null}
  # The following Curl examples are equivalent.
  # `-u` is the shorthand for `--user`, and can be used to avoid manually encoding the credentials.

  curl -u 'public_test_123456324234234':'private_test_9u2orj....sd02lk3)i03423' \
  -X POST \
  --data '{"org_connection_id":"ebea708d-c5fa-4294-9051-da48ef08c78a"}' \
  https://api.connect.fastenhealth.com/v1/bridge/fhir/ehi-export



  curl -H 'Authorization: Basic cHVibGljX3Rlc3RfMTIzNDU2MzI0MjM0MjM0OnByaXZhdGVfdGVzdF85dTJvcmpzZDAybGszKWkwMzQyMwo=' \
  -X POST \
  --data '{"org_connection_id":"ebea708d-c5fa-4294-9051-da48ef08c78a"}' \
  https://api.connect.fastenhealth.com/v1/bridge/fhir/ehi-export

  ```

  ```go Go theme={null}
  publicID := "public_test_123456324234234"
  privateKey := "private_test_9u2orjsd02lk3)i03423"

  // Concatenate the Public ID and Private Key with a colon
  authString := publicID + ":" + privateKey

  // Base64 encode the concatenated string
  encodedAuth := base64.StdEncoding.EncodeToString([]byte(authString))

  // Create the Authorization header value
  authHeader := "Basic " + encodedAuth

  // Example HTTP request
  req, err := http.NewRequest("POST", "https://api.connect.fastenhealth.com/v1/bridge/....", nil)
  if err != nil {
      fmt.Println("Error creating request:", err)
      return
  }

  // Add the Authorization header
  req.Header.Add("Authorization", authHeader)
  client := &http.Client{}
  resp, err := client.Do(req)
  ```

  ```javascript JavaScript/Node.js theme={null}
  const https = require('https');

  // Public ID and Private Key
  const publicID = 'public_test_123456324234234';
  const privateKey = 'private_test_9u2orjsd02lk3)i03423';

  // Concatenate the Public ID and Private Key with a colon
  const authString = `${publicID}:${privateKey}`;

  // Base64 encode the concatenated string
  const encodedAuth = Buffer.from(authString).toString('base64');

  // Create the Authorization header value
  const authHeader = `Basic ${encodedAuth}`;

  // Example HTTP request options
  const options = {
      hostname: 'api.connect.fastenhealth.com',
      port: 443,
      path: '/v1/bridge/....',
      method: 'POST',
      headers: {
          'Authorization': authHeader,
          'Content-Type': 'application/json',
      },
  };

  // Send the HTTP request
  const req = https.request(options, (res) => {
      console.log(`Status Code: ${res.statusCode}`);
  });
  req.end();
  ```

  ```python Python theme={null}
  import requests
  from requests.auth import HTTPBasicAuth

  # Public ID and Private Key
  public_id = "public_test_123456324234234"
  private_key = "private_test_9u2orjsd02lk3)i03423"

  # API endpoint
  url = "https://api.connect.fastenhealth.com/v1/bridge/...."

  # Make the POST request with Basic Authentication
  response = requests.post(url, auth=HTTPBasicAuth(public_id, private_key))
  ```

  ```java Java theme={null}
  String publicId = "public_test_123456324234234";
  String privateKey = "private_test_9u2orjsd02lk3)i03423";
  String endpoint = "https://api.connect.fastenhealth.com/v1/bridge/...";

  // Concatenate Public ID and Private Key with a colon
  String authString = publicId + ":" + privateKey;

  // Base64 encode the concatenated string
  String encodedAuth = Base64.getEncoder().encodeToString(authString.getBytes());

  // Create the Authorization header value
  String authHeader = "Basic " + encodedAuth;

  // Create the HTTP connection
  URL url = new URL(endpoint);
  HttpURLConnection connection = (HttpURLConnection) url.openConnection();
  connection.setRequestMethod("POST");
  connection.setRequestProperty("Authorization", authHeader);
  connection.setRequestProperty("Content-Type", "application/json");
  connection.setDoOutput(true);
  os.flush();
  ```
</CodeGroup>

### Curl Example
