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 identityApiConnector 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
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) |
APIConnectors.ReadWrite.All |
Not available. |
Delegated (personal Microsoft account) |
Not supported. |
Not supported. |
Application |
APIConnectors.ReadWrite.All |
Not available. |
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. External ID User Flow Administrator is the least privileged role supported for this operation.
HTTP request
POST /identity/apiConnectors
Request body
In the request body, supply a JSON representation of the identityApiConnector object.
The following table lists the properties that are required when you create the identityApiConnector.
Response
If successful, this method returns a 201 Created
response code and an identityApiConnector object in the response body.
Examples
Example 1: Create an API connector with basic authentication
Request
The following example shows a request.
POST https://graph.microsoft.com/beta/identity/apiConnectors
Content-Type: application/json
{
"displayName":"Test API",
"targetUrl":"https://someapi.com/api",
"authenticationConfiguration": {
"@odata.type":"#microsoft.graph.basicAuthentication",
"username":"<USERNAME>",
"password":"<PASSWORD>"
}
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new IdentityApiConnector
{
DisplayName = "Test API",
TargetUrl = "https://someapi.com/api",
AuthenticationConfiguration = new BasicAuthentication
{
OdataType = "#microsoft.graph.basicAuthentication",
Username = "<USERNAME>",
Password = "<PASSWORD>",
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Identity.ApiConnectors.PostAsync(requestBody);
mgc-beta identity api-connectors create --body '{\
"displayName":"Test API",\
"targetUrl":"https://someapi.com/api",\
"authenticationConfiguration": {\
"@odata.type":"#microsoft.graph.basicAuthentication",\
"username":"<USERNAME>",\
"password":"<PASSWORD>"\
}\
}\
'
// 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"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewIdentityApiConnector()
displayName := "Test API"
requestBody.SetDisplayName(&displayName)
targetUrl := "https://someapi.com/api"
requestBody.SetTargetUrl(&targetUrl)
authenticationConfiguration := graphmodels.NewBasicAuthentication()
username := "<USERNAME>"
authenticationConfiguration.SetUsername(&username)
password := "<PASSWORD>"
authenticationConfiguration.SetPassword(&password)
requestBody.SetAuthenticationConfiguration(authenticationConfiguration)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
apiConnectors, err := graphClient.Identity().ApiConnectors().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
IdentityApiConnector identityApiConnector = new IdentityApiConnector();
identityApiConnector.setDisplayName("Test API");
identityApiConnector.setTargetUrl("https://someapi.com/api");
BasicAuthentication authenticationConfiguration = new BasicAuthentication();
authenticationConfiguration.setOdataType("#microsoft.graph.basicAuthentication");
authenticationConfiguration.setUsername("<USERNAME>");
authenticationConfiguration.setPassword("<PASSWORD>");
identityApiConnector.setAuthenticationConfiguration(authenticationConfiguration);
IdentityApiConnector result = graphClient.identity().apiConnectors().post(identityApiConnector);
const options = {
authProvider,
};
const client = Client.init(options);
const identityApiConnector = {
displayName: 'Test API',
targetUrl: 'https://someapi.com/api',
authenticationConfiguration: {
'@odata.type':'#microsoft.graph.basicAuthentication',
username: '<USERNAME>',
password: '<PASSWORD>'
}
};
await client.api('/identity/apiConnectors')
.version('beta')
.post(identityApiConnector);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Models\IdentityApiConnector;
use Microsoft\Graph\Beta\Generated\Models\BasicAuthentication;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new IdentityApiConnector();
$requestBody->setDisplayName('Test API');
$requestBody->setTargetUrl('https://someapi.com/api');
$authenticationConfiguration = new BasicAuthentication();
$authenticationConfiguration->setOdataType('#microsoft.graph.basicAuthentication');
$authenticationConfiguration->setUsername('<USERNAME>');
$authenticationConfiguration->setPassword('<PASSWORD>');
$requestBody->setAuthenticationConfiguration($authenticationConfiguration);
$result = $graphServiceClient->identity()->apiConnectors()->post($requestBody)->wait();
Import-Module Microsoft.Graph.Beta.Identity.SignIns
$params = @{
displayName = "Test API"
targetUrl = "https://someapi.com/api"
authenticationConfiguration = @{
"@odata.type" = "#microsoft.graph.basicAuthentication"
username = "<USERNAME>"
password = "<PASSWORD>"
}
}
New-MgBetaIdentityApiConnector -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.models.identity_api_connector import IdentityApiConnector
from msgraph_beta.generated.models.basic_authentication import BasicAuthentication
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = IdentityApiConnector(
display_name = "Test API",
target_url = "https://someapi.com/api",
authentication_configuration = BasicAuthentication(
odata_type = "#microsoft.graph.basicAuthentication",
username = "<USERNAME>",
password = "<PASSWORD>",
),
)
result = await graph_client.identity.api_connectors.post(request_body)
Response
The following example shows 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#identity/apiConnectors/$entity",
"id":"GUID",
"displayName": "Test API",
"targetUrl": "https://someapi.com/api",
"authenticationConfiguration": {
"@odata.type": "#microsoft.graph.basicAuthentication",
"username": "<USERNAME>",
"password": "******"
}
}
Example 2: Create an API connector with client certificate authentication
Request
The following example shows a request.
Note: authenticationConfiguration
in the request is of type microsoft.graph.pkcs12certificate, which represents the configuration of a certificate needed on upload or create.
POST https://graph.microsoft.com/beta/identity/apiConnectors
Content-Type: application/json
{
"displayName":"Test API",
"targetUrl":"https://someotherapi.com/api",
"authenticationConfiguration": {
"@odata.type":"#microsoft.graph.pkcs12Certificate",
"pkcs12Value": "eyJhbGciOiJSU0EtT0FFUCIsImVuYyI6IkEyNTZHQ00ifQ...kDJ04sJShkkgjL9Bm49plA",
"password": "<password>"
}
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new IdentityApiConnector
{
DisplayName = "Test API",
TargetUrl = "https://someotherapi.com/api",
AuthenticationConfiguration = new Pkcs12Certificate
{
OdataType = "#microsoft.graph.pkcs12Certificate",
Pkcs12Value = "eyJhbGciOiJSU0EtT0FFUCIsImVuYyI6IkEyNTZHQ00ifQ...kDJ04sJShkkgjL9Bm49plA",
Password = "<password>",
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Identity.ApiConnectors.PostAsync(requestBody);
mgc-beta identity api-connectors create --body '{\
"displayName":"Test API",\
"targetUrl":"https://someotherapi.com/api",\
"authenticationConfiguration": {\
"@odata.type":"#microsoft.graph.pkcs12Certificate",\
"pkcs12Value": "eyJhbGciOiJSU0EtT0FFUCIsImVuYyI6IkEyNTZHQ00ifQ...kDJ04sJShkkgjL9Bm49plA",\
"password": "<password>"\
}\
}\
'
// 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"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewIdentityApiConnector()
displayName := "Test API"
requestBody.SetDisplayName(&displayName)
targetUrl := "https://someotherapi.com/api"
requestBody.SetTargetUrl(&targetUrl)
authenticationConfiguration := graphmodels.NewPkcs12Certificate()
pkcs12Value := "eyJhbGciOiJSU0EtT0FFUCIsImVuYyI6IkEyNTZHQ00ifQ...kDJ04sJShkkgjL9Bm49plA"
authenticationConfiguration.SetPkcs12Value(&pkcs12Value)
password := "<password>"
authenticationConfiguration.SetPassword(&password)
requestBody.SetAuthenticationConfiguration(authenticationConfiguration)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
apiConnectors, err := graphClient.Identity().ApiConnectors().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
IdentityApiConnector identityApiConnector = new IdentityApiConnector();
identityApiConnector.setDisplayName("Test API");
identityApiConnector.setTargetUrl("https://someotherapi.com/api");
Pkcs12Certificate authenticationConfiguration = new Pkcs12Certificate();
authenticationConfiguration.setOdataType("#microsoft.graph.pkcs12Certificate");
authenticationConfiguration.setPkcs12Value("eyJhbGciOiJSU0EtT0FFUCIsImVuYyI6IkEyNTZHQ00ifQ...kDJ04sJShkkgjL9Bm49plA");
authenticationConfiguration.setPassword("<password>");
identityApiConnector.setAuthenticationConfiguration(authenticationConfiguration);
IdentityApiConnector result = graphClient.identity().apiConnectors().post(identityApiConnector);
const options = {
authProvider,
};
const client = Client.init(options);
const identityApiConnector = {
displayName: 'Test API',
targetUrl: 'https://someotherapi.com/api',
authenticationConfiguration: {
'@odata.type':'#microsoft.graph.pkcs12Certificate',
pkcs12Value: 'eyJhbGciOiJSU0EtT0FFUCIsImVuYyI6IkEyNTZHQ00ifQ...kDJ04sJShkkgjL9Bm49plA',
password: '<password>'
}
};
await client.api('/identity/apiConnectors')
.version('beta')
.post(identityApiConnector);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Models\IdentityApiConnector;
use Microsoft\Graph\Beta\Generated\Models\Pkcs12Certificate;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new IdentityApiConnector();
$requestBody->setDisplayName('Test API');
$requestBody->setTargetUrl('https://someotherapi.com/api');
$authenticationConfiguration = new Pkcs12Certificate();
$authenticationConfiguration->setOdataType('#microsoft.graph.pkcs12Certificate');
$authenticationConfiguration->setPkcs12Value('eyJhbGciOiJSU0EtT0FFUCIsImVuYyI6IkEyNTZHQ00ifQ...kDJ04sJShkkgjL9Bm49plA');
$authenticationConfiguration->setPassword('<password>');
$requestBody->setAuthenticationConfiguration($authenticationConfiguration);
$result = $graphServiceClient->identity()->apiConnectors()->post($requestBody)->wait();
Import-Module Microsoft.Graph.Beta.Identity.SignIns
$params = @{
displayName = "Test API"
targetUrl = "https://someotherapi.com/api"
authenticationConfiguration = @{
"@odata.type" = "#microsoft.graph.pkcs12Certificate"
pkcs12Value = "eyJhbGciOiJSU0EtT0FFUCIsImVuYyI6IkEyNTZHQ00ifQ...kDJ04sJShkkgjL9Bm49plA"
password = "<password>"
}
}
New-MgBetaIdentityApiConnector -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.models.identity_api_connector import IdentityApiConnector
from msgraph_beta.generated.models.pkcs12_certificate import Pkcs12Certificate
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = IdentityApiConnector(
display_name = "Test API",
target_url = "https://someotherapi.com/api",
authentication_configuration = Pkcs12Certificate(
odata_type = "#microsoft.graph.pkcs12Certificate",
pkcs12_value = "eyJhbGciOiJSU0EtT0FFUCIsImVuYyI6IkEyNTZHQ00ifQ...kDJ04sJShkkgjL9Bm49plA",
password = "<password>",
),
)
result = await graph_client.identity.api_connectors.post(request_body)
Response
The following example shows the response.
Note: authenticationConfiguration
in the response is of type microsoft.graph.clientCertificateAuthentication because this represents the public information of uploaded certificates.
HTTP/1.1 201 Created
Content-Type: application/json
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#identity/apiConnectors/$entity",
"id":"GUID",
"displayName": "Test API",
"targetUrl": "https://someotherapi.com/api",
"authenticationConfiguration": {
"@odata.type": "#microsoft.graph.clientCertificateAuthentication",
"certificateList": [
{
"thumbprint": "0EB255CC895477798BA418B378255204304897AD",
"notAfter": 1666350522,
"notBefore": 1508670522,
"isActive": true
}
]
}
}