Skip to main content
Deleting a recipient
  • The ID of the document must be stored.
  • Get the document details and store the returned JSON value. Remove the entry for the recipient in the actions array.
  • Add a deleted_actions array which contains the action_id of the recipient to be removed.
<?php
$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,"GET");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($curl);
$jsonbody = json_decode($response); // contain filed tyes response
if ($jsonbody->status == "success") {
    $createdRequestId = $jsonbody->requests->request_id;
    //Save the ID from the response to update later
    $createdRequest=new stdClass();
    $createdRequest = $jsonbody->requests;
} else //Error check for error
{
    echo $jsonbody->message;
}
curl_close($curl);

$actionsJson=new stdClass();
$actionsJson->action_id = $createdRequest->actions[0]->action_id;
$actionsJson->recipient_name = $createdRequest->actions[0]->recipient_name;
$actionsJson->recipient_email = $createdRequest->actions[0]->recipient_email;
$actionsJson->action_type = $createdRequest->actions[0]->action_type;
$requestJSON=new stdClass();
$requestJSON->deleted_actions=array($actionsJson->action_id);
$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/".$createdRequestId);
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('/deleteRecipient', async (req, res) => {
    let HEADERS = {};
    HEADERS['Authorization'] = 'Zoho-oauthtoken <Oauth Token>';
    let URL = 'https://sign.zoho.com/api/v1/requests/<Request-Id>';
    let method = 'GET';
    let requestOptions = {
        method: method,
        headers: HEADERS
    };

    let response = await fetch(URL, requestOptions)
        .then((_res) => {
            console.log(`Return code is ${_res.status}`);
            return _res.json().then((responseJson) => {
                return responseJson['requests'];
            });
        })
        .catch((error) => {
            let errorResponse = {};
            errorResponse['message'] = 'call failed to initiate'; //check internet connection or proper DC type
            errorResponse['status'] = 'failure';
            res.send(errorResponse);
        });
    let action_id = response.actions[0].action_id;
    let requestJSON = {};
    requestJSON['deleted_actions'] = new Array(action_id);
    let data = {};
    data['requests'] = requestJSON;
    var payload = new FormData();
    payload.append('data', JSON.stringify(data));
    let requestOptions1 = {
        method: 'PUT',
        headers: HEADERS,
        body: payload
    };
    await fetch(URL, requestOptions1)
        .then((_res) => {
            console.log(`Return code is ${_res.status}`);
            return _res.json().then((responseJson) => {
                res.send(responseJson);
                return responseJson['requests'];
            });
        })
        .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}`);
});
deleteActionList = List();
res = zoho.sign.getDocumentById("<requestID>");
actions = res.get('requests').get('actions');
for each i in actions
{
	if ( i.get('recipient_email') == "<recipient email>") 
	{
		deleteActionList.add(i.get('action_id'));
	}
}

request = Map();
request.put("deleted_actions",deleteActionList);
data = Map();
data.put("requests",request);
updateMap = Map();
updateMap.put("data",data);
res = zoho.sign.updateDocument("<requestID>",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);
 if(temp.getString("status").equals("success"))
{
JSONObject documentJson = temp.getJSONObject("requests");
int deletedIndex = 1;
                                
//Find which recipient is next in line to sign
                                
JSONArray actions = documentJson.getJSONArray("actions");
JSONObject deletedAction = actions.getJSONObject(deletedIndex);
String deletedActionId = deletedAction.getString("action_id");
JSONArray deletedActions = new JSONArray();
deletedActions.put(deletedActionId);
JSONArray newActions = new JSONArray();
for(int i=0 ; i < actions.length(); i++)
{
if(i != deletedIndex)
{
newActions.put(actions.getJSONObject(i));
}
}
documentJson.put("actions",newActions);
documentJson.put("deleted_actions", deletedActions);
client = new DefaultHttpClient();
MultipartEntityBuilder reqEntity = MultipartEntityBuilder.create();
JSONObject dataJson = new JSONObject().put("requests",documentJson);
reqEntity.addTextBody("data", dataJson.toString());
HttpEntity multipart = reqEntity.build();
HttpPut postMethod = new HttpPut("https://sign.zoho.com/api/v1/requests/"+requestId);
postMethod.setHeader("Authorization","Zoho-oauthtoken "+ "<access-token>");
postMethod.setEntity(multipart);
response = client.execute(postMethod);
responseJSON = EntityUtils.toString(response.getEntity(), "UTF-8");
JSONObject submitResponse = new JSONObject(responseJSON);
if(submitResponse.has("status") && submitResponse.getString("status").equals("success"))
{
System.out.println("Document sent successfully");
}
else
{
System.out.println("Error : "+submitResponse.getString("message"));
}
}
else
{
System.out.println("Error in get document : " + temp.getString("message"));
}
def deleteRecipient(request_id,Oauthtoken):
	response = getDocumentDetailsById(request_id,Oauthtoken)
	headers = {'Authorization':'Zoho-oauthtoken '+Oauthtoken}
	actions = response['requests']['actions']
	deletedActions = []
	for i in actions:
		if i['recipient_email'] == '<recipient_email>':
			deletedActions.append(i['action_id'])
	req_data={}
	req_data['deleted_actions'] = deletedActions
	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()
var Client = new RestClient("https://sign.zoho.com/api/v1/requests/" + <<requestId>>);
var getRequest = new RestRequest();
getRequest.AddHeader("Authorization", "Zoho-oauthtoken " + <<accessToken>>);
var getResponse = Client.Get(getRequest);
string responseString = getResponse.Content;
JObject responseObj = JObject.Parse(responseString);
JObject requestObj = new JObject();
JArray actions = new JArray();

if (responseObj.SelectToken("status").ToString().Equals("success"))
{
if (responseObj.ContainsKey("requests"))
{
	requestObj = (JObject)responseObj.GetValue("requests");
	actions = (JArray)requestObj.GetValue("actions");
}
}

//The Index in the actions array to be deleted
int deleteIndex = 1;

JArray deletedActions = new JArray();
if (deleteIndex < actions.Count)
{
	string action_id = actions[deleteIndex].SelectToken("action_id").ToString();
	deletedActions.Add(action_id);
}

JArray newActions = new JArray();
for(int i=0; i<actions.Count;i++)
{
if (i != deleteIndex)
{
	JObject action = (JObject)actions[i];
	action.Remove("allow_signing");
	action.Remove("action_status");
	newActions.Add(actions[i]);
}
}


JObject request = new JObject();
request.Add("actions", newActions);
request.Add("deleted_actions", deletedActions);

JObject dataJson = new JObject();
dataJson.Add("requests", request);

string dataStr = Newtonsoft.Json.JsonConvert.SerializeObject(dataJson);

Client = new RestClient("https://sign.zoho.com/api/v1/requests/" + <<requestId>>);
var putRequest = new RestRequest();
putRequest.AddHeader("Authorization", "Zoho-oauthtoken " + <<accessToken>>);
putRequest.AddParameter("data", dataStr);
var response = Client.Put(putRequest);
var content = response.Content;
string requestResponse = content.ToString();

Show full

Show less

Request Demo