Creates a new organization instance
Initializes an organization with the provided configuration data. Organizations are the primary containers for managing AI resources, team members, and settings.
Configuration data including: - name: Organization name - short_description: Brief description - long_description: Detailed description - metadata: Custom metadata object
Optionaluri: stringOptional custom URI path for the organization endpoint
Basic organization:
const org = new Organization({
name: 'Tech Solutions',
short_description: 'AI solutions provider'
});
Detailed configuration:
const org = new Organization({
name: 'Enterprise AI',
short_description: 'Enterprise AI solutions',
long_description: 'Comprehensive AI solutions for enterprises',
metadata: {
industry: 'technology',
size: 'enterprise',
region: 'global',
compliance: ['gdpr', 'hipaa'],
features: ['agents', 'models', 'apps']
}
}, '/enterprise/org');
Get the organization's AI agents
This getter provides access to the organization's AI agents through the Agents collection. It enables management of all AI agents within the organization.
Agents collection for managing AI agents
Get the organization's applications
This getter provides access to the organization's applications through the Apps collection. It enables management of all applications within the organization.
Apps collection for managing applications
Get the organization's OAuth clients
This getter provides access to the organization's OAuth clients through the Clients collection. It enables management of authentication and authorization for external applications.
Clients collection for managing OAuth clients
List clients:
const clients = await org.clients.get();
clients.forEach(client => {
console.log(`Client: ${client.name}`);
console.log(`ID: ${client.client_id}`);
});
Create OAuth client:
const client = await org.clients.create({
name: 'Web Dashboard',
redirect_uris: ['https://app.example.com/oauth/callback'],
scopes: ['read:agents', 'write:apps'],
metadata: {
type: 'web-application',
environment: 'production'
}
});
console.log('Client credentials:');
console.log(`ID: ${client.client_id}`);
console.log(`Secret: ${client.client_secret}`);
Get the organization's AI models
This getter provides access to the organization's AI models through the Models collection. It enables management of model configurations and customizations for the organization's AI capabilities.
Models collection for managing AI models
Get the organization's team members
This getter provides access to the organization's user relationships through the OrgUsers collection. It enables management of team members, their roles, and permissions within the organization.
OrgUsers collection for managing team members
Get the organization's tools
This getter provides access to the organization's tools through the Tools collection. It enables management of custom tools and integrations that extend agent capabilities.
Tools collection for managing custom tools
List tools:
const tools = await org.tools.get();
tools.forEach(tool => {
console.log(`Tool: ${tool.name}`);
console.log(`Type: ${tool.type}`);
});
Create custom tool:
const tool = await org.tools.create({
name: 'Weather API',
type: 'api',
description: 'Get weather forecasts',
api_url: 'https://api.weather.com',
api_key: process.env.WEATHER_API_KEY,
metadata: {
provider: 'weather-service',
capabilities: ['current', 'forecast'],
rate_limit: 1000
}
});
Get the image functionality for this organization's profile
This getter provides access to the organization's profile image operations through the Image class. It allows for profile image uploads and other image-related operations specific to this organization.
A new Image instance configured for this organization's profile
Get the organization's access policies
This getter provides access to the organization's access control policies through the AccessPolicies collection. It enables management of IAM policies that define fine-grained permissions for resources and actions.
AccessPolicies collection for managing access control policies
Get the organization's permissions
This getter provides access to the organization's permissions through the OrgPermissions collection. It enables management of permissions that associate users, agents, or clients with access policies.
OrgPermissions collection for managing organization permissions
Get the organization's usage meters
This getter provides access to the organization's usage meters through the Meters collection. It enables tracking of service consumption and associated costs for billing purposes.
Meters collection for managing usage meters
Get the organization's wallet
This getter provides access to the organization's wallet through the Wallets collection. It enables management of balances, payment methods, and financial transactions.
Wallets collection for managing the organization wallet
Check if the entity is active
This method checks the active status of the entity. Most entities in the system can be active or inactive, which affects their availability and usability in the platform.
True if the entity is active, false otherwise
Convert model instance to interface data
This method serializes the model instance to a plain object that matches the interface type. This is useful for:
The model data as a plain object matching the interface type
Convert model instance to API payload
This method creates a payload suitable for API requests by:
A clean object suitable for API requests
Update model data with new values
This method updates the model's data and instance properties with new values. It performs a shallow merge of the updates with existing data, allowing for partial updates of the model's properties.
Object containing properties to update
const user = new User({
email: 'old@example.com',
firstName: 'John'
});
// Update multiple properties
user.update({
email: 'new@example.com',
lastName: 'Doe'
});
// Save changes to API
await user.save();
This method only updates the local model instance. To persist changes to the API, call save after updating.
Save the model instance to the API
This method persists the current state of the model to the API using a PUT request. It requires the model to have an ID (existing instance). For new instances, use the collection's create method instead.
The method:
Promise resolving to the updated model data
Delete the model instance from the API
This method permanently deletes the model instance from the API and clears the local data. This operation cannot be undone.
The method:
Promise that resolves when deletion is successful
Organization class for managing organizational entities
This class represents an organization in the Mosaia platform. Organizations are the top-level containers that group users, resources, and settings. They provide isolation and management capabilities for teams and enterprises.
Features:
Remarks
Organizations provide:
Available resources:
Example
Basic organization setup:
Example
Resource management: