> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.basement.chat/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.basement.chat/_mcp/server.

# Ask to share a folder

POST https://mcp.basement.chat/v1/tools/share_folder
Content-Type: application/json

Ask to share a folder with all members of the organization, or with some members by email. This call shares nothing. Basement emails a 6-digit code to the person who connected you. Ask that person for the code, then call confirm_folder_share. The person must be the owner of the folder, or an owner or admin of the organization. A request is valid for 15 minutes; you can make 5 requests in one hour. Requires write access.

Reference: https://docs.basement.chat/api-reference/gateway-api/folders/share

## Authentication

- `Authorization` header (bearer token, required) — A Basement key (bsmt_...), from Agents, Connect in the app.

## Request

### Body (application/json)

This endpoint expects an object.

- `folderId` (string, required) — The folder ID from list_folders
- `level` (enum, required) — view: read the files. edit: also add and change files. A viewer of the organization never edits
  - Allowed values: `view`, `edit`
- `withOrganization` (boolean, optional) — true to share with all members of the organization. Do not give emails
- `emails` (list of string, optional) — The emails of the members to share with. Each one must be a member of the organization. Do not give withOrganization

## Response

### 200

The tool's answer.

- `shareId` (string, required) — Give it to confirm_folder_share with the code
- `confirmation` ("code_sent", required)
- `sentTo` (string, required) — The email that got the code, with its name part hidden
- `expiresInMinutes` (integer, required)
- `message` (string, required) — What to do next

## Errors

### 400 Bad Request Error

The arguments are not valid, or the tool refused them.

- `error` (ErrorResponseError, required)

### 401 Unauthorized Error

The API key is missing, wrong, revoked or expired.

- `error` (ErrorResponseError, required)

### 403 Forbidden Error

The key's access level does not allow this call.

- `error` (ErrorResponseError, required)

### 429 Too Many Requests Error

Too many calls in a minute. Wait and try again.

- `error` (ErrorResponseError, required)

### 500 Internal Server Error

Basement failed to complete the call.

- `error` (ErrorResponseError, required)

## Types

### ErrorResponseError

- `code` (string, required) — unauthorized, forbidden, invalid_request, not_found, rate_limited, service_error or internal_error
- `message` (string, required) — What went wrong, in English

## Examples

**Request**

```json
{
  "folderId": "string",
  "level": "view"
}
```

**Response**

```json
{
  "shareId": "string",
  "confirmation": "string",
  "sentTo": "string",
  "expiresInMinutes": 1,
  "message": "string"
}
```

**SDK Code**

```python
import requests

url = "https://mcp.basement.chat/v1/tools/share_folder"

payload = {
    "folderId": "string",
    "level": "view"
}
headers = {
    "Authorization": "Bearer <apiKey>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://mcp.basement.chat/v1/tools/share_folder';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <apiKey>', 'Content-Type': 'application/json'},
  body: '{"folderId":"string","level":"view"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://mcp.basement.chat/v1/tools/share_folder"

	payload := strings.NewReader("{\n  \"folderId\": \"string\",\n  \"level\": \"view\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://mcp.basement.chat/v1/tools/share_folder")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"folderId\": \"string\",\n  \"level\": \"view\"\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://mcp.basement.chat/v1/tools/share_folder")
  .header("Authorization", "Bearer <apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"folderId\": \"string\",\n  \"level\": \"view\"\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://mcp.basement.chat/v1/tools/share_folder', [
  'body' => '{
  "folderId": "string",
  "level": "view"
}',
  'headers' => [
    'Authorization' => 'Bearer <apiKey>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://mcp.basement.chat/v1/tools/share_folder");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"folderId\": \"string\",\n  \"level\": \"view\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "folderId": "string",
  "level": "view"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://mcp.basement.chat/v1/tools/share_folder")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```