Zoho crm Logo

数据共享 API

在 Zoho CRM 中的数据共享为属于其他角色和群组的用户提供扩展对CRM记录访问权限的选项。默认情况下,组织权限设置为私有,仅允许记录所有者及其经理查看和访问CRM数据。

在其权限配置中具有 模块自定义权限 的 Users 可以访问此功能。对于具有 Admin 权限配置的 Users,此权限将默认启用。要启用模块自定义权限,请前往 设置 > 安全控制 > 权限配置。选择需要该权限的权限配置,然后在设置权限下的Admin 级别部分启用“模块自定义”选项。

获取数据共享规则

目的

要检索您 Zoho CRM 组织中配置的数据共享规则列表。

端点

  • GET /settings/data_sharing/rules
  • GET /settings/data_sharing/rules/{rule_ID}

请求详情

请求 URL

要检索所有数据共享规则:
{api-domain}/crm/{version}/settings/data_sharing/rules

要获取特定的共享规则:
{api-domain}/crm/{version}/settings/data_sharing/rules/{rule_ID}

支持的模块

潜在客户、Accounts、联系人、交易、任务、会议、电话、产品、Vendors、价目表、报价单、Sales Orders、采购Orders、Invoices,以及自定义模块

标题

授权: Zoho-oauthtoken d92d4xxxxxxxxxxxxx15f52

范围

ZohoCRM.settings.data_sharing.READ

参数

  • module字符串,可选

    指定要获取其数据共享规则的模块的 API 名称。例如,Leads、Contacts、Account、Deals 等。

检索所有数据共享规则的示例请求

Copiedcurl "https://www.zohoapis.com/crm/v8/settings/data_sharing/rules"
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
-X GET

响应 JSON

  • 模块JSON object

    表示共享规则适用的模块。它由 API 名称、显示标签以及该模块的唯一标识符组成。

  • superiors_allowedboolean
    指示与其共享记录的特定角色或群组的上级是否被允许访问这些记录。 
    可能的取值:
    true- 允许上级访问
    false- 不允许上级访问
  • typestring
    指定共享规则的类型,可基于记录所有者或基于要共享记录的特定条件。 
    可选值:
    Record_Owner_Based- 数据共享基于记录所有者
    Criteria_Based- 数据共享基于条件。
  • shared_toJSON object

    表示数据被共享到的资源的详细信息。数据可以共享给角色、角色及其下属、群组或所有用户。

    • 资源JSON object

      表示数据被共享到的资源。它由该资源的名称和唯一标识符组成。

    • type string
      指定数据共享到的资源类型。可能的取值:
      roles- 如果 subordinates 键为 false,则记录共享给角色;如果 subordinates 键为 true,则记录共享给角色及其下属。
      可能的取值:
      groups- 记录共享给群组
      all_users- 记录共享给所有用户。
    • subordinatesboolean
      指示当 "type" 键为 roles 时是否包含下属。
      可能的值:
      true- 包含下属。
      false- 不包含下属。

    键 "type" 和 "subordinates" 共同表示以下这些数据共享方式(角色、角色及下属、所有用户或群组)。

    数据共享到的资源类型包含下属
    群组群组否
    RoleRole否
    Role及下属Role是
    所有用户所有用户否
  • 分享来源

    表示其数据被共享的资源的详细信息。当数据共享类型为基于记录所有者时,这些详细信息可用。数据可以从角色、角色及其下属或群组进行共享。

    • 资源JSON object

      表示其数据被共享的资源。它由资源的名称和唯一标识符组成。

    • type string
      表示其数据被共享的资源类型。数据可以从 roles,或从 roles 与 subordinates,或从 groups 进行共享。可能的取值:
      roles- 当 subordinates 键为 false 时,记录从 roles 共享;当 subordinates 键为 true 时,记录从 roles 和 subordinates 共享。
      groups- 记录被共享到组。
    • 下属 布尔值
      表示当 "type" 键为 roles 时是否包含下属。
      可能的值:
      true- 包含下属。
      false- 不包含下属。

    键 "type" 和 "subordinate"s 共同表示可共享其数据的不同资源类型(例如,角色、角色及其下属,或群组),如下所述。

    数据共享到的资源类型下属
    群组群组否
    RoleRole否
    Role及下属Role是
  • 条件 JSON object

    它表示用于共享记录的条件。当数据共享类型为基于条件且 获取了特定的数据共享规则时,这些详细信息可用。当获取到特定规则时,请参阅示例响应,见此处。

    • group_operator string

      指定在条件中使用的组运算符

    • 组 JSON array

      它表示用于筛选记录的条件组。

      • 字段JSON object

        它表示该字段的 API 名称。

      • comparatorstring

        它表示在条件中使用的比较运算符。

      • valuestring

        它表示在条件中使用的值。 

  • permission_typestring
    指定授予的权限或访问类型。
    可能的取值:
    read- 只读
    read_write- 读/写。
    read_write_delete- 读/写/删除。
  • namestring
    表示共享规则的名称。
  • idstring
    表示此共享规则的唯一标识符。
  • match_limit_exceeded boolean
    表示该规则是否匹配超过四百万条记录的最大限制。 
    可能的取值: 
    true
    false

