Share endpoints allow sharing files with other users.
/share
(auth required)The /share
endpoint shares 1 or more filesystem items
with one or more recipients. The recipients will receive
some notification about the shared item, making this
different from calling /grant-user-user
with a permission.
string | Array<string>
string
: email or usernamestring | object | Array<string | object>
bool
api:share
v0.0.0
"success"
, "mixed"
, "aborted"
api:status-report
or
heyputer:api/APIError
api:status-report
or
heyputer:api/APIError
true
if present{
"$": "api:share",
"$version": "v0.0.0",
"status": "success",
"recipients": [
{
"$": "api:status-report",
"status": "success"
}
],
"paths": [
{
"$": "api:status-report",
"status": "success"
}
],
"dry_run": true
}
{
"$": "api:share",
"$version": "v0.0.0",
"status": "mixed",
"recipients": [
{
"$": "api:status-report",
"status": "success"
}
],
"paths": [
{
"$": "heyputer:api/APIError",
"code": "subject_does_not_exist",
"message": "File or directory not found.",
"status": 404
}
],
"dry_run": true
}
{
"$": "api:share",
"$version": "v0.0.0",
"status": "mixed",
"recipients": [
{
"$": "heyputer:api/APIError",
"code": "user_does_not_exist",
"message": "The user `non_existing_user` does not exist.",
"username": "non_existing_user",
"status": 422
}
],
"paths": [
{
"$": "api:status-report",
"status": "success"
}
],
"dry_run": true
}
/share/item-by-username
(auth required)The /share/item-by-username
endpoint grants access permission
for an item to the specified user. This user will also receive an
email about the shared item.
Name | Description | Default Value |
---|---|---|
path | Location of the item | required |
username | Username of the user to share to | required |
access_level | Either 'read' or 'write' |
'write' |
This endpoint responds with an empty object ({}
).
await fetch("https://api.puter.local/share/item-by-username", {
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${puter.authToken}`,
},
body: JSON.stringify({
path: "/my-username/Desktop/some-file.txt",
username: "other-username",
}),
method: "POST",
});