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.
POST https://graph.microsoft.com/v1.0/education/users
Content-Type: application/json
{
"@odata.type": "#microsoft.graph.educationUser",
"primaryRole": "String",
"middleName": "String",
"externalSource": "String",
"externalSourceDetail": "String",
"residenceAddress": {
"@odata.type": "microsoft.graph.physicalAddress"
},
"mailingAddress": {
"@odata.type": "microsoft.graph.physicalAddress"
},
"student": {
"@odata.type": "microsoft.graph.educationStudent"
},
"teacher": {
"@odata.type": "microsoft.graph.educationTeacher"
},
"createdBy": {
"@odata.type": "microsoft.graph.identitySet"
},
"accountEnabled": "Boolean",
"assignedLicenses": [
{
"@odata.type": "microsoft.graph.assignedLicense"
}
],
"assignedPlans": [
{
"@odata.type": "microsoft.graph.assignedPlan"
}
],
"businessPhones": [
"String"
],
"department": "String",
"displayName": "String",
"givenName": "String",
"mail": "String",
"mailNickname": "String",
"mobilePhone": "String",
"passwordPolicies": "String",
"passwordProfile": {
"@odata.type": "microsoft.graph.passwordProfile"
},
"officeLocation": "String",
"preferredLanguage": "String",
"provisionedPlans": [
{
"@odata.type": "microsoft.graph.provisionedPlan"
}
],
"refreshTokensValidFromDateTime": "String (timestamp)",
"showInAddressList": "Boolean",
"surname": "String",
"usageLocation": "String",
"userPrincipalName": "String",
"userType": "String",
"onPremisesInfo": {
"@odata.type": "microsoft.graph.educationOnPremisesInfo"
}
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new EducationUser
{
OdataType = "#microsoft.graph.educationUser",
PrimaryRole = EducationUserRole.Student,
MiddleName = "String",
ExternalSource = EducationExternalSource.Sis,
ExternalSourceDetail = "String",
ResidenceAddress = new PhysicalAddress
{
OdataType = "microsoft.graph.physicalAddress",
},
MailingAddress = new PhysicalAddress
{
OdataType = "microsoft.graph.physicalAddress",
},
Student = new EducationStudent
{
OdataType = "microsoft.graph.educationStudent",
},
Teacher = new EducationTeacher
{
OdataType = "microsoft.graph.educationTeacher",
},
CreatedBy = new IdentitySet
{
OdataType = "microsoft.graph.identitySet",
},
AccountEnabled = boolean,
AssignedLicenses = new List<AssignedLicense>
{
new AssignedLicense
{
OdataType = "microsoft.graph.assignedLicense",
},
},
AssignedPlans = new List<AssignedPlan>
{
new AssignedPlan
{
OdataType = "microsoft.graph.assignedPlan",
},
},
BusinessPhones = new List<string>
{
"String",
},
Department = "String",
DisplayName = "String",
GivenName = "String",
Mail = "String",
MailNickname = "String",
MobilePhone = "String",
PasswordPolicies = "String",
PasswordProfile = new PasswordProfile
{
OdataType = "microsoft.graph.passwordProfile",
},
OfficeLocation = "String",
PreferredLanguage = "String",
ProvisionedPlans = new List<ProvisionedPlan>
{
new ProvisionedPlan
{
OdataType = "microsoft.graph.provisionedPlan",
},
},
RefreshTokensValidFromDateTime = DateTimeOffset.Parse("String (timestamp)"),
ShowInAddressList = boolean,
Surname = "String",
UsageLocation = "String",
UserPrincipalName = "String",
UserType = "String",
OnPremisesInfo = new EducationOnPremisesInfo
{
OdataType = "microsoft.graph.educationOnPremisesInfo",
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Education.Users.PostAsync(requestBody);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
mgc education users create --body '{\
"@odata.type": "#microsoft.graph.educationUser",\
"primaryRole": "String",\
"middleName": "String",\
"externalSource": "String",\
"externalSourceDetail": "String",\
"residenceAddress": {\
"@odata.type": "microsoft.graph.physicalAddress"\
},\
"mailingAddress": {\
"@odata.type": "microsoft.graph.physicalAddress"\
},\
"student": {\
"@odata.type": "microsoft.graph.educationStudent"\
},\
"teacher": {\
"@odata.type": "microsoft.graph.educationTeacher"\
},\
"createdBy": {\
"@odata.type": "microsoft.graph.identitySet"\
},\
"accountEnabled": "Boolean",\
"assignedLicenses": [\
{\
"@odata.type": "microsoft.graph.assignedLicense"\
}\
],\
"assignedPlans": [\
{\
"@odata.type": "microsoft.graph.assignedPlan"\
}\
],\
"businessPhones": [\
"String"\
],\
"department": "String",\
"displayName": "String",\
"givenName": "String",\
"mail": "String",\
"mailNickname": "String",\
"mobilePhone": "String",\
"passwordPolicies": "String",\
"passwordProfile": {\
"@odata.type": "microsoft.graph.passwordProfile"\
},\
"officeLocation": "String",\
"preferredLanguage": "String",\
"provisionedPlans": [\
{\
"@odata.type": "microsoft.graph.provisionedPlan"\
}\
],\
"refreshTokensValidFromDateTime": "String (timestamp)",\
"showInAddressList": "Boolean",\
"surname": "String",\
"usageLocation": "String",\
"userPrincipalName": "String",\
"userType": "String",\
"onPremisesInfo": {\
"@odata.type": "microsoft.graph.educationOnPremisesInfo"\
}\
}\
'
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
"time"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewEducationUser()
primaryRole := graphmodels.STRING_EDUCATIONUSERROLE
requestBody.SetPrimaryRole(&primaryRole)
middleName := "String"
requestBody.SetMiddleName(&middleName)
externalSource := graphmodels.STRING_EDUCATIONEXTERNALSOURCE
requestBody.SetExternalSource(&externalSource)
externalSourceDetail := "String"
requestBody.SetExternalSourceDetail(&externalSourceDetail)
residenceAddress := graphmodels.NewPhysicalAddress()
requestBody.SetResidenceAddress(residenceAddress)
mailingAddress := graphmodels.NewPhysicalAddress()
requestBody.SetMailingAddress(mailingAddress)
student := graphmodels.NewEducationStudent()
requestBody.SetStudent(student)
teacher := graphmodels.NewEducationTeacher()
requestBody.SetTeacher(teacher)
createdBy := graphmodels.NewIdentitySet()
requestBody.SetCreatedBy(createdBy)
accountEnabled := boolean
requestBody.SetAccountEnabled(&accountEnabled)
assignedLicense := graphmodels.NewAssignedLicense()
assignedLicenses := []graphmodels.AssignedLicenseable {
assignedLicense,
}
requestBody.SetAssignedLicenses(assignedLicenses)
assignedPlan := graphmodels.NewAssignedPlan()
assignedPlans := []graphmodels.AssignedPlanable {
assignedPlan,
}
requestBody.SetAssignedPlans(assignedPlans)
businessPhones := []string {
"String",
}
requestBody.SetBusinessPhones(businessPhones)
department := "String"
requestBody.SetDepartment(&department)
displayName := "String"
requestBody.SetDisplayName(&displayName)
givenName := "String"
requestBody.SetGivenName(&givenName)
mail := "String"
requestBody.SetMail(&mail)
mailNickname := "String"
requestBody.SetMailNickname(&mailNickname)
mobilePhone := "String"
requestBody.SetMobilePhone(&mobilePhone)
passwordPolicies := "String"
requestBody.SetPasswordPolicies(&passwordPolicies)
passwordProfile := graphmodels.NewPasswordProfile()
requestBody.SetPasswordProfile(passwordProfile)
officeLocation := "String"
requestBody.SetOfficeLocation(&officeLocation)
preferredLanguage := "String"
requestBody.SetPreferredLanguage(&preferredLanguage)
provisionedPlan := graphmodels.NewProvisionedPlan()
provisionedPlans := []graphmodels.ProvisionedPlanable {
provisionedPlan,
}
requestBody.SetProvisionedPlans(provisionedPlans)
refreshTokensValidFromDateTime , err := time.Parse(time.RFC3339, "String (timestamp)")
requestBody.SetRefreshTokensValidFromDateTime(&refreshTokensValidFromDateTime)
showInAddressList := boolean
requestBody.SetShowInAddressList(&showInAddressList)
surname := "String"
requestBody.SetSurname(&surname)
usageLocation := "String"
requestBody.SetUsageLocation(&usageLocation)
userPrincipalName := "String"
requestBody.SetUserPrincipalName(&userPrincipalName)
userType := "String"
requestBody.SetUserType(&userType)
onPremisesInfo := graphmodels.NewEducationOnPremisesInfo()
requestBody.SetOnPremisesInfo(onPremisesInfo)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
users, err := graphClient.Education().Users().Post(context.Background(), requestBody, nil)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
EducationUser educationUser = new EducationUser();
educationUser.setOdataType("#microsoft.graph.educationUser");
educationUser.setPrimaryRole(EducationUserRole.Student);
educationUser.setMiddleName("String");
educationUser.setExternalSource(EducationExternalSource.Sis);
educationUser.setExternalSourceDetail("String");
PhysicalAddress residenceAddress = new PhysicalAddress();
residenceAddress.setOdataType("microsoft.graph.physicalAddress");
educationUser.setResidenceAddress(residenceAddress);
PhysicalAddress mailingAddress = new PhysicalAddress();
mailingAddress.setOdataType("microsoft.graph.physicalAddress");
educationUser.setMailingAddress(mailingAddress);
EducationStudent student = new EducationStudent();
student.setOdataType("microsoft.graph.educationStudent");
educationUser.setStudent(student);
EducationTeacher teacher = new EducationTeacher();
teacher.setOdataType("microsoft.graph.educationTeacher");
educationUser.setTeacher(teacher);
IdentitySet createdBy = new IdentitySet();
createdBy.setOdataType("microsoft.graph.identitySet");
educationUser.setCreatedBy(createdBy);
educationUser.setAccountEnabled(boolean);
LinkedList<AssignedLicense> assignedLicenses = new LinkedList<AssignedLicense>();
AssignedLicense assignedLicense = new AssignedLicense();
assignedLicense.setOdataType("microsoft.graph.assignedLicense");
assignedLicenses.add(assignedLicense);
educationUser.setAssignedLicenses(assignedLicenses);
LinkedList<AssignedPlan> assignedPlans = new LinkedList<AssignedPlan>();
AssignedPlan assignedPlan = new AssignedPlan();
assignedPlan.setOdataType("microsoft.graph.assignedPlan");
assignedPlans.add(assignedPlan);
educationUser.setAssignedPlans(assignedPlans);
LinkedList<String> businessPhones = new LinkedList<String>();
businessPhones.add("String");
educationUser.setBusinessPhones(businessPhones);
educationUser.setDepartment("String");
educationUser.setDisplayName("String");
educationUser.setGivenName("String");
educationUser.setMail("String");
educationUser.setMailNickname("String");
educationUser.setMobilePhone("String");
educationUser.setPasswordPolicies("String");
PasswordProfile passwordProfile = new PasswordProfile();
passwordProfile.setOdataType("microsoft.graph.passwordProfile");
educationUser.setPasswordProfile(passwordProfile);
educationUser.setOfficeLocation("String");
educationUser.setPreferredLanguage("String");
LinkedList<ProvisionedPlan> provisionedPlans = new LinkedList<ProvisionedPlan>();
ProvisionedPlan provisionedPlan = new ProvisionedPlan();
provisionedPlan.setOdataType("microsoft.graph.provisionedPlan");
provisionedPlans.add(provisionedPlan);
educationUser.setProvisionedPlans(provisionedPlans);
OffsetDateTime refreshTokensValidFromDateTime = OffsetDateTime.parse("String (timestamp)");
educationUser.setRefreshTokensValidFromDateTime(refreshTokensValidFromDateTime);
educationUser.setShowInAddressList(boolean);
educationUser.setSurname("String");
educationUser.setUsageLocation("String");
educationUser.setUserPrincipalName("String");
educationUser.setUserType("String");
EducationOnPremisesInfo onPremisesInfo = new EducationOnPremisesInfo();
onPremisesInfo.setOdataType("microsoft.graph.educationOnPremisesInfo");
educationUser.setOnPremisesInfo(onPremisesInfo);
EducationUser result = graphClient.education().users().post(educationUser);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
const options = {
authProvider,
};
const client = Client.init(options);
const educationUser = {
'@odata.type': '#microsoft.graph.educationUser',
primaryRole: 'String',
middleName: 'String',
externalSource: 'String',
externalSourceDetail: 'String',
residenceAddress: {
'@odata.type': 'microsoft.graph.physicalAddress'
},
mailingAddress: {
'@odata.type': 'microsoft.graph.physicalAddress'
},
student: {
'@odata.type': 'microsoft.graph.educationStudent'
},
teacher: {
'@odata.type': 'microsoft.graph.educationTeacher'
},
createdBy: {
'@odata.type': 'microsoft.graph.identitySet'
},
accountEnabled: 'Boolean',
assignedLicenses: [
{
'@odata.type': 'microsoft.graph.assignedLicense'
}
],
assignedPlans: [
{
'@odata.type': 'microsoft.graph.assignedPlan'
}
],
businessPhones: [
'String'
],
department: 'String',
displayName: 'String',
givenName: 'String',
mail: 'String',
mailNickname: 'String',
mobilePhone: 'String',
passwordPolicies: 'String',
passwordProfile: {
'@odata.type': 'microsoft.graph.passwordProfile'
},
officeLocation: 'String',
preferredLanguage: 'String',
provisionedPlans: [
{
'@odata.type': 'microsoft.graph.provisionedPlan'
}
],
refreshTokensValidFromDateTime: 'String (timestamp)',
showInAddressList: 'Boolean',
surname: 'String',
usageLocation: 'String',
userPrincipalName: 'String',
userType: 'String',
onPremisesInfo: {
'@odata.type': 'microsoft.graph.educationOnPremisesInfo'
}
};
await client.api('/education/users')
.post(educationUser);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Models\EducationUser;
use Microsoft\Graph\Generated\Models\EducationUserRole;
use Microsoft\Graph\Generated\Models\EducationExternalSource;
use Microsoft\Graph\Generated\Models\PhysicalAddress;
use Microsoft\Graph\Generated\Models\EducationStudent;
use Microsoft\Graph\Generated\Models\EducationTeacher;
use Microsoft\Graph\Generated\Models\IdentitySet;
use Microsoft\Graph\Generated\Models\AssignedLicense;
use Microsoft\Graph\Generated\Models\AssignedPlan;
use Microsoft\Graph\Generated\Models\PasswordProfile;
use Microsoft\Graph\Generated\Models\ProvisionedPlan;
use Microsoft\Graph\Generated\Models\EducationOnPremisesInfo;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new EducationUser();
$requestBody->setOdataType('#microsoft.graph.educationUser');
$requestBody->setPrimaryRole(new EducationUserRole('string'));
$requestBody->setMiddleName('String');
$requestBody->setExternalSource(new EducationExternalSource('string'));
$requestBody->setExternalSourceDetail('String');
$residenceAddress = new PhysicalAddress();
$residenceAddress->setOdataType('microsoft.graph.physicalAddress');
$requestBody->setResidenceAddress($residenceAddress);
$mailingAddress = new PhysicalAddress();
$mailingAddress->setOdataType('microsoft.graph.physicalAddress');
$requestBody->setMailingAddress($mailingAddress);
$student = new EducationStudent();
$student->setOdataType('microsoft.graph.educationStudent');
$requestBody->setStudent($student);
$teacher = new EducationTeacher();
$teacher->setOdataType('microsoft.graph.educationTeacher');
$requestBody->setTeacher($teacher);
$createdBy = new IdentitySet();
$createdBy->setOdataType('microsoft.graph.identitySet');
$requestBody->setCreatedBy($createdBy);
$requestBody->setAccountEnabled(boolean);
$assignedLicensesAssignedLicense1 = new AssignedLicense();
$assignedLicensesAssignedLicense1->setOdataType('microsoft.graph.assignedLicense');
$assignedLicensesArray []= $assignedLicensesAssignedLicense1;
$requestBody->setAssignedLicenses($assignedLicensesArray);
$assignedPlansAssignedPlan1 = new AssignedPlan();
$assignedPlansAssignedPlan1->setOdataType('microsoft.graph.assignedPlan');
$assignedPlansArray []= $assignedPlansAssignedPlan1;
$requestBody->setAssignedPlans($assignedPlansArray);
$requestBody->setBusinessPhones(['String', ]);
$requestBody->setDepartment('String');
$requestBody->setDisplayName('String');
$requestBody->setGivenName('String');
$requestBody->setMail('String');
$requestBody->setMailNickname('String');
$requestBody->setMobilePhone('String');
$requestBody->setPasswordPolicies('String');
$passwordProfile = new PasswordProfile();
$passwordProfile->setOdataType('microsoft.graph.passwordProfile');
$requestBody->setPasswordProfile($passwordProfile);
$requestBody->setOfficeLocation('String');
$requestBody->setPreferredLanguage('String');
$provisionedPlansProvisionedPlan1 = new ProvisionedPlan();
$provisionedPlansProvisionedPlan1->setOdataType('microsoft.graph.provisionedPlan');
$provisionedPlansArray []= $provisionedPlansProvisionedPlan1;
$requestBody->setProvisionedPlans($provisionedPlansArray);
$requestBody->setRefreshTokensValidFromDateTime(new \DateTime('String (timestamp)'));
$requestBody->setShowInAddressList(boolean);
$requestBody->setSurname('String');
$requestBody->setUsageLocation('String');
$requestBody->setUserPrincipalName('String');
$requestBody->setUserType('String');
$onPremisesInfo = new EducationOnPremisesInfo();
$onPremisesInfo->setOdataType('microsoft.graph.educationOnPremisesInfo');
$requestBody->setOnPremisesInfo($onPremisesInfo);
$result = $graphServiceClient->education()->users()->post($requestBody)->wait();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
Import-Module Microsoft.Graph.Education
$params = @{
"@odata.type" = "#microsoft.graph.educationUser"
primaryRole = "String"
middleName = "String"
externalSource = "String"
externalSourceDetail = "String"
residenceAddress = @{
"@odata.type" = "microsoft.graph.physicalAddress"
}
mailingAddress = @{
"@odata.type" = "microsoft.graph.physicalAddress"
}
student = @{
"@odata.type" = "microsoft.graph.educationStudent"
}
teacher = @{
"@odata.type" = "microsoft.graph.educationTeacher"
}
createdBy = @{
"@odata.type" = "microsoft.graph.identitySet"
}
accountEnabled = "Boolean"
assignedLicenses = @(
@{
"@odata.type" = "microsoft.graph.assignedLicense"
}
)
assignedPlans = @(
@{
"@odata.type" = "microsoft.graph.assignedPlan"
}
)
businessPhones = @(
"String"
)
department = "String"
displayName = "String"
givenName = "String"
mail = "String"
mailNickname = "String"
mobilePhone = "String"
passwordPolicies = "String"
passwordProfile = @{
"@odata.type" = "microsoft.graph.passwordProfile"
}
officeLocation = "String"
preferredLanguage = "String"
provisionedPlans = @(
@{
"@odata.type" = "microsoft.graph.provisionedPlan"
}
)
refreshTokensValidFromDateTime = [System.DateTime]::Parse("String (timestamp)")
showInAddressList = "Boolean"
surname = "String"
usageLocation = "String"
userPrincipalName = "String"
userType = "String"
onPremisesInfo = @{
"@odata.type" = "microsoft.graph.educationOnPremisesInfo"
}
}
New-MgEducationUser -BodyParameter $params
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.models.education_user import EducationUser
from msgraph.generated.models.education_user_role import EducationUserRole
from msgraph.generated.models.education_external_source import EducationExternalSource
from msgraph.generated.models.physical_address import PhysicalAddress
from msgraph.generated.models.education_student import EducationStudent
from msgraph.generated.models.education_teacher import EducationTeacher
from msgraph.generated.models.identity_set import IdentitySet
from msgraph.generated.models.assigned_license import AssignedLicense
from msgraph.generated.models.assigned_plan import AssignedPlan
from msgraph.generated.models.password_profile import PasswordProfile
from msgraph.generated.models.provisioned_plan import ProvisionedPlan
from msgraph.generated.models.education_on_premises_info import EducationOnPremisesInfo
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = EducationUser(
odata_type = "#microsoft.graph.educationUser",
primary_role = EducationUserRole.Student,
middle_name = "String",
external_source = EducationExternalSource.Sis,
external_source_detail = "String",
residence_address = PhysicalAddress(
odata_type = "microsoft.graph.physicalAddress",
),
mailing_address = PhysicalAddress(
odata_type = "microsoft.graph.physicalAddress",
),
student = EducationStudent(
odata_type = "microsoft.graph.educationStudent",
),
teacher = EducationTeacher(
odata_type = "microsoft.graph.educationTeacher",
),
created_by = IdentitySet(
odata_type = "microsoft.graph.identitySet",
),
account_enabled = Boolean,
assigned_licenses = [
AssignedLicense(
odata_type = "microsoft.graph.assignedLicense",
),
],
assigned_plans = [
AssignedPlan(
odata_type = "microsoft.graph.assignedPlan",
),
],
business_phones = [
"String",
],
department = "String",
display_name = "String",
given_name = "String",
mail = "String",
mail_nickname = "String",
mobile_phone = "String",
password_policies = "String",
password_profile = PasswordProfile(
odata_type = "microsoft.graph.passwordProfile",
),
office_location = "String",
preferred_language = "String",
provisioned_plans = [
ProvisionedPlan(
odata_type = "microsoft.graph.provisionedPlan",
),
],
refresh_tokens_valid_from_date_time = "String (timestamp)",
show_in_address_list = Boolean,
surname = "String",
usage_location = "String",
user_principal_name = "String",
user_type = "String",
on_premises_info = EducationOnPremisesInfo(
odata_type = "microsoft.graph.educationOnPremisesInfo",
),
)
result = await graph_client.education.users.post(request_body)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.