newOS for Developers
Back to Mood Management
Create Mood
beginnerCreate a new folder or space for organizing content
POST /moodOverview
Moods (also called folders or spaces) are the primary organizational unit in Newgraph. The createFolder action creates a new mood with configurable title, description, privacy settings, and optional future grantees.
The action supports a "future" mode where a provisional folder is created locally in the cache before being committed to the server. This enables optimistic UI updates.
Request
import { createFolder } from "newgraph-signals/actions/folder";
// Create a new mood via progressive handler
const progress = createFolder();
// Execute the creation
progress.exec({
title: "My Collection",
description: "A space for my content",
isPrivate: true, // Default: true
licenseType: "private", // "private" | "cc0" | "cc-by"
future: false, // Create provisionally first
futureGrantees: [{ id: "userId" }], // Users to grant access
});
// Track progress
progress.done; // boolean - is operation complete
progress.error; // Error | undefined
progress.loading; // boolean - is loadingParameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| title | string | Yes | Display name for the mood |
| description | string | No | Optional description text |
| isPrivate | boolean | No | Access visibility (default: true) |
| licenseType | string | No | "private" | "cc0" | "cc-by" |
| future | boolean | No | Create provisional folder locally first |
| futureGrantees | {id: string}[] | No | Users to auto-grant access on creation |
Response
// MoodCreateResponse
{
"id": "aec78e08-fbf2-4511-a3d8-e360686297da",
"title": "My Collection",
"description": "A space for my content",
"isPrivate": true,
"author": {
"id": "user-uuid",
"username": "creator"
},
"created": "2024-01-15T10:30:00Z",
"updated": "2024-01-15T10:30:00Z"
}Edge Cases
Future Mode: When
future: true, the folder is created locally with a UUID before server commit. Use for optimistic UI patterns.Caching: Created folders are automatically cached in IndexedDB via
cacheFolders().Auto-Grant: If
futureGrantees is provided, access is automatically granted after creation via grantWriteAccessMulti.