Users can subscribe to other users. The subscriber is notified when the other user adds an article to a section, adds a comment to an article or a post, or adds a post to a topic.

JSON format

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

NameTypeRead-onlyMandatoryDescription
followed_idintegertruetrueThe id of the user being followed
follower_idintegertruetrueThe id of the user doing the following
idintegertruetrueAutomatically assigned when the subscription is created

Example

{  "followed_id": 65466,  "follower_id": 98354,  "id": 1635}

List User Subscriptions By User

  • GET /api/v2/help_center/users/{user_id}/user_subscriptions

Lists the user subscriptions of a given user. To list your own subscriptions, specify me as the user id.

Allowed for

  • End users
  • Agents
  • Managers

Pagination

  • Cursor pagination (recommended)
  • Offset pagination

See Pagination.

Sideloads

The following sideloads are supported:

NameWill sideloadFor
usersusersall

Parameters

NameTypeInRequiredDescription
typestringQueryfalseSelects whether to find who the given user is following ("followings") or who is following the given user ("followers"). The default is "followers". Allowed values are "followings", or "followers".
user_idintegerPathtrueThe unique ID of the user

Code Samples

curl
curl https://{subdomain}.zendesk.com/api/v2/help_center/users/{user_id}/user_subscriptions \  -v -u {email_address}/token:{api_token}
Go
import (	"fmt"	"io"	"net/http")
func main() {	url := "https://support.zendesk.com/api/v2/help_center/users/1234/user_subscriptions?type="	method := "GET"	req, err := http.NewRequest(method, url, nil)
	if err != nil {		fmt.Println(err)		return	}	req.Header.Add("Content-Type", "application/json")	req.Header.Add("Authorization", "Basic <auth-value>") // Base64 encoded "{email_address}/token:{api_token}"
	client := &http.Client {}	res, err := client.Do(req)	if err != nil {		fmt.Println(err)		return	}	defer res.Body.Close()
	body, err := io.ReadAll(res.Body)	if err != nil {		fmt.Println(err)		return	}	fmt.Println(string(body))}
