API Reference

Organizations

List Organizations

  • API Name: List Organizations
  • API Route: GET /api/v1/organizations
  • Request:
    • Auth: Session required, permission: org.view
  • What it does: Returns a list of organizations. Super admins (super_admin, super_user) see all organizations in the system. Regular users see only the organization they belong to.
  • Returns:
json
  { "data": [ { "id", "name", "description", "plan", "ownerId", ... } ] }

Returns an empty array if the user has no organization.

Create Organization

  • API Name: Create Organization
  • API Route: POST /api/v1/organizations
  • Request:
    • Body:
json
    {
      "name": "string (required)",
      "description": "string (optional)",
      "plan": "string (optional, default: 'free')"
    }
  • What it does: Creates a new organization and automatically adds the creator as a member with the super_admin role. Only super admins can create organizations.
  • Returns: 201 with the created organization object. 400 if validation fails. 403 if user lacks permission.

Get Organization

  • API Name: Get Organization by ID
  • API Route: GET /api/v1/organizations/[orgId]
  • Request:
    • Params: orgId (string) — Organization ID
    • Auth: Session required, permission: org.view
  • What it does: Fetches details for a specific organization by its ID.
  • Returns: The organization object. 404 if not found.

Update Organization

  • API Name: Update Organization
  • API Route: PATCH /api/v1/organizations/[orgId]
  • Request:
    • Params: orgId (string) — Organization ID
    • Body:
json
    {
      "name": "string (optional)",
      "description": "string (optional)",
      "plan": "string (optional)",
      "isActive": "boolean (optional)"
    }
  • What it does: Updates the name, description, plan, or active status of an organization.
  • Returns: The updated organization object. 400 if validation fails. 403 if user lacks permission.