Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .devproxy/api-specs/sharepoint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,35 @@ paths:
responses:
200:
description: OK
/_api/Lists(guid{listId})/items({itemId})/Archive:
post:
parameters:
- name: listId
in: path
required: true
description: list GUID
schema:
type: string
example: "'b2307a39-e878-458b-bc90-03bc578531d6'"
- name: itemId
in: path
required: true
description: list item ID
schema:
type: integer
example: 1
security:
- delegated:
- AllSites.Write
- AllSites.Manage
- AllSites.FullControl
- application:
- Sites.ReadWrite.All
- Sites.Manage.All
- Sites.FullControl.All
responses:
200:
description: OK
/_api/SP_TenantSettings_Current:
get:
security:
Expand Down Expand Up @@ -238,6 +267,30 @@ paths:
responses:
200:
description: OK
/_api/web/GetFileByServerRelativePath(DecodedUrl={filePath}):
get:
parameters:
- name: filePath
in: path
required: true
description: URL-encoded server-relative path to the file
schema:
type: string
example: "'%2Fsites%2FM365SOBA%2Fshared%20documents%2Fgeneral%2Fdocument.docx'"
security:
- delegated:
- AllSites.Read
- AllSites.Write
- AllSites.Manage
- AllSites.FullControl
- application:
- Sites.Read.All
- Sites.ReadWrite.All
- Sites.Manage.All
- Sites.FullControl.All
responses:
200:
description: OK
/_api/web/GetFileByServerRelativePath(DecodedUrl={filePath})/$value:
get:
parameters:
Expand Down
106 changes: 106 additions & 0 deletions docs/docs/cmd/spo/file/file-archive.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import Global from '../../_global.mdx';
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

# spo file archive

Archives a file

## Usage

```sh
m365 spo file archive [options]
```

## Options

```md definition-list
`-u, --webUrl <webUrl>`
: The URL of the site where the file is located.

`--url [url]`
: The server- or site-relative decoded URL of the file to archive. Specify either `url` or `id`, but not both.

`-i, --id [id]`
: The UniqueId (GUID) of the file to archive. Specify either `url` or `id`, but not both.

`-f, --force`
: Don't prompt for confirmation.
```

<Global />

## Permissions

<Tabs>
<TabItem value="Delegated">

| Resource | Permissions |
|------------|----------------|
| SharePoint | AllSites.Write |

</TabItem>
<TabItem value="Application">

| Resource | Permissions |
|------------|---------------------|
| SharePoint | Sites.ReadWrite.All |

</TabItem>
</Tabs>

## Examples

Archive a file without prompting for confirmation

```sh
m365 spo file archive --webUrl https://contoso.sharepoint.com/sites/Marketing --id 7a8c9207-7745-4cda-b0e2-be2618ee3030 --force
```

Archive a file by URL with prompting for confirmation

```sh
m365 spo file archive --webUrl https://contoso.sharepoint.com/sites/Marketing --url '/sites/Marketing/shared documents/document.docx'
```

## Response

<Tabs>
<TabItem value="JSON">

```json
{
"value": "fullyArchived"
}
```

</TabItem>
<TabItem value="Text">

```text
value: fullyArchived
```

</TabItem>
<TabItem value="CSV">

```csv
value
fullyArchived
```

</TabItem>
<TabItem value="Markdown">

```md
# spo file archive --debug "false" --verbose "false" --webUrl "https://afonline.sharepoint.com/sites/M365SOBA" --url "/sites/M365SOBA/shared documents/general/M365 responsibility.pptx" --force "true"

Date: 4/4/2026

Property | Value
---------|-------
value | fullyArchived
```

</TabItem>
</Tabs>
5 changes: 5 additions & 0 deletions docs/src/config/sidebars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2686,6 +2686,11 @@ const sidebars: SidebarsConfig = {
label: 'file add',
id: 'cmd/spo/file/file-add'
},
{
type: 'doc',
label: 'file archive',
id: 'cmd/spo/file/file-archive'
},
{
type: 'doc',
label: 'file checkin',
Expand Down
1 change: 1 addition & 0 deletions src/m365/spo/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export default {
FIELD_REMOVE: `${prefix} field remove`,
FIELD_SET: `${prefix} field set`,
FILE_ADD: `${prefix} file add`,
FILE_ARCHIVE: `${prefix} file archive`,
FILE_CHECKIN: `${prefix} file checkin`,
FILE_CHECKOUT: `${prefix} file checkout`,
FILE_CHECKOUT_UNDO: `${prefix} file checkout undo`,
Expand Down
Loading