Learn how to use the portal service to set the sharing level for an item in your portal.
Prerequisites
You need the following for this tutorial:
- Account: An ArcGIS Location Platform, ArcGIS Online, or ArcGIS Enterprise account.
 - Authentication: A basic understanding of API key authentication or User authentication.
 
Steps
Set up authentication
Create a new API key credential with privileges to access the resources used in this tutorial.
- Go to the Create an API key tutorial and create an API key with the following privilege(s):
- Privileges
- Location services > Basemaps
 
 
- Item access
- Note: If you are using your own custom data layer for this tutorial, you need to grant the API key credentials access to the layer item. Learn more in Item access privileges.
 
 
 - Privileges
 - When prompted, copy and paste the API key to a safe location. It will be used in the next step.
 
Set up environment
- In a different window, launch Postman and create a blank request.
 
Create a new private item
You will create a new web map in your portal. The default sharing level will be private. In a later step, you will use the web map item ID to change the sharing level to public using the portal service.
- In a different tab, sign in to your portal.
 - Click on Map to open up Map Viewer.
 - Add a basemap, layer, and viewpoint for your map.
 - Click Save > Save as.
 - Provide a title and tags for your web map. Then, click Save.
 - In the URL part of your browser, copy the web map item ID and store it in a safe location. You can find the item ID in 
https. You will use this item ID in a later step.://arcgis.com/apps/mapviewer/index.html?webmap= <ITEM _ID >  
Perform a share request
Now, you will be changing the sharing level of your item from private to public using the portal service.
- Set the request type to 
POST. - In the URL field, type in 
https. Replace://arcgis.com/sharing/rest/content/users/ <USER _NAME >/items/ <ITEM _ID >/share <USERwith your username and_NAME > <ITEMwith the item ID you copied in the previous step._ID >  - Set the 
fparameter topjsonin the parameter list. - Set the 
everyoneparameter totrueto set the sharing level to public. To see other sharing levels, go to Sharing items. - Set the 
tokenparameter to your access token. - Set the 
qparameter totypein the parameter list.: " Web Map"  - Run the request.
 
POST https://arcgis.com/sharing/rest/content/users/<USER_NAME>/items/<ITEM_ID>/share
Content-Type: application/x-www-form-urlencoded
&f=json
&everyone=true
&token=<YOUR_ACCESS_TOKEN>View the results
Go back to your portal and you should see that the sharing level of your item has changed to public. Your code may also print an output like this to verify that the operation was successful:
{
    "notSharedWith": [],
    "itemId": "<ITEM_ID>"
}What's next

Copy a hosted layer item
Use the portal service to copy a hosted layer item in your portal.

Create a new group and add members
Use the portal service to create a new group and add members in your portal.