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

# Authentication

> How the SDK obtains and refreshes tokens

# SDK Authentication

Your backend sends your `Api-Key` and `Customer-Id` to the `/auth` endpoint and receives a **Bearer token**.\
You then attach this token to all IdCanopy API calls (e.g., Handshake).

## Configure

<Tabs>
  <Tab title="Node (JS/TS)">
    ```ts theme={null}
    // Obtain a token from the IdCanopy Auth endpoint
    const authResponse = await fetch(
      "https://api-umbrella.io/api/services/auth",
      {
        method: "POST",
        headers: {
          "Content-Type": "application/x-www-form-urlencoded",
          "Api-Key": process.env.IDCANOPY_API_KEY!,
          "Customer-Id": process.env.IDCANOPY_CUSTOMER_ID!
        }
      }
    );

    if (!authResponse.ok) {
      throw new Error("Authentication failed");
    }

    const { access_token, expires_in } = await authResponse.json();

    // Use this bearer token for all further API calls
    const token = access_token;

    // Example: call the Handshake endpoint
    await fetch("https://api-umbrella.io/api/services/sdk/universal/handshake", {
      method: "POST",
      headers: {
        "Authorization": `Bearer ${token}`,
        "Content-Type": "application/json"
      },
      body: JSON.stringify(handshakeDto)
    });
    ```
  </Tab>
</Tabs>

<Note> Under the hood, the SDK calls the same `/auth` endpoint documented in [API Authentication](/authentication) and caches the token until it expires. </Note>
