Manually onboarding a new user is a familiar, often tedious, process. It's a checklist of repetitive tasks: create a home folder, provision project directories, set the right permissions, and add them to the correct team shares. This process is not only slow but also prone to human error, leading to inconsistent setups and potential security gaps. What if you could standardize and automate this entire workflow with just a few lines of code?
With the directories.do API, you can. By treating directory structures as a programmable resource, you can turn complex organizational tasks into simple, automated, and scalable workflows. Let's explore how to build a seamless user onboarding process from scratch.
For a small team, manual onboarding might seem manageable. But as your organization grows, the cracks begin to show:
The core problem is that traditional directory management is a manual, reactive task. The solution is to make it a proactive, code-driven one.
directories.do provides a simple REST API to create, list, query, and manage complex directory structures for your organization, users, or applications. Instead of clicking through a UI, you execute commands. This is the foundation of an agentic workflow, where automated agents handle operational tasks based on triggers and code.
Let's build an automated onboarding script for a new employee, "Jane Doe."
When a new user is created in your HR system, a webhook can trigger a script that uses our API. The first step is to create a primary directory for Jane, complete with essential metadata.
Our code example shows just how straightforward this is:
import { Directories } from '@do-sdk/core';
// Initialize the Directories agent
const directoryService = new Directories();
// Create a new user directory with metadata
const newUserDirectory = await directoryService.create({
path: '/users/jane.doe/documents',
metadata: {
userId: 'user-id-12345',
team: 'engineering',
access: ['read', 'write']
},
recursive: true // Creates parent directories if they don't exist
});
console.log('Successfully created directory:', newUserDirectory.path);
Let's break down what's happening here:
Permissions are no longer buried in a complex ACL panel. With directories.do, access control is managed directly through the metadata you define. Your application can now query a directory's metadata to enforce permissions before granting access.
For example, when Jane tries to access a file, your application can first check the access array in the metadata for her parent directory. This makes implementing role-based access control (RBAC) incredibly simple and transparent.
Jane needs more than just one folder. She needs a standard set of directories for private work, team projects, and company templates. You can easily extend the script to provision this structure with a simple loop.
// (Continuing from the previous example)
const standardFolders = [
{ name: 'private', access: ['full-control'] },
{ name: 'team-projects', access: ['read', 'write'] },
{ name: 'templates', access: ['read-only'] }
];
for (const folder of standardFolders) {
await directoryService.create({
path: `/users/jane.doe/documents/${folder.name}`,
metadata: {
...newUserDirectory.metadata, // Inherit base metadata
access: folder.access // Override with specific permissions
}
});
}
console.log('Standard folder structure for Jane Doe has been provisioned.');
In minutes, you've codified your entire onboarding directory policy. Every new user gets the exact same structure with the correct permissions, every single time.
This programmatic approach extends to the entire user lifecycle.
directories.do was built to help you ORGANIZE. AUTOMATE. SCALE.
Ready to stop clicking and start coding? Transform your manual directory operations into a fast, reliable, and scalable automated workflow.
Visit directories.do to dive into our documentation and get your API key today.