Create Bulk Read job (Bulk Export)

Purpose

To create a bulk read job to export records.

Request Details

Request URL

https://www.zohoapis.com/bigin/bulk/v1/read

Header

Authorization: Zoho-oauthtoken d92d4xxxxxxxxxxxxx15f52

Scope

scope=ZohoBigin.bulk.read
(and)
scope=ZohoBigin.modules.{module_name}.{operation_type}

Possible module names

companies, contacts, deals, tasks, events, calls, products and activities.

Possible operation types

ALL - Full access to the record
READ - Get bulk read job

Sample Request

Copiedcurl "https://www.zohoapis.com/bigin/bulk/v1/read"
-X POST
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
-H "Content-Type: application/json"
-d "@inputData.json"

Request JSON

  • callbackJSON Object, optional

    The JSON object represents the following details of a bulk read job.

    • url(string)-
      A valid URL, that should allow HTTP Post method. The Bulk Read Job's details is posted to this URL on successful completion of job or on failure of job.

    • method(string)-
      The HTTP method of the callback url. The supported value is post.

  • queryJSON Object, optional

    Represents the JSON object that holds the keys and their value that form the criteria for bulk export. The following are the keys in the JSON object:

    • module(string, mandatory)-
      Represents the API Name of the module you want to export the records from. Specify the module name as "Events" if you want to export the records in the Events module as an ICS file.

    • cvid(string, mandatory) -
      Represents the unique ID of the custom view when you want to export records in a custom view. You can obtain the cvid from the Custom View Metadata API.

    • file_type(string, mandatory when you want to export the events as an ICS file)-
      Specify the value for this key as "ics" to export all records in the Events module as an ICS file.

    • fields(JSON array, optional) -
      Represents the API name of the fields that you want to export. For instance, First_Name, Last_Name, Email, Owner.last_name, and so on. Do not input this key when you want to export the records in the Events module as an ICS file.

    • page(integer, optional) -
      The default value is 1 and means that the first 200,000 records matching your query will get exported. If you want to fetch the records from the range 200,001 to 400,000, then mention the value as '2'.

    • criteria(JSON object, optional) -
      Represents the details that the system uses to filter records.Ex: The API Name of a module or field, comparators used to add two or more criteria, a group which the record/module/field belongs to etc. the following are the keys of this JSON object:

      • group_operator(string, mandatory if api_name, comparator and value are not specified) -
        Represents the Logical operators. Supported values - and, or.

      • group(JSON array, mandatory if api_name, comparator and value are not specified) -
        Represents the array of criteria objects. Each object in the criteria has the following keys:

        • api_name(string, mandatory if group and group_operator are not specified)-
          Here in this example the key is given as a part of "group" JSON array. You can also specify it directly inside the criteria JSON object. The key represents the API name of a field to be compared. For instance: First_Name, Last_Name, Owner.last_name etc.

        • value(string/JSON array, mandatory if group and group_operator are not specified)-
          Here in this example the key is given as a part of "group" JSON array. You can also specify it directly inside the criteria JSON object. The key represents the value with which the records must be filtered.

        • comparator(string, mandatory if group and group_operator are not specified.)-
          Here in this example the key is given as a part of "group" JSON array. You can also specify it directly inside the criteria JSON object. The key represents the comparator. Example: equal, greater_than. The following table shows the supported comparators.

Allowed Comparators
Data typeComparatorValue and limits
Number(Integer)/Decimal/BigInteger/ Currency/Percentequal, not_equal, in, not_in, less_than, less_equal, greater_than, greater_equalAny number values or ${EMPTY} for an empty value. Not more than 19 digits for big integer, decimal values for decimal and currency fields. In multi-currency enabled accounts, only the home currency value is supported.
Text (Email, Phone, URL, Picklist, Multi-select, etc)equal, not_equal, in, not_in, contains, not_contains, starts_with, ends_withAny text values or ${EMPTY} for empty value. Not more than 255 characters.
Date and DateTimeequal, not_equal, in, not_in, between, not_betweenAny date values in the ISO 8601 format or ${EMPTY} for an empty value. For DateTime fields, milliseconds is not supported.
BooleanequalTrue or false.
Lookupequal, not_equal, in, not_inBig integer value of the lookup, ${EMPTY} for empty value, or use the .(dot) operator to establish a relation between two modules. Example: "Owner" fetches the ID of the Owner, whereas "Owner.last_name" fetches the last name of the owner. "Account_Name" fetches the ID of the Account associated with the base module, whereas "Account_Name.Phone" fetches the phone number of the account associated with the base module.

