User Segments

A user segment defines who can view the content of a section or topic. It can specify any of the following access restrictions:

You can use this API to define or change the access restrictions of user segments. However, you must use the Sections or Topics API to apply the user segments to sections or topics in Help Center.

JSON Format

User Segments are represented as JSON objects with the following properties:

Name Type Read-only Mandatory Description
built_in boolean true false Whether the user segment is built-in. Built-in user segments cannot be modified
created_at string true false When the user segment was created
group_ids array false false The ids of the groups that have access
id integer true false Automatically assigned when the user segment is created
name string false false User segment name (localized to the locale of the current user for built-in user segments)
or_tags array false false A user must have at least one tag in the list to have access
organization_ids array false false The ids of the organizations that have access
tags array false false All the tags a user must have to have access
updated_at string true false When the user segment was last updated
user_type string false true The set of users who can view content

The user_type attribute takes one of the following values:

Value Users
signed_in_users only authenticated users
staff only agents and Help Center managers

For group_ids, organization_ids, tags, and or_tags, an empty array means that access is not restricted by the attribute. For example, if no group ids are specified, then users don't have to be in any specific group to have access.

For tags, a user must have all the listed tags to have access. For or_tags, a user must have at least one of the listed tags to have access.

Example
{
  "built_in": false,
  "created_at": "2017-07-20T22:55:29Z",
  "group_ids": [
    12
  ],
  "name": "VIP agents",
  "organization_ids": [
    42
  ],
  "tags": [
    "vip"
  ],
  "updated_at": "2017-07-23T21:43:28Z",
  "user_type": "staff"
}

List User Segments

  • GET /api/v2/help_center/user_segments
  • GET /api/v2/help_center/user_segments/applicable
  • GET /api/v2/help_center/users/{user_id}/user_segments

Some user segments can only be applied to sections and topics on certain Guide plans. For instance, user segments with a user_type of "staff" cannot be applied to sections and topics on accounts with the Guide Lite plan. To request only user segments applicable on the account's current Guide plan, use the /api/v2/help_center/user_segments/applicable.json endpoint.

The /api/v2/help_center/users/{user_id}/user_segments.json endpoint returns the list of user segments that a particular user belongs to. This is the only list endpoint that agents have access to. When an agent makes a request to this endpoint with another user's id, the response only includes user segments that the requesting agent also belongs to.

These endpoints support pagination, as described in the pagination documentation.

Allowed for
  • Help Center managers
  • Agents
Parameters
Name Type In Required Description
built_in boolean Query false Only built_in user segments if true, only custom user segments if false
Using curl
curl https://{subdomain}.zendesk.com/api/v2/help_center/user_segments.json \
  -v -u {email_address}:{password}

# Requesting only applicable user segments:
curl https://{subdomain}.zendesk.com/api/v2/help_center/user_segments/applicable.json \
  -v -u {email_address}:{password}
Example Response
Status 200 OK

{
  "user_segments": [
    {
      "built_in": false,
      "created_at": "2017-05-21T20:01:12Z",
      "group_ids": [
        12
      ],
      "id": 7284,
      "name": "VIP agents",
      "or_tags": [],
      "organization_ids": [],
      "tags": [
        "vip"
      ],
      "updated_at": "2017-06-30T01:00:25Z",
      "user_type": "staff"
    },
    {
      "built_in": false,
      "created_at": "2017-04-09T15:33:11Z",
      "group_ids": [],
      "id": 9930,
      "name": "Privileged users",
      "or_tags": [],
      "organization_ids": [
        42
      ],
      "tags": [],
      "updated_at": "2017-08-10T18:41:01Z",
      "user_type": "signed_in_users"
    }
  ]
}

Create User Segment

  • POST /api/v2/help_center/user_segments
Allowed for
  • Help Center managers
Using curl
curl https://{subdomain}.zendesk.com/api/v2/help_center/user_segments.json \
  -d '{ \
    "user_segment": { \
      "name": "VIP agents", \
      "user_type": "staff", \
      "group_ids": [12, ...], \
      "tags": ["vip"] \
    } \
  }' \
  -v -u {email_address}:{password} -X POST -H "Content-Type: application/json"
Example Response
Status 201 Created

{
  "user_segment": {
    "built_in": false,
    "created_at": "2017-05-21T20:01:12Z",
    "group_ids": [
      12
    ],
    "id": 7284,
    "name": "VIP agents",
    "or_tags": [],
    "organization_ids": [],
    "tags": [
      "vip"
    ],
    "updated_at": "2017-05-21T20:01:12Z",
    "user_type": "staff"
  }
}

