Isolate documents with workspaces
Ce contenu n’est pas encore disponible dans votre langue.
Workspaces allow you to isolate documents and control access within your team. Only workspace members can see documents uploaded to that workspace, enabling you to silo different teams or customer documents in the same account.
Prerequisites
Section titled “Prerequisites”- A Subnoto account with API credentials (access key and secret key)
- API access configured via API Proxy or SDKs
How Workspace Isolation Works
Section titled “How Workspace Isolation Works”When you upload a document to a workspace, only members of that workspace can access it. This enables:
- Team separation: Keep different teams’ documents isolated
- Customer isolation: Separate documents by customer or project
- Privacy control: Limit document visibility to specific workspace members
-
Create a Workspace
Create a new workspace for isolating your documents:
Using curl:
Terminal window curl -X POST http://localhost:8080/public/workspace/create \-H "Authorization: Bearer $ACCESS_KEY:$SECRET_KEY" \-H "Content-Type: application/json" \-d '{"name": "Customer A Documents","colorHex": "#3B82F6"}'Using TypeScript SDK:
import { SubnotoClient } from "@subnoto/api-client";const client = new SubnotoClient({apiBaseUrl: "https://enclave.subnoto.com",accessKey: process.env.API_ACCESS_KEY,secretKey: process.env.API_SECRET_KEY});const { data, error } = await client.POST("/public/workspace/create", {body: {name: "Customer A Documents",colorHex: "#3B82F6"}});if (error) {throw new Error(`Failed to create workspace: ${error}`);}const workspaceUuid = data.workspace.uuid;Response:
{"workspace": {"uuid": "workspace-uuid","name": "Customer A Documents","creationDate": 1704067200000,"updateDate": 1704067200000,"isDefault": false,"colorHex": "#3B82F6"}} -
List Workspaces
List all workspaces you have access to:
Using curl:
Terminal window curl -X POST http://localhost:8080/public/workspace/list \-H "Authorization: Bearer $ACCESS_KEY:$SECRET_KEY" \-H "Content-Type: application/json" \-d '{}'Using TypeScript SDK:
const { data, error } = await client.POST("/public/workspace/list", {body: {}});if (error) {throw new Error(`Failed to list workspaces: ${error}`);}console.log("Workspaces:", data.workspaces);Response:
{"workspaces": [{"uuid": "workspace-uuid-1","name": "Customer A Documents","creationDate": 1704067200000,"updateDate": 1704067200000,"membersCount": 3},{"uuid": "workspace-uuid-2","name": "Customer B Documents","creationDate": 1704067300000,"updateDate": 1704067300000,"membersCount": 2}]} -
Get Workspace Details
Retrieve details for a specific workspace by UUID or name:
Using curl:
Terminal window # By UUIDcurl -X POST http://localhost:8080/public/workspace/get \-H "Authorization: Bearer $ACCESS_KEY:$SECRET_KEY" \-H "Content-Type: application/json" \-d '{"workspaceUuid": "workspace-uuid"}'# Or by namecurl -X POST http://localhost:8080/public/workspace/get \-H "Authorization: Bearer $ACCESS_KEY:$SECRET_KEY" \-H "Content-Type: application/json" \-d '{"workspaceName": "Customer A Documents"}'Using TypeScript SDK:
// By UUIDconst { data, error } = await client.POST("/public/workspace/get", {body: {workspaceUuid: "workspace-uuid"}});// Or by nameconst { data: dataByName, error: errorByName } = await client.POST("/public/workspace/get", {body: {workspaceName: "Customer A Documents"}});if (data) {console.log("Workspace details:", data.workspace);} -
Upload Documents to a Workspace
Upload documents to a specific workspace. Only workspace members will be able to access these documents:
Using curl:
Terminal window curl -X POST http://localhost:8080/public/envelope/create-from-file \-H "Authorization: Bearer $ACCESS_KEY:$SECRET_KEY" \-F "workspaceUuid=your-workspace-uuid" \-F "envelopeTitle=Customer A Contract" \-F "file=@path/to/document.pdf"Using TypeScript SDK:
import { readFileSync } from "fs";const workspaceUuid = "your-workspace-uuid";const pdfBuffer = readFileSync("path/to/document.pdf");const result = await client.uploadDocument({workspaceUuid,fileBuffer: pdfBuffer,envelopeTitle: "Customer A Contract"});console.log("Envelope created in workspace:", result.envelopeUuid);Important: Always specify the
workspaceUuidwhen creating envelopes. Documents uploaded without a workspace UUID will be placed in your default workspace.
Complete Example: Isolating Customer Documents
Section titled “Complete Example: Isolating Customer Documents”Here’s a complete example that creates separate workspaces for different customers and uploads documents to each:
import { SubnotoClient } from "@subnoto/api-client";import { readFileSync } from "fs";
const client = new SubnotoClient({ apiBaseUrl: "https://enclave.subnoto.com", accessKey: process.env.API_ACCESS_KEY, secretKey: process.env.API_SECRET_KEY});
async function isolateCustomerDocuments() { // 1. Create workspace for Customer A const { data: workspaceA } = await client.POST("/public/workspace/create", { body: { name: "Customer A Documents", colorHex: "#3B82F6" } }); const workspaceAUuid = workspaceA.workspace.uuid;
// 2. Create workspace for Customer B const { data: workspaceB } = await client.POST("/public/workspace/create", { body: { name: "Customer B Documents", colorHex: "#10B981" } }); const workspaceBUuid = workspaceB.workspace.uuid;
// 3. Upload document to Customer A workspace const pdfBufferA = readFileSync("customer-a-contract.pdf"); const resultA = await client.uploadDocument({ workspaceUuid: workspaceAUuid, fileBuffer: pdfBufferA, envelopeTitle: "Customer A Contract" });
// 4. Upload document to Customer B workspace const pdfBufferB = readFileSync("customer-b-agreement.pdf"); const resultB = await client.uploadDocument({ workspaceUuid: workspaceBUuid, fileBuffer: pdfBufferB, envelopeTitle: "Customer B Agreement" });
console.log("Documents isolated in separate workspaces"); console.log("Customer A workspace:", workspaceAUuid); console.log("Customer B workspace:", workspaceBUuid);}
isolateCustomerDocuments().catch(console.error);Access Control
Section titled “Access Control”- Workspace members: Only users who are members of a workspace can see documents in that workspace
- Team members: All team members can be added to workspaces, but they won’t see documents unless explicitly added to the workspace
- API access: API keys inherit the workspace access of the user who created them
Related Resources
Section titled “Related Resources”- API Proxy Usage - Set up API access via the proxy container
- TypeScript SDK - Use the TypeScript SDK for type-safe API access
- Python SDK - Use the Python SDK for async API access
- Create and Send Envelopes - Complete envelope workflow tutorial
- API Reference - Complete API documentation