Sample Input with lookup fields

Copied{
  "callback": {
    "url": "https://www.example.com/callback",
    "method": "post"
  },
  "query": {
    "module": "Contacts",
    "fields": [
      "Last_Name",
      "Owner",
      "Owner.last_name",
      "Account_Name.Account_Name",
      "Account_Name.Phone",
      "Created_Time"
    ],
    "criteria": {
      "group_operator": "or",
      "group": [
        {
          "api_name": "Owner.last_name",
          "comparator": "equal",
          "value": "Boyle"
        },
        {
          "api_name": "Account_Name.Phone",
          "comparator": "contains",
          "value": "5"
        }
      ]
    },
    "page": 1
  }
}

This query fetches records based on the specified criteria and the "."(dot) operator is used to fetch data from the parent modules. Account_Name is the default lookup field in the Contacts module. Here, Owner.last_name returns the last name of the owner of the contact, Account_Name returns the ID and Account_Name.Account_Name returns the name of the account associated with the contact, and Account_Name.Phone returns the phone number of the account associated with the contact.

Sample input with cvid and criteria

Copied{
  "callback": {
    "url": "https://www.example.com/callback",
    "method": "post"
  },
  "query": {
    "module": "Accounts",
    "cvid": "554023000000093005",
    "fields": [
      "Account_Name",
      "Owner",
      "Owner.last_name",
      "Created_Time"
    ],
    "criteria": {
      "api_name": "Owner.last_name",
      "comparator": "equal",
      "value": "Patricia Boyle"
    }
  }
}

Sample input to export meetings in the ICS format

Copied{
    "query": {
        "module": "Events",
        "criteria": {
            "group": [
                {
                    "group": [
                        {
                            "api_name": "All_day",
                            "comparator": "equal",
                            "value": "false"
                        },
                        {
                            "api_name": "Owner",
                            "comparator": "in",
                            "value": [
                                "554023000000695002",
                                "554023000000691003"
                            ]
                        }
                    ],
                    "group_operator": "and"
                },
                {
                    "api_name": "Created_Time",
                    "comparator": "greater_equal",
                    "value": "2019-10-14T15:30:00+05:30"
                }
            ],
            "group_operator": "or"
        }
    },
    "file_type": "ics"
}

Response Structure

  • statusstring

    Specifies the status of the API call. Sample - "status": "success".

  • messagestring

    Specifies the pre-defined comments for the job. Useful in case any errors occur. Sample - "message": "Added successfully."

  • detailsJSON object

    Contains the following details of the bulk read job.

    • operation(string)-
      Specifies the type of action the API completed. Sample - "operation" : "read”.

    • created_by(JSON object)-
      Specifies the ID and Name of the user who initiated the bulk read job. Sample - "created_by": { "id": "1000000031045", "name": "Patricia Boyle" }.

    • created_time (JSON object)-
      Specifies the created time of the bulk read job.

    • state(string)-
      Specifies the current status of the bulk read job. Example: "state": "ADDED" or "IN PROGRESS" or "COMPLETED".

    • id(string)-
      Specifies the unique identifier of the bulk read job. Use this ID to check the job status and download the result. Sample - "id": "1000010760002".

Sample response