检索到所有数据共享规则时的示例响应

Copied{
    "sharing_rules": [
        {
            "module": {
                "api_name": "Leads",
                "name": "Leads",
                "id": "3602353000000000125"
            },
            "superiors_allowed": true,
            "type": "Record_Owner_Based",
            "shared_to": {
                "resource": {
                    "name": "Manager",
                    "id": "3602353000000015969"
                },
                "type": "roles",
                "subordinates": false
            },
            "shared_from": {
                "resource": {
                    "name": "CEO",
                    "id": "3602353000000015966"
                },
                "type": "roles",
                "subordinates": false
            },
            "permission_type": "read_write",
            "name": "Rule1",
            "id": "3602353000000603003",
            "status": "active",
            "match_limit_exceeded": false
        },
        {
            "module": {
                "api_name": "Accounts",
                "name": "Accounts",
                "id": "3602353000000000127"
            },
            "superiors_allowed": false,
            "type": "Record_Owner_Based",
            "shared_to": {
                "resource": {
                    "name": "User Group1",
                    "id": "3602353000000601002"
                },
                "type": "groups",
                "subordinates": false
            },
            "shared_from": {
                "resource": {
                    "name": "CEO",
                    "id": "3602353000000015966"
                },
                "type": "roles",
                "subordinates": false
            },
            "permission_type": "read_write_delete",
            "name": "Accounts sharing rules",
            "id": "3602353000000602055",
            "status": "active",
            "match_limit_exceeded": false
        },
        {
            "module": {
                "api_name": "Accounts",
                "name": "Accounts",
                "id": "3602353000000000129"
            },
            "superiors_allowed": false,
            "type": "Criteria_Based",
            "shared_to": {
                "resource": {
                    "name": "User Group NY",
                    "id": "3602353000000601002"
                },
                "type": "groups",
                "subordinates": false
            },
            "shared_from": null,
            "permission_type": "read_write_delete",
            "name": "NY Rule",
            "id": "3602353000000602043",
            "status": "active",
            "match_limit_exceeded": false
        }
    ],
    "info": {
        "per_page": 200,
        "count": 3,
        "page": 1,
        "more_records": false
    }
}

获取特定规则的示例请求

Copiedcurl "https://www.zohoapis.com/crm/v8/settings/data_sharing/rules/3602353000000602043"
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
-X GET

可能的错误

  • 无内容HTTP 204

    当未配置共享规则时。

  • INVALID_REQUEST_METHODHTTP 400

    请求方法不正确。
    解决方案:请使用 HTTP GET 方法发起此 API 调用。使用其他任何请求方法都会导致此错误。

  • OAUTH_SCOPE_MISMATCHHTTP 401

    您用于进行此 API 调用的访问令牌不具备所需的作用域。
    解决方案: 生成一个包含此 API 所需作用域的新访问令牌。有关所需作用域列表,请参见本页开头的作用域部分。

  • NO_PERMISSIONHTTP 403

    您没有模块自定义权限。
    解决方案:请获取模块自定义权限。

  • INVALID_URL_PATTERNHTTP 404

    请求 URL 不正确。
    解决方案:请指定有效的请求 URL。有关更多详细信息,请参阅本页开头的请求 URL 部分。

  • INTERNAL_ERRORHTTP 500

    服务器出现了意外且未处理的异常。 
    解决方案: 请联系支持团队:support@zohocrm.com。

当检索到特定规则(基于条件的规则)时的示例响应

Copied{
    "sharing_rules": [
        {
              "criteria": {
                "comparator": "equal",
                "field": {
                    "api_name": "Billing_City",
                    "id": "3643104000000002467"
                },
                "type": "value",
                "value": "New York"
            },
            "module": {
                "api_name": "Accounts",
                "name": "Accounts",
                "id": "3602353000000000129"
            },
            "superiors_allowed": false,
            "type": "Criteria_Based",
            "shared_to": {
                "resource": {
                    "name": "User Group NY",
                    "id": "3602353000000601002"
                },
                "type": "groups",
                "subordinates": false
            },
            "shared_from": null,
            "permission_type": "read_write_delete",
            "name": "NY Rule",
            "id": "3602353000000602043",
            "status": "active",
            "match_limit_exceeded": false
        }
    ]
}