Monitored X (formerly Twitter) handles represent the X accounts that you have configured on your account to pull new tweets into Zendesk Support as tickets.
JSON format
Monitored X handles are represented as JSON objects with the following properties:
| Name | Type | Read-only | Mandatory | Description |
|---|---|---|---|---|
| allow_reply | boolean | true | false | If replies are allowed for this handle |
| avatar_url | string | true | false | The profile image url of the handle |
| brand_id | integer | true | false | What brand the handle is associated with |
| can_reply | boolean | true | false | If replies are allowed for this handle |
| created_at | string | true | false | The time the handle was created |
| id | integer | true | true | Automatically assigned upon creation |
| name | string | true | false | The profile name of the handle |
| screen_name | string | true | true | The X handle |
| twitter_user_id | integer | true | true | The country's code |
| updated_at | string | true | false | The time of the last update of the handle |
Example
{"created_at": "2009-05-13T00:07:08Z","id": 211,"screen_name": "@zendesk","twitter_user_id": 67462376832,"updated_at": "2011-07-22T00:11:12Z"}
List Monitored X Handles
GET /api/v2/channels/twitter/monitored_twitter_handles
Allowed For
- Admins
- Agents
Code Samples
curl
curl https://{subdomain}.zendesk.com/api/v2/channels/twitter/monitored_twitter_handles
Go
import ("fmt""io""net/http")func main() {url := "https://example.zendesk.com/api/v2/channels/twitter/monitored_twitter_handles"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://example.zendesk.com/api/v2/channels/twitter/monitored_twitter_handles").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://example.zendesk.com/api/v2/channels/twitter/monitored_twitter_handles',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://example.zendesk.com/api/v2/channels/twitter/monitored_twitter_handles"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://example.zendesk.com/api/v2/channels/twitter/monitored_twitter_handles")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{"monitored_twitter_handles": [{"created_at": "2009-05-13T00:07:08Z","id": 211,"screen_name": "@zendesk","twitter_user_id": 67462376832,"updated_at": "2011-07-22T00:11:12Z"},{"created_at": "2010-05-13T22:07:08Z","id": 431,"screen_name": "@zendeskops","twitter_user_id": 67923318930,"updated_at": "2011-07-22T00:15:19Z"}]}
Show Monitored X Handle
GET /api/v2/channels/twitter/monitored_twitter_handles/{monitored_twitter_handle_id}
Allowed For
- Admins
- Agents
Parameters
| Name | Type | In | Required | Description |
|---|---|---|---|---|
| monitored_twitter_handle_id | integer | Path | true | The ID of the custom agent role |
Code Samples
curl
curl https://{subdomain}.zendesk.com/api/v2/channels/twitter/monitored_twitter_handles/{monitored_twitter_handle_id} \-H "Authorization: Bearer {access_token}"
Go
import ("fmt""io""net/http")func main() {url := "https://example.zendesk.com/api/v2/channels/twitter/monitored_twitter_handles/431"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://example.zendesk.com/api/v2/channels/twitter/monitored_twitter_handles/431").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://example.zendesk.com/api/v2/channels/twitter/monitored_twitter_handles/431',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://example.zendesk.com/api/v2/channels/twitter/monitored_twitter_handles/431"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://example.zendesk.com/api/v2/channels/twitter/monitored_twitter_handles/431")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{"monitored_twitter_handle": {"created_at": "2010-05-13T22:07:08Z","id": 431,"screen_name": "@zendeskops","twitter_user_id": 67923318930,"updated_at": "2011-07-22T00:15:19Z"}}
Create Ticket from Tweet
POST /api/v2/channels/twitter/tickets
Turns a tweet into a ticket. You must provide the tweet id as well as the id of a monitored X (formerly Twitter) handle configured for your account.
The submitter of the ticket is set to be the user submitting the API request.
Allowed For
- Agents
Code Samples
curl
curl https://{subdomain}.zendesk.com/api/v2/channels/twitter/tickets \-H "Content-Type: application/json" \-d '{"ticket": {"twitter_status_message_id": 8605426295771136, "monitored_twitter_handle_id": 45}}' \-H "Authorization: Bearer {access_token}" -X POST
Go
import ("fmt""io""net/http")func main() {url := "https://example.zendesk.com/api/v2/channels/twitter/tickets"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://example.zendesk.com/api/v2/channels/twitter/tickets").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://example.zendesk.com/api/v2/channels/twitter/tickets',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://example.zendesk.com/api/v2/channels/twitter/tickets"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://example.zendesk.com/api/v2/channels/twitter/tickets")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 Creatednull
List Ticket statuses
GET /api/v2/channels/twitter/tickets/{comment_id}/statuses
Allowed For
- Agents
Parameters
| Name | Type | In | Required | Description |
|---|---|---|---|---|
| ids | string | Query | false | Optional comment ids to retrieve tweet information for only particular comments |
| comment_id | integer | Path | true | The ID of the comment |
Code Samples
curl
curl https://{subdomain}.zendesk.com/api/v2/channels/twitter/tickets/{comment_id}/statuses \-H "Authorization: Bearer {access_token}"
Go
import ("fmt""io""net/http")func main() {url := "https://example.zendesk.com/api/v2/channels/twitter/tickets/654321/statuses?ids=1%2C3%2C5"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://example.zendesk.com/api/v2/channels/twitter/tickets/654321/statuses").newBuilder().addQueryParameter("ids", "1,3,5");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://example.zendesk.com/api/v2/channels/twitter/tickets/654321/statuses',headers: {'Content-Type': 'application/json','Authorization': 'Basic <auth-value>', // Base64 encoded "{email_address}/token:{api_token}"},params: {'ids': '1%2C3%2C5',},};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://example.zendesk.com/api/v2/channels/twitter/tickets/654321/statuses?ids=1%2C3%2C5"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://example.zendesk.com/api/v2/channels/twitter/tickets/654321/statuses")uri.query = URI.encode_www_form("ids": "1,3,5")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{"statuses": [{"favorited": true,"id": 834,"retweeted": false,"user_followed": true}]}