Java
import com.squareup.okhttp.*;OkHttpClient client = new OkHttpClient();HttpUrl.Builder urlBuilder = HttpUrl.parse("https://support.zendesk.com/api/v2/help_center/users/1234/user_subscriptions")		.newBuilder()		.addQueryParameter("type", "");String userCredentials = "your_email_address" + "/token:" + "your_api_token";String basicAuth = "Basic " + java.util.Base64.getEncoder().encodeToString(userCredentials.getBytes());
Request request = new Request.Builder()		.url(urlBuilder.build())		.method("GET", null)		.addHeader("Content-Type", "application/json")		.addHeader("Authorization", basicAuth)		.build();Response response = client.newCall(request).execute();
Nodejs
var axios = require('axios');
var config = {  method: 'GET',  url: 'https://support.zendesk.com/api/v2/help_center/users/1234/user_subscriptions',  headers: {	'Content-Type': 'application/json',	'Authorization': 'Basic <auth-value>', // Base64 encoded "{email_address}/token:{api_token}"  },  params: {    'type': '',  },};
axios(config).then(function (response) {  console.log(JSON.stringify(response.data));}).catch(function (error) {  console.log(error);});
Python
import requestsfrom requests.auth import HTTPBasicAuth
url = "https://support.zendesk.com/api/v2/help_center/users/1234/user_subscriptions?type="headers = {	"Content-Type": "application/json",}email_address = 'your_email_address'api_token = 'your_api_token'# Use basic authenticationauth = HTTPBasicAuth(f'{email_address}/token', api_token)
response = requests.request(	"GET",	url,	auth=auth,	headers=headers)
print(response.text)
Ruby
require "net/http"require "base64"uri = URI("https://support.zendesk.com/api/v2/help_center/users/1234/user_subscriptions")uri.query = URI.encode_www_form("type": "")request = Net::HTTP::Get.new(uri, "Content-Type": "application/json")email = "your_email_address"api_token = "your_api_token"credentials = "#{email}/token:#{api_token}"encoded_credentials = Base64.strict_encode64(credentials)request["Authorization"] = "Basic #{encoded_credentials}"response = Net::HTTP.start uri.hostname, uri.port, use_ssl: true do |http|	http.request(request)end

Example response(s)

200 OK
// Status 200 OK
{  "user_subscriptions": [    {      "followed_id": 8748733,      "follower_id": 398452,      "id": 35467    }  ]}

Create User Subscription

  • POST /api/v2/help_center/users/{user_id}/user_subscriptions

Creates a user subscription for a given user. To create your own user subscription, specify me as the user id.

Allowed for

  • End users
  • Managers

Parameters

NameTypeInRequiredDescription
user_idintegerPathtrueThe unique ID of the user

Example body

{  "user_subscription": {    "followed_id": 65466,    "include_comments": false  }}

Code Samples

curl

user_subscription.json

{  "user_subscription": {    "followed_id": 65466,    "include_comments": false  }}

curl snippet

curl https://{subdomain}.zendesk.com/api/v2/help_center/users/{user_id}/user_subscriptions \  -d @user_subscription.json \  -H "Content-Type: application/json" -X POST \  -v -u {email_address}/token:{api_token}
Go
import (	"fmt"	"io"	"net/http"	"strings")
func main() {	url := "https://support.zendesk.com/api/v2/help_center/users/1234/user_subscriptions"	method := "POST"	payload := strings.NewReader(`{  "user_subscription": {    "followed_id": 65466,    "include_comments": false  }}`)	req, err := http.NewRequest(method, url, payload)
	if err != nil {		fmt.Println(err)		return	}	req.Header.Add("Content-Type", "application/json")	req.Header.Add("Authorization", "Basic <auth-value>") // Base64 encoded "{email_address}/token:{api_token}"
	client := &http.Client {}	res, err := client.Do(req)	if err != nil {		fmt.Println(err)		return	}	defer res.Body.Close()
	body, err := io.ReadAll(res.Body)	if err != nil {		fmt.Println(err)		return	}	fmt.Println(string(body))}
Java
import com.squareup.okhttp.*;OkHttpClient client = new OkHttpClient();HttpUrl.Builder urlBuilder = HttpUrl.parse("https://support.zendesk.com/api/v2/help_center/users/1234/user_subscriptions")		.newBuilder();RequestBody body = RequestBody.create(MediaType.parse("application/json"),		"""{  \"user_subscription\": {    \"followed_id\": 65466,    \"include_comments\": false  }}""");String userCredentials = "your_email_address" + "/token:" + "your_api_token";String basicAuth = "Basic " + java.util.Base64.getEncoder().encodeToString(userCredentials.getBytes());
Request request = new Request.Builder()		.url(urlBuilder.build())		.method("POST", body)		.addHeader("Content-Type", "application/json")		.addHeader("Authorization", basicAuth)		.build();Response response = client.newCall(request).execute();
Nodejs
var axios = require('axios');var data = JSON.stringify({  "user_subscription": {    "followed_id": 65466,    "include_comments": false  }});
var config = {  method: 'POST',  url: 'https://support.zendesk.com/api/v2/help_center/users/1234/user_subscriptions',  headers: {	'Content-Type': 'application/json',	'Authorization': 'Basic <auth-value>', // Base64 encoded "{email_address}/token:{api_token}"  },  data : data,};
axios(config).then(function (response) {  console.log(JSON.stringify(response.data));}).catch(function (error) {  console.log(error);});
Python
import requestsimport jsonfrom requests.auth import HTTPBasicAuth
url = "https://support.zendesk.com/api/v2/help_center/users/1234/user_subscriptions"
payload = json.loads("""{  "user_subscription": {    "followed_id": 65466,    "include_comments": false  }}""")headers = {	"Content-Type": "application/json",}email_address = 'your_email_address'api_token = 'your_api_token'# Use basic authenticationauth = HTTPBasicAuth(f'{email_address}/token', api_token)
response = requests.request(	"POST",	url,	auth=auth,	headers=headers,	json=payload)
print(response.text)
Ruby
require "net/http"require "base64"uri = URI("https://support.zendesk.com/api/v2/help_center/users/1234/user_subscriptions")request = Net::HTTP::Post.new(uri, "Content-Type": "application/json")request.body = %q({  "user_subscription": {    "followed_id": 65466,    "include_comments": false  }})email = "your_email_address"api_token = "your_api_token"credentials = "#{email}/token:#{api_token}"encoded_credentials = Base64.strict_encode64(credentials)request["Authorization"] = "Basic #{encoded_credentials}"response = Net::HTTP.start uri.hostname, uri.port, use_ssl: true do |http|	http.request(request)end

Example response(s)

201 Created
// Status 201 Created
{  "user_subscription": {    "followed_id": 8748733,    "follower_id": 398452,    "id": 35467  }}
409 Conflict
// Status 409 Conflict
null

Delete User Subscription

  • DELETE /api/v2/help_center/users/{user_id}/user_subscriptions/{subscription_id}

Removes the specified user subscription for the specified user. To remove your own subscription, specify me as the user id.

Allowed for

  • End users
  • Managers

Parameters

NameTypeInRequiredDescription
subscription_idintegerPathtrueThe unique ID of the subscription
user_idintegerPathtrueThe unique ID of the user

Code Samples

curl
curl https://{subdomain}.zendesk.com/api/v2/help_center/users/{user_id}/user_subscriptions/{subscription_id} \  -v -u {email_address}/token:{api_token} -X DELETE
Go
import (	"fmt"	"io"	"net/http")
func main() {	url := "https://support.zendesk.com/api/v2/help_center/users/1234/user_subscriptions/1234"	method := "DELETE"	req, err := http.NewRequest(method, url, nil)
	if err != nil {		fmt.Println(err)		return	}	req.Header.Add("Content-Type", "application/json")	req.Header.Add("Authorization", "Basic <auth-value>") // Base64 encoded "{email_address}/token:{api_token}"
	client := &http.Client {}	res, err := client.Do(req)	if err != nil {		fmt.Println(err)		return	}	defer res.Body.Close()
	body, err := io.ReadAll(res.Body)	if err != nil {		fmt.Println(err)		return	}	fmt.Println(string(body))}
Java
import com.squareup.okhttp.*;OkHttpClient client = new OkHttpClient();HttpUrl.Builder urlBuilder = HttpUrl.parse("https://support.zendesk.com/api/v2/help_center/users/1234/user_subscriptions/1234")		.newBuilder();String userCredentials = "your_email_address" + "/token:" + "your_api_token";String basicAuth = "Basic " + java.util.Base64.getEncoder().encodeToString(userCredentials.getBytes());
Request request = new Request.Builder()		.url(urlBuilder.build())		.method("DELETE", null)		.addHeader("Content-Type", "application/json")		.addHeader("Authorization", basicAuth)		.build();Response response = client.newCall(request).execute();
Nodejs
var axios = require('axios');
var config = {  method: 'DELETE',  url: 'https://support.zendesk.com/api/v2/help_center/users/1234/user_subscriptions/1234',  headers: {	'Content-Type': 'application/json',	'Authorization': 'Basic <auth-value>', // Base64 encoded "{email_address}/token:{api_token}"  },};
axios(config).then(function (response) {  console.log(JSON.stringify(response.data));}).catch(function (error) {  console.log(error);});
Python
import requestsfrom requests.auth import HTTPBasicAuth
url = "https://support.zendesk.com/api/v2/help_center/users/1234/user_subscriptions/1234"headers = {	"Content-Type": "application/json",}email_address = 'your_email_address'api_token = 'your_api_token'# Use basic authenticationauth = HTTPBasicAuth(f'{email_address}/token', api_token)
response = requests.request(	"DELETE",	url,	auth=auth,	headers=headers)
print(response.text)
Ruby
require "net/http"require "base64"uri = URI("https://support.zendesk.com/api/v2/help_center/users/1234/user_subscriptions/1234")request = Net::HTTP::Delete.new(uri, "Content-Type": "application/json")email = "your_email_address"api_token = "your_api_token"credentials = "#{email}/token:#{api_token}"encoded_credentials = Base64.strict_encode64(credentials)request["Authorization"] = "Basic #{encoded_credentials}"response = Net::HTTP.start uri.hostname, uri.port, use_ssl: true do |http|	http.request(request)end

Example response(s)

204 No Content
// Status 204 No Content
null