Organizations, Roles & Billing API
Relevant source files
The following files were used as context for generating this wiki page:
- libs/api-client/src/api/organizations-api.ts
- apps/dashboard/src/billing-api/billingApiClient.ts
- libs/api-client-ruby/lib/daytona_api_client/models/organization_user.rb
- libs/api-client-ruby/lib/daytona_api_client/models/organization_role.rb
- libs/api-client-ruby/lib/daytona_api_client/models/organization_invitation.rb
- libs/api-client-go/model_organization_usage_overview.go
- apps/dashboard/src/pages/Onboarding.tsx
Introduction
The Organizations, Roles, and Billing systems form the administrative backbone of the Daytona platform. Organizations serve as the top-level multi-tenant containers that group users, resources (like sandboxes), and billing configurations. The Role-Based Access Control (RBAC) system allows fine-grained permission management within these organizations, distinguishing between owners and members while supporting custom roles with specific permission sets.
The Billing API integrates with these organizational structures to manage usage tracking, wallet balances, subscription tiers, and invoicing. This ensures that resource consumption—such as snapshot storage and volume usage—is accurately attributed and billed to the correct entity.
Sources: libs/api-client/src/api/organizations-api.ts, apps/dashboard/src/billing-api/billingApiClient.ts
Organization Management
Organizations are the primary entities for collaboration in Daytona. Users can create, update, or delete organizations and manage membership through an invitation system.
Organization Lifecycle and Invitations
The invitation workflow allows organization owners to recruit new members by sending invitations to email addresses. These invitations have statuses such as pending, accepted, declined, or cancelled.
The diagram above illustrates the states an invitation can transition through before a user becomes a member.
Sources: libs/api-client-ruby/lib/daytona_api_client/models/organization_invitation.rb:141-143, libs/api-client/src/api/organizations-api.ts:253-279
Key API Endpoints
| Endpoint | Method | Description |
|---|---|---|
/organizations | POST | Create a new organization |
/organizations/{id} | GET | Retrieve organization details |
/organizations/{id}/invitations | POST | Invite a new user to the organization |
/organizations/invitations/{id}/accept | POST | Accept a pending invitation |
Sources: libs/api-client/src/api/organizations-api.ts:100-300
Roles and Permissions
Daytona employs an RBAC model where OrganizationRole objects define a set of permissions. Users are assigned one or more roles within an organization context.
Data Structures
The OrganizationUser model links a user to an organization with a specific primary role and a collection of assigned roles.
module DaytonaApiClient
class OrganizationUser
attr_accessor :user_id
attr_accessor :organization_id
attr_accessor :role # "owner" or "member"
attr_accessor :assigned_roles # Array<OrganizationRole>
end
end
Sources: libs/api-client-ruby/lib/daytona_api_client/models/organization_user.rb:18-39
The OrganizationRole model contains the actual permission strings that grant access to platform features.
Permissions Logic
Permissions are enforced at the UI and API levels. For example, the WRITE_SANDBOXES permission is required for a user to utilize onboarding snippets or create new environments.
Sources: apps/dashboard/src/pages/Onboarding.tsx:50-55
Billing API and Usage Tracking
The Billing system monitors resource consumption and manages financial transactions for organizations.
Billing Client Architecture
The BillingApiClient handles communication with the billing microservice. It manages several core domains:
- Usage: Tracking current and past resource consumption.
- Wallet: Managing credits and automatic top-ups.
- Tiers: Managing subscription levels (e.g., upgrading/downgrading tiers).
- Invoices: Retrieving and paying invoices via payment URLs.
Sources: apps/dashboard/src/billing-api/billingApiClient.ts:22-35
Usage Metrics
Usage is summarized through the OrganizationUsageOverview, which tracks storage and region-specific resource utilization.
| Field | Type | Description |
|---|---|---|
totalSnapshotQuota | float32 | Total allowed snapshot storage |
currentSnapshotUsage | float32 | Current snapshot storage used |
totalVolumeQuota | float32 | Total volume storage quota |
currentVolumeUsage | float32 | Current volume storage used |
Sources: libs/api-client-go/model_organization_usage_overview.go:21-27
Payment Workflow
The system generates payment URLs for both wallet top-ups and invoice settlements, typically redirecting users to an external payment processor.
Conclusion
The Organizations, Roles, and Billing systems provide the necessary structure for enterprise-grade management of Daytona resources. By combining a flexible RBAC model with a robust billing and usage tracking API, the platform allows organizations to scale their development infrastructure while maintaining strict control over access and costs.
Sources: libs/api-client/src/api/organizations-api.ts, apps/dashboard/src/billing-api/billingApiClient.ts