Delete Records - v2.1

Updates in V2.1

1. New parameters have been added:

  • In V2.1, by default, all associated workflows will get triggered. skip_workflow parameter key allows the restriction of schedules and form workflows. In API V2, this provision of skipping certain workflows is not possible.

Overview

This API deletes the records displayed by a report of your Zoho Creator application. A maximum of 200 records can be deleted per request. The delete request is subject to custom validations configured for the target form.

Request Details

Request URL

https://<base_url>/creator/v2.1/data/<account_owner_name>/<app_link_name>/report/<report_link_name>

Request method

DELETE

Header

KeyValueDescription
Authorization

Zoho-oauthtoken 1000.8cb99dxxxx

xxxxxxxxx9be93.9

b8xxxxxxxxxxxxxxxf

An authentication token (authtoken) allows users to access apps and APIs without having to enter their login credentials each time.
environmentdevelopment/stageRefers to the environment stage.
demo_user_namedemouser_1, demouser_2, demouser_3..Demo users in your Creator app can be appended along with the environment. 
Note: By default, production value will be considered for the environment header.

OAuth scope

scope=ZohoCreator.report.DELETE

where,

base_urlthe base URL of your Creator account
For example, it's www.zohoapis.com if your account belongs to Zoho's US DC, and is www.zohoapis.eu if it belongs to Zoho's EU DC.
account_owner_namethe username of the Creator account's owner
app_link_namethe link name of the target application
report_link_namethe link name of the report from which you want to delete records

Body

  • criteria string

    (Mandatory) The criteria using which you want to filter the target report. If you're looking to delete all matching records, you'll have to include "criteria": "ID!=0" or "criteria": "ID!=null" in your request. Criteria is mandated to prevent you from accidentally deleting all matching records. The sample input on the right sports a criteria that'll filter for records where the Single_Line field contains the value "Single Line of Text".

  • skip_workflow list

    (Optional) Prevents the associated form workflows from being executed on the deletion of records.
    Possible values: form_workflow

    Note: By default:

    • If this parameter is not supplied, all associated workflows will be triggered.
    • Blueprints and approvals will be triggered on deletion of records, and cannot be skipped.
    Sample value for the parameter "skip_workflow"Description
    "skip_workflow" : ["form_workflow"]Prevents the associated form workflows from being triggered when the records are deleted using API

Defining the Search Criteria

  • The search criteria is a combination of one or more expressions. An expression is defined using a field, operator, and value.
  • An expression can use all field types except section and add notes. The field's data type dictates the operator that can be used and the format in which the value is to be given.
  • You can use logical operators&& (AND), || (OR), and ! (NOT) to link the expressions in your criteria. These operators are subject to precedence, which you can manage using parentheses ().
  • Values for STRING type fields, such as single line, email, and phone, must be enclosed in double-quotes, and the double-quotes must be escaped.
  • Values for the time, date, and date-time fields must adhere to the application's date and time formats and must be enclosed in single-quotes.
  • The record ID must be passed when you want to filter the records using the lookup and integration fields.
  • When using the multi select, checkbox or multi-select lookup fields, you can specify only one value per expression.
