Is there any way to provide permission to a particular user to a page using Notion API (curl)?
Tried multiple endpoints such as update etc , however nothing worked
private function grantFullAccessToUser($userEmail, $pageId)
{
// Prepare the request data
$url = 'https://api.notion.com/v1/pages/' . $pageId . '/permissions';
$headers = [
'Authorization: Bearer NOTION_TOKEN',
'Content-Type: application/json',
'Notion-Version: 2021-05-13'
];
$data = [
'role' => 'editor',
'user_id' => $userEmail
];
// Send the request to grant access
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
$response = curl_exec($ch);
curl_close($ch);
// Handle the response
if ($response) {
// Access granted successfully
echo 'Full access granted to user: ' . $userEmail;
} else {
// Access granting failed
echo 'Failed to grant full access to user: ' . $userEmail;
}
}