How to Restore an Item
This guide explains the algorithm behind restoring an item by selecting a point in time. It walks through every stage in execution order and shows the exact API calls at each step.
Overview
The algorithm consists of the following stages:
- Search — find the target item using the bsearch API.
- Snapshot lookup — resolve the desired timestamp to a concrete snapshot ID.
- Submit — POST a restore job for the item and collect the result.
- Verify (optional) — confirm the job was accepted and track its progress.
All requests require HTTP Basic authentication and the standard API headers. See the Authentication and API Headers pages for details.
Stage 1 — Search for the Item
See the Search Backup page for details.
Use the bsearch endpoint to locate the target item. Use filterOr=AND:!sys; to exclude system items from the results.
| Method | GET |
| Endpoint | https://{baseUrl}/users/{accountId}/bsearch |
| Body | none |
Set the following query parameters:
| Parameter | Value |
|---|---|
apiVersion | 2 — API version |
device | {connectorId} |
pathRoot | {pathRoot} — see pathRoot by item type |
filterOr | AND:!sys; — excludes system items |
sortTerms | folder,title,id — sort order for results |
recursive | 1 to search all subfolders under pathRoot; optional, defaults to 0 |
curl
Code
Add &searchTerms={searchTerms} to narrow results by keyword (optional). Omit
it to return all items under the given pathRoot.
Optionally, you can paginate through the results: request one page of count
items at a time, increasing startIndex by count for each next page, until a
page returns fewer than count items. For example, with count=500, request
startIndex=0, then 500, then 1000, and so on.
pathRoot by item type
The pathRoot value depends on the item type being restored.
Email:
Code
Omit /{folderName} to search the entire Outlook mailbox. Otherwise, append the folder name to narrow the search (e.g. /Users/{userIdentity}/Outlook/Inbox).
OneDrive:
Code
If the search returns zero results, retry with the alternate OneDrive path:
- If
pathFromRootstarts withOneDrive:/Users/{userIdentity}/OneDriveSP/DocLibs/Documents/Content - Otherwise:
/Users/{userIdentity}/OneDrive
SharePoint:
Code
Omit /{encodedSiteUrl} to search across all SharePoint sites. To target one site, set encodedSiteUrl to the escape-masked site URL. For example, https://m365x47291058.sharepoint.com/sites/allcompany becomes /SharePoint/https-c-s-sm365x47291058.sharepoint.com-ssites-sallcompany.
Groups & Teams:
Code
Omit /{groupId} to search across all groups. To target one group, set groupId to the escape-masked group GUID. For example, /Groups/f3a1b2c4--d7e8--4f91--a023--b6c5d4e3f2a1.
Path segment encoding
Special characters inside individual path segments must be escaped before
building pathRoot. See Escape Masking for the full rules and
examples.
Example
Code
Response
Code: 200 OK
The API returns XML. Each <entry> represents one item:
Code
A deleted item includes an additional <deleted/> element:
Code
[!TIP]
<updated>is an ISO 8601 UTC timestamp identifying when the item was last seen in a snapshot — you will need this value in Stage 2. Identify the target<entry>from the results before proceeding.
Stage 2 — Resolve Snapshot ID
See the [Retrieve Snapshot History Range] page for details.
For the target item you need the snapshot ID that corresponds to
the desired point in time. Query the snapshot history range endpoint
backwards from the item's <updated> timestamp.
| Method | PUT |
| Endpoint | https://{baseUrl}/users/{accountId}/devices/{connectorId}/history/range |
| Body | XML <range> |
Send the following <range> body:
| Body field | Value |
|---|---|
start | {updated} — the item's <updated> value from Stage 1 (UTC ISO 8601); need not be exact, any timestamp within span resolves to the right snapshot |
span | P30D — look back up to 30 days from start |
count | 1 — only the single nearest snapshot is needed |
reverse | (empty element) — walk backwards in time from start |
curl
Code
Example
Code
Code
Response
Code: 200 OK
Code
Extract the <root> value of the first <backup> element — the snapshot ID to use when building the restore job.
Stage 3 — Build and Submit the Restore Job
See the Create Device Job page for details.
Construct the XML job definition and POST it to the API.
| Method | POST |
| Endpoint | https://{baseUrl}/users/{accountId}/devices/{connectorId}/jobs/ |
| Body | XML <job> |
Build the following <job> body:
| Body field | Value |
|---|---|
description | free-text label, e.g. [srestore] Restore of an item |
type | srestore |
immediate | (empty element) — run the job immediately |
priority | 1 |
SnapshotId | {snapshotId} — snapshot hash from Stage 2 <root> |
FolderRestoreMode | DeltaAppend |
FileConflictResolutionMode | Restore — overwrite existing items on conflict |
Method | InPlace (original location) or ToFolder (a different folder) |
Path | {path} — the <id> with kng://{connectorId} stripped |
XML job definition
Code
Path value inside <Path>:
To get the <Path> value for the restore job, strip the kng://{connectorId} prefix, leaving just /{path}, then XML-escape the result as defined by the XML specification (encode &, <, >, ", and ' as their XML entities).
For example, given the <id> returned by bsearch:
Code
The <Path> value is:
Code
curl
Code
Example
Code
Code
Response
Code: 201 Created — no body.
Stage 4 — Verify the Restore Job (optional)
See the List Device Jobs page for details.
To confirm the job was accepted and track its progress, query the jobs endpoint:
| Method | GET |
| Endpoint | https://{baseUrl}/users/{accountId}/devices/{connectorId}/jobs |
| Body | none |
curl
Code
Example
Code
Response
Code: 200 OK
Code
<progress>— a float between0.0and1.0.<succeeded>/<failed>— on completion, the job carries one of these timestamps:<succeeded>if it succeeded,<failed>if it failed.<active>—trueonly while the job is still running.