Skip to main content
Zoho sign
Zoho sign
Adding a recipient
  • The ID of the document must be stored.
  • Construct the actions object with the details of the new recipient to be added to the document.
  • Update the document by sending this constructed object to the update document details APIcall.
<?php

//Add recipients to request and field for them
$actionsJson=new stdClass();
$actionsJson->recipient_name = "<Recipient-Name>";
$actionsJson->recipient_email = "<Recipient-Email>";
$actionsJson->action_type = "SIGN";
$actionsJson->private_notes = "Please get back to us for further queries";
$actionsJson->signing_order = 1;
$actionsJson->verify_recipient = true;
$actionsJson->verification_type = "EMAIL";

$fieldJson=new stdClass();
$fieldJson->document_id = "<Document-Id";
$fieldJson->field_name = "TextField";
$fieldJson->field_type_name = "Textfield";
$fieldJson->field_label = "Text - 1";
$fieldJson->field_category = "Textfield";
$fieldJson->abs_width = "200";
$fieldJson->abs_height = "18";
$fieldJson->is_mandatory = true;
$fieldJson->x_coord = "30";
$fieldJson->y_coord = "30";
$fieldJson->page_no = 0;

$actionsJson->fields = array($fieldJson);
$requestJSON=new stdClass();
$requestJSON->actions = array($actionsJson);
$request=new stdClass();
$request->requests = $requestJSON;
$data = json_encode($request);
$POST_DATA = array(
    'data' => $data
);
$curl = curl_init("https://sign.zoho.com/api/v1/requests/<Request-Id>");
curl_setopt($curl, CURLOPT_TIMEOUT, 30);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
    'Authorization:Zoho-oauthtoken <Oauth-Token>',
));
curl_setopt($curl,CURLOPT_CUSTOMREQUEST,"PUT");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $POST_DATA);
$response = curl_exec($curl);
echo $response;
$jsonbody = json_decode($response); // contain filed tyes response
if ($jsonbody->status == "success") {
    $created_request_id = $jsonbody->requests->request_id; //Save the ID from the response to update later
    $status = $jsonbody->requests->request_status;
    echo $status;
} 
else //Error check for error
{
    echo $jsonbody->message;
}
curl_close($curl);
?>
const express = require('express');
const FormData = require('form-data');
const fetch = require('node-fetch');

const app = express();
const port = 4000;
app.get('/addRecipient', async (req, res) => {
    let actionsJson = {};
    actionsJson['recipient_name'] = '<Recipient-Name>';
    actionsJson['recipient_email'] = '<Recipient-Email>';
    actionsJson['action_type'] = 'SIGN';
    actionsJson['private_notes'] = 'Please get back to us for further queries';
    actionsJson['signing_order'] = 2;
    actionsJson['verify_recipient'] = true;
    actionsJson['verification_type'] = 'EMAIL';

    let fieldJson = {};
    fieldJson['document_id'] = '<Document-Id>';
    fieldJson['field_name'] = 'TextField';
    fieldJson['field_type_name'] = 'Textfield';
    fieldJson['field_label'] = 'Text';
    fieldJson['field_category'] = 'Textfield';
    fieldJson['abs_width'] = '200';
    fieldJson['abs_height'] = '18';
    fieldJson['is_mandatory'] = true;
    fieldJson['x_coord'] = '30';
    fieldJson['y_coord'] = '30';
    fieldJson['page_no'] = 0;

    actionsJson['fields'] = new Array(fieldJson);
    let documentJson = {};
    documentJson['actions'] = new Array(actionsJson);
    let data = {};
    data['requests'] = documentJson;
    var payload = new FormData();
    payload.append('data', JSON.stringify(data));
    let HEADERS = {};
    HEADERS['Authorization'] = 'Zoho-oauthtoken <Oauth Token>';
    let URL = 'https://sign.zoho.com/api/v1/requests/<Request-Id>';
    let method = 'PUT';
    let requestOptions = {
        method: method,
        headers: HEADERS,
        body: payload
    };

    let response = await fetch(URL, requestOptions)
        .then((_res) => {
            console.log(`Return code is ${_res.status}`);
            return _res.json().then((responseJson) => {
                res.send(responseJson);
                return;
            });
        })
        .catch((error) => {
            let errorResponse = {};
            errorResponse['message'] = 'call failed to initiate'; //check internet connection or proper DC type
            errorResponse['status'] = 'failure';
            res.send(errorResponse);
        });
});
app.listen(port, () => {
    console.log(`Example app listening on port  {port}`);
});
reciMap = Map();
reciMap.put("recipient_name","<Recipient_Name>");
reciMap.put("recipient_email","<Recipient_Email>");
reciMap.put("action_type","SIGN");
reciMap.put("signing_order",0);
reciList = List();
reciList.add(reciMap);