Copied{
    "data": [
        {
            "status": "success",
            "code": "ADDED_SUCCESSFULLY",
            "message": "Added successfully.",
            "details": {
                "id": "554023000000568002",
                "operation": "read",
                "state": "ADDED",
                "created_by": {
                    "id": "554023000000235011",
                    "name": "Patricia Boyle"
                },
                "created_time": "2019-05-09T14:01:24+05:30"
            }
        }
    ],
    "info": {}
}
Note
  • A maximum of two hundred thousand records can be exported in a single export job. i.e, "page" would be "1" and the records in the page would be "200,000". To know more about the Bulk API limits, go here.

  • The first 200,000 records matching the criteria are taken for export if the value of the "page" is "1".

  • To fetch data from parent modules, use the "."(dot) operator. For example, Contacts module has the default Account_Name lookup field. To fetch the name of the account that the contact is associated with, use Contacts.Account_Name.Account_Name.

  • Use only API names of fields and modules in the input.

  • If the "fields" attribute in the query JSON is left empty, all the fields available for the corresponding base module are listed in the CSV file. In case you need only specific fields, specify the field API names for export.

  • It is mandatory to specify the cvid if you want to export records under a custom view.

  • Along with cvid, you can also specify additional criteria. These criteria will be appended with the existing criteria for the custom/standard view.

For ICS file type
  • Exporting records in ICS format is supported only for the Meetings module.

  • You can export a maximum of 20,000 records from the Meetings module per batch.

  • The "fields" attribute is not supported when you want to export the meetings as an ICS file.

  • If you do not specify "file_type" as "ics", the records will be exported in the CSV format, by default.

  • If the value of more_records is "true" in the response of the Get Job Details API call, there are more records to be fetched.

Sample callback for job completed

Copied{
  "job_id": "554023000000568002",
  "operation": "read",
  "state": "COMPLETED",
  "query": {
    "module": "Contacts",
    "criteria": {
      "group": [
        {
          "api_name": "Owner.last_name",
          "comparator": "equal",
          "value": "Patricia Boyle"
        }
      ],
      "group_operator": "and"
    },
    "page": 1,
    "fields": [
      "Last_Name",
      "Owner",
      "Owner.last_name",
      "Company",
      "Email",
      "Mobile",
      "Created_Time"
    ],
    "cvid": "554023000000093005"
  },
  "result": {
    "page": 1,
    "count": 1588,
    "download_url": "/bigin/bulk/v1/read/554023000000568002/result",
    "per_page": 200000,
    "more_records": false
  }
}

Possible Errors

  • MEDIA_TYPE_NOT_SUPPORTEDHTTP 415

    Media type is not supported.
    Resolution: You have not passed the 'Content-Type' header along with the request.

  • INVALID_URL_PATTERNHTTP 404

    Please check if the URL trying to access is a correct one
    Resolution: The request URL specified is incorrect. Specify a valid request URL. Refer to request URL section above.

  • OAUTH_SCOPE_MISMATCHHTTP 401

    Unauthorized
    Resolution: Client does not have ZohoBigin.bulk.read or ZohoBigin.modules.{module_name}.READ. Create a new client with valid scope. Refer to scope section above.

  • NO_PERMISSIONHTTP 403

    Permission denied to read
    Resolution: The user does not have permission to read records. Contact your system administrator.

  • INTERNAL_ERRORHTTP 500

    Internal Server Error
    Resolution: Unexpected and unhandled exception in Server. Contact support team.

  • INVALID_REQUEST_METHODHTTP 400

    The http request method type is not a valid one
    Resolution: You have specified an invalid HTTP method to access the API URL. Specify a valid request method. Refer to endpoints section above.

  • AUTHORIZATION_FAILEDHTTP 400

    User does not have sufficient privilege to read.
    Resolution: The user does not have the permission to read records. Contact your system administrator.

Sample callback for job failed

Copied{
  "job_id": "554023000000568002",
  "operation": "read",
  "state": "FAILURE",
  "query": {
    "module": "Contacts",
    "criteria": {
      "group": [
        {
          "api_name": "Owner.last_name",
          "comparator": "equal",
          "value": "Patricia Boyle"
        }
      ],
      "group_operator": "and"
    },
    "page": 1,
    "fields": [
      "Last_Name",
      "Owner",
      "Owner.last_name",
      "Email",
      "Mobile",
      "Created_Time"
    ],
    "cvid": "554023000000093005"
  },
    "result": {
    "error_message": {
      "message": "<error message>",
      "details": "<detailed messages>",
      "status": "error",
      "code": "<ERROR CODE>"
    }
  }
}