# Microsoft SharePoint

{% hint style="info" %}
The following documentation is for **Microsoft SharePoint v2.2.5** *(BDK)*.
{% endhint %}

## Overview

Microsoft SharePoint offers enterprise content management and collaboration platform for document sharing and team sites. This integration enables automated document workflows, content management, and team collaboration processes. Enhance organizational knowledge sharing and streamline document management.

## Prerequisites

### 1. Required Books

The following Book(s) need to be added to your agent so it can learn and understand the automation procedures defined within them:

* **Microsoft SharePoint**

#### How to Add the Book(s)

1. Go to **Books** → **All Books**.
2. Search for the name of the book and click on it.
3. Click on <kbd>**Install**</kbd> or <kbd>**Add Connection**</kbd> to add the book to your agent.
4. If adding a connection, you'll be prompted for [**connectivity**](#connectivity) details.

## Connectivity

This section outlines the available methods for connecting to the Book, along with the required configuration details for each.

### Connect using Client ID, Client Secret and Tenant ID

Connect to the Microsoft Graph API using the provided client credentials.

| Label         | Description                                                  | Type        |
| ------------- | ------------------------------------------------------------ | ----------- |
| Client ID     | The client ID of the application registered in Azure AD.     | `text`      |
| Client Secret | The client secret of the application registered in Azure AD. | `sensitive` |
| Tenant ID     | The tenant ID of the Azure AD directory.                     | `text`      |

### Connect using Client ID, Certificate and Tenant ID

Connect to the Microsoft Graph API using certificate credentials.

| Label       | Description                                                                           | Type        |
| ----------- | ------------------------------------------------------------------------------------- | ----------- |
| Client ID   | The client ID of the application registered in Azure AD.                              | `text`      |
| Certificate | PEM-encoded X.509 certificate string containing both the certificate and private key. | `sensitive` |
| Tenant ID   | The tenant ID of the Azure AD directory.                                              | `text`      |

### Connect using Client ID, Certificate, Private Key and Tenant ID

Connect to the Microsoft Graph API using certificate and private key.

| Label       | Description                                              | Type        |
| ----------- | -------------------------------------------------------- | ----------- |
| Client ID   | The client ID of the application registered in Azure AD. | `text`      |
| Certificate | PEM-encoded certificate string.                          | `sensitive` |
| Private Key | PEM-encoded private key string.                          | `sensitive` |
| Tenant ID   | The tenant ID of the Azure AD directory.                 | `text`      |

## Procedures

### to add a column to a slist

Adds a column to a given SharePoint list using the Microsoft Graph API.

For now, it will remain the same as the BCI version. In the future, we should try to support more col types, opening up the configuration for them.

**Input Concepts**

