| title | servicePrincipal: Add owner |
|---|---|
| description | Use this API to add an owner for the service principal. |
| ms.localizationpriority | high |
| doc_type | apiPageType |
| ms.subservice | entra-applications |
| author | Jackson-Woods |
| ms.date | 07/30/2024 |
Namespace: microsoft.graph
Use this API to add an owner for the servicePrincipal. Service principal owners can be users, the service principal itself, or other service principals.
[!INCLUDE national-cloud-support]
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.
[!INCLUDE permissions-table]
Important
In delegated scenarios with work or school accounts, the signed-in user must be assigned a supported Microsoft Entra role or a custom role with a supported role permission. The following least privileged roles are supported for this operation.
- Hybrid Identity Administrator
- Cloud Application Administrator
- Application Administrator
You can address the service principal using either its id or appId. id and appId are referred to as the Object ID and Application (Client) ID, respectively, in app registrations in the Microsoft Entra admin center.
POST /servicePrincipals/{id}/owners/$ref
POST /servicePrincipals(appId='{appId}')/owners/$ref
| Name | Description |
|---|---|
| Authorization | Bearer {token}. Required. Learn more about authentication and authorization. |
| Content-Type | application/json. Required. |
In the request body, supply a JSON representation of directoryObject object.
If successful, this method returns a 204 No Content response code and a directoryObject object in the response body.
The following example shows a request.
POST https://graph.microsoft.com/v1.0/servicePrincipals/{id}/owners/$ref
Content-type: application/json
{
"@odata.id": "https://graph.microsoft.com/v1.0/directoryObjects/{id}"
}[!INCLUDE sample-code] [!INCLUDE sdk-documentation]
[!INCLUDE sample-code] [!INCLUDE sdk-documentation]
[!INCLUDE sample-code] [!INCLUDE sdk-documentation]
[!INCLUDE sample-code] [!INCLUDE sdk-documentation]
[!INCLUDE sample-code] [!INCLUDE sdk-documentation]
[!INCLUDE sample-code] [!INCLUDE sdk-documentation]
[!INCLUDE sample-code] [!INCLUDE sdk-documentation]
In the request body, supply a JSON representation of directoryObject object.
The following example shows the response.
HTTP/1.1 204 No Content