Skip to main content

Integrate Prism Auth in 3 steps

Get authenticated browser sessions for any website without maintaining login scripts.

Step 1: Get Your API Key

Navigate to your Prism Auth Dashboard to generate your organization-scoped API key. 1. Sign in to prismai.sh/workspace 2. Create a new API key for your organization 3. Copy your API key (starts with pk_) 4. Store it securely in your environment variables
Never expose your API key in client-side code or commit it to version control.
Store your API key as an environment variable in your application: bash # .env PRISM_AUTH_API_KEY=pk_your_actual_api_key_here
API keys are organization-scoped and provide access to all authentication endpoints.

Step 2: Make Your First Authentication Call

Use the /login endpoint to authenticate a user and receive live session cookies:
const response = await fetch("https://prismai.sh/api/login", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": `Bearer ${process.env.PRISM_AUTH_API_KEY}`
  },
  body: JSON.stringify({
    cred: {
      username: "user@example.com",
      password: "userPassword123"
    },
    loginMethod: "password",
    domain: "https://github.com/login"
  })
});

const authData = await response.json();
Replace the credentials with actual user credentials for the target website.
Apply the returned cookies to your browser context for authenticated access:
// The API returns structured cookie data
const { cookies, origins } = authData;

// Apply cookies to your browser session
cookies.forEach(cookie => {
  // Set cookie in browser context
  // (implementation depends on your browser automation tool)
  browser.setCookie(cookie);
});

// Now make authenticated requests to the target website
const authenticatedPage = await browser.newPage();
await authenticatedPage.goto("https://github.com/dashboard");

Step 3: Implement Session Management

Store credential references for future session refresh:
// For signup endpoint, store the credential ID for refreshing
const signupResponse = await fetch("https://prismai.sh/api/signup", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": `Bearer ${process.env.PRISM_AUTH_API_KEY}`
  },
  body: JSON.stringify({
    signup_method: "email",
    domain: "https://newservice.com/signup",
    cred: {
      email: "agent@yourcompany.com",
      password: "generated_secure_password"
    }
  })
});

const { cookies, credentialId } = await signupResponse.json();

// Store credentialId for future refresh calls
// When session expires, refresh it:
const refreshResponse = await fetch("https://prismai.sh/api/refresh", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": `Bearer ${process.env.PRISM_AUTH_API_KEY}`
  },
  body: JSON.stringify({
    credentialId: credentialId
  })
});

Next steps

Now that you have authentication working, explore these advanced features:
Need help? Check our API Reference for detailed endpoint documentation and authentication method examples.
I