| Concept                     | Description                                 | Type              | Required | Default Value |
| --------------------------- | ------------------------------------------- | ----------------- | -------- | ------------- |
| [`slist`](#sharepoint-list) | The list to which the column will be added. | `sharepoint list` | Yes      | (no default)  |
| `name`                      | The name of the column to be added.         | `text`            | Yes      | (no default)  |
| `description`               | The description of the column to be added.  | `text`            | No       | (no default)  |

**Examples**

```generic
add a column to the list
  the name is "NewColumn"
  the description is "The newest column"
```

### to add an (item) to a slist

Adds an item to a given SharePoint list using the Microsoft Graph API.

**Input Concepts**

| Concept                     | Description                                                                                         | Type              | Required | Default Value |
| --------------------------- | --------------------------------------------------------------------------------------------------- | ----------------- | -------- | ------------- |
| [`slist`](#sharepoint-list) | The list to which the item will be added.                                                           | `sharepoint list` | Yes      | (no default)  |
| `item`                      | The item to be added to the list. The fields in the Dict should match the column names in the list. | `json`            | Yes      | (no default)  |

**Output Concepts**

| Concept                         | Description | Type                   |
| ------------------------------- | ----------- | ---------------------- |
| [`item`](#sharepoint-list-item) | None.       | `sharepoint list item` |

**Examples**

```generic
create a json
use the above as the item body
set the item body's "Title" to "First Item"
set the item body's "column1" to "col 1 value"
add the item body to the list
```

### to copy an item to a folder

Copies an item (folder or file) to a given folder using the Microsoft Graph API.

**Input Concepts**

| Concept                                  | Description                                                                                    | Type                                                         | Required | Default Value |
| ---------------------------------------- | ---------------------------------------------------------------------------------------------- | ------------------------------------------------------------ | -------- | ------------- |
| `item`                                   | The item (folder or file) that will be copied.                                                 | `sharepoint file reference` or `sharepoint folder reference` | Yes      | (no default)  |
| [`folder`](#sharepoint-folder-reference) | The destination folder where the file will be copied.                                          | `sharepoint folder reference`                                | Yes      | (no default)  |
| `item name`                              | The new name for the copy. If this isn't provided, the same name will be used as the original. | `text`                                                       | No       | (no default)  |
| `conflict behavior`                      | The behavior when a conflict occurs. Possible values are 'fail', 'replace', 'rename'.          | `text`                                                       | No       | rename        |

**Examples**

Copy an item to a folder

```generic
get a folder at "/My Site/My Documents/My Folder"
use the above as the source folder
get a folder at "/My Site/My Documents/My Other Folder"
use the above as the destination folder
copy the source folder to the destination folder
```

### to create a (folder) in a document library

Creates a new folder at the root of the given SharePoint document library using the Microsoft Graph API.

**Input Concepts**

| Concept                                            | Description                                                                           | Type                          | Required | Default Value |
| -------------------------------------------------- | ------------------------------------------------------------------------------------- | ----------------------------- | -------- | ------------- |
| [`document library`](#sharepoint-document-library) | The document library where the folder will be created.                                | `sharepoint document library` | Yes      | (no default)  |
| `folder name`                                      | The name of the folder to be created.                                                 | `text`                        | Yes      | (no default)  |
| `conflict behavior`                                | The behavior when a conflict occurs. Possible values are 'fail', 'replace', 'rename'. | `text`                        | No       | rename        |

**Output Concepts**

| Concept                                  | Description                                                           | Type                          |
| ---------------------------------------- | --------------------------------------------------------------------- | ----------------------------- |
| [`folder`](#sharepoint-folder-reference) | A sharepoint document library folder representing the created folder. | `sharepoint folder reference` |

**Examples**

Create a folder named "My New Folder" in the document library "My Documents" the folder name is "My New Folder"

```generic
get site from sharepoint whose name is "Human Resources"
get some site's document libraries
create a folder in the first library
```

### to create a (folder) in another folder

Creates a new folder at the given SharePoint document library item using the Microsoft Graph API.

**Input Concepts**

| Concept                                          | Description                                                                           | Type                          | Required | Default Value |
| ------------------------------------------------ | ------------------------------------------------------------------------------------- | ----------------------------- | -------- | ------------- |
| [`another folder`](#sharepoint-folder-reference) | The folder under which the new folder will be created.                                | `sharepoint folder reference` | Yes      | (no default)  |
| `folder name`                                    | The name of the folder to be created.                                                 | `text`                        | Yes      | (no default)  |
| `conflict behavior`                              | The behavior when a conflict occurs. Possible values are 'fail', 'replace', 'rename'. | `text`                        | No       | rename        |

**Output Concepts**

| Concept                                  | Description                                                         | Type                          |
| ---------------------------------------- | ------------------------------------------------------------------- | ----------------------------- |
| [`folder`](#sharepoint-folder-reference) | A sharepoint document library item representing the created folder. | `sharepoint folder reference` |

**Examples**

Create a folder named "My New Folder" under the folder "My Folder"

```generic
get a folder at "/My Site/My Documents/My Folder"
use the above as the other folder
create a folder in the other folder
  the folder name is "My New Folder"
```

### to create a list in a sharepoint site

Creates a new list in a given SharePoint site using the Microsoft Graph API.

**Input Concepts**

| Concept                    | Description                              | Type              | Required | Default Value |
| -------------------------- | ---------------------------------------- | ----------------- | -------- | ------------- |
| [`site`](#sharepoint-site) | The site where the list will be created. | `sharepoint site` | Yes      | (no default)  |
| `list name`                | The name of the list to be created.      | `text`            | Yes      | (no default)  |

**Output Concepts**

| Concept                      | Description                                            | Type              |
| ---------------------------- | ------------------------------------------------------ | ----------------- |
| [`answer`](#sharepoint-list) | A SharepointList object representing the created list. | `sharepoint list` |

**Examples**

```generic
create a list in the site
the list name is "My List"
```

### to delete a column from a list

Deletes a column from a given SharePoint list using the Microsoft Graph API.

**Input Concepts**

| Concept                             | Description               | Type                     | Required | Default Value |
| ----------------------------------- | ------------------------- | ------------------------ | -------- | ------------- |
| [`column`](#sharepoint-list-column) | The column to be deleted. | `sharepoint list column` | Yes      | (no default)  |

**Examples**

```generic
delete the column from the list
```

### to delete a slist

Deletes a list in a given SharePoint site using the Microsoft Graph API.

**Input Concepts**

| Concept                     | Description             | Type              | Required | Default Value |
| --------------------------- | ----------------------- | ----------------- | -------- | ------------- |
| [`slist`](#sharepoint-list) | The list to be deleted. | `sharepoint list` | Yes      | (no default)  |

**Examples**

```generic
delete the list
```

### to delete an item

Deletes an item (folder or file) within a given SharePoint document library using the Microsoft Graph API.

**Input Concepts**

| Concept | Description                              | Type                                                         | Required | Default Value |
| ------- | ---------------------------------------- | ------------------------------------------------------------ | -------- | ------------- |
| `item`  | The item (folder or file) to be deleted. | `sharepoint file reference` or `sharepoint folder reference` | Yes      | (no default)  |

**Examples**

Delete an item

```generic
get a folder at "/My Site/My Documents/My Folder"
get the folder's items
delete the first item
```

### to delete an item from list

Deletes one or many items in a given SharePoint list using the Microsoft Graph API.

**Input Concepts**

| Concept | Description                      | Type                                                     | Required | Default Value |
| ------- | -------------------------------- | -------------------------------------------------------- | -------- | ------------- |
| `item`  | The item or items to be deleted. | `list of sharepoint list item` or `sharepoint list item` | Yes      | (no default)  |

**Examples**

```generic
delete the created item in list
```

```generic
get the list as the slist
get the slist's items whose "Title" is "First Item"
use the above as the items
delete the items in list
```

### to download a file

Downloads a file from a given SharePoint document library using the Microsoft Graph API.

**Input Concepts**

| Concept                              | Description                                  | Type                        | Required | Default Value |
| ------------------------------------ | -------------------------------------------- | --------------------------- | -------- | ------------- |
| [`file`](#sharepoint-file-reference) | The SharePoint file that will be downloaded. | `sharepoint file reference` | Yes      | (no default)  |

**Output Concepts**

| Concept  | Description         | Type   |
| -------- | ------------------- | ------ |
| `answer` | The downloaded file | `file` |

**Examples**

Download a file

```generic
get a folder at "/My Site/My Documents/My Folder"
get the folder's items
download the first item
```

### to edit an item

Edits an item in a given SharePoint list using the Microsoft Graph API.

**Input Concepts**

| Concept                         | Description            | Type                   | Required | Default Value |
| ------------------------------- | ---------------------- | ---------------------- | -------- | ------------- |
| [`item`](#sharepoint-list-item) | The item to be edited. | `sharepoint list item` | Yes      | (no default)  |

**Examples**

The created item is a JSON or a SharepointListItem concept

```generic
set the created item's "field.Title" to "Updated Title"
edit the created item
```

### to get a (folder's items)

![FILTER - CAPABLE](https://img.shields.io/static/v1?label=FILTER\&message=CAPABLE\&color=blue)

Retrieves all child items from the specified document library folder using the Microsoft Graph API.

**Input Concepts**

| Concept                                  | Description                                               | Type                          | Required | Default Value |
| ---------------------------------------- | --------------------------------------------------------- | ----------------------------- | -------- | ------------- |
| [`folder`](#sharepoint-folder-reference) | The document library folder from which to retrieve items. | `sharepoint folder reference` | Yes      | (no default)  |

**Output Concepts**

| Concept          | Description                                                 | Type                                                         |
| ---------------- | ----------------------------------------------------------- | ------------------------------------------------------------ |
| `folder's items` | A list of items within the specified document library item. | `sharepoint file reference` or `sharepoint folder reference` |

**Examples**

Retrieve all items from the folder "My Folder"

```generic
get a folder at "/My Site/My Documents/My Folder"
get the folder's items
```

### to get a (folder) at a path

Retrieves the root folder of a given SharePoint document library using the Microsoft Graph API.

**Input Concepts**

| Concept | Description                                                           | Type   | Required | Default Value |
| ------- | --------------------------------------------------------------------- | ------ | -------- | ------------- |
| `path`  | The path to the folder to retrieve with the following format: ////... | `text` | Yes      | (no default)  |

**Output Concepts**

| Concept                                  | Description                                                                       | Type                          |
| ---------------------------------------- | --------------------------------------------------------------------------------- | ----------------------------- |
| [`folder`](#sharepoint-folder-reference) | A sharepoint document library item representing the folder at the specified path. | `sharepoint folder reference` |

**Examples**

Retrieve the root folder of the document library "My Documents" in the site "My Site"

```generic
get a folder at "/My Site/My Documents"
```

Retrieve the folder "My Folder" within the document library "My Documents" in the site "My Site"

```generic
get a folder at "/My Site/My Documents/My Folder"
```

### to get a (root folder) from a document library

Retrieves the root folder of a given SharePoint document library using the Microsoft Graph API.

**Input Concepts**

| Concept                                            | Description                                                  | Type                          | Required | Default Value |
| -------------------------------------------------- | ------------------------------------------------------------ | ----------------------------- | -------- | ------------- |
| [`document library`](#sharepoint-document-library) | The document library from which to retrieve the root folder. | `sharepoint document library` | Yes      | (no default)  |

**Output Concepts**

| Concept                                       | Description                                        | Type                          |
| --------------------------------------------- | -------------------------------------------------- | ----------------------------- |
| [`root folder`](#sharepoint-folder-reference) | The root folder of the specified document library. | `sharepoint folder reference` |

**Examples**

Retrieve the root folder of the document library "My Documents"

```generic
get site from sharepoint whose name is "Human Resources"
get some site's document libraries
use the above as the testing libraries
get a root folder from the first testing library
```

### to get some (items) from a document library

![FILTER - CAPABLE](https://img.shields.io/static/v1?label=FILTER\&message=CAPABLE\&color=blue)

Retrieves all items within a given SharePoint document library using the Microsoft Graph API.

**Input Concepts**

| Concept                                            | Description                                        | Type                          | Required | Default Value |
| -------------------------------------------------- | -------------------------------------------------- | ----------------------------- | -------- | ------------- |
| [`document library`](#sharepoint-document-library) | The document library from which to retrieve items. | `sharepoint document library` | Yes      | (no default)  |

**Output Concepts**

| Concept | Description                                            | Type                                                         |
| ------- | ------------------------------------------------------ | ------------------------------------------------------------ |
| `items` | A list of items within the specified document library. | `sharepoint file reference` or `sharepoint folder reference` |

**Examples**

```generic
get site from sharepoint whose name is "Human Resources"
get some site's document libraries
```

### to get some (site's document libraries)

Retrieves all document libraries within a given SharePoint site using the Microsoft Graph API.

**Input Concepts**

| Concept                    | Description                                                                              | Type              | Required | Default Value |
| -------------------------- | ---------------------------------------------------------------------------------------- | ----------------- | -------- | ------------- |
| [`site`](#sharepoint-site) | A SharePointSite object representing the site from which to retrieve document libraries. | `sharepoint site` | Yes      | (no default)  |

**Output Concepts**

| Concept                                                     | Description                                             | Type                          |
| ----------------------------------------------------------- | ------------------------------------------------------- | ----------------------------- |
| [`site's document libraries`](#sharepoint-document-library) | A list of document libraries within the specified site. | `sharepoint document library` |

**Examples**

```generic
get site from sharepoint whose name is "Human Resources"
get some site's document libraries
```

### to get some (sites) from *sharepoint*

![FILTER - CAPABLE](https://img.shields.io/static/v1?label=FILTER\&message=CAPABLE\&color=blue)

Get SharePoint sites accessible via the Microsoft Graph API.

**Output Concepts**

| Concept                     | Description                 | Type              |
| --------------------------- | --------------------------- | ----------------- |
| [`sites`](#sharepoint-site) | A list of sharepoint sites. | `sharepoint site` |

**Examples**

Retrieve accessible sites from SharePoint

```generic
get sites from sharepoint
process each site as follows
  say site's name
```

Retrieve a single site by name

```generic
get sites from sharepoint whose name is "Human Resources"
```

### to get some (slist's items)

![FILTER - CAPABLE](https://img.shields.io/static/v1?label=FILTER\&message=CAPABLE\&color=blue)

Retrieves all items within a given SharePoint list using the Microsoft Graph API.

When using it, it is very important to mark the item you are working with as a "slist" (Sharepoint list) so that the Brain matches this procedure.

**Input Concepts**

| Concept                     | Description                                    | Type              | Required | Default Value |
| --------------------------- | ---------------------------------------------- | ----------------- | -------- | ------------- |
| [`slist`](#sharepoint-list) | The list from which to retrieve items.         | `sharepoint list` | Yes      | (no default)  |
| `include empty columns`     | Whether to include empty columns in the table. | `boolean`         | No       | False         |
| `limit`                     | The maximum number of items to retrieve.       | `number`          | No       | (no default)  |

**Output Concepts**

| Concept                                  | Description                                | Type                   |
| ---------------------------------------- | ------------------------------------------ | ---------------------- |
| [`slist's items`](#sharepoint-list-item) | A list of items within the specified list. | `sharepoint list item` |

**Examples**

Get the items in a list

```generic
get the list as the slist
get the slist's items
```

Get the items in a list filtered by a column

```generic
get the list as the slist
get the slist's items whose "Title" is "First Item"
```

Get the items in a list filtered by a column and include empty columns

```generic
get the list as the slist
get the slist's items whose "Title" is "First Item"
    the include empty columns is "True"
```

### to move an item to a folder

Moves an item (folder or file) to a given folder using the Microsoft Graph API.

**Input Concepts**

| Concept                                  | Description                                                                                    | Type                                                         | Required | Default Value |
| ---------------------------------------- | ---------------------------------------------------------------------------------------------- | ------------------------------------------------------------ | -------- | ------------- |
| `item`                                   | An item (folder or file) that will be moved.                                                   | `sharepoint file reference` or `sharepoint folder reference` | Yes      | (no default)  |
| [`folder`](#sharepoint-folder-reference) | The destination folder where the item will be moved.                                           | `sharepoint folder reference`                                | Yes      | (no default)  |
| `file name`                              | The new name for the move. If this isn't provided, the same name will be used as the original. | `text`                                                       | No       | (no default)  |
| `conflict behavior`                      | The behavior when a conflict occurs. Possible values are 'fail', 'replace', 'rename'.          | `text`                                                       | No       | rename        |

**Examples**

Move an item to a folder

```generic
get a folder at "/My Site/My Documents/My Folder"
use the above as the source folder
get a folder at "/My Site/My Documents/My Other Folder"
use the above as the destination folder
move the source folder to the destination folder
```

### to rename a (slist)

Renames a list in a given SharePoint site using the Microsoft Graph API.

**Input Concepts**

| Concept                     | Description                | Type              | Required | Default Value |
| --------------------------- | -------------------------- | ----------------- | -------- | ------------- |
| [`slist`](#sharepoint-list) | The list to be renamed.    | `sharepoint list` | Yes      | (no default)  |
| `name`                      | The new name for the list. | `text`            | Yes      | (no default)  |

**Output Concepts**

| Concept                     | Description       | Type              |
| --------------------------- | ----------------- | ----------------- |
| [`slist`](#sharepoint-list) | the renamed slist | `sharepoint list` |

**Examples**

```generic
rename the list
the name is "My Renamed List"
```

### to rename a column in a list

Edits a column in a given SharePoint list using the Microsoft Graph API.

IMPORTANT: This rename does not affect the internal name of the column, only the display name.

**Input Concepts**

| Concept                             | Description                          | Type                     | Required | Default Value |
| ----------------------------------- | ------------------------------------ | ------------------------ | -------- | ------------- |
| [`column`](#sharepoint-list-column) | The name of the column to be edited. | `sharepoint list column` | Yes      | (no default)  |
| `new column name`                   | The new name for the column.         | `text`                   | Yes      | (no default)  |
| `description`                       | The new description for the column.  | `text`                   | No       |               |

**Output Concepts**

| Concept                             | Description | Type                     |
| ----------------------------------- | ----------- | ------------------------ |
| [`answer`](#sharepoint-list-column) | None.       | `sharepoint list column` |

**Examples**

```generic
rename the column in the list
the new column name is "New Column Name"
the description is "The new column description"
```

### to rename an item to a name

Renames a folder or a file using the Microsoft Graph API.

**Input Concepts**

| Concept             | Description                                                                           | Type                                                         | Required | Default Value |
| ------------------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------ | -------- | ------------- |
| `item`              | A SharePoint file that will be renamed.                                               | `sharepoint file reference` or `sharepoint folder reference` | Yes      | (no default)  |
| `name`              | The new name for the file.                                                            | `text`                                                       | Yes      | (no default)  |
| `conflict behavior` | The behavior when a conflict occurs. Possible values are 'fail', 'replace', 'rename'. | `text`                                                       | No       | rename        |

**Examples**

Rename a file

```generic
get a folder at "/My Site/My Documents/My Folder"
get the folder's items
rename the first item to "My New File.txt"
```

### to retrieve a (document library) at a url

Retrieves a SharePoint document library by its web URL using the Microsoft Graph API.

URL Structure: https\://{tenant}.sharepoint.com/sites/{sitename}/{libraryname} Example: <https://contoso.sharepoint.com/sites/bdk-testing/Shared%20Documents/Forms/AllItems.aspx> Note: The library name is extracted from the URL path. Extra path segments like "Forms/AllItems.aspx" are ignored.

**Input Concepts**

| Concept | Description                                      | Type   | Required | Default Value |
| ------- | ------------------------------------------------ | ------ | -------- | ------------- |
| `url`   | The web URL of the document library to retrieve. | `text` | Yes      | (no default)  |

**Output Concepts**

| Concept                                            | Description                           | Type                          |
| -------------------------------------------------- | ------------------------------------- | ----------------------------- |
| [`document library`](#sharepoint-document-library) | A SharePoint document library object. | `sharepoint document library` |

**Examples**

Retrieve a document library by its URL

```generic
retrieve a document library by url "https://contoso.sharepoint.com/sites/HR/Documents"
```

Get a document library by URL and list its contents

```generic
retrieve a document library by url "https://contoso.sharepoint.com/sites/Finance/Shared Documents"
use the above as the library
get some items from the library
```

### to retrieve a (file) at a url

Retrieves a SharePoint file by its web URL using the Microsoft Graph API.

URL Structure: SharePoint sharing link format with a file type indicator: https\://{tenant}.sharepoint.com/:{type}:/s/{sitename}/{encoded-file-id}?e={share-token} File type indicators: :x: (Excel), :w: (Word), :p: (PowerPoint), :o: (OneNote), :u: (other) Example: <https://contoso.sharepoint.com/:x:/s/bdk-testing/IQBeb0d3aEHrQ6FjalfpQ0YMAaGJLzwchRkDm49QQonv9Zs?e=kMch0g> To get this URL: Right-click on the file in SharePoint and select "Copy link".

**Input Concepts**

| Concept | Description                                         | Type   | Required | Default Value |
| ------- | --------------------------------------------------- | ------ | -------- | ------------- |
| `url`   | The web URL (sharing link) of the file to retrieve. | `text` | Yes      | (no default)  |

**Output Concepts**

| Concept                              | Description                         | Type                        |
| ------------------------------------ | ----------------------------------- | --------------------------- |
| [`file`](#sharepoint-file-reference) | A SharePoint file reference object. | `sharepoint file reference` |

**Examples**

Retrieve a file by its URL

```generic
retrieve a file by url "https://contoso.sharepoint.com/:x:/s/HR/AbC123..."
```

Get a file by URL and download it

```generic
retrieve a file by url "https://contoso.sharepoint.com/:w:/s/Finance/XyZ789..."
use the above as the file
download the file
```

### to retrieve a (folder) at a url

Retrieves a SharePoint folder by its web URL using the Microsoft Graph API.

URL Structure: SharePoint sharing link format with :f: indicating a folder: https\://{tenant}.sharepoint.com/:f:/s/{sitename}/{encoded-folder-id}?e={share-token} Example: <https://contoso.sharepoint.com/:f:/s/bdk-testing/IgAu9BS6my2MRKogPH9TanUJAdITnMhz9MC63mh2yYcQofw?e=Qg73q2> To get this URL: Right-click on the folder in SharePoint and select "Copy link".

**Input Concepts**

| Concept | Description                                           | Type   | Required | Default Value |
| ------- | ----------------------------------------------------- | ------ | -------- | ------------- |
| `url`   | The web URL (sharing link) of the folder to retrieve. | `text` | Yes      | (no default)  |

**Output Concepts**

| Concept                                  | Description                           | Type                          |
| ---------------------------------------- | ------------------------------------- | ----------------------------- |
| [`folder`](#sharepoint-folder-reference) | A SharePoint folder reference object. | `sharepoint folder reference` |

**Examples**

Retrieve a folder by its URL

```generic
retrieve a folder by url "https://contoso.sharepoint.com/:f:/s/HR/AbC123..."
```

Get a folder by URL and list its contents

```generic
retrieve a folder by url "https://contoso.sharepoint.com/:f:/s/Finance/XyZ789..."
use the above as the folder
get the folder's items
```

### to retrieve a (site) at a url

Retrieves a SharePoint site by its web URL using the Microsoft Graph API.

URL Structure: https\://{tenant}.sharepoint.com/sites/{sitename} Example: <https://contoso.sharepoint.com/sites/bdk-testing>

**Input Concepts**

| Concept | Description                                     | Type   | Required | Default Value |
| ------- | ----------------------------------------------- | ------ | -------- | ------------- |
| `url`   | The web URL of the SharePoint site to retrieve. | `text` | Yes      | (no default)  |

**Output Concepts**

| Concept                    | Description               | Type              |
| -------------------------- | ------------------------- | ----------------- |
| [`site`](#sharepoint-site) | A SharePoint site object. | `sharepoint site` |

**Examples**

Retrieve a site by its URL

```generic
retrieve a site at "https://contoso.sharepoint.com/sites/HR"
```

Get a site by URL and then retrieve its lists

```generic
retrieve a site at "https://contoso.sharepoint.com/sites/Finance"
use the above as the site
retrieve the site's lists
```

### to retrieve a (slist) at a url

Retrieves a SharePoint list by its web URL using the Microsoft Graph API.

URL Structure: https\://{tenant}.sharepoint.com/sites/{sitename}/Lists/{listname}/AllItems.aspx Example: <https://contoso.sharepoint.com/sites/bdk-testing/Lists/BDK%20Test%20List%201/AllItems.aspx> Note: The list name is extracted from the path segment after "Lists/". The "/AllItems.aspx" suffix is optional and ignored if present.

**Input Concepts**

| Concept | Description                                     | Type   | Required | Default Value |
| ------- | ----------------------------------------------- | ------ | -------- | ------------- |
| `url`   | The web URL of the SharePoint list to retrieve. | `text` | Yes      | (no default)  |

**Output Concepts**

| Concept                     | Description               | Type              |
| --------------------------- | ------------------------- | ----------------- |
| [`slist`](#sharepoint-list) | A SharePoint list object. | `sharepoint list` |

**Examples**

Retrieve a list by its URL

```generic
retrieve a slist by url "https://contoso.sharepoint.com/sites/HR/Lists/Employees"
```

Get a list by URL and retrieve its items

```generic
retrieve a slist by url "https://contoso.sharepoint.com/sites/Projects/Lists/Tasks"
use the above as the slist
get the slist's items
```

### to retrieve a slist as a (table)

Retrieve a sharepoint list as a table.

**Input Concepts**

| Concept                     | Description                                    | Type              | Required | Default Value |
| --------------------------- | ---------------------------------------------- | ----------------- | -------- | ------------- |
| [`slist`](#sharepoint-list) | The reference to the sharepoint list.          | `sharepoint list` | Yes      | (no default)  |
| `include empty columns`     | Whether to include empty columns in the table. | `boolean`         | No       | False         |

**Output Concepts**

| Concept | Description          | Type    |
| ------- | -------------------- | ------- |
| `table` | The list as a table. | `table` |

**Examples**

```generic
retrieve the list as a table
```

### to retrieve some (column definitions) from a slist

![FILTER - CAPABLE](https://img.shields.io/static/v1?label=FILTER\&message=CAPABLE\&color=blue)

Retrieves the column definitions of a given SharePoint list using the Microsoft Graph API.

**Input Concepts**

| Concept                     | Description                                       | Type              | Required | Default Value |
| --------------------------- | ------------------------------------------------- | ----------------- | -------- | ------------- |
| [`slist`](#sharepoint-list) | The list from which the schema will be retrieved. | `sharepoint list` | Yes      | (no default)  |

**Output Concepts**

| Concept                                         | Description                                         | Type                     |
| ----------------------------------------------- | --------------------------------------------------- | ------------------------ |
| [`column definitions`](#sharepoint-list-column) | A list of column definitions in the specified list. | `sharepoint list column` |

**Examples**

```generic
retrieve column definitions from the list
```

```generic
retrieve column definitions from the list whose name is "Title"
```

### to retrieve some (site's lists)

![FILTER - CAPABLE](https://img.shields.io/static/v1?label=FILTER\&message=CAPABLE\&color=blue)

Retrieves all lists within a given SharePoint site using the Microsoft Graph API.

**Input Concepts**

| Concept                    | Description                                                                              | Type              | Required | Default Value |
| -------------------------- | ---------------------------------------------------------------------------------------- | ----------------- | -------- | ------------- |
| [`site`](#sharepoint-site) | A SharePointSite object representing the site from which to retrieve document libraries. | `sharepoint site` | Yes      | (no default)  |
| `limit`                    | The maximum number of lists to retrieve.                                                 | `number`          | No       | (no default)  |

**Output Concepts**

| Concept                            | Description                                           | Type              |
| ---------------------------------- | ----------------------------------------------------- | ----------------- |
| [`site's lists`](#sharepoint-list) | A list of SharePoint lists within the specified site. | `sharepoint list` |

**Examples**

```generic
get some sites from sharepoint whose name is "Human Resources"
use the above as the site
retrieve the site's lists
```

```generic
get some sites from sharepoint whose name is "Human Resources"
use the above as the site
retrieve the site's lists whose name is "My List"
```

### to retrieve some (site's subsites)

![FILTER - CAPABLE](https://img.shields.io/static/v1?label=FILTER\&message=CAPABLE\&color=blue)

Retrieves all subsites within a given SharePoint site using the Microsoft Graph API.

**Input Concepts**

| Concept                    | Description                                                                    | Type              | Required | Default Value |
| -------------------------- | ------------------------------------------------------------------------------ | ----------------- | -------- | ------------- |
| [`site`](#sharepoint-site) | A SharePointSite object representing the site from which to retrieve subsites. | `sharepoint site` | Yes      | (no default)  |

**Output Concepts**

| Concept                               | Description                                              | Type              |
| ------------------------------------- | -------------------------------------------------------- | ----------------- |
| [`site's subsites`](#sharepoint-site) | A list of SharePoint subsites within the specified site. | `sharepoint site` |

**Examples**

Retrieve subsites from a SharePoint site.

```generic
use the above as the site
retrieve some site's subsites
```

### to upload a file to a folder and get the file reference

Uploads a file to a given SharePoint document library using the Microsoft Graph API.

**Input Concepts**

| Concept                                  | Description                                                                           | Type                          | Required | Default Value |
| ---------------------------------------- | ------------------------------------------------------------------------------------- | ----------------------------- | -------- | ------------- |
| [`folder`](#sharepoint-folder-reference) | The document library folder where the file will be uploaded.                          | `sharepoint folder reference` | Yes      | (no default)  |
| `file`                                   | The content of the file to be uploaded as bytes.                                      | `file`                        | Yes      | (no default)  |
| `file name`                              | The name of the file to be uploaded.                                                  | `text`                        | Yes      | (no default)  |
| `conflict behavior`                      | The behavior when a conflict occurs. Possible values are 'fail', 'replace', 'rename'. | `text`                        | No       | rename        |

**Output Concepts**

| Concept                                        | Description                             | Type                        |
| ---------------------------------------------- | --------------------------------------- | --------------------------- |
| [`file reference`](#sharepoint-file-reference) | An item representing the uploaded file. | `sharepoint file reference` |

**Examples**

Upload a file named "My File.txt" to the folder "My Folder" the file name is "My File.txt"

```generic
get a folder at "/My Site/My Documents/My Folder"
use the above as the folder
the new file                                                       # This will ask a question, you need to upload a file
upload the new file to the folder
```

## Concepts

### Sharepoint list

A SharePoint list is a structured collection of data within a SharePoint site. It provides a way to organize and manage information in a tabular format, with columns representing different data fields and rows containing specific data entries.Lists are commonly used for tasks like tracking project progress, managing contacts, or storing custom data.

| Field Name                 | Description                              | Type             |
| -------------------------- | ---------------------------------------- | ---------------- |
| [`columns`](#list-of-text) | The columns of the list.                 | `list of text`   |
| `created_date_time`        | The date and time the list was created.  | `datetime`       |
| `display_name`             | The display name of the list.            | `text`           |
| `id`                       | The unique identifier for the list.      | `text`           |
| `name`                     | The name of the list.                    | `text`           |
| `web_url`                  | The URL of the list.                     | `text`           |
| `site_id`                  | The id of the site this list belongs to. | `text`           |
| `description`              | The description of the list.             | `optional[text]` |

### Sharepoint list item

A SharePoint list item represents an individual entry within a SharePoint list. It contains specific data values corresponding to the columns defined in the list. List items are used to store and manage structured data within a SharePoint list, enabling efficient organization and retrieval of information.

| Field Name | Description                              | Type   |
| ---------- | ---------------------------------------- | ------ |
| `id`       | The unique identifier for the list item. | `text` |
| `list_id`  | The id of the list this item belongs to. | `text` |
| `site_id`  | The id of the site this item belongs to. | `text` |
| `fields`   | The fields of the list item.             | `json` |
| `web_url`  | The URL of the list item.                | `text` |

### Sharepoint file reference

A Sharepoint File Reference is a reference to a file in a SharePoint document library.

| Field Name                                                        | Description                                                                                                                          | Type                |
| ----------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ | ------------------- |
| `id`                                                              | The unique identifier for the document library.                                                                                      | `optional[text]`    |
| `name`                                                            | The name of the document library.                                                                                                    | `optional[text]`    |
| `web_url`                                                         | URL that either displays the resource in the browser (for Office file formats), or is a direct link to the file (for other formats). | `optional[text]`    |
| [`parent_reference`](#parent_reference-sharepoint-file-reference) | Parent information, if the item has a parent.                                                                                        | `optional[json]`    |
| `is_folder`                                                       | Boolean flag indicating whenever this item is a folder or not.                                                                       | `optional[boolean]` |
| `file_name`                                                       | The name of the file. Same as name.                                                                                                  | `optional[text]`    |

### Sharepoint folder reference

A Sharepoint Folder Reference is a reference to a folder in a SharePoint document library.

| Field Name                                                          | Description                                                                                                                          | Type                |
| ------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ | ------------------- |
| `id`                                                                | The unique identifier for the document library.                                                                                      | `optional[text]`    |
| `name`                                                              | The name of the document library.                                                                                                    | `optional[text]`    |
| `web_url`                                                           | URL that either displays the resource in the browser (for Office file formats), or is a direct link to the file (for other formats). | `optional[text]`    |
| [`parent_reference`](#parent_reference-sharepoint-folder-reference) | Parent information, if the item has a parent.                                                                                        | `optional[json]`    |
| `is_folder`                                                         | Boolean flag indicating whenever this item is a folder or not.                                                                       | `optional[boolean]` |
| `folder_name`                                                       | The name of the folder. Same as name.                                                                                                | `optional[text]`    |

### Sharepoint site

A SharePoint site is a versatile web-based platform within Microsoft SharePoint designed for team collaboration,document management, and content sharing. It provides a centralized space where users can store and manage documents with version control, organize information in lists, create and publish web pages, and control permissions for different users.

| Field Name         | Description                                                                                                                                     | Type                |
| ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------- | ------------------- |
| `id`               | The unique identifier for the site. Read-only.                                                                                                  | `text`              |
| `name`             | The name of the site. Read-write.                                                                                                               | `optional[text]`    |
| `display_name`     | The full title for the site. Read-only.                                                                                                         | `optional[text]`    |
| `web_url`          | URL that either displays the resource in the browser (for Office file formats), or is a direct link to the file (for other formats). Read-only. | `optional[text]`    |
| `is_personal_site` | Identifies whether the site is personal or not. Read-only.                                                                                      | `optional[boolean]` |
| `description`      | Provides a user-visible description of the site. Optional.                                                                                      | `optional[text]`    |

### Sharepoint document library

A SharePoint Document Library is a specialized storage location within a SharePoint site designed for storing, organizing,and managing documents. It supports advanced document management features such as version control, metadata tagging, and workflow automation, making it ideal for team collaboration and enterprise content management.

| Field Name    | Description                                                                                                                                                                                                                | Type             |
| ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------- |
| `id`          | The unique identifier for the document library. Read-only.                                                                                                                                                                 | `text`           |
| `drive_type`  | Describes the type of drive represented by this resource. OneDrive personal drives will return personal. OneDrive for Business will return business. SharePoint document libraries will return documentLibrary. Read-only. | `optional[text]` |
| `name`        | The name of the document library. Read-write.                                                                                                                                                                              | `optional[text]` |
| `web_url`     | URL that either displays the resource in the browser (for Office file formats), or is a direct link to the file (for other formats). Read-only.                                                                            | `optional[text]` |
| `description` | Provides a user-visible description of the document library. Optional.                                                                                                                                                     | `optional[text]` |

### Sharepoint list column

A SharePoint list column definition represents the configuration and properties of a column within a SharePoint list.

| Field Name                 | Description                                 | Type             |
| -------------------------- | ------------------------------------------- | ---------------- |
| `id`                       | The unique identifier for the column.       | `text`           |
| `type`                     | The type of the column.                     | `text`           |
| `list_id`                  | The id of the list this column belongs to.  | `text`           |
| `site_id`                  | The id of the site this column belongs to.  | `text`           |
| `general_definition`       | The general definition of the column.       | `json`           |
| `type_specific_definition` | The type specific definition of the column. | `optional[json]` |

**Concept attribute specifications**

**parent\_reference (sharepoint file reference)**

| Name       | Type             |
| ---------- | ---------------- |
| `id`       | `optional[text]` |
| `drive_id` | `optional[text]` |

**parent\_reference (sharepoint folder reference)**

| Name       | Type             |
| ---------- | ---------------- |
| `id`       | `optional[text]` |
| `drive_id` | `optional[text]` |