Sample criteria in the JSONDescription
"criteria": "Status==\"Closed\""To fetch the records where the Status (a drop down or radio field) is "Closed"
"criteria": "Status!=\"Open\""To fetch the records where the Status (a drop down or radio field) is not "Open"
"criteria": "Email.endswith(\"zylker.com\")"To fetch the records where the Email (an email field) ends with "zylker.com"
"criteria": "Email.startswith(\"ja\")"To fetch the records where the Email (an email field) starts with "ja", such as "jason@zylker.com" and "janine@zylker.com"
"criteria": "Feedback.contains(\"it's awful\")"To fetch the records where the Feedback (a multi line or rich text field) contains "it's awful"
"criteria": "Age!=28"To fetch the records where the Feedback (a multi line or rich text field) is not 28
"criteria": "Total=250.43"To fetch the records where the Total (a decimal or currency field) is 250.43
"criteria": "Total>=250.43"To fetch the records where the Total (a decimal or currency field) is greater than or equal to 250.43
"criteria": "Appointment_Date==\"14-Apr-2020\""To fetch the records where the appointment date (a date field) is 14-Apr-2020 (as per the application's date format)
"criteria": "Expedited_Delivery=false"To fetch the records where the Expedited_Delivery (a decision box field) is false
"criteria": "Hobbies.contains(\"Hiking\")"To fetch the records where the Hobbies (a multi select or checkbox field) includes "Hiking"
"criteria": "Status==\"Open\" || Status==\"In-progress\""To fetch the records where the Status (a drop down or radio field) is either "Open" or "In-progress"
"criteria": "Status==\"Closed\" && Email.endswith(\"zylker.com\")"To fetch the records where the Status (a drop down or radio field) is "Closed" and the Email (an email field) ends with "zylker.com"

Understanding the Response

The success or failure of the API will be conveyed in its response. The response of the Delete Records API includes the following keys:

  • result

    This key will contain the details about the records deleted by this API.

  • code

    At the overall request's level, this key denotes its success or failure. Inside the "result" key, this key denotes the success or failure of the delete operation. Refer to this page for the complete list of codes and messages.

  • message
    • When the API request includes "message": true, the response will contain "message":"Data Deleted Successfully" or the message that's configured as part of a show message workflow action
    • When the API request includes "message": false or does not include this the message key, the response will contain "message":"Data Deleted Successfully"
  • data

    This key will contain the ID of the deleted record.

  • tasks

    When the API request includes this key with value true, the response will return the details of the form, report, page, or URL to which the target form is configured to redirect to upon successful deletion record deletion. Redirection can be set up using a redirection workflow action. The "type" key will contain the type of window in which the target URL is to open (same window, new window, or parent window). The "url" key will contain one of the following, for example:

    • #Form:<form_link_name>
    • #Report:<report_link_name>
    • #Page:<page_link_name>
    • https://www.zylker.com

Possible Errors

Refer to this page for the list of error codes and messages.

  • process_until_limit string

    A maximum of 200 records can be deleted per request. When the number of matching records exceeds 200, your request will fail unless it includes this parameter. Including process_until_limit=true in your request ensures it deletes the first 200 records and returns the more_records key in the response. You'll have to loop your API requests until the more_records key in the response is returned as false.

Sample Request for Production environment (for C6 users)

Copiedcurl "https://www.zohoapis.com/creator/v2.1/data/jason18/zylker-store/report/All_Orders"
-X DELETE
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
Copiedpackage org.example;

import okhttp3.HttpUrl;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import org.json.JSONArray;
import org.json.JSONObject;

public class DeleteRecords
{
    public static void main(String[] args)
    {
        JSONObject payload = new JSONObject();

        payload.put("criteria","Single_Line == \"Single Line of Text\"");

        JSONArray skipWorkflowArr = new JSONArray();
        skipWorkflowArr.put("form_workflow");

        payload.put("skip_workflow",skipWorkflowArr);

        JSONObject resultObj = new JSONObject();

        resultObj.put("message",true);
        resultObj.put("tasks",true);

        payload.put("result",resultObj);

        OkHttpClient client = new OkHttpClient();
        MediaType mediaType = MediaType.parse("application/json");
        RequestBody body = RequestBody.create(mediaType, payload.toString());

        HttpUrl.Builder urlBuilder = HttpUrl.parse("https://www.zohoapis.com/creator/v2.1/data/jason18/zylker-store/report/All_Orders").newBuilder()
                .addQueryParameter("process_until_limit","true");
        Request request = new Request.Builder()
                .url(urlBuilder.toString())
                .method("DELETE", body)
                .addHeader("Authorization", "Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf")
                .build();
        try
        {
            JSONObject response = new JSONObject(client.newCall(request).execute().body().string());
        }
        catch (Exception e)
        {
            System.out.println("Exception while making the API request.");
        }
    }
}
Copiedlet payload = {
    "criteria": "Single_Line == \"Single Line of Text\"",
    "skip_workflow": [
        "form_workflow"
    ],
    "result": {
        "message": true,
        "tasks": true
    }
}

let api_headers = {
    "Authorization": "Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
}

try {
    let response = fetch("https://www.zohoapis.com/creator/v2.1/data/jason18/zylker-store/report/All_Orders?process_until_limit=true", {
        method: "DELETE",
        headers: api_headers,
        body: JSON.stringify(payload)
    })
}
catch (exception) {
    console.error(exception)
}
Copiedimport requests

payload = {
    "criteria": "Single_Line == \"Single Line of Text\"",
    "skip_workflow": [
        "form_workflow"
    ],
    "result": {
        "message": True,
        "tasks": True
    }
}

api_parameters = {
    "process_until_limit": True
}

api_headers = {
    "Authorization": "Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
}

try:
    response = requests.delete("https://www.zohoapis.com/creator/v2.1/data/jason18/zylker-store/report/All_Orders/", params=api_parameters, headers=api_headers, data=str(payload))
except:
    print("Exception while making the API request.")

This sample request will delete the records displayed in the All Orders report of the Zylker Store application. The sample input below shows how to include a criteria in this request.

Sample Request for Development/ Stage environments (for C6 users)

Copiedcurl "https://www.zohoapis.com/creator/v2.1/data/jason18/zylker-store/report/All_Orders"
-X DELETE
-H 'Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf'  
-H 'environment: development'
-H 'demo_user_name: demouser_1'

Sample Input

Copied{
  "criteria": "(Single_Line.contains(\"Single Line of Text\"))",
  "skip_workflow": ["form_workflow"],
  "result": {
    "message": true,
    "tasks": true
  }
}

Sample Response

Copied{
  "result": [
    {
      "code": 3001,
      "data": {
        "ID": "3000000013011"
      },
      "error": [
        "Failed to Delete Data."
      ]
    },
    {
      "code": 3000,
      "data": {
        "ID": "3000000015003"
      },
      "message": "Record Deleted Successfully!"
    },
    {
      "code": 3000,
      "data": {
        "ID": "3000000015007"
      },
      "message": "Record Deleted Successfully!"
    }
  ],
  "code": 3000
}