Community Sync API — Integration Guide

This guide explains how to connect any Replit project to the Community Hub CRM so that when a user signs in via Replit Auth on your project, their activity is tracked centrally.


What This Does

When a user signs in with Replit Auth on your project, your app calls the Community Hub API to:

  1. Register the user — creates a record if they don't already exist
  2. Apply a tag — marks which project(s) the user has signed into (e.g., "AuraGlobe", "Mobile Build-a-thon")
  3. Return a profile link — a URL to the user's Community Hub profile page

You can also fetch a user's 90-day usage data (prompt counts, agent sessions, projects created, etc.) to display in your own UI.


Setup

Add these environment variables (Secrets) to your Replit project:

VariableValue
COMMUNITY_SYNC_API_KEYYour project's API key (csk_…). A Community Hub admin mints one per client project on the Admin → API page and hands it to you.
COMMUNITY_HUB_URLThe deployed URL of the Community Hub (e.g., https://your-community-hub.replit.app)
COMMUNITY_SYNC_TAGA lowercase tag name for your project (e.g., aura-globe, mobile-buildathon). This tag is applied to every user who signs in on your project.

API Keys & Scopes

Keys are issued per client project from the Community Hub's Admin → API page — there is no shared key anymore.


API Reference

1. Identify User (POST)

Call this after a user signs in with Replit Auth.

POST {COMMUNITY_HUB_URL}/api/external/identify

Headers:

Authorization: Bearer {COMMUNITY_SYNC_API_KEY}
Content-Type: application/json

Request Body:

{
  "replitUserId": "12345678",
  "tag": "aura-globe"
}
FieldTypeRequiredDescription
replitUserIdstringYesThe user's Replit ID (from claims.sub in Replit Auth)
tagstringYesA fixed tag name for your project. Use lowercase with hyphens (e.g., aura-globe, mobile-buildathon). Tags are automatically lowercased and trimmed on the server. Store this in the COMMUNITY_SYNC_TAG environment variable (see Setup).

Response (200):

{
  "success": true,
  "userId": "12345678",
  "username": "janedoe",
  "profileUrl": "https://community-hub.replit.app/profile/janedoe",
  "tagApplied": "aura-globe",
  "isNewUser": false,
  "profileReady": true,
  "allowlisted": true
}

Notes:


1b. Bulk Sync (POST + poll)

Use the bulk endpoint when you need to push more than a handful of users in one shot — for example, importing every signup from a partner project, or one-time backfills of up to 50,000 people. The same identify logic runs server-side (user upsert, tag, allowlist, profile setup, background BigQuery project sync) but in chunks under bounded concurrency, so a 50k push completes in roughly 1–3 minutes instead of stalling on per-request HTTP round trips.

The flow is async:

  1. POST /api/external/identify/batch with up to 50k {replitUserId, tag} pairs → returns 202 with a jobId.
  2. GET /api/external/jobs/:id → poll every few seconds until status is completed or failed. The response includes per-item results in the same order as you sent them.

Submit a job

POST {COMMUNITY_HUB_URL}/api/external/identify/batch

Headers:

Authorization: Bearer {COMMUNITY_SYNC_API_KEY}
Content-Type: application/json

Request body:

{
  "people": [
    { "replitUserId": "12345678", "tag": "aura-globe" },
    { "replitUserId": "87654321", "tag": "aura-globe" },
    { "replitUserId": "99999999", "tag": "mobile-buildathon" }
  ]
}
FieldTypeRequiredDescription
peoplearrayYes1–50,000 items, each {replitUserId, tag}. Tag may differ per row — use this to mix multiple integration sources in one push.

Response (202):

{
  "jobId": "9f7e1c10-7b6a-4e0b-b2b7-9b1f8e8a0a2f",
  "status": "queued",
  "total": 3,
  "statusUrl": "/api/external/jobs/9f7e1c10-7b6a-4e0b-b2b7-9b1f8e8a0a2f"
}

Rate limits (per API key):

Poll for results

GET {COMMUNITY_HUB_URL}/api/external/jobs/{jobId}

Headers:

Authorization: Bearer {COMMUNITY_SYNC_API_KEY}

The job is scoped to the API key that created it — keys can't read each other's jobs (you'll get 404).

Response (200) — in progress:

{
  "jobId": "9f7e1c10-7b6a-4e0b-b2b7-9b1f8e8a0a2f",
  "status": "running",
  "total": 50000,
  "processed": 12500,
  "succeeded": 12498,
  "failed": 2,
  "results": [],
  "createdAt": "2026-05-21T16:30:00.000Z",
  "startedAt": "2026-05-21T16:30:01.000Z",
  "completedAt": null
}

status cycles queued → running → completed | failed. results is empty until the job reaches a terminal state — until then, track progress via processed, succeeded, and failed.

Response (200) — completed:

{
  "jobId": "9f7e1c10-7b6a-4e0b-b2b7-9b1f8e8a0a2f",
  "status": "completed",
  "total": 3,
  "processed": 3,
  "succeeded": 2,
  "failed": 1,
  "results": [
    {
      "index": 0,
      "status": "success",
      "userId": "12345678",
      "username": "janedoe",
      "profileUrl": "https://community-hub.replit.app/profile/janedoe",
      "tagApplied": "aura-globe",
      "isNewUser": false,
      "profileReady": true,
      "allowlisted": true
    },
    {
      "index": 1,
      "status": "success",
      "userId": "87654321",
      "username": "87654321",
      "profileUrl": "https://community-hub.replit.app/profile/87654321",
      "tagApplied": "aura-globe",
      "isNewUser": true,
      "profileReady": true,
      "allowlisted": true
    },
    {
      "index": 2,
      "status": "error",
      "replitUserId": "",
      "error": { "message": "Invalid item: replitUserId and tag (<=100 chars) are required" }
    }
  ],
  "createdAt": "2026-05-21T16:30:00.000Z",
  "startedAt": "2026-05-21T16:30:01.000Z",
  "completedAt": "2026-05-21T16:31:42.000Z"
}

Result item shape:

Notes:


2. Get User Activity (GET)

Fetch a user's 90-day usage data and tags.

GET {COMMUNITY_HUB_URL}/api/external/user/{replitUserId}/activity

Headers:

Authorization: Bearer {COMMUNITY_SYNC_API_KEY}

Response (200):

{
  "userId": "12345678",
  "username": "janedoe",
  "profileUrl": "https://community-hub.replit.app/profile/janedoe",
  "tags": [
    { "name": "AuraGlobe", "color": "blue" },
    { "name": "Mobile Build-a-thon", "color": "blue" }
  ],
  "snapshots": [
    {
      "date": "2026-03-18",
      "promptCount": 42,
      "agentSessions": 3,
      "projectsCreated": 1,
      "totalDeployments": 0,
      "daysActive": 1
    },
    {
      "date": "2026-03-17",
      "promptCount": 15,
      "agentSessions": 2,
      "projectsCreated": 0,
      "totalDeployments": 1,
      "daysActive": 1
    }
  ],
  "rollup": {
    "cumulativeAgentSessions": 89,
    "cumulativePrompts": 1204,
    "cumulativeProjectsCreated": 12,
    "cumulativeDeployments": 5,
    "cumulativeDaysActive": 45,
    "builderScore": "7.2",
    "pctlOverall": 82.5,
    "lastRollupAt": "2026-03-19T03:00:00.000Z"
  }
}
FieldDescription
snapshotsArray of daily activity records (up to 90 days). Use this to render a spark/line graph.
rollupCumulative totals and scores for the 90-day period. builderScore is a 1-10 scale. pctlOverall is the user's percentile rank among all community members.
tagsAll tags assigned to this user across all projects.

Response (404): User not found in the Community Hub.


Integration Code

For Express/Node.js projects (TypeScript)

Add this utility file to your project:

// lib/communitySync.ts

const COMMUNITY_HUB_URL = process.env.COMMUNITY_HUB_URL;
const COMMUNITY_SYNC_API_KEY = process.env.COMMUNITY_SYNC_API_KEY;
const COMMUNITY_SYNC_TAG = process.env.COMMUNITY_SYNC_TAG;

interface IdentifyResponse {
  success: boolean;
  userId: string;
  username: string;
  profileUrl: string;
  tagApplied: string;
  isNewUser: boolean;
  profileReady: boolean;
  allowlisted: boolean;
}

interface UserActivityResponse {
  userId: string;
  username: string;
  profileUrl: string;
  tags: { name: string; color: string }[];
  snapshots: {
    date: string;
    promptCount: number;
    agentSessions: number;
    projectsCreated: number;
    totalDeployments: number;
    daysActive: number;
  }[];
  rollup: {
    cumulativeAgentSessions: number;
    cumulativePrompts: number;
    cumulativeProjectsCreated: number;
    cumulativeDeployments: number;
    cumulativeDaysActive: number;
    builderScore: string;
    pctlOverall: number | null;
    lastRollupAt: string;
  } | null;
}

export async function identifyUser(
  replitUserId: string
): Promise<IdentifyResponse | null> {
  if (!COMMUNITY_HUB_URL || !COMMUNITY_SYNC_API_KEY || !COMMUNITY_SYNC_TAG) {
    console.warn("[CommunitySync] Missing COMMUNITY_HUB_URL, COMMUNITY_SYNC_API_KEY, or COMMUNITY_SYNC_TAG");
    return null;
  }

  try {
    const response = await fetch(`${COMMUNITY_HUB_URL}/api/external/identify`, {
      method: "POST",
      headers: {
        "Authorization": `Bearer ${COMMUNITY_SYNC_API_KEY}`,
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        replitUserId,
        tag: COMMUNITY_SYNC_TAG,
      }),
    });

    if (!response.ok) {
      console.error("[CommunitySync] identify failed:", response.status, await response.text());
      return null;
    }

    return await response.json();
  } catch (error) {
    console.error("[CommunitySync] identify error:", error);
    return null;
  }
}

export async function getUserActivity(replitUserId: string): Promise<UserActivityResponse | null> {
  if (!COMMUNITY_HUB_URL || !COMMUNITY_SYNC_API_KEY) {
    console.warn("[CommunitySync] Missing COMMUNITY_HUB_URL or COMMUNITY_SYNC_API_KEY");
    return null;
  }


  try {
    const response = await fetch(
      `${COMMUNITY_HUB_URL}/api/external/user/${replitUserId}/activity`,
      {
        headers: {
          "Authorization": `Bearer ${COMMUNITY_SYNC_API_KEY}`,
        },
      }
    );

    if (!response.ok) {
      if (response.status === 404) return null;
      console.error("[CommunitySync] activity failed:", response.status, await response.text());
      return null;
    }

    return await response.json();
  } catch (error) {
    console.error("[CommunitySync] activity error:", error);
    return null;
  }
}

Usage in your auth callback:

// In your Replit Auth callback or login handler:
import { identifyUser } from "./lib/communitySync";

// After successful Replit Auth login:
const claims = req.user.claims;
const result = await identifyUser(
  claims.sub           // Replit user ID
);

if (result) {
  console.log(`User synced to Community Hub. Profile: ${result.profileUrl}`);
}

Agent Instructions

If you're setting up a new Replit project and want to integrate with the Community Hub, paste the following into the agent's context:

Community Sync Integration: This project integrates with a centralized Community Hub CRM. After setting up Replit Auth (Login with Replit), add the Community Sync integration:

  1. Add three Secrets: COMMUNITY_HUB_URL (the deployed Community Hub URL), COMMUNITY_SYNC_API_KEY (a per-project key minted by a Community Hub admin on the Admin → API page — ask them for one), and COMMUNITY_SYNC_TAG (a lowercase tag name for this project, e.g., aura-globe).
  2. Create a file lib/communitySync.ts with the utility code from the Community Sync API Guide.
  3. In the Replit Auth callback (after successful login), call identifyUser(claims.sub).
  4. This call is fire-and-forget — it shouldn't block the login flow. Wrap it in a .catch() or run it without await if preferred.
  5. Optionally, use getUserActivity(replitUserId) to fetch and display the user's 90-day usage stats.
  6. If this project has user profile pages, use the Replit User ID (claims.sub) as the profile route — e.g., /profile/{replitUserId}. This enables the Community Hub to link to your project's profiles. To link back to the Community Hub, use the profileUrl returned by the identify response — do not construct it manually. See the "Profile Page Convention" section for details.

Error Handling

StatusMeaning
200Success
400Invalid request body (check required fields)
401Missing Authorization header, or the key is unknown (check the value; it may have been rotated)
403Key has been revoked, or lacks the scope this endpoint requires
404User not found (activity endpoint), or job not found / owned by another key (jobs endpoint)
429Batch rate limit exceeded (max 10 jobs/hour per key, 1 in-flight job at a time)

All errors return JSON with an error field describing the issue.


Tag Convention

Each project should use one fixed tag name stored in the COMMUNITY_SYNC_TAG environment variable. Use lowercase with hyphens (e.g., aura-globe, mobile-buildathon). Tags are automatically lowercased and trimmed by the server, so even if a tag is sent with mixed casing, it will be normalized. This tag will appear in the admin dashboard next to each user, showing which projects they've signed into.

Tags created through this API are automatically marked as system tags:


Profile Page Convention

There are two different URL patterns at play — one for the Community Hub, and one for external integrated projects.

Community Hub — Uses System Username

The Community Hub creates profile pages using the user's Replit username (looked up from BigQuery on login). The profile URL follows this pattern:

https://community-hub.replit.app/profile/{username}

Example:

https://community-hub.replit.app/profile/janedoe

This URL is returned as profileUrl in the /api/external/identify response. External projects should always use the returned profileUrl to link back to the Community Hub — never construct it manually from a user ID or username.

If BigQuery has no username for the user, the system falls back to the Replit User ID as the username. Either way, the profileUrl in the API response is the canonical link.

External Projects — Use Replit User ID

When your external project has its own profile pages, use the Replit User ID (claims.sub) as the profile route parameter:

https://your-project.replit.app/profile/{replitUserId}

Example:

https://aura-globe.replit.app/profile/12345678
https://mobile-buildathon.replit.app/profile/12345678

This makes it possible for the Community Hub to programmatically link to a user's profile on any integrated project using just the project's root URL and the user's Replit ID.

How to Implement (External Projects)

In your project's routing, register the profile page using the Replit User ID:

// Example with wouter (React)
<Route path="/profile/:replitUserId" component={ProfilePage} />

// Example with Express
app.get("/profile/:replitUserId", (req, res) => {
  const { replitUserId } = req.params;
  // Look up user by replitUserId and render their profile
});

Cross-Linking Pattern

The two URL patterns work together:

// Linking TO the Community Hub — use the profileUrl from the identify response:
const result = await identifyUser(claims.sub);
const communityHubProfile = result.profileUrl;
// → "https://community-hub.replit.app/profile/janedoe"

// Linking TO an external project — use the Replit User ID:
const auraGlobeProfile = `https://aura-globe.replit.app/profile/${replitUserId}`;
// → "https://aura-globe.replit.app/profile/12345678"

Builder Profile Button

External projects that link back to the Community Hub should use the Builder Profile Button for a consistent look and feel across all integrated sites. This button opens the user's Community Hub profile in a new tab.

Rendering Rules

Self-Contained HTML Snippet

No framework or library required. Copy and paste this anywhere — all styles are inline. Replace {BUILDER_PROFILE_URL} with the profileUrl from your data source.

<a
  href="{BUILDER_PROFILE_URL}"
  target="_blank"
  rel="noopener noreferrer"
  style="text-decoration: none;"
>
  <button style="
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    color: inherit;
    background-color: transparent;
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 6px;
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease;
    white-space: nowrap;
  "
  onmouseover="this.style.borderColor='rgb(99,102,241)'; this.style.backgroundColor='rgba(99,102,241,0.05)';"
  onmouseout="this.style.borderColor='rgba(99,102,241,0.3)'; this.style.backgroundColor='transparent';"
  >
    <!-- Replit Logo -->
    <svg width="16" height="16" viewBox="0 0 374 512" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
      <path d="M187.608 134.319C187.608 136.611 187.608 137.758 187.688 138.929C188.186 146.185 191.261 153.609 196.04 159.092C196.811 159.976 197.514 160.68 198.921 162.087C205.185 168.35 213.73 171.754 222.59 171.754H318.59C337.77 171.754 347.36 171.754 354.69 175.487C361.14 178.772 366.38 184.012 369.66 190.457C373.4 197.785 373.4 207.377 373.4 226.562V284.517C373.4 303.702 373.4 313.294 369.66 320.622C366.38 327.067 361.14 332.308 354.69 335.592C347.36 339.325 337.77 339.325 318.59 339.325H222.59C213.73 339.325 205.185 342.729 198.921 348.993C197.514 350.4 196.811 351.103 196.04 351.987C191.261 357.471 188.186 364.894 187.688 372.151C187.608 373.321 187.608 374.468 187.608 376.76V455.546C187.608 474.731 187.608 484.323 183.868 491.651C180.588 498.097 175.348 503.337 168.898 506.621C161.568 510.354 151.978 510.354 132.798 510.354H54.4104C35.2254 510.354 25.6354 510.354 18.3054 506.621C11.8554 503.337 6.61545 498.097 3.33545 491.651C-0.397461 484.323 -0.397461 474.731 -0.397461 455.546V56.4484C-0.397461 37.2634 -0.397461 27.6734 3.33545 20.3434C6.61545 13.8984 11.8554 8.65836 18.3054 5.37836C25.6354 1.64539 35.2254 1.64539 54.4104 1.64539H132.798C151.978 1.64539 161.568 1.64539 168.898 5.37836C175.348 8.65836 180.588 13.8984 183.868 20.3434C187.608 27.6734 187.608 37.2634 187.608 56.4484V134.319Z" fill="currentColor"/>
    </svg>
    <!-- Label -->
    <span style="font-size: 14px; font-weight: 500;">Builder Profile</span>
    <!-- External link indicator -->
    <svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24"
      fill="none" stroke="currentColor" stroke-width="2"
      stroke-linecap="round" stroke-linejoin="round"
      style="opacity: 0.5;" aria-hidden="true">
      <path d="M15 3h6v6"/>
      <path d="M10 14 21 3"/>
      <path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/>
    </svg>
  </button>
</a>

Tailwind + shadcn Version (React)

For projects using Tailwind CSS and shadcn/ui:

import { ExternalLink } from "lucide-react";
import { Button } from "@/components/ui/button";

// builderProfileUrl comes from the identify response's profileUrl field
{builderProfileUrl && (
  <a
    href={builderProfileUrl}
    target="_blank"
    rel="noopener noreferrer"
  >
    <Button
      variant="outline"
      size="sm"
      className="gap-2 border-primary/30 hover:border-primary hover:bg-primary/5 transition-all"
    >
      <img src="/Replit logo.svg" alt="Replit" className="h-4 w-4" />
      <span className="text-sm font-medium">Builder Profile</span>
      <ExternalLink className="h-3 w-3 text-muted-foreground" />
    </Button>
  </a>
)}

The Replit logo SVG file should be placed at /public/Replit logo.svg in your project. The full SVG source is provided below in the Icons section.

Icons

Replit Logo SVG (/public/Replit logo.svg):

<svg width="374" height="512" viewBox="0 0 374 512" fill="none" xmlns="http://www.w3.org/2000/svg">
  <path d="M187.608 134.319C187.608 136.611 187.608 137.758 187.688 138.929C188.186 146.185 191.261 153.609 196.04 159.092C196.811 159.976 197.514 160.68 198.921 162.087C205.185 168.35 213.73 171.754 222.59 171.754H318.59C337.77 171.754 347.36 171.754 354.69 175.487C361.14 178.772 366.38 184.012 369.66 190.457C373.4 197.785 373.4 207.377 373.4 226.562V284.517C373.4 303.702 373.4 313.294 369.66 320.622C366.38 327.067 361.14 332.308 354.69 335.592C347.36 339.325 337.77 339.325 318.59 339.325H222.59C213.73 339.325 205.185 342.729 198.921 348.993C197.514 350.4 196.811 351.103 196.04 351.987C191.261 357.471 188.186 364.894 187.688 372.151C187.608 373.321 187.608 374.468 187.608 376.76V455.546C187.608 474.731 187.608 484.323 183.868 491.651C180.588 498.097 175.348 503.337 168.898 506.621C161.568 510.354 151.978 510.354 132.798 510.354H54.4104C35.2254 510.354 25.6354 510.354 18.3054 506.621C11.8554 503.337 6.61545 498.097 3.33545 491.651C-0.397461 484.323 -0.397461 474.731 -0.397461 455.546V56.4484C-0.397461 37.2634 -0.397461 27.6734 3.33545 20.3434C6.61545 13.8984 11.8554 8.65836 18.3054 5.37836C25.6354 1.64539 35.2254 1.64539 54.4104 1.64539H132.798C151.978 1.64539 161.568 1.64539 168.898 5.37836C175.348 8.65836 180.588 13.8984 183.868 20.3434C187.608 27.6734 187.608 37.2634 187.608 56.4484V134.319Z" fill="currentColor"/>
</svg>

External Link Icon (from Lucide, or use the raw SVG):

<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24"
  fill="none" stroke="currentColor" stroke-width="2"
  stroke-linecap="round" stroke-linejoin="round">
  <path d="M15 3h6v6"/>
  <path d="M10 14 21 3"/>
  <path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/>
</svg>

Style Reference

PropertyValue
Border1px solid at ~30% primary color opacity
Border on hoverFull primary color, no opacity
BackgroundTransparent; 5% primary color on hover
Gap (icon / text)8px
Padding6px 12px (small button)
Border radius6px
Font size14px, weight 500
Replit logo size16×16px
External icon12×12px, muted / 50% opacity
Transitionborder-color and background-color, 150ms ease
Opens inNew tab (target="_blank")

Agent Instructions Addendum

When setting up a new project with profile pages, include this in the agent's context:

Profile Page Routing: If this project has user profile pages, use the Replit User ID (claims.sub from Replit Auth) as the profile route parameter. The profile URL must follow the pattern /profile/{replitUserId}. This enables the Community Hub to link to any user's profile on your project. To link back to the Community Hub, use the profileUrl returned by the /api/external/identify endpoint — do not construct it manually.

Builder Profile Button: When linking back to the Community Hub from your profile pages or user cards, use the standardized Builder Profile Button component documented in the "Builder Profile Button" section of this guide. This ensures a consistent appearance across all integrated projects. Only render the button when the user has a profileUrl. Use the self-contained HTML snippet (framework-free) or the Tailwind + shadcn React version depending on your stack.