Create servicePrincipal
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 a new servicePrincipal object.
Important
Adding passwordCredential when creating servicePrincipals is not supported. Use the addPassword method to add passwords or secrets for a servicePrincipal.
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) | Application.ReadWrite.All, Directory.ReadWrite.All |
| Delegated (personal Microsoft account) | Not supported. |
| Application | Application.ReadWrite.OwnedBy, Application.ReadWrite.All, Directory.ReadWrite.All |
Important
The following additional requirements must be met for an app to create a service principal:
- If the backing application is registered in the calling app's home tenant, the calling app must be the owner of the backing application.
- If the backing application is registered in another Azure AD tenant, the calling app must be assigned the
Cloud Application AdministratororApplication Administratorrole.
HTTP request
POST /servicePrincipals
Request headers
| Name | Description |
|---|---|
| Authorization | Bearer {token}. Required. |
| Content-Type | application/json. Required. |
Request body
In the request body, supply a JSON representation of a serviceprincipal object. The request body must contain appId.
Response
If successful, this method returns a 201 Created response code and a serviceprincipal object in the response body.
Examples
Request
Here is an example of the request.
POST https://graph.microsoft.com/beta/servicePrincipals
Content-type: application/json
{
"appId": "65415bb1-9267-4313-bbf5-ae259732ee12",
}
Response
Here is an example of the response.
Note: The response object shown here might be shortened for readability.
HTTP/1.1 201 Created
Content-type: application/json
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#servicePrincipals/$entity",
"id": "59e617e5-e447-4adc-8b88-00af644d7c92",
"deletedDateTime": null,
"accountEnabled": true,
"appDisplayName": "My App",
"appId": "65415bb1-9267-4313-bbf5-ae259732ee12",
"applicationTemplateId": null,
"appOwnerOrganizationId": "1bc1c026-2f7b-48a5-98da-afa2fd8bc7bc",
"appRoleAssignmentRequired": false,
"displayName": "foo",
"errorUrl": null,
"homepage": null,
"loginUrl": null,
"logoutUrl": null,
"notificationEmailAddresses": [],
"preferredSingleSignOnMode": null,
"preferredTokenSigningKeyEndDateTime": null,
"preferredTokenSigningKeyThumbprint": null,
"publisherName": "Contoso",
"replyUrls": [],
"samlMetadataUrl": null,
"samlSingleSignOnSettings": null,
"servicePrincipalNames": [
"f1bd758f-4a1a-4b71-aa20-a248a22a8928"
],
"signInAudience": "AzureADandPersonalMicrosoftAccount",
"tags": [],
"addIns": [],
"api": {
"resourceSpecificApplicationPermissions": []
},
"appRoles": [],
"info": {
"termsOfServiceUrl": null,
"supportUrl": null,
"privacyStatementUrl": null,
"marketingUrl": null,
"logoUrl": null
},
"keyCredentials": [],
"publishedPermissionScopes": [],
"passwordCredentials": []
}
Feedback
Submit and view feedback for