request = Map();
request.put("actions",reciList);
data = Map();
data.put("requests",request);
updateMap = Map();
updateMap.put("data",data);
res = zoho.sign.updateDocument("<Request_ID>",updateMap);
info res;
String requestId = "<request-id>";
HttpClient client = new DefaultHttpClient();
HttpGet getMethod = new HttpGet("https://sign.zoho.com/api/v1/requests/"+requestId);
getMethod.setHeader("Authorization","Zoho-oauthtoken "+ "<access-token>");
HttpResponse response = client.execute(getMethod); 
String responseJSON = EntityUtils.toString(response.getEntity(), "UTF-8");
JSONObject temp = new JSONObject(responseJSON);
JSONObject responseObj = temp.getJSONObject("requests");

// construct new recipient JSON details

JSONObject newRecipient =new JSONObject();
newRecipient.put("recipient_name","<New recipient name>");
newRecipient.put("recipient_email","<New recipient email>");
newRecipient.put("action_type","<new recipient action type - SIGN/VIEW>");
newRecipient.put("verify_recipient",false);
JSONArray actions = responseObj.getJSONArray("actions");
actions.put(newRecipient);
JSONObject dataJson =new JSONObject();
dataJson.put("requests", responseObj);
MultipartEntityBuilder reqEntity = MultipartEntityBuilder.create();
reqEntity.addTextBody("data",dataJson.toString());
HttpEntity multipart = reqEntity.build();
HttpPut putMethod = new HttpPut("https://sign.zoho.com/api/v1/request/requests"+requestId);
putMethod.setHeader("Authorization","Zoho-oauthtoken "+ "<access-token>");
putMethod.setEntity(multipart);
response = client.execute(putMethod);
responseJSON = EntityUtils.toString(response.getEntity(), "UTF-8");
JSONObject documentJson = new JSONObject(responseJSON);
if(documentJson.getString("status").equals("success"))
{
System.out.println("Recipient added successfully");
}
else
{
System.out.println("Failure in adding recipient :"+documentJson.getString("message"));
}
def addRecipient(request_id,Oauthtoken):
	headers = {'Authorization':'Zoho-oauthtoken '+Oauthtoken}
	req_data={}
	actions_list=[]
	actions_list.append({"recipient_name":"<recipient_name>","recipient_email":"<recipient_email>","action_type":"SIGN","private_notes":"Please get back to us for further queries","signing_order":0})
	req_data['actions']=actions_list
	data={}
	data['requests']=req_data
	data_json={}
	data_json['data'] = json.dumps(data)
	r = requests.put('https://sign.zoho.com/api/v1/requests/'+request_id, data=data_json,headers=headers)
	return r.json()
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://sign.zoho.com/api/v1/requests/"+<<Request Id>>);
request.Headers["Authorization"] = "Zoho-oauthtoken " + <<accessToken>>;
request.Method = "GET";
JObject responseObj = new JObject();
string requestStatus = string.Empty;
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
	Stream stream = response.GetResponseStream();
	StreamReader reader = new StreamReader(stream);
	String responseString = reader.ReadToEnd();
	responseObj = JObject.Parse(responseString);
}
if(responseObj.SelectToken("status").ToString().Equals("success"))
{
	if(responseObj.ContainsKey("requests"))
	{
		JObject requests = (JObject)responseObj.GetValue("requests");
		requestStatus = requests.GetValue("request_status").ToString();
	}
}

Show full

Show less

Request Demo