Send document on behalf of others using oauth

BoldSign enables performing actions on behalf of another user, thereby enhancing document management. This feature enables users to dispatch documents on behalf of other individuals.

To make use of this feature, it's necessary to obtain approval from an individual to use their email address to send documents on their behalf.

Follow these steps to send document on behalf of another individual

Create sender identity

Create a sender identity by using the name and email address of the individual to send documents on their behalf.

Here are example codes you can use to create a sender identity:

Code snippet

curl -X 'POST' \
  'https://api.boldsign.com/v1/senderIdentities/create' \
  -H 'accept: */*' \
  -H 'X-API-KEY: {your API key}' \
  -H 'Content-Type: application/json;' \
  -d '{
  "name": "Sender identity",
  "email": "senderidentity@email.com"
}'

var apiClient = new ApiClient("https://api.boldsign.com", "{your API key}");
var senderIdentityClient = new SenderIdentityClient(apiClient);
var senderIdentityRequest = new SenderIdentityRequest("Luther Cooper", "luthercooper@cubeflakes.com",null);
var senderIdentityCreated = senderIdentityClient.CreateSenderIdentity(senderIdentityRequest);
import requests

url = "https://api.boldsign.com/v1/senderIdentities/create"

payload = "{\r\n  \"name\": \"Sender identity\",\r\n  \"email\": \"senderidentity232@email.com\"\r\n}"
headers = {
  'accept': '*/*',
  'X-API-KEY': '{Your API key}',
  'Content-Type': 'application/json;'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)
const axios = require('axios');
let data = '{\r\n  "name": "Sender identity",\r\n  "email": "senderidentity@email.com"\r\n}';

