Namespace: microsoft.graph
Important
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.
Create (register) a printer with the Universal Print service. This is a long-running operation and as such, it returns a printerCreateOperation that can be used to track and verify the registration of the printer.
This API is available in the following national cloud deployments.
Global service |
US Government L4 |
US Government L5 (DOD) |
China operated by 21Vianet |
✅ |
✅ |
✅ |
❌ |
Permissions
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) |
Printer.Create |
Printer.FullControl.All, Printer.ReadWrite.All |
Delegated (personal Microsoft account) |
Not supported. |
Not supported. |
Application |
Not supported. |
Not supported. |
HTTP request
POST /print/printers/create
Request body
In the request body, provide a JSON object with the following properties.
Parameter |
Type |
Description |
Required? |
displayName |
String |
The display name to assign to the printer. |
Yes |
manufacturer |
String |
The manufacturer of the printer. |
Yes |
model |
String |
The model of the printer. |
Yes |
physicalDeviceId |
String |
The physical device UUID of the printer. Required if the hasPhysicalDevice property is true. |
No |
hasPhysicalDevice |
Boolean |
True if the printer has physical output device, false otherwise. If omitted, the default value is true. |
No |
certificateSigningRequest |
printCertificateSigningRequest |
The X.509 Certificate Signing Request (CSR) for the certificate created and used by the printer to identify itself. |
Yes |
connectorId |
String |
Id of Connector acting as proxy to the printer. |
No |
Response
If successful, this method returns a 202 Accepted
response code and a link to the associated printerCreateOperation in the Operation-Location
header.
Making a GET request to the linked URL can be used to get the status of an ongoing printer registration. Once printer registration has completed successfully, a GET request to the linked URL will contain the created printer object and registered certificate.
Example
Request
The following example shows a request.
POST https://graph.microsoft.com/beta/print/printers/create
Content-type: application/json
{
"displayName": "Test Printer",
"manufacturer": "Test Printer Manufacturer",
"model": "Test Printer Model",
"physicalDeviceId": null,
"hasPhysicalDevice": false,
"certificateSigningRequest": {
"content": "{content}",
"transportKey": "{sampleTransportKey}"
},
"connectorId": null
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Print.Printers.Create;
using Microsoft.Graph.Beta.Models;
var requestBody = new CreatePostRequestBody
{
DisplayName = "Test Printer",
Manufacturer = "Test Printer Manufacturer",
Model = "Test Printer Model",
PhysicalDeviceId = null,
HasPhysicalDevice = false,
CertificateSigningRequest = new PrintCertificateSigningRequest
{
Content = "{content}",
TransportKey = "{sampleTransportKey}",
},
ConnectorId = null,
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
await graphClient.Print.Printers.Create.PostAsync(requestBody);
mgc-beta print printers create post --body '{\
"displayName": "Test Printer",\
"manufacturer": "Test Printer Manufacturer",\
"model": "Test Printer Model",\
"physicalDeviceId": null,\
"hasPhysicalDevice": false,\
"certificateSigningRequest": { \
"content": "{content}",\
"transportKey": "{sampleTransportKey}"\
},\
"connectorId": null\
}\
'
// 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"
graphprint "github.com/microsoftgraph/msgraph-beta-sdk-go/print"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphprint.NewCreatePostRequestBody()
displayName := "Test Printer"
requestBody.SetDisplayName(&displayName)
manufacturer := "Test Printer Manufacturer"
requestBody.SetManufacturer(&manufacturer)
model := "Test Printer Model"
requestBody.SetModel(&model)
physicalDeviceId := null
requestBody.SetPhysicalDeviceId(&physicalDeviceId)
hasPhysicalDevice := false
requestBody.SetHasPhysicalDevice(&hasPhysicalDevice)
certificateSigningRequest := graphmodels.NewPrintCertificateSigningRequest()
content := "{content}"
certificateSigningRequest.SetContent(&content)
transportKey := "{sampleTransportKey}"
certificateSigningRequest.SetTransportKey(&transportKey)
requestBody.SetCertificateSigningRequest(certificateSigningRequest)
connectorId := null
requestBody.SetConnectorId(&connectorId)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
graphClient.Print().Printers().Create().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
com.microsoft.graph.beta.print.printers.create.CreatePostRequestBody createPostRequestBody = new com.microsoft.graph.beta.print.printers.create.CreatePostRequestBody();
createPostRequestBody.setDisplayName("Test Printer");
createPostRequestBody.setManufacturer("Test Printer Manufacturer");
createPostRequestBody.setModel("Test Printer Model");
createPostRequestBody.setPhysicalDeviceId(null);
createPostRequestBody.setHasPhysicalDevice(false);
PrintCertificateSigningRequest certificateSigningRequest = new PrintCertificateSigningRequest();
certificateSigningRequest.setContent("{content}");
certificateSigningRequest.setTransportKey("{sampleTransportKey}");
createPostRequestBody.setCertificateSigningRequest(certificateSigningRequest);
createPostRequestBody.setConnectorId(null);
graphClient.print().printers().create().post(createPostRequestBody);
const options = {
authProvider,
};
const client = Client.init(options);
const create = {
displayName: 'Test Printer',
manufacturer: 'Test Printer Manufacturer',
model: 'Test Printer Model',
physicalDeviceId: null,
hasPhysicalDevice: false,
certificateSigningRequest: {
content: '{content}',
transportKey: '{sampleTransportKey}'
},
connectorId: null
};
await client.api('/print/printers/create')
.version('beta')
.post(create);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Print\Printers\Create\CreatePostRequestBody;
use Microsoft\Graph\Beta\Generated\Models\PrintCertificateSigningRequest;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new CreatePostRequestBody();
$requestBody->setDisplayName('Test Printer');
$requestBody->setManufacturer('Test Printer Manufacturer');
$requestBody->setModel('Test Printer Model');
$requestBody->setPhysicalDeviceId(null);
$requestBody->setHasPhysicalDevice(false);
$certificateSigningRequest = new PrintCertificateSigningRequest();
$certificateSigningRequest->setContent('{content}');
$certificateSigningRequest->setTransportKey('{sampleTransportKey}');
$requestBody->setCertificateSigningRequest($certificateSigningRequest);
$requestBody->setConnectorId(null);
$graphServiceClient->escapedPrint()->printers()->create()->post($requestBody)->wait();
Import-Module Microsoft.Graph.Beta.Devices.CloudPrint
$params = @{
displayName = "Test Printer"
manufacturer = "Test Printer Manufacturer"
model = "Test Printer Model"
physicalDeviceId = $null
hasPhysicalDevice = $false
certificateSigningRequest = @{
content = '{content}'
transportKey = '{sampleTransportKey}'
}
connectorId = $null
}
New-MgBetaPrintPrinter -BodyParameter $params
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.print.printers.create.create_post_request_body import CreatePostRequestBody
from msgraph_beta.generated.models.print_certificate_signing_request import PrintCertificateSigningRequest
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = CreatePostRequestBody(
display_name = "Test Printer",
manufacturer = "Test Printer Manufacturer",
model = "Test Printer Model",
physical_device_id = None,
has_physical_device = False,
certificate_signing_request = PrintCertificateSigningRequest(
content = "{content}",
transport_key = "{sampleTransportKey}",
),
connector_id = None,
)
await graph_client.print.printers.create.post(request_body)
Response
The following example shows the response.
HTTP/1.1 202 Accepted
Operation-Location: https://graph.microsoft.com/beta/print/operations/f221760a-52e8-4c11-b8c5-5dfaef3a49db
Retry-After: 5