Show User Segment

  • GET /api/v2/help_center/user_segments/{user_segment_id}
Allowed for
  • Help Center managers
Parameters
Name Type In Required Description
user_segment_id integer Path true The unique ID of this UserSegmentId
Using curl
curl https://{subdomain}.zendesk.com/api/v2/help_center/user_segments/{user_segment_id}.json \
  -v -u {email_address}:{password}
Example Response
Status 200 OK

{
  "user_segment": {
    "built_in": false,
    "created_at": "2017-05-21T20:01:12Z",
    "group_ids": [
      12
    ],
    "id": 7284,
    "name": "VIP agents",
    "or_tags": [],
    "organization_ids": [],
    "tags": [
      "vip"
    ],
    "updated_at": "2017-05-21T20:01:12Z",
    "user_type": "staff"
  }
}

Update User Segment

  • PUT /api/v2/help_center/user_segments/{user_segment_id}
Allowed for
  • Help Center managers
Parameters
Name Type In Required Description
user_segment_id integer Path true The unique ID of this UserSegmentId
Using curl
curl https://{subdomain}.zendesk.com/api/v2/help_center/user_segments/{user_segment_id}.json \
  -d '{ \
    "user_segment": { \
      "name": "VIP agents", \
      "user_type": "staff", \
      "group_ids": [12, ...], \
      "organization_ids": [42, ...], \
      "tags": ["vip"] \
    } \
  }' \
  -v -u {email_address}:{password} -X PUT -H "Content-Type: application/json"
Example Response
Status 200 OK

{
  "user_segment": {
    "built_in": false,
    "created_at": "2017-05-21T20:01:12Z",
    "group_ids": [
      12
    ],
    "id": 7284,
    "name": "VIP agents",
    "or_tags": [],
    "organization_ids": [],
    "tags": [
      "vip"
    ],
    "updated_at": "2017-05-21T20:01:12Z",
    "user_type": "staff"
  }
}

Delete User Segment

  • DELETE /api/v2/help_center/user_segments/{user_segment_id}
Allowed for
  • Help Center managers
Parameters
Name Type In Required Description
user_segment_id integer Path true The unique ID of this UserSegmentId
Using curl
curl https://{subdomain}.zendesk.com/api/v2/help_center/user_segments/{user_segment_id}.json \
  -v -u {email_address}:{password} -X DELETE
Example Response
Status 204 No Content

List Sections using a User Segment

  • GET /api/v2/help_center/user_segments/{user_segment_id}/sections

This endpoint supports pagination, as described in the pagination documentation.

Allowed for
  • Help Center managers
Parameters
Name Type In Required Description
user_segment_id integer Path true The unique ID of this UserSegmentId
Using curl
curl https://{subdomain}.zendesk.com/api/v2/help_center/user_segments/{user_segment_id}/sections.json \
  -v -u {email_address}:{password}
Example Response
Status 200 OK

{
  "sections": [
    {
      "html_url": "https://{subdomain}.zendesk.com/hc/en/sections/3242-A-section-",
      "id": 3242,
      "locale": "en",
      "name": "A section",
      "url": "https://{subdomain}.zendesk.com/api/v2/help_center/en/sections/3242-A-section-.json"
    },
    {
      "html_url": "https://{subdomain}.zendesk.com/hc/en/sections/7352-Another-section-",
      "id": 7352,
      "locale": "en",
      "name": "Another section",
      "url": "https://{subdomain}.zendesk.com/api/v2/help_center/en/sections/7352-Another-section-.json"
    }
  ]
}

List Topics using a User Segment

  • GET /api/v2/help_center/user_segments/{user_segment_id}/topics

This endpoint supports pagination, as described in the pagination documentation.

Allowed for
  • Help Center managers
Parameters
Name Type In Required Description
user_segment_id integer Path true The unique ID of this UserSegmentId
Using curl
curl https://{subdomain}.zendesk.com/api/v2/help_center/user_segments/{user_segment_id}/topics.json \
  -v -u {email_address}:{password}
Example Response
Status 200 OK

{
  "topics": [
    {
      "html_url": "https://{subdomain}.zendesk.com/hc/en/community/topics/9273-A-topic-",
      "id": 9273,
      "name": "A topic",
      "url": "https://{subdomain}.zendesk.com/api/v2/community/topics/9273.json"
    },
    {
      "html_url": "https://{subdomain}.zendesk.com/hc/en/community/topics/2292-Another-topic-",
      "id": 2292,
      "name": "Another topic",
      "url": "https://{subdomain}.zendesk.com/api/v2/community/topics/2292-Another-topic-.json"
    }
  ]
}