let config = {
  method: 'post',
  url: 'https://api.boldsign.com/v1/senderIdentities/create',
  headers: { 
    'accept': '*/*', 
    'X-API-KEY': '{your API key}', 
    'Content-Type': 'application/json;'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

In the above example, replace the name and email with the name and email of the individual that you want to send the documents on their behalf. Then, provide the notificationSettings to customize how sender identity should recieve email notification for the documents sent on behalf of them. For example, if viewed is set to true, an email will be automatically sent to the sender identity email address when the document is viewed by the signers.

After executing the above request, an approval email will be sent to the mentioned email address. Using the link within this email, the sender can assess the request and provide authorization for you to send documents using their email address. Once the sender grants approval, the requesting user gains the ability to send documents on behalf of the approving user.

Create OAuth app

To send a document using OAuth authorization, it's necessary to create an OAuth app. Subsequently, generate a Bearer token using the client ID and client secret ID obtained from the created OAuth app, which should then be employed for the purpose of authorization.

Follow these steps to create Oauth App:

  1. Click on the Oauth Apps option under the API category from the left sidebar.

    Step 1

  2. Click the Create App button on the right side of the page.

  3. Enter the application name and any other required details in the dialog box that appears. Then, click the Save button to create the OAuth app.

    Step 2

  4. Once created, client ID and client secret ID will be generated.

  5. Use the client ID and client secret ID to generate a bearer token.

Send document on behalf of others using OAuth

Here are example codes that can be used to do this:

Code snippet

curl -X 'POST' \ 'https://api.boldsign.com/v1/document/send' \
     -H 'accept: application/json' \
     -H 'Authorization: Bearer {your bearer token}' \
     -H 'Content-Type: multipart/form-data' \
     -F 'OnBehalfOf=' \
     -F 'Message=' \
     -F 'Signers={
        "name": "Hanky",
        "emailAddress": "hankyWhites@cubeflakes.com",
        "signerType": "Signer",
        "formFields": [
           {
                "id": "string",
                "name": "string",
                "fieldType": "Signature",
                "pageNumber": 1,
                "bounds": {
                  "x": 50,
                  "y": 50,
                  "width": 1,
                  "height": 1
                   },
      "isRequired": true
    }
  ],
  "locale": "EN"
}' \
  -F 'Files={your file}' \
  -F 'Title={title}' \

var configuration = new Configuration();

// set your OAuth2 Access Token for authentication.
configuration.SetBearerToken("your-oauth2-token");
var apiClient = new ApiClient(configuration);
var documentClient = new DocumentClient(apiClient);

var documentFilePath = new DocumentFilePath
{
   ContentType = "application/pdf",
   FilePath = "{Your file path}", 
};

var filesToUpload = new List<IDocumentFile>
{
    documentFilePath,
};

var signatureField = new FormField(
   id: "sign",
   isRequired: true,
   type: FieldType.Signature,
   pageNumber: 1,
   bounds: new Rectangle(x: 100, y: 100, width: 100, height: 50));

var formFieldCollections = new List<FormField>()
{
    signatureField
};

var signer = new DocumentSigner(
  signerName: "David",
  signerType: SignerType.Signer,
  signerEmail: "david@cubeflakes.com",
  formFields: formFieldCollections,
  locale: Locales.EN);

var documentSigners = new List<DocumentSigner>()
{
    signer
};

var sendForSign = new SendForSign()
{
   Message = "please sign this",
   Title = "Agreement",
   OnBehalfOf = "",
   Signers = documentSigners,
   Files = filesToUpload
};
var documentCreated = documentClient.SendDocument(sendForSign);
import requests
import json

url = "https://api.boldsign.com/v1/document/send"

signer_data = {
    "name": "Hanky",
    "emailAddress": "hankyWhites@cubeflakes.com",
    "signerType": "Signer",
    "formFields": [
        {
            "id": "string",
            "name": "string",
            "fieldType": "Signature",
            "pageNumber": 1,
            "bounds": {
                "x": 50,
                "y": 50,
                "width": 1,
                "height": 1
            },
            "isRequired": True
        }
    ],
    "locale": "EN"
}

payload = {
    'OnBehalfOf': '',
    'Message': '',
    'Signers': json.dumps(signer_data),
    'Title': '{title}'
}

files = [
    ('Files', (
        'doc-2.pdf',
        open('{Your file path}', 'rb'),
        'application/pdf'
    ))
]

headers = {
    'accept': 'application/json',
    'Authorization': 'Bearer {your bearer token}'
}

response = requests.request("POST", url, headers=headers, data=payload, files=files)

print(response.text)

const axios = require('axios');
const FormData = require('form-data');
const fs = require('fs');
let data = new FormData();
data.append('OnBehalfOf', '');
data.append('Message', '');
data.append('Signers', '{\r\n        "name": "Hanky",\r\n        "emailAddress": "hankyWhites@cubeflakes.com",\r\n        "signerType": "Signer",\r\n        "formFields": [\r\n           {\r\n                "id": "string",\r\n                "name": "string",\r\n                "fieldType": "Signature",\r\n                "pageNumber": 1,\r\n                "bounds": {\r\n                  "x": 50,\r\n                  "y": 50,\r\n                  "width": 1,\r\n                  "height": 1\r\n                   },\r\n      "isRequired": true\r\n    }\r\n  ],\r\n  "locale": "EN"\r\n}');
data.append('Files', fs.createReadStream('{Your file path}'));
data.append('Title', '{title}');

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://api.boldsign.com/v1/document/send',
  headers: { 
    'accept': 'application/json', 
    'Authorization': 'Bearer {your bearer token}', 
    ...data.getHeaders()
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

In the above example, Authorize the API request with the bearer token generated from the above-mentioned steps, prefixed with the word Bearer. Replace Files, Title, and Signers with necessary details.

In the OnBehalfOf field, include only the email ID of the user who has been set as the sender identity. Once the required fields are filled, execute the above codes and document will be created if the fields filled are in required format.

By following these steps, a document can be sent on behalf of another user using Oauth in BoldSign successfully.