Create identityApiConnector

Namespace: microsoft.graph

Create a new identityApiConnector object.

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) APIConnectors.ReadWrite.All
Delegated (personal Microsoft account) Not supported.
Application APIConnectors.ReadWrite.All

The work or school account needs to belong to one of the following roles:

  • Global administrator
  • External Identity User Flow administrator

HTTP request

POST /identity/apiConnectors

Request headers

Name Description
Authorization Bearer {token}. Required.
Content-Type application/json. Required.

Request body

In the request body, supply a JSON representation of the identityApiConnector object.

The following table shows the properties that are required when you create the identityApiConnector.

Property Type Description
displayName String The name of the API connector.
targetUrl String The URL of the API endpoint to call.
authenticationConfiguration apiAuthenticationConfigurationBase The object which describes the authentication configuration details for calling the API. Basic authentication and PKCS 12 client certificate are supported.

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 is an example of the request.

POST https://graph.microsoft.com/v1.0/identity/apiConnectors
Content-Type: application/json

{
    "displayName":"Test API",
    "targetUrl":"https://someapi.com/api",
    "authenticationConfiguration": {
      "@odata.type":"#microsoft.graph.basicAuthentication",
      "username": "MyUsername",
      "password": "MyPassword"
    }
}

Response

The following 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/v1.0/$metadata#identity/apiConnectors/$entity",
    "id":"45715bb8-13f9-4bf6-927f-ef96c102d394",
    "displayName": "Test API",
    "targetUrl": "https://someapi.com/api",
    "authenticationConfiguration": {
        "@odata.type": "#microsoft.graph.basicAuthentication",
        "username": "MyUsername",
        "password": "******"
    }
}

Example 2: Create an API connector with client certificate authentication

Request

The following is an example of the 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/v1.0/identity/apiConnectors
Content-Type: application/json

{
    "displayName":"Test API",
    "targetUrl":"https://someotherapi.com/api",
    "authenticationConfiguration": {
        "@odata.type":"#microsoft.graph.pkcs12Certificate",
        "pkcs12Value": "eyJhbGciOiJSU0EtT0FFUCIsImVuYyI6IkEyNTZHQ00ifQ...kDJ04sJShkkgjL9Bm49plA",
        "password": "CertificatePassword"
    }
}

Response

The following is an example of 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/v1.0/$metadata#identity/apiConnectors/$entity",
    "id":"45715bb8-13f9-4bf6-927f-ef96c102d394",
    "displayName": "Test API",
    "targetUrl": "https://someotherapi.com/api",
    "authenticationConfiguration": {
        "@odata.type": "#microsoft.graph.clientCertificateAuthentication",
        "certificateList": [
            {
                "thumbprint": "0EB255CC895477798BA418B378255204304897AD",
                "notAfter": 1666350522,
                "notBefore": 1508670522,
                "isActive": true
            }
        ]
    }
}