Topics
A topic represents a collection of community posts on a subject.
JSON format
Topics are represented as JSON objects with the following properties:
| Name | Type | Read-only | Mandatory | Description |
|---|---|---|---|---|
| created_at | string | true | false | When the topic was created |
| description | string | false | false | The description of the topic. By default an empty string |
| follower_count | integer | true | false | The number of users following the topic |
| html_url | string | true | false | The community url of the topic |
| id | integer | true | false | Automatically assigned when the topic is created |
| manageable_by | string | false | false | The set of users who can manage this topic. Allowed values are "staff", or "managers". |
| name | string | false | true | The name of the topic |
| position | integer | false | false | The position of the topic relative to other topics in the community |
| updated_at | string | true | false | When the topic was last updated |
| url | string | true | false | The API url of the topic |
| user_segment_id | integer | false | false | The id of the user segment to which this topic belongs |
The manageable_by attribute takes one of the following values:
| Value | Users |
|---|---|
| staff | agents and managers |
| managers | only Help Center managers |
Note that manageable_by is only displayed to users who can manage the topic.
Example
{"created_at": "2012-04-04T09:14:57Z","description": "Security Best Practices","follower_count": 332,"id": 1635,"manageable_by": "staff","name": "Security"}
List Topics
GET /api/v2/community/topics
Lists all topics.
Allowed for
- Anonymous users
Pagination
- Cursor pagination (recommended)
- Offset pagination
See Pagination.
Code Samples
curl
curl https://{subdomain}.zendesk.com/api/v2/community/topics.json \-v -u {email_address}/token:{api_token}
Go
import ("fmt""io""net/http")func main() {url := "https://support.zendesk.com/api/v2/community/topics"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/community/topics").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("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/community/topics',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 HTTPBasicAuthurl = "https://support.zendesk.com/api/v2/community/topics"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/community/topics")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{"topics": [{"html_url": "https://{subdomain}.zendesk.com/hc/en-us/community/topics/10-Using-Help-Center-Tips-Tricks","id": 10,"name": "Using Help Center - Tips & Tricks","url": "https://{subdomain}.zendesk.com/api/v2/community/topics/10.json"},{"html_url": "https://{subdomain}.zendesk.com/hc/en-us/community/topics/11-Using-Help-Center-Getting-Started-Guide","id": 11,"name": "Using Help Center - Getting Started Guide","url": "https://{subdomain}.zendesk.com/api/v2/community/topics/11.json"}]}
Show Topic
GET /api/v2/community/topics/{topic_id}
Shows information about a single topic.
Allowed for
- Anonymous users
Parameters
| Name | Type | In | Required | Description |
|---|---|---|---|---|
| topic_id | integer | Path | true | The unique ID of the topic |
Code Samples
curl
curl https://{subdomain}.zendesk.com/api/v2/community/topics/{topic_id}.json \-v -u {email_address}/token:{api_token}
Go
import ("fmt""io""net/http")func main() {url := "https://support.zendesk.com/api/v2/community/topics/360001326113"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/community/topics/360001326113").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("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/community/topics/360001326113',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 HTTPBasicAuthurl = "https://support.zendesk.com/api/v2/community/topics/360001326113"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/community/topics/360001326113")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{"topic": {"description": "Security Best Practices","id": 35467,"name": "Help Center-Tricks"}}
Create Topic
POST /api/v2/community/topics
Allowed for
- Help Center managers
Agents with the Help Center Manager role can optionally supply a created_at as part of the topic object. If it is not provided created_at is set to the current time.
Code Samples
curl
curl https://{subdomain}.zendesk.com/api/v2/community/topics.json \-v -u {email_address}/token:{api_token} -d '{"topic": {"name": "Help Center-Tricks"}}' \-X POST -H "Content-Type: application/json"
Go
import ("fmt""io""net/http")func main() {url := "https://support.zendesk.com/api/v2/community/topics"method := "POST"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/community/topics").newBuilder();RequestBody body = RequestBody.create(MediaType.parse("application/json"),"""""");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 config = {method: 'POST',url: 'https://support.zendesk.com/api/v2/community/topics',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 HTTPBasicAuthurl = "https://support.zendesk.com/api/v2/community/topics"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)print(response.text)
Ruby
require "net/http"require "base64"uri = URI("https://support.zendesk.com/api/v2/community/topics")request = Net::HTTP::Post.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)
201 Created
// Status 201 Created{"topic": {"description": "Security Best Practices","id": 35467,"name": "Help Center-Tricks"}}
Update Topic
PUT /api/v2/community/topics/{topic_id}
Allowed for
- Help Center managers
Parameters
| Name | Type | In | Required | Description |
|---|---|---|---|---|
| topic_id | integer | Path | true | The unique ID of the topic |
Code Samples
curl
curl -v -u {email_address}/token:{api_token} -d '{"topic": {"name": "Help Center-Tricks Updated"}}' \-X PUT -H "Content-Type: application/json"
Go
import ("fmt""io""net/http")func main() {url := "https://support.zendesk.com/api/v2/community/topics/360001326113"method := "PUT"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/community/topics/360001326113").newBuilder();RequestBody body = RequestBody.create(MediaType.parse("application/json"),"""""");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("PUT", body).addHeader("Content-Type", "application/json").addHeader("Authorization", basicAuth).build();Response response = client.newCall(request).execute();
Nodejs
var axios = require('axios');var config = {method: 'PUT',url: 'https://support.zendesk.com/api/v2/community/topics/360001326113',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 HTTPBasicAuthurl = "https://support.zendesk.com/api/v2/community/topics/360001326113"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("PUT",url,auth=auth,headers=headers)print(response.text)
Ruby
require "net/http"require "base64"uri = URI("https://support.zendesk.com/api/v2/community/topics/360001326113")request = Net::HTTP::Put.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{"topic": {"description": "Security Best Practices","id": 35467,"name": "Help Center-Tricks"}}
Delete Topic
DELETE /api/v2/community/topics/{topic_id}
Allowed for
- Help Center managers
Parameters
| Name | Type | In | Required | Description |
|---|---|---|---|---|
| topic_id | integer | Path | true | The unique ID of the topic |
Code Samples
curl
curl https://{subdomain}.zendesk.com/api/v2/community/topics/{topic_id}.json \-v -u {email_address}/token:{api_token} -X DELETE
Go
import ("fmt""io""net/http")func main() {url := "https://support.zendesk.com/api/v2/community/topics/360001326113"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/community/topics/360001326113").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/community/topics/360001326113',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 HTTPBasicAuthurl = "https://support.zendesk.com/api/v2/community/topics/360001326113"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/community/topics/360001326113")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 Contentnull