Skip to main content

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

// 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)
});
Under the hood, the SDK calls the same /auth endpoint documented in API Authentication and caches the token until it expires.