Quick IAM integration tutorial


This guide shows a minimal integration you can run locally: fetch data, display it, and handle errors.

What you’ll build

  • A small script or app that calls our API
  • Error handling and basic retries
  • A simple display of the response

Step 1: Set up

Create a new project (we use Bun):

mkdir my-integration && cd my-integration
bun init -y

Step 2: Call the API

const API_KEY = process.env.API_KEY;
const response = await fetch('https://api.example.com/v1/resources', {
  headers: { Authorization: `Bearer ${API_KEY}` },
});

if (!response.ok) {
  throw new Error(`API error: ${response.status}`);
}

const data = await response.json();
console.log(data);

Step 3: Add retries (optional)

For production, add simple retries for transient failures:

async function fetchWithRetry(url, options, maxRetries = 3) {
  for (let i = 0; i < maxRetries; i++) {
    const res = await fetch(url, options);
    if (res.ok || res.status < 500) return res;
    await new Promise((r) => setTimeout(r, 1000 * (i + 1)));
  }
  throw new Error('Max retries exceeded');
}

Next steps