---
schema_version: "1"
id: 59ddd922877eda6ba3b24f3a2748943f5703455bf3c21da47524a5f0b6e2e4d1
title: Integrating IDP with Anypoint Studio
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/idp/integrating-idp-with-anypoint-studio.md
canonical_url: https://docs.mulesoft.com/idp/integrating-idp-with-anypoint-studio
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 62f5fe455b8140d616a82398cb29b689ced1eb79689a3ab1443ac6cdd16d67e3
description: MuleSoft Documentation Site
latest: true
---
---
product: IDP
---

# Integrating IDP with Anypoint Studio

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

Execute a published document action and retrieve the results from Anypoint Studio using that
document action’s IDP Runtime Service API connector. This connector generates automatically when you
publish a document action to Anypoint Exchange. Then, you can download it as a Mule connector from
Exchange.

Each document action version generates a different connector. For example, when you publish a
document action for the first time, it generates a connector in Exchange that executes version
`1.0.0` of this document action. Then, if you modify the document action and republish it as version
`1.1.0`, it generates a different connector that you must download and install in Studio to execute
this new document action version. Consider this behavior when building your integrations.

The IDP Runtime Service API connector has the following operations:

- **getDocumentActionExecution**

  Retrieves the result of a document action execution.

- **postDocumentActionExecution**

  Submits a document to IDP for processing.

## Before You Begin

Ensure you have the following Anypoint permissions:

Execute Published Actions

Enables a user to execute a published document action and retrieve the results of the execution.

If you already have a connected app configured for IDP, you don’t need the **Configure Connected
Apps** permission and you can use your existing connected app instead of creating a new one.

## Create a Connected App

To communicate with the IDP API, create a connected app with the following details:

- Type: `App acts on its own behalf (client credentials)`

- Scopes: `Execute Published Actions`

After you create the connected app, copy its **ID** and **Secret** for further use.

For more information, see
[Connected Apps in Anypoint Platform](https://docs.mulesoft.com/access-management/connected-apps-overview).

## Obtain the Access Token

After you configure the connected app, use the following `curl` command to get the token:

```bash
curl --location --request POST 'https://anypoint.mulesoft.com/accounts/api/v2/oauth2/token' \ (1)
--header 'Content-Type: application/json' \
--data-raw '{
 "grant_type": "client_credentials",
 "client_id": "<connected-app-client-id>", (2)
 "client_secret": "<connected-app-client-secret>" (3)
}'
```

<table><tbody><tr><td><i data-value="1"></i><b>1</b></td><td>If you are in the EU region, use the <code>eu1.anypoint.mulesoft.com</code> domain.</td></tr><tr><td><i data-value="2"></i><b>2</b></td><td>Replace <code>&lt;connected-app-client-id&gt;</code> with the client ID from your connected app.</td></tr><tr><td><i data-value="3"></i><b>3</b></td><td>Replace <code>&lt;connected-app-client-secret&gt;</code> with the client secret from your connected app.</td></tr></tbody></table>

Use the access token when calling the IDP API.

## Configure the IDP Runtime Service API Connector

Before using its operations, configure the connector by providing the following values, either
manually or through a Global Configuration Element:

- **host**: Anypoint endpoint URL

  Use the appropriate endpoint for your region:

  - US East (Virginia): `idp-rt.us-east-1.anypoint.mulesoft.com`

  - EU Central (Frankfurt): `idp-rt.eu-central-1.eu1.anypoint.mulesoft.com`

- **port**: HTTP port for the connection

  For example: `443`

- **basePath**: Base path of the URL to call, without the protocol

- **protocol**: Protocol for the call, in uppercase

  For example: `HTTPS`

- **Response timeout**: Response timeout for this operation

- **clientId**: Client ID of the connected app to call IDP

- **clientSecret**: Client Secret of the connected app to call IDP

- **accessTokenUrl**: URL to obtain the access token for your connected app

  For example:
  `[https://anypoint.mulesoft.com/accounts/api/v2/oauth2/token](https://anypoint.mulesoft.com/accounts/api/v2/oauth2/token)`

## Submit a Document to IDP

Use the **postDocumentActionExecution** operation to send a document to IDP and execute the
corresponding document action version.

Specify the details of the request in the **Postdocumentactionexecution request data** field of the
connector. The following is a sample request:

```bash
%dw 2.0
output multipart/form-data
---
{
   parts : {
   	 callback : {
   	 	  headers : {
               "Content-Type" : "text/plain"
               },
           content : '{"noAuthUrl": "https://{yourCallbackURL}.com"}'
       },
       file : {
           headers : {
               "Content-Disposition" : {
                   "name": "file",
                   "filename": "{myFile.jpg}",
                   "subtype": "form-data"
                   },
               "Content-Type" : "image/jpg"
               },
           content : payload
           }
       }
}
```

The response from this operation contains the execution ID that you must use to retrieve the
execution results.

## Retrieve the Results of the Execution

Use the **getDocumentActionExecution** operation to get the results of a document action execution
by specifying its execution ID.

The following is a sample response from this operation, shortened for better readability:

```linenums
{
    "id": "d68e099e-8d37-4188-905a-0eac68b7bf61",
    "documentName": "invoice-1.jpg",
    "status": "SUCCEEDED",
    "pages": [
        {
            "page": 1,
            "fields": {
                "invoiceDate": {
                    "value": "1 June, 1983"
                },
                "invoiceNumber": {
                    "value": "8248"
                }
                ...

            },
            "tables": {
                "table1": [
                    {
                        "unitPrice": {
                            "value": ""
                        },
                        "price": {
                            "value": "$ 198.00"
                        }
                        ...
                    }
                ]
            },
            "prompts": {
                "business": {
                    "prompt": "what is the company main business",
                    "source": "document",
                    "answer": {
                        "value": null
                    }
                }
            }
        }
    ]
}
```

## See Also

- [Analyzing Documents Using Pre-Built Schemas](https://docs.mulesoft.com/idp/creating-document-actions)

- [Publishing Document Actions](https://docs.mulesoft.com/idp/publishing-document-actions)
