Skip to Content
DocsAPIOrgs & Projects

Orgs & Projects

Multi-tenant hierarchy for the Pug platform. All analytics data is scoped to a project.

Services: OrgsService, ProjectsService
Auth: JWT + x-project-id (for project-scoped operations)

Hierarchy

Organization ├── Members (roles: admin, member, viewer) ├── Billing ├── Email provider config └── Projects ├── API keys (SDK + shared) ├── Events ├── Profiles └── Dashboards

Organizations are the billing and member boundary. Projects are the data boundary — events, profiles, and dashboards never cross project lines.

OrgsService

Manage organizations and membership.

MethodDescription
CreateCreate a new organization
GetGet org details
ListList orgs for the authenticated user
UpdateUpdate org name and settings
InviteMemberSend email invitation
ListMembersList org members and roles
RemoveMemberRemove a member

Invite member

{ "email": "teammate@example.com", "role": "ROLE_MEMBER" }

See Members for role permissions.

ProjectsService

Manage projects within an org.

MethodDescription
CreateCreate a new project
GetGet project details
ListList projects in the org
UpdateUpdate project name, timezone
CreateApiKeyGenerate a new API key
ListApiKeysList active API keys
RevokeApiKeyRevoke an API key

Create project

{ "name": "Production", "timezone": "America/New_York" }

Set timezone at creation — it affects all Insights bucket boundaries. Changing it later shifts historical chart boundaries.

Create API key

{ "type": "API_KEY_TYPE_SDK", "name": "Web app production" } // Response { "apiKey": { "id": "key_abc123", "key": "pk_sdk_...", "type": "API_KEY_TYPE_SDK", "createdAt": "2026-06-01T10:00:00Z" } }
Key typeUse in
API_KEY_TYPE_SDKBrowser/mobile SDK init()
API_KEY_TYPE_SHAREDServer-side scripts, cron jobs

The raw key value is only returned once at creation. Store it immediately — it cannot be retrieved again.

Rotate an API key

  1. CreateApiKey — generate new key
  2. Update SDK init or server env vars
  3. Deploy
  4. RevokeApiKey — revoke old key

Scoping rules

ResourceScoped to
Events, profiles, dashboardsProject
API keysProject
Members, billing, email providerOrganization

A JWT for org A cannot access org B’s projects. An API key for project X cannot write to project Y.

Request headers

All dashboard API requests:

Authorization: Bearer <jwt> x-project-id: <project-id> Content-Type: application/json Connect-Protocol-Version: 1

SDK requests:

Authorization: Bearer <sdk-api-key> x-project-id: <project-id>

See Authentication for client setup examples.

TypeScript client

import { ProjectsService } from './gen/projects/v1/projects_connect' const client = createClient(ProjectsService, jwtTransport) const { project } = await client.create({ name: 'Staging', timezone: 'UTC' }) const { apiKey } = await client.createApiKey({ projectId: project.id, type: 'API_KEY_TYPE_SDK', name: 'Staging web app' }) console.log('Store this key now:', apiKey.key)

Further reading

Last updated on