Namespace: microsoft.graph
Note: The Microsoft Graph API for Intune requires an active Intune license for the tenant.
Create a new importedWindowsAutopilotDeviceIdentity object.
This API is available in the following national cloud deployments.
Global service |
US Government L4 |
US Government L5 (DOD) |
China operated by 21Vianet |
✅ |
✅ |
✅ |
✅ |
Permissions
One of the following permissions is required to call this API. To learn more, including how to choose permissions, see Permissions.
Permission type |
Permissions (from least to most privileged) |
Delegated (work or school account) |
DeviceManagementServiceConfig.ReadWrite.All |
Delegated (personal Microsoft account) |
Not supported. |
Application |
DeviceManagementServiceConfig.ReadWrite.All |
HTTP Request
POST /deviceManagement/importedWindowsAutopilotDeviceIdentities
Request body
In the request body, supply a JSON representation for the importedWindowsAutopilotDeviceIdentity object.
The following table shows the properties that are required when you create the importedWindowsAutopilotDeviceIdentity.
Property |
Type |
Description |
id |
String |
The GUID for the object |
groupTag |
String |
Group Tag of the Windows autopilot device. |
serialNumber |
String |
Serial number of the Windows autopilot device. |
productKey |
String |
Product Key of the Windows autopilot device. |
importId |
String |
The Import Id of the Windows autopilot device. |
hardwareIdentifier |
Binary |
Hardware Blob of the Windows autopilot device. |
state |
importedWindowsAutopilotDeviceIdentityState |
Current state of the imported device. |
assignedUserPrincipalName |
String |
UPN of the user the device will be assigned |
Response
If successful, this method returns a 201 Created
response code and a importedWindowsAutopilotDeviceIdentity object in the response body.
Example
Request
Here is an example of the request.
POST https://graph.microsoft.com/v1.0/deviceManagement/importedWindowsAutopilotDeviceIdentities
Content-type: application/json
Content-length: 631
{
"@odata.type": "#microsoft.graph.importedWindowsAutopilotDeviceIdentity",
"groupTag": "Group Tag value",
"serialNumber": "Serial Number value",
"productKey": "Product Key value",
"importId": "Import Id value",
"hardwareIdentifier": "aGFyZHdhcmVJZGVudGlmaWVy",
"state": {
"@odata.type": "microsoft.graph.importedWindowsAutopilotDeviceIdentityState",
"deviceImportStatus": "pending",
"deviceRegistrationId": "Device Registration Id value",
"deviceErrorCode": 15,
"deviceErrorName": "Device Error Name value"
},
"assignedUserPrincipalName": "Assigned User Principal Name value"
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new ImportedWindowsAutopilotDeviceIdentity
{
OdataType = "#microsoft.graph.importedWindowsAutopilotDeviceIdentity",
GroupTag = "Group Tag value",
SerialNumber = "Serial Number value",
ProductKey = "Product Key value",
ImportId = "Import Id value",
HardwareIdentifier = Convert.FromBase64String("aGFyZHdhcmVJZGVudGlmaWVy"),
State = new ImportedWindowsAutopilotDeviceIdentityState
{
OdataType = "microsoft.graph.importedWindowsAutopilotDeviceIdentityState",
DeviceImportStatus = ImportedWindowsAutopilotDeviceIdentityImportStatus.Pending,
DeviceRegistrationId = "Device Registration Id value",
DeviceErrorCode = 15,
DeviceErrorName = "Device Error Name value",
},
AssignedUserPrincipalName = "Assigned User Principal Name value",
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.DeviceManagement.ImportedWindowsAutopilotDeviceIdentities.PostAsync(requestBody);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
mgc device-management imported-windows-autopilot-device-identities create --body '{\
"@odata.type": "#microsoft.graph.importedWindowsAutopilotDeviceIdentity",\
"groupTag": "Group Tag value",\
"serialNumber": "Serial Number value",\
"productKey": "Product Key value",\
"importId": "Import Id value",\
"hardwareIdentifier": "aGFyZHdhcmVJZGVudGlmaWVy",\
"state": {\
"@odata.type": "microsoft.graph.importedWindowsAutopilotDeviceIdentityState",\
"deviceImportStatus": "pending",\
"deviceRegistrationId": "Device Registration Id value",\
"deviceErrorCode": 15,\
"deviceErrorName": "Device Error Name value"\
},\
"assignedUserPrincipalName": "Assigned User Principal Name value"\
}\
'
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"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewImportedWindowsAutopilotDeviceIdentity()
groupTag := "Group Tag value"
requestBody.SetGroupTag(&groupTag)
serialNumber := "Serial Number value"
requestBody.SetSerialNumber(&serialNumber)
productKey := "Product Key value"
requestBody.SetProductKey(&productKey)
importId := "Import Id value"
requestBody.SetImportId(&importId)
hardwareIdentifier := []byte("aGFyZHdhcmVJZGVudGlmaWVy")
requestBody.SetHardwareIdentifier(&hardwareIdentifier)
state := graphmodels.NewImportedWindowsAutopilotDeviceIdentityState()
deviceImportStatus := graphmodels.PENDING_IMPORTEDWINDOWSAUTOPILOTDEVICEIDENTITYIMPORTSTATUS
state.SetDeviceImportStatus(&deviceImportStatus)
deviceRegistrationId := "Device Registration Id value"
state.SetDeviceRegistrationId(&deviceRegistrationId)
deviceErrorCode := int32(15)
state.SetDeviceErrorCode(&deviceErrorCode)
deviceErrorName := "Device Error Name value"
state.SetDeviceErrorName(&deviceErrorName)
requestBody.SetState(state)
assignedUserPrincipalName := "Assigned User Principal Name value"
requestBody.SetAssignedUserPrincipalName(&assignedUserPrincipalName)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
importedWindowsAutopilotDeviceIdentities, err := graphClient.DeviceManagement().ImportedWindowsAutopilotDeviceIdentities().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);
ImportedWindowsAutopilotDeviceIdentity importedWindowsAutopilotDeviceIdentity = new ImportedWindowsAutopilotDeviceIdentity();
importedWindowsAutopilotDeviceIdentity.setOdataType("#microsoft.graph.importedWindowsAutopilotDeviceIdentity");
importedWindowsAutopilotDeviceIdentity.setGroupTag("Group Tag value");
importedWindowsAutopilotDeviceIdentity.setSerialNumber("Serial Number value");
importedWindowsAutopilotDeviceIdentity.setProductKey("Product Key value");
importedWindowsAutopilotDeviceIdentity.setImportId("Import Id value");
byte[] hardwareIdentifier = Base64.getDecoder().decode("aGFyZHdhcmVJZGVudGlmaWVy");
importedWindowsAutopilotDeviceIdentity.setHardwareIdentifier(hardwareIdentifier);
ImportedWindowsAutopilotDeviceIdentityState state = new ImportedWindowsAutopilotDeviceIdentityState();
state.setOdataType("microsoft.graph.importedWindowsAutopilotDeviceIdentityState");
state.setDeviceImportStatus(ImportedWindowsAutopilotDeviceIdentityImportStatus.Pending);
state.setDeviceRegistrationId("Device Registration Id value");
state.setDeviceErrorCode(15);
state.setDeviceErrorName("Device Error Name value");
importedWindowsAutopilotDeviceIdentity.setState(state);
importedWindowsAutopilotDeviceIdentity.setAssignedUserPrincipalName("Assigned User Principal Name value");
ImportedWindowsAutopilotDeviceIdentity result = graphClient.deviceManagement().importedWindowsAutopilotDeviceIdentities().post(importedWindowsAutopilotDeviceIdentity);
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 importedWindowsAutopilotDeviceIdentity = {
'@odata.type': '#microsoft.graph.importedWindowsAutopilotDeviceIdentity',
groupTag: 'Group Tag value',
serialNumber: 'Serial Number value',
productKey: 'Product Key value',
importId: 'Import Id value',
hardwareIdentifier: 'aGFyZHdhcmVJZGVudGlmaWVy',
state: {
'@odata.type': 'microsoft.graph.importedWindowsAutopilotDeviceIdentityState',
deviceImportStatus: 'pending',
deviceRegistrationId: 'Device Registration Id value',
deviceErrorCode: 15,
deviceErrorName: 'Device Error Name value'
},
assignedUserPrincipalName: 'Assigned User Principal Name value'
};
await client.api('/deviceManagement/importedWindowsAutopilotDeviceIdentities')
.post(importedWindowsAutopilotDeviceIdentity);
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\ImportedWindowsAutopilotDeviceIdentity;
use Microsoft\Graph\Generated\Models\ImportedWindowsAutopilotDeviceIdentityState;
use Microsoft\Graph\Generated\Models\ImportedWindowsAutopilotDeviceIdentityImportStatus;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new ImportedWindowsAutopilotDeviceIdentity();
$requestBody->setOdataType('#microsoft.graph.importedWindowsAutopilotDeviceIdentity');
$requestBody->setGroupTag('Group Tag value');
$requestBody->setSerialNumber('Serial Number value');
$requestBody->setProductKey('Product Key value');
$requestBody->setImportId('Import Id value');
$requestBody->setHardwareIdentifier(\GuzzleHttp\Psr7\Utils::streamFor(base64_decode('aGFyZHdhcmVJZGVudGlmaWVy')));
$state = new ImportedWindowsAutopilotDeviceIdentityState();
$state->setOdataType('microsoft.graph.importedWindowsAutopilotDeviceIdentityState');
$state->setDeviceImportStatus(new ImportedWindowsAutopilotDeviceIdentityImportStatus('pending'));
$state->setDeviceRegistrationId('Device Registration Id value');
$state->setDeviceErrorCode(15);
$state->setDeviceErrorName('Device Error Name value');
$requestBody->setState($state);
$requestBody->setAssignedUserPrincipalName('Assigned User Principal Name value');
$result = $graphServiceClient->deviceManagement()->importedWindowsAutopilotDeviceIdentities()->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.DeviceManagement.Enrollment
$params = @{
"@odata.type" = "#microsoft.graph.importedWindowsAutopilotDeviceIdentity"
groupTag = "Group Tag value"
serialNumber = "Serial Number value"
productKey = "Product Key value"
importId = "Import Id value"
hardwareIdentifier = [System.Text.Encoding]::ASCII.GetBytes("aGFyZHdhcmVJZGVudGlmaWVy")
state = @{
"@odata.type" = "microsoft.graph.importedWindowsAutopilotDeviceIdentityState"
deviceImportStatus = "pending"
deviceRegistrationId = "Device Registration Id value"
deviceErrorCode = 15
deviceErrorName = "Device Error Name value"
}
assignedUserPrincipalName = "Assigned User Principal Name value"
}
New-MgDeviceManagementImportedWindowsAutopilotDeviceIdentity -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.imported_windows_autopilot_device_identity import ImportedWindowsAutopilotDeviceIdentity
from msgraph.generated.models.imported_windows_autopilot_device_identity_state import ImportedWindowsAutopilotDeviceIdentityState
from msgraph.generated.models.imported_windows_autopilot_device_identity_import_status import ImportedWindowsAutopilotDeviceIdentityImportStatus
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = ImportedWindowsAutopilotDeviceIdentity(
odata_type = "#microsoft.graph.importedWindowsAutopilotDeviceIdentity",
group_tag = "Group Tag value",
serial_number = "Serial Number value",
product_key = "Product Key value",
import_id = "Import Id value",
hardware_identifier = base64.urlsafe_b64decode("aGFyZHdhcmVJZGVudGlmaWVy"),
state = ImportedWindowsAutopilotDeviceIdentityState(
odata_type = "microsoft.graph.importedWindowsAutopilotDeviceIdentityState",
device_import_status = ImportedWindowsAutopilotDeviceIdentityImportStatus.Pending,
device_registration_id = "Device Registration Id value",
device_error_code = 15,
device_error_name = "Device Error Name value",
),
assigned_user_principal_name = "Assigned User Principal Name value",
)
result = await graph_client.device_management.imported_windows_autopilot_device_identities.post(request_body)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
Response
Here is an example of the response. Note: The response object shown here may be truncated for brevity. All of the properties will be returned from an actual call.
HTTP/1.1 201 Created
Content-Type: application/json
Content-Length: 680
{
"@odata.type": "#microsoft.graph.importedWindowsAutopilotDeviceIdentity",
"id": "985b4f49-4f49-985b-494f-5b98494f5b98",
"groupTag": "Group Tag value",
"serialNumber": "Serial Number value",
"productKey": "Product Key value",
"importId": "Import Id value",
"hardwareIdentifier": "aGFyZHdhcmVJZGVudGlmaWVy",
"state": {
"@odata.type": "microsoft.graph.importedWindowsAutopilotDeviceIdentityState",
"deviceImportStatus": "pending",
"deviceRegistrationId": "Device Registration Id value",
"deviceErrorCode": 15,
"deviceErrorName": "Device Error Name value"
},
"assignedUserPrincipalName": "Assigned User Principal Name value"
}