Overview
The Organizations API allows you to create and manage organizations in Hazel Chat. Organizations are the top-level entities that contain members, channels, and settings. This API handles organization lifecycle, slug management, public invite mode, WorkOS domain verification, and admin portal access. All organization operations require authentication and are protected by role-based access control policies. Most operations are restricted to organization admins and owners.Create organization
Creates a new organization and automatically adds the authenticated user as the owner.The organization name.
URL-friendly slug for the organization. Must be unique across all organizations. If provided and already exists, returns
OrganizationSlugAlreadyExistsError.URL to the organization’s logo image.
Custom settings object for organization-specific configuration.
Response
Transaction ID for optimistic UI updates.
Errors
OrganizationSlugAlreadyExistsError- The provided slug is already in useUnauthorizedError- User is not authenticatedInternalServerError- Unexpected server error
Update organization
Updates an existing organization. Only admins and owners can update organizations.Organization ID to update.
New organization name.
New slug. Must be unique.
New logo URL.
Updated settings object.
Response
Returns the same structure as create organization.Errors
OrganizationNotFoundError- Organization does not existOrganizationSlugAlreadyExistsError- Slug is already takenUnauthorizedError- User lacks permissionInternalServerError- Unexpected server error
Delete organization
Deletes an organization (soft delete). Only admins and owners can delete organizations.Organization ID to delete.
Response
Transaction ID for optimistic UI updates.
Errors
OrganizationNotFoundError- Organization does not existUnauthorizedError- User lacks permissionInternalServerError- Unexpected server error
Set organization slug
Sets or updates the organization’s slug. Only admins and owners can modify slugs.Organization ID.
New slug value. Must be unique.
Response
Returns the same structure as create organization.Errors
OrganizationNotFoundError- Organization does not existOrganizationSlugAlreadyExistsError- Slug is already takenUnauthorizedError- User lacks permissionInternalServerError- Unexpected server error
Set public mode
Toggles public invite mode for an organization. When enabled, anyone with the invite URL can join the workspace. Only admins and owners can modify this setting.Organization ID.
Whether to enable or disable public invite mode.
Response
Returns the same structure as create organization.Errors
OrganizationNotFoundError- Organization does not existUnauthorizedError- User lacks permissionInternalServerError- Unexpected server error
Get public organization info
Retrieves limited public information about an organization by slug. No authentication required. Only returns data if the organization has public invites enabled.Organization slug to look up.
Response
Organization ID.
Organization name.
Organization slug.
Logo URL.
Number of members in the organization.
Returns
null if the organization is not found or does not have public invites enabled.Errors
InternalServerError- Unexpected server error
Join via public invite
Joins an organization via public invite link. Requires authentication. Creates membership with “member” role.Organization slug from the public invite URL.
Response
Returns the same structure as create organization.Errors
OrganizationNotFoundError- Organization does not existPublicInviteDisabledError- Organization has public invites disabledAlreadyMemberError- User is already a memberUnauthorizedError- User is not authenticatedInternalServerError- Unexpected server error
Get admin portal link
Generates a WorkOS Admin Portal link for managing SSO, domain verification, directory sync, audit logs, and log streams. Only admins and owners can access the admin portal.Organization ID.
Portal intent. One of:
"sso", "domain_verification", "dsync", "audit_logs", "log_streams".Response
WorkOS admin portal URL.
Errors
OrganizationNotFoundError- Organization does not existUnauthorizedError- User lacks permissionInternalServerError- Unexpected server error
List domains
Lists all verified and pending domains for an organization. Only admins and owners can list domains.Organization ID.
Response
Returns an array of domain objects:Domain ID from WorkOS.
Domain name (e.g., “example.com”).
Verification state. One of:
"pending", "verified", "failed", "legacy_verified".TXT record value for domain verification.
Errors
OrganizationNotFoundError- Organization does not existUnauthorizedError- User lacks permissionInternalServerError- Unexpected server error
Add domain
Adds a domain to an organization for verification. Only admins and owners can add domains.Organization ID.
Domain name to add (e.g., “example.com”).
Response
Domain ID from WorkOS.
Domain name.
Verification state (will be “pending” for new domains).
TXT record value to add to DNS for verification.
Errors
OrganizationNotFoundError- Organization does not existUnauthorizedError- User lacks permissionInternalServerError- Unexpected server error
Remove domain
Removes a domain from an organization. Only admins and owners can remove domains.Organization ID.
Domain ID to remove.
Response
Always
true on successful deletion.Errors
OrganizationNotFoundError- Organization does not existUnauthorizedError- User lacks permissionInternalServerError- Unexpected server error