APIs under the /beta version in Microsoft Graph are subject to change. Use of these APIs in production applications is not supported. To determine whether an API is available in v1.0, use the Version selector.
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)
Agreement.ReadWrite.All
Not available.
Delegated (personal Microsoft account)
Not supported.
Not supported.
Application
Not supported.
Not supported.
In delegated scenarios with work or school accounts, the signed-in user must be an owner or member of the group or be assigned a supported Microsoft Entra role or a custom role with a supported role permission. Security Administrator and Conditional Access Administrator are the least privileged roles supported for this operation.
HTTP request
POST /identityGovernance/termsOfUse/agreements
Request headers
Name
Type
Description
Authorization
string
Bearer {token}. Required.
Request body
In the request body, supply a JSON representation of agreement object.
The following table shows the properties that are required when you create a user.
Property
Type
Description
displayName
String
Display name of the agreement.
isViewingBeforeAcceptanceRequired
Boolean
Indicates whether the user has to expand and view the agreement before accepting.
files/fileName
String
Name of the agreement file (for example, TOU.pdf).
files/isDefault
Boolean
Indicates whether this is the default agreement file if none of the culture matches the client preference. If none of the file is marked as default, the first one will be treated as default.
files/language
String
Culture of the agreement file in the format languagecode2-country/regioncode2. languagecode2 is a lowercase two-letter code derived from ISO 639-1. country/regioncode2 is derived from ISO 3166 and usually consists of two uppercase letters, or a BCP-47 language tag (for example, en-US).
files/fileData/data
Binary
Data representing the terms of use the PDF document.
Response
If successful, this method returns a 201, Created response code and agreement object in the response body.
Example
Request
In the request body, supply a JSON representation of the agreement object.
POST https://graph.microsoft.com/beta/identityGovernance/termsOfUse/agreements
Content-type: application/json
{
"displayName": "Contoso ToU for guest users",
"isViewingBeforeAcceptanceRequired": true,
"files": [
{
"fileName": "TOU.pdf",
"language": "en",
"isDefault": true,
"fileData": {
"data": "SGVsbG8gd29ybGQ=//truncated-binary"
}
}
]
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new Agreement
{
DisplayName = "Contoso ToU for guest users",
IsViewingBeforeAcceptanceRequired = true,
Files = new List<AgreementFileLocalization>
{
new AgreementFileLocalization
{
FileName = "TOU.pdf",
Language = "en",
IsDefault = true,
FileData = new AgreementFileData
{
Data = Convert.FromBase64String("SGVsbG8gd29ybGQ=//truncated-binary"),
},
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.IdentityGovernance.TermsOfUse.Agreements.PostAsync(requestBody);
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewAgreement()
displayName := "Contoso ToU for guest users"
requestBody.SetDisplayName(&displayName)
isViewingBeforeAcceptanceRequired := true
requestBody.SetIsViewingBeforeAcceptanceRequired(&isViewingBeforeAcceptanceRequired)
agreementFileLocalization := graphmodels.NewAgreementFileLocalization()
fileName := "TOU.pdf"
agreementFileLocalization.SetFileName(&fileName)
language := "en"
agreementFileLocalization.SetLanguage(&language)
isDefault := true
agreementFileLocalization.SetIsDefault(&isDefault)
fileData := graphmodels.NewAgreementFileData()
data := []byte("sGVsbG8gd29ybGQ=//truncated-binary")
fileData.SetData(&data)
agreementFileLocalization.SetFileData(fileData)
files := []graphmodels.AgreementFileLocalizationable {
agreementFileLocalization,
}
requestBody.SetFiles(files)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
agreements, err := graphClient.IdentityGovernance().TermsOfUse().Agreements().Post(context.Background(), requestBody, nil)
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
Agreement agreement = new Agreement();
agreement.setDisplayName("Contoso ToU for guest users");
agreement.setIsViewingBeforeAcceptanceRequired(true);
LinkedList<AgreementFileLocalization> files = new LinkedList<AgreementFileLocalization>();
AgreementFileLocalization agreementFileLocalization = new AgreementFileLocalization();
agreementFileLocalization.setFileName("TOU.pdf");
agreementFileLocalization.setLanguage("en");
agreementFileLocalization.setIsDefault(true);
AgreementFileData fileData = new AgreementFileData();
byte[] data = Base64.getDecoder().decode("SGVsbG8gd29ybGQ=//truncated-binary");
fileData.setData(data);
agreementFileLocalization.setFileData(fileData);
files.add(agreementFileLocalization);
agreement.setFiles(files);
Agreement result = graphClient.identityGovernance().termsOfUse().agreements().post(agreement);
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Models\Agreement;
use Microsoft\Graph\Beta\Generated\Models\AgreementFileLocalization;
use Microsoft\Graph\Beta\Generated\Models\AgreementFileData;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new Agreement();
$requestBody->setDisplayName('Contoso ToU for guest users');
$requestBody->setIsViewingBeforeAcceptanceRequired(true);
$filesAgreementFileLocalization1 = new AgreementFileLocalization();
$filesAgreementFileLocalization1->setFileName('TOU.pdf');
$filesAgreementFileLocalization1->setLanguage('en');
$filesAgreementFileLocalization1->setIsDefault(true);
$filesAgreementFileLocalization1FileData = new AgreementFileData();
$filesAgreementFileLocalization1FileData->setData(\GuzzleHttp\Psr7\Utils::streamFor(base64_decode('SGVsbG8gd29ybGQ=//truncated-binary')));
$filesAgreementFileLocalization1->setFileData($filesAgreementFileLocalization1FileData);
$filesArray []= $filesAgreementFileLocalization1;
$requestBody->setFiles($filesArray);
$result = $graphServiceClient->identityGovernance()->termsOfUse()->agreements()->post($requestBody)->wait();
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.models.agreement import Agreement
from msgraph_beta.generated.models.agreement_file_localization import AgreementFileLocalization
from msgraph_beta.generated.models.agreement_file_data import AgreementFileData
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = Agreement(
display_name = "Contoso ToU for guest users",
is_viewing_before_acceptance_required = True,
files = [
AgreementFileLocalization(
file_name = "TOU.pdf",
language = "en",
is_default = True,
file_data = AgreementFileData(
data = base64.urlsafe_b64decode("SGVsbG8gd29ybGQ=//truncated-binary"),
),
),
],
)
result = await graph_client.identity_governance.terms_of_use.agreements.post(request_body)
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.