Create
To create a new folder you need to execute a POST request against the /libraries/:id/folders endpoint.
Two fields are available in the JSON body of the POST request:
name - the name of the folder. Required.
parent_id - the id of the parent folder. Omit this field if the folder is attached to the root of the library and not to a parent folder.
In the response you will find the unique id which identifies the folder.
1. Request (folder created in the root of the library)
curl --request POST \
--header "Content-Type: application/json" \
--url https://api.digitalsamba.com/api/v1/libraries/8606721f-d847-4721-a5dc-6537e822104c/folders \
--user YOUR_TEAM_ID:YOUR_DEVELOPER_KEY \
--data '{"name": "Birthday Party"}'import com.fasterxml.jackson.databind.ObjectMapper;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.http.HttpResponse.BodyHandlers;
import java.util.Base64;
import java.util.Map;
String TEAM_ID = "YOUR_TEAM_ID";
String DEVELOPER_KEY = "YOUR_DEVELOPER_KEY";
String authorizationHeader = "Bearer " + Base64.getEncoder().encodeToString((TEAM_ID + ":" + DEVELOPER_KEY).getBytes());
//Put your library id here - this value is just an example
final String libraryId = "8606721f-d847-4721-a5dc-6537e822104c";
Map<String, String> data = Map.of(
"name", "Birthday Party"
);
String jsonData = new ObjectMapper().writeValueAsString(data);
HttpRequest request = HttpRequest.newBuilder()
.POST(HttpRequest.BodyPublishers.ofString(jsonData))
.uri(new URI("https://api.digitalsamba.com/api/v1/libraries/" + libraryId + "/folders"))
.header("Authorization", authorizationHeader)
.header("Content-Type", "application/json")
.build();
HttpClient client = HttpClient.newHttpClient();
HttpResponse<String> response = client.send(request, BodyHandlers.ofString());
System.out.println("Status code: " + response.statusCode());
System.out.println("Body: " + response.body());Response (200 OK)
{
"id": "1fc95d41-5358-4a81-adb4-5cd8c12e8308",
"name": "Birthday Party",
"parent_id": null,
"source": "api",
"created_at": "2024-10-08T08:05:51Z"
}2. Request (creates a nested folder in the existing "Birthday Party" folder)
curl --request POST \
--header "Content-Type: application/json" \
--url https://api.digitalsamba.com/api/v1/rooms \
--user YOUR_TEAM_ID:YOUR_DEVELOPER_KEY \
--data '{"name": "Holiday in Greece", "parent_id": "1fc95d41-5358-4a81-adb4-5cd8c12e8308"}'import com.fasterxml.jackson.databind.ObjectMapper;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.http.HttpResponse.BodyHandlers;
import java.util.Base64;
import java.util.Map;
String TEAM_ID = "YOUR_TEAM_ID";
String DEVELOPER_KEY = "YOUR_DEVELOPER_KEY";
String authorizationHeader = "Bearer " + Base64.getEncoder().encodeToString((TEAM_ID + ":" + DEVELOPER_KEY).getBytes());
Map<String, String> data = Map.of(
"name", "2024",
"parent_id", "1fc95d41-5358-4a81-adb4-5cd8c12e8308",
);
String jsonData = new ObjectMapper().writeValueAsString(data);
HttpRequest request = HttpRequest.newBuilder()
.POST(HttpRequest.BodyPublishers.ofString(jsonData))
.uri(new URI("https://api.digitalsamba.com/api/v1/libraries"))
.header("Authorization", authorizationHeader)
.header("Content-Type", "application/json")
.build();
HttpClient client = HttpClient.newHttpClient();
HttpResponse<String> response = client.send(request, BodyHandlers.ofString());
System.out.println("Status code: " + response.statusCode());
System.out.println("Body: " + response.body());Response (200 OK)
{
"id": "428c31a2-ae2d-468c-a1f7-46b832c7b13a",
"name": "2024",
"parent_id": "1fc95d41-5358-4a81-adb4-5cd8c12e8308",
"source": "api",
"created_at": "2024-10-08T10:04:36Z"
}Last updated