Skip to main content
Each conversation or search thread starts with a new AdMesh session. A session ensures all exposures, clicks, and conversions are tied together.
  • TypeScript/JavaScript
  • React
  • Android (Kotlin)
  • Flutter (Dart)
  • Swift/iOS
  • React Native
const ADMESH_BASE = "https://api.useadmesh.com";

export async function createAdmeshSession() {
  try {
    const res = await fetch(`${ADMESH_BASE}/agent/session/new`, { method: "POST" });
    if (!res.ok) throw new Error("Failed to create AdMesh session");

    const { session_id } = await res.json();
    localStorage.setItem("admesh_session_id", session_id);
    console.log("✅ Session created:", session_id);
    return session_id;
  } catch (err) {
    console.error("⚠️ Session creation failed:", err);
    return `admesh_temp_${Date.now()}`;
  }
}

When to create

  • When a user starts a new chat or query
  • When a previous session expires (401)
  • When the platform resets its context

Response Format

{
  "session_id": "admesh_sess_1760022990_w8RkKA",
  "created_at": "2024-10-20T10:30:00Z",
  "expires_at": "2024-10-20T11:30:00Z"
}

Next → Get Recommendations