You can use the API to list existing OAuth access tokens for the Zendesk Chat API, or to revoke them.

JSON format

OAuth Tokens are represented as JSON objects with the following properties:

NameTypeRead-onlyMandatoryDescription
access_tokenstringtruefalseThe access token
agent_idintegertruefalseThe ID of the user this token authenticates as
client_identifierstringtruefalseThe ID of the client this token belongs to
create_datestringtruefalseThe time the token was created
expire_datestringtruefalseThe refresh token, if generated
idintegertruefalseThe ID of the token. Automatically assigned when created
refresh_tokenstringtruefalseThe refresh token, if generated
scopesstringtruefalseOne or more allowed scopes for the client. Can be "read", "write", and "chat". See OAuth Authentication
token_typestringtruefalseToken type. Must be "Bearer"

Example

{  "access_token": "L0m2pVzxYpiVZOnzuWfGTHJjUxMicmbsEeGh4QSBqTTaScnprJNC8DusW5RwFTuo",  "agent_id": 100000204,  "client_identifier": "zopim",  "create_date": "2014-09-09T07:49:20Z",  "expire_date": "2014-09-09T17:49:20Z",  "id": 38,  "refresh_token": "pLZYNfA082RVrUt6ArGiKroVrN6CS9ZJ2glbty5rA1CejmSVlGPk5GjfKarDR5VS",  "scopes": "read write",  "token_type": "Bearer"}

List OAuth Tokens

  • GET /api/v2/chat/oauth/tokens

Lists all tokens under an agent.

Allowed for

  • Administrator

Code Samples

curl
curl https://{subdomain}.zendesk.com/api/v2/chat/oauth/tokens \  -v -H "Authorization: Bearer {token}"
Go
import (	"fmt"	"io"	"net/http")
func main() {	url := "https://subdomain.zendesk.com/api/v2/chat/oauth/tokens"	method := "GET"	req, err := http.NewRequest(method, url, nil)
	if err != nil {		fmt.Println(err)		return	}	req.Header.Add("Content-Type", "application/json")
	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://subdomain.zendesk.com/api/v2/chat/oauth/tokens")		.newBuilder();
Request request = new Request.Builder()		.url(urlBuilder.build())		.method("GET", null)		.addHeader("Content-Type", "application/json")		.build();Response response = client.newCall(request).execute();
Nodejs
var axios = require('axios');
var config = {  method: 'GET',  url: 'https://subdomain.zendesk.com/api/v2/chat/oauth/tokens',  headers: {	'Content-Type': 'application/json',  },};
axios(config).then(function (response) {  console.log(JSON.stringify(response.data));}).catch(function (error) {  console.log(error);});
Python
import requests
url = "https://subdomain.zendesk.com/api/v2/chat/oauth/tokens"headers = {	"Content-Type": "application/json",}
response = requests.request(	"GET",	url,	headers=headers)
print(response.text)
Ruby
require "net/http"uri = URI("https://subdomain.zendesk.com/api/v2/chat/oauth/tokens")request = Net::HTTP::Get.new(uri, "Content-Type": "application/json")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
[  {    "access_token": "L0m2pVzxYpiVZOnzuWfGTHJjUxMicmbsEeGh4QSBqTTaScnprJNC8DusW5RwFTuo",    "agent_id": 100000204,    "client_identifier": "zopim",    "create_date": "2014-09-09T07:49:20Z",    "expire_date": "2014-09-09T17:49:20Z",    "id": 38,    "refresh_token": "pLZYNfA082RVrUt6ArGiKroVrN6CS9ZJ2glbty5rA1CejmSVlGPk5GjfKarDR5VS",    "scopes": "read write",    "token_type": "Bearer"  },  {    "access_token": "L0m2pVz124sdsGTHJjUxMicmbsEeGh4QSBqTTaScnprJNC8DusW5RwFTuo",    "agent_id": 10000026,    "client_identifier": "zendesk",    "create_date": "2014-09-09T07:49:20Z",    "expire_date": "2014-09-09T17:49:20Z",    "id": 143,    "refresh_token": "pLZYNfA082RV34sdsroVrN6CS9ZJ2glbty5rA1CejmSVlGPk5GjfKarDR5VS",    "scopes": "read write",    "token_type": "Bearer"  }]

Delete OAuth Token

  • DELETE /api/v2/chat/oauth/tokens/{oauth_token_id}

Revokes the specified token.

Allowed for

  • Administrator

Parameters

NameTypeInRequiredDescription
oauth_token_idintegerPathtrueThe ID of the OAuth Token

Code Samples

curl
curl https://{subdomain}.zendesk.com/api/v2/chat/oauth/tokens/{id} \  -v -H "Authorization: Bearer {token}" -X DELETE
Go
import (	"fmt"	"io"	"net/http")
func main() {	url := "https://subdomain.zendesk.com/api/v2/chat/oauth/tokens/1"	method := "DELETE"	req, err := http.NewRequest(method, url, nil)
	if err != nil {		fmt.Println(err)		return	}	req.Header.Add("Content-Type", "application/json")
	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://subdomain.zendesk.com/api/v2/chat/oauth/tokens/1")		.newBuilder();
Request request = new Request.Builder()		.url(urlBuilder.build())		.method("DELETE", null)		.addHeader("Content-Type", "application/json")		.build();Response response = client.newCall(request).execute();
Nodejs
var axios = require('axios');
var config = {  method: 'DELETE',  url: 'https://subdomain.zendesk.com/api/v2/chat/oauth/tokens/1',  headers: {	'Content-Type': 'application/json',  },};
axios(config).then(function (response) {  console.log(JSON.stringify(response.data));}).catch(function (error) {  console.log(error);});
Python
import requests
url = "https://subdomain.zendesk.com/api/v2/chat/oauth/tokens/1"headers = {	"Content-Type": "application/json",}
response = requests.request(	"DELETE",	url,	headers=headers)
print(response.text)
Ruby
require "net/http"uri = URI("https://subdomain.zendesk.com/api/v2/chat/oauth/tokens/1")request = Net::HTTP::Delete.new(uri, "Content-Type": "application/json")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