> ## Documentation Index
> Fetch the complete documentation index at: https://docs.coreflux.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Docu Sign OAuth

> LoT connector for DocuSign OAuth: exchange an externally signed JWT for an access token and read user info for the DocuSign eSignature connectors

Beta

> [!NOTE]
>
> **Beta.** This REST API app template is beta. Hub metadata sets `WITH STATUS "beta"`. The deployable `.lot` file does not include `ADD METADATA`.

## Overview

Client-mode REST API connectors for DocuSign eSignature: send inspection reports, test certificates and permits for signature from MQTT, follow envelope and recipient status, read signed field values and download the signed PDF with its certificate of completion, authenticated with the OAuth 2.0 JWT grant; a server-mode companion connector receives DocuSign Connect webhooks.

This is one of the templates in the DocuSign eSignature REST API app (`docusign-esignature`). Deploy it alongside the other connectors of that app when they depend on each other (for example a token connector plus an API connector).

## Auth

* **schemes**: \["JwtToken: POST /oauth/token on DocuSignOAuth, form body grant\_type=urn:ietf:params:oauth:grant-type:jwt-bearer (baked in) + assertion (JWT RS256 signed outside the broker with the integration key's RSA private key; claims iss = integration key, sub = user ID GUID, aud = account-d.docusign.com / account.docusign.com without https\://, iat, exp \<= 1 h, scope 'signature impersonation'); returns access\_token, Bearer, expires\_in 3600, no refresh token", "UserInfo: GET /oauth/userinfo with Bearer -> accounts\[].account\_id + base\_uri (sets BASE\_ADDRESS and account\_id)", "Authorization: Bearer \{value.json.access\_token} on every eSignature event except ServiceInformation (no auth)", "One-time consent (browser): [https://account-d.docusign.com/oauth/auth?response\_type=code\&scope=signature%20impersonation\&client\_id=\<key>\&redirect\_uri=\<uri](https://account-d.docusign.com/oauth/auth?response_type=code\&scope=signature%20impersonation\&client_id=\<key>\&redirect_uri=\<uri)>, or organization admin consent", "Authorization Code grant and the legacy X-DocuSign-Authentication header not packaged"]
* **secrets**: \["DOCUSIGN\_INTEGRATION\_KEY", "DOCUSIGN\_USER\_ID", "DOCUSIGN\_PRIVATE\_KEY (for the external JWT signer only; never in the broker connector)", "DOCUSIGN\_ACCESS\_TOKEN (optional, current token)", "DOCUSIGN\_ACCOUNT\_ID"]
* **permissions**: The token acts as the impersonated user (permission profile must allow sending envelopes; Connect reads need account admin).
* **note**: Inject secrets with a LoT action (GET SECRET); never retain topics that carry a JWT or token; restrict finance/docusign-esignature/auth/# with ACLs. LoT cannot sign RS256, so a signer service publishes the JWT.

Auth headers used by the template: `Authorization: Bearer {value.json.access_token}`.

## Template parameters

| Placeholder | Type | Description | Required |
| - | - | - | - |
| `RouteName` | string | Name of the Docu Sign OAuth connector | no |
| `BaseUrl` | string | Docu Sign OAuth base URL without trailing slash (e.g. [https://account-d.docusign.com](https://account-d.docusign.com)) | yes |

`BASE_ADDRESS` default: `https://account-d.docusign.com`.

## Events

| Event | Method | Endpoint | Request topic | Response topic | Payload fields |
| - | - | - | - | - | - |
| `JwtToken` | POST | `/oauth/token` | `finance/docusign-esignature/auth/token` | `finance/docusign-esignature/auth/token/response` | `assertion` |
| `UserInfo` | GET | `/oauth/userinfo` | `finance/docusign-esignature/auth/userinfo` | `finance/docusign-esignature/auth/userinfo/response` | `access_token` |

## Deploy

Get the template card (JSON with `template` and `metadata`) from the broker, then deploy the connector:

```bash theme={"theme":{"light":"css-variables","dark":"css-variables"},"languages":{"custom":["/languages/lot.json"]}}
mosquitto_pub -t '$SYS/Coreflux/Command' -m "-connectorCode DOCU_SIGN_OAUTH"
```

The deployable connector from the REST API app, with `BASE_ADDRESS` already filled in:

```lot theme={"theme":{"light":"css-variables","dark":"css-variables"},"languages":{"custom":["/languages/lot.json"]}}
DEFINE CONNECTOR DocuSignOAuth WITH TYPE REST_API
    ADD REST_API_CONFIG
        WITH BASE_ADDRESS "https://account-d.docusign.com"
        WITH ENABLE_CLIENT "true"
        WITH USE_SSL "true"
        WITH REQUEST_TIMEOUT '60'
        WITH DEFAULT_CONTENT_TYPE "application/json"
    ADD EVENT JwtToken
        WITH SOURCE_TOPIC "finance/docusign-esignature/auth/token"
        WITH DESTINATION_TOPIC "finance/docusign-esignature/auth/token/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/oauth/token"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
            ADD "Content-Type" "application/x-www-form-urlencoded"
        WITH BODY "grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Ajwt-bearer&assertion={value.json.assertion}"
    ADD EVENT UserInfo
        WITH SOURCE_TOPIC "finance/docusign-esignature/auth/userinfo"
        WITH DESTINATION_TOPIC "finance/docusign-esignature/auth/userinfo/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/oauth/userinfo"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
            ADD "Authorization" "Bearer {value.json.access_token}"
```

Deploy it with `-addConnector` (do not include `ADD METADATA`).

## Usage example

Call `JwtToken` by publishing a JSON payload to its request topic, and read the reply on the response topic:

```bash theme={"theme":{"light":"css-variables","dark":"css-variables"},"languages":{"custom":["/languages/lot.json"]}}
mosquitto_sub -t 'finance/docusign-esignature/auth/token/response' &
mosquitto_pub -t 'finance/docusign-esignature/auth/token' -m '{"assertion": "<assertion>"}'
```

## Related

* [REST API Connectors](https://docs.coreflux.org/v2.22/lot-language/routes/rest-api-routes.md)
* [REST API Apps catalog](https://docs.coreflux.org/v2.22/lot-language/routes/rest-api-apps.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.