curl --request POST \
--url http://api.den.local/v1/capabilities/google-workspace/drive-file-share/{fileId} \
--header 'Content-Type: application/json' \
--data '
{
"emailAddress": "jsmith@example.com",
"domain": "<string>",
"role": "reader",
"sendNotificationEmail": true
}
'import requests
url = "http://api.den.local/v1/capabilities/google-workspace/drive-file-share/{fileId}"
payload = {
"emailAddress": "jsmith@example.com",
"domain": "<string>",
"role": "reader",
"sendNotificationEmail": True
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
emailAddress: 'jsmith@example.com',
domain: '<string>',
role: 'reader',
sendNotificationEmail: true
})
};
fetch('http://api.den.local/v1/capabilities/google-workspace/drive-file-share/{fileId}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "http://api.den.local/v1/capabilities/google-workspace/drive-file-share/{fileId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'emailAddress' => 'jsmith@example.com',
'domain' => '<string>',
'role' => 'reader',
'sendNotificationEmail' => true
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "http://api.den.local/v1/capabilities/google-workspace/drive-file-share/{fileId}"
payload := strings.NewReader("{\n \"emailAddress\": \"jsmith@example.com\",\n \"domain\": \"<string>\",\n \"role\": \"reader\",\n \"sendNotificationEmail\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("http://api.den.local/v1/capabilities/google-workspace/drive-file-share/{fileId}")
.header("Content-Type", "application/json")
.body("{\n \"emailAddress\": \"jsmith@example.com\",\n \"domain\": \"<string>\",\n \"role\": \"reader\",\n \"sendNotificationEmail\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://api.den.local/v1/capabilities/google-workspace/drive-file-share/{fileId}")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"emailAddress\": \"jsmith@example.com\",\n \"domain\": \"<string>\",\n \"role\": \"reader\",\n \"sendNotificationEmail\": true\n}"
response = http.request(request)
puts response.read_body{
"ok": true,
"fileId": "<string>",
"permissionId": "<string>",
"type": "<string>",
"role": "<string>"
}{
"error": "invalid_request",
"details": [
{
"message": "<string>",
"path": [
"<string>"
]
}
],
"capability": "<string>"
}{
"error": "unauthorized"
}{
"error": "needs_connection",
"message": "<string>"
}{
"error": "google_api_error",
"message": "<string>"
}Share a Google Drive file with a person or the organization
Creates a Drive permission for one file using the calling member’s Google Workspace account. To share with one person pass type=user plus emailAddress; to share with the entire organization pass type=domain plus the org’s Google Workspace domain (e.g. openworklabs.com). Sharing files not created through OpenWork needs the Full Drive access feature enabled by an admin.
curl --request POST \
--url http://api.den.local/v1/capabilities/google-workspace/drive-file-share/{fileId} \
--header 'Content-Type: application/json' \
--data '
{
"emailAddress": "jsmith@example.com",
"domain": "<string>",
"role": "reader",
"sendNotificationEmail": true
}
'import requests
url = "http://api.den.local/v1/capabilities/google-workspace/drive-file-share/{fileId}"
payload = {
"emailAddress": "jsmith@example.com",
"domain": "<string>",
"role": "reader",
"sendNotificationEmail": True
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
emailAddress: 'jsmith@example.com',
domain: '<string>',
role: 'reader',
sendNotificationEmail: true
})
};
fetch('http://api.den.local/v1/capabilities/google-workspace/drive-file-share/{fileId}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "http://api.den.local/v1/capabilities/google-workspace/drive-file-share/{fileId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'emailAddress' => 'jsmith@example.com',
'domain' => '<string>',
'role' => 'reader',
'sendNotificationEmail' => true
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "http://api.den.local/v1/capabilities/google-workspace/drive-file-share/{fileId}"
payload := strings.NewReader("{\n \"emailAddress\": \"jsmith@example.com\",\n \"domain\": \"<string>\",\n \"role\": \"reader\",\n \"sendNotificationEmail\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("http://api.den.local/v1/capabilities/google-workspace/drive-file-share/{fileId}")
.header("Content-Type", "application/json")
.body("{\n \"emailAddress\": \"jsmith@example.com\",\n \"domain\": \"<string>\",\n \"role\": \"reader\",\n \"sendNotificationEmail\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://api.den.local/v1/capabilities/google-workspace/drive-file-share/{fileId}")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"emailAddress\": \"jsmith@example.com\",\n \"domain\": \"<string>\",\n \"role\": \"reader\",\n \"sendNotificationEmail\": true\n}"
response = http.request(request)
puts response.read_body{
"ok": true,
"fileId": "<string>",
"permissionId": "<string>",
"type": "<string>",
"role": "<string>"
}{
"error": "invalid_request",
"details": [
{
"message": "<string>",
"path": [
"<string>"
]
}
],
"capability": "<string>"
}{
"error": "unauthorized"
}{
"error": "needs_connection",
"message": "<string>"
}{
"error": "google_api_error",
"message": "<string>"
}Path Parameters
Google Drive file id.
1 - 512Body
Use type=user to share with one person, or type=domain to share with the entire organization.
user, domain Required when type=user; pass the person's email address, for example raghav@openworklabs.com.
320^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$Required when type=domain; pass the organization's Google Workspace domain, for example openworklabs.com.
1 - 255Drive permission role to grant.
reader, commenter, writer Whether Google should email the recipient about the new access.
Was this page helpful?