Get newly created, updated, or deleted sites without having to perform a full read of the entire sites collection.
A delta function call for sites is similar to a GET request, except that by appropriately applying state tokens in one or more of these calls,
you can query for incremental changes in the sites. It allows you to maintain and synchronize a local store of a user's sites without having to fetch all the sites from the server every time.
The application calls the API without specifying any parameters.
The service begins enumerating sites and returns pages of changes to these sites, accompanied by either an @odata.nextLink or an @odata.deltaLink.
Your application should continue making calls using the @odata.nextLink until there's an @odata.deltaLink in the response.
After you receive all the changes, you can apply them to your local state.
To monitor future changes, call the delta API by using the @odata.deltaLink in the previous response.
Any resources marked as deleted should be removed from your local state.
Choose the permission or permissions marked as least privileged for this API. Use a higher privileged permission or permissions only if your app requires it. For details about delegated and application permissions, see Permission types. To learn more about these permissions, see the permissions reference.
Permission type
Least privileged permissions
Higher privileged permissions
Delegated (work or school account)
Sites.Read.All
Sites.ReadWrite.All
Delegated (personal Microsoft account)
Not supported.
Not supported.
Application
Sites.Read.All
Sites.ReadWrite.All
HTTP request
GET /sites/delta
Query parameters
In the request URL, you can include the following optional query parameter.
Parameter
Type
Description
token
String
If the value is latest, the call returns an empty response with the latest delta token. If the value is a previous delta token, the call returns the new state since that token was issued.
This method also supports the $select, $expand, and $topOData query parameters to customize the response.
If successful, this method returns a 200 OK response code and a collection of site objects in the response body.
In addition to the collection of site objects, the response also includes one of the following properties.
Name
Value
Description
@odata.nextLink
URL
A URL to retrieve the next available page of changes if there are more changes in the current set.
@odata.deltaLink
URL
A URL returned instead of @odata.nextLink after all current changes are returned. Use this property to read the next set of changes in the future.
In some cases, the service returns a 410 Gone response code with an error response that contains one of the following error codes, and a Location header that contains a new nextLink that starts a fresh delta enumeration. It occurs when the service can't provide a list of changes for a given token; for example, if a client tries to reuse an old token after being disconnected for a long time, or if the server state changed and a new token is required.
After the full enumeration is completed, compare the returned sites with your local state and follow the instructions based on the error type.
Error type
Instructions
resyncChangesApplyDifferences
Replace any local sites with the versions from the server (including deletes) if you're sure that the service was up-to-date with your local changes when you last synchronized. Upload any local changes that the server doesn't know about.
resyncChangesUploadDifferences
Upload any local sites that the service didn't return and upload any sites that differ from the versions from the server. Keep both copies if you're not sure which one is more up-to-date.
// Code snippets are only available for the latest version. Current version is 5.x
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Sites.Delta.GetAsDeltaGetResponseAsync();
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
//other-imports
)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
delta, err := graphClient.Sites().Delta().GetAsDeltaGetResponse(context.Background(), nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
var result = graphClient.sites().delta().get();
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
result = await graph_client.sites.delta.get()
The following example shows the response that includes the first page of changes and the @odata.nextLink property that indicates that no more sites are available in the current set of sites. Your app should continue to request the URL value of @odata.nextLink until all pages of sites are retrieved.
GET https://graph.microsoft.com/v1.0/sites/delta?token=1230919asd190410jlka
// Code snippets are only available for the latest version. Current version is 5.x
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Sites.Delta.GetAsDeltaGetResponseAsync((requestConfiguration) =>
{
requestConfiguration.QueryParameters.Token = "1230919asd190410jlka";
});
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphsites "github.com/microsoftgraph/msgraph-sdk-go/sites"
//other-imports
)
requestToken := "1230919asd190410jlka"
requestParameters := &graphsites.SitesDeltaWithRequestBuilderGetQueryParameters{
Token: &requestToken,
}
configuration := &graphsites.SitesDeltaWithRequestBuilderGetRequestConfiguration{
QueryParameters: requestParameters,
}
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
delta, err := graphClient.Sites().Delta().GetAsDeltaGetResponse(context.Background(), configuration)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
var result = graphClient.sites().delta().get(requestConfiguration -> {
requestConfiguration.queryParameters.token = "1230919asd190410jlka";
});
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.sites.delta.delta_request_builder import DeltaRequestBuilder
from kiota_abstractions.base_request_configuration import RequestConfiguration
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
query_params = DeltaRequestBuilder.DeltaRequestBuilderGetQueryParameters(
token = "1230919asd190410jlka",
)
request_configuration = RequestConfiguration(
query_parameters = query_params,
)
result = await graph_client.sites.delta.get(request_configuration = request_configuration)
The following example shows the response that indicates that the site named All Company was deleted between the initial request and this request to update the local state.
The final page of sites includes the @odata.deltaLink property that provides the URL that can be used later to retrieve changes since the current set of sites.
HTTP/1.1 200 OK
Content-type: application/json
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#sites",
"@odata.deltaLink": "https://graph.microsoft.com/v1.0/sites/delta?$deltatoken=b2vm2fSuZ-V_1Gdq4ublGPD4lReifRNHYMGxkFf0yz2fTqr9U6jMyWv8hihThODJCO_5I7JbpAFLQAIOUzYXhCPl0jlQdjTC1o24iBe81xQyAWJOiP3q1xyMKjlfZUawWok3Njc_LIrrSgrdSydhsVCL6XYpRkYGJ9JDYxFMiJw2vUs1QC_S0cW6hqYQnOimeA918dQZwD8pJI9oUJryV2Ow-7Dj9p18p1I6pFg044k.xipVdgMKlOFIlXzPipsKzlFJbYUTD1sGiFiPe7uZA7Q",
"value": [
{
"createdDateTime": "2024-03-11T02:36:04Z",
"name": "All Company",
"displayName": "All Company",
"isPersonalSite": false,
"id": "bd565af7-7963-4658-9a77-26e11ac73186",
"root": {}
}
]
}
Example 3: Delta link request
In some scenarios, you might want to request the current deltaLink value without first enumerating all of the sites, lists, and webs. It can be useful if your app only wants to know about changes and doesn't need to know about existing sites.
To retrieve the latest deltaLink, call delta with the query string parameter ?token=latest.
Note: If you want to maintain a full local representation of the resources, you must use delta for the initial enumeration. Using delta is the only way to guarantee that you've read all of the data you need to.
GET https://graph.microsoft.com/v1.0/sites/delta?token=latest
// Code snippets are only available for the latest version. Current version is 5.x
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Sites.Delta.GetAsDeltaGetResponseAsync((requestConfiguration) =>
{
requestConfiguration.QueryParameters.Token = "latest";
});
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphsites "github.com/microsoftgraph/msgraph-sdk-go/sites"
//other-imports
)
requestToken := "latest"
requestParameters := &graphsites.SitesDeltaWithRequestBuilderGetQueryParameters{
Token: &requestToken,
}
configuration := &graphsites.SitesDeltaWithRequestBuilderGetRequestConfiguration{
QueryParameters: requestParameters,
}
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
delta, err := graphClient.Sites().Delta().GetAsDeltaGetResponse(context.Background(), configuration)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
var result = graphClient.sites().delta().get(requestConfiguration -> {
requestConfiguration.queryParameters.token = "latest";
});
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.sites.delta.delta_request_builder import DeltaRequestBuilder
from kiota_abstractions.base_request_configuration import RequestConfiguration
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
query_params = DeltaRequestBuilder.DeltaRequestBuilderGetQueryParameters(
token = "latest",
)
request_configuration = RequestConfiguration(
query_parameters = query_params,
)
result = await graph_client.sites.delta.get(request_configuration = request_configuration)