> ## Documentation Index
> Fetch the complete documentation index at: https://www.canva.dev/docs/apps/llms.txt
> Use this file to discover all available pages before exploring further.
# Revoke a token
Revoke a token and its lineage.
Revoke an access token or a refresh token.
If you revoke a *refresh token*, be aware that:
* The refresh token's lineage is also revoked. This means that access tokens created from that refresh token are also revoked.
* The user's consent for your app is also revoked. This means that the user must go through the OAuth process again to use your app.
Requests to this endpoint require authentication with your client ID and client secret, using *one* of the following methods:
* **Basic access authentication** (Recommended): For [basic access authentication](https://en.wikipedia.org/wiki/Basic_access_authentication), the `{credentials}` string must be a Base64 encoded value of `{client id}:{client secret}`.
* **Body parameters**: Provide your app's credentials using the `client_id` and `client_secret` body parameters.
This endpoint can't be called from a user's web-browser client because it uses client authentication with client secrets. Requests must come from your app's backend, otherwise they'll be blocked by Canva's [Cross-Origin Resource Sharing (CORS)](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) policy.
## HTTP method and URL path
POST https\://api.canva.com/rest/v1/oauth/revoke
## Authentication and authorization
This endpoint uses HTTP basic access authentication.
## Header parameters
Provides credentials to authenticate the request, in the form of [basic access authentication](https://en.wikipedia.org/wiki/Basic_access_authentication).
For example: `Authorization: Basic {credentials}`
NOTE: We recommend that you use basic access authentication instead of specifying `client_id` and `client_secret` as body parameters.
Indicates the media type of the information sent in the request. This must be set to `application/x-www-form-urlencoded`.
For example: `Content-Type: application/x-www-form-urlencoded`
## Body parameters
The token to revoke.
Your app's unique ID, for authenticating the request.
NOTE: We recommend that you use basic access authentication instead of specifying `client_id` and `client_secret` as body parameters.
Your app's client secret, for authenticating the request. Begins with `cnvca`.
NOTE: We recommend that you use basic access authentication instead of specifying `client_id` and `client_secret` as body parameters.
## Example request
Examples for using the `/v1/oauth/revoke` endpoint:
```sh
curl --request POST 'https://api.canva.com/rest/v1/oauth/revoke' \
--header 'Authorization: Basic {credentials}' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'token=agALLazU0i2ld9WW4zTO4kaG0lkvP8Y5sSO206ZwxNF4E1y3xKJKF7TzN17BXTfaNOeY0P88AeRCE6cRF7SJzvf3Sx97rA80sGHtFplFo' \
--data-urlencode 'client_id=OC-FAB12-AbCdEf' \
--data-urlencode 'client_secret=cnvcaAbcdefg12345_hijklm6789'
```
```js
const fetch = require("node-fetch");
const { URLSearchParams } = require("url");
fetch("https://api.canva.com/rest/v1/oauth/revoke", {
method: "POST",
headers: {
"Authorization": "Basic {credentials}",
"Content-Type": "application/x-www-form-urlencoded",
},
body: new URLSearchParams("token=agALLazU0i2ld9WW4zTO4kaG0lkvP8Y5sSO206ZwxNF4E1y3xKJKF7TzN17BXTfaNOeY0P88AeRCE6cRF7SJzvf3Sx97rA80sGHtFplFo&client_id=OC-FAB12-AbCdEf&client_secret=cnvcaAbcdefg12345_hijklm6789"),
})
.then(async (response) => {
const data = await response.json();
console.log(data);
})
.catch(err => console.error(err));
```
```java
import java.io.IOException;
import java.net.URI;
import java.net.http.*;
public class ApiExample {
public static void main(String[] args) throws IOException, InterruptedException {
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.canva.com/rest/v1/oauth/revoke"))
.header("Authorization", "Basic {credentials}")
.header("Content-Type", "application/x-www-form-urlencoded")
.method("POST", HttpRequest.BodyPublishers.ofString("token=agALLazU0i2ld9WW4zTO4kaG0lkvP8Y5sSO206ZwxNF4E1y3xKJKF7TzN17BXTfaNOeY0P88AeRCE6cRF7SJzvf3Sx97rA80sGHtFplFo&client_id=OC-FAB12-AbCdEf&client_secret=cnvcaAbcdefg12345_hijklm6789"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(
request,
HttpResponse.BodyHandlers.ofString()
);
System.out.println(response.body());
}
}
```
```py
import requests
headers = {
"Authorization": "Basic {credentials}",
"Content-Type": "application/x-www-form-urlencoded"
}
data = {
"token": "agALLazU0i2ld9WW4zTO4kaG0lkvP8Y5sSO206ZwxNF4E1y3xKJKF7TzN17BXTfaNOeY0P88AeRCE6cRF7SJzvf3Sx97rA80sGHtFplFo",
"client_id": "OC-FAB12-AbCdEf"
"client_secret": "cnvcaAbcdefg12345_hijklm6789",
}
response = requests.post("https://api.canva.com/rest/v1/oauth/revoke",
headers=headers,
data=data
)
print(response.json())
```
```csharp
using System.Net.Http;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("https://api.canva.com/rest/v1/oauth/revoke"),
Headers =
{
{ "Authorization", "Basic {credentials}" },
},
Content = new StringContent(
"token=agALLazU0i2ld9WW4zTO4kaG0lkvP8Y5sSO206ZwxNF4E1y3xKJKF7TzN17BXTfaNOeY0P88AeRCE6cRF7SJzvf3Sx97rA80sGHtFplFo&client_id=OC-FAB12-AbCdEf&client_secret=cnvcaAbcdefg12345_hijklm6789",
Encoding.UTF8,
"application/x-www-form-urlencoded"
),
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
};
```
```go
package main
import (
"fmt"
"io"
"net/http"
"strings"
)
func main() {
payload := strings.NewReader("token=agALLazU0i2ld9WW4zTO4kaG0lkvP8Y5sSO206ZwxNF4E1y3xKJKF7TzN17BXTfaNOeY0P88AeRCE6cRF7SJzvf3Sx97rA80sGHtFplFo&client_id=OC-FAB12-AbCdEf&client_secret=cnvcaAbcdefg12345_hijklm6789")
url := "https://api.canva.com/rest/v1/oauth/revoke"
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Basic {credentials}")
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}
```
```php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.canva.com/rest/v1/oauth/revoke",
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Authorization: Basic {credentials}',
'Content-Type: application/x-www-form-urlencoded',
),
CURLOPT_POSTFIELDS => "token=agALLazU0i2ld9WW4zTO4kaG0lkvP8Y5sSO206ZwxNF4E1y3xKJKF7TzN17BXTfaNOeY0P88AeRCE6cRF7SJzvf3Sx97rA80sGHtFplFo&client_id=OC-FAB12-AbCdEf&client_secret=cnvcaAbcdefg12345_hijklm6789"
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if (empty($err)) {
echo $response;
} else {
echo "Error: " . $err;
}
```
```ruby
require 'net/http'
require 'uri'
url = URI('https://api.canva.com/rest/v1/oauth/revoke')
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request['Authorization'] = 'Basic {credentials}'
request['Content-Type'] = 'application/x-www-form-urlencoded'
request.body = "token=agALLazU0i2ld9WW4zTO4kaG0lkvP8Y5sSO206ZwxNF4E1y3xKJKF7TzN17BXTfaNOeY0P88AeRCE6cRF7SJzvf3Sx97rA80sGHtFplFo&client_id=OC-FAB12-AbCdEf&client_secret=cnvcaAbcdefg12345_hijklm6789"
response = http.request(request)
puts response.read_body
```
## Success response
If successful, the endpoint returns a `200` response with an empty JSON body.
## Example response
```json
{}
```
## Error responses
### 400 Bad Request
A short string indicating what failed. This field can be used to handle errors programmatically. For a complete list of error codes, see [Error responses](/docs/apps/rest-apis/error-responses/).
A human-readable description of what went wrong.
#### Example error responses
##### client\_id body parameter has multiple values
```json
{
"code": "invalid_field",
"message": "client_id body param must have a single value"
}
```
##### client\_id body parameter is blank or empty
```json
{
"code": "invalid_field",
"message": "client_id body param must not be blank or empty"
}
```
##### client\_secret body parameter has multiple values
```json
{
"code": "invalid_field",
"message": "client_secret body param must have a single value"
}
```
##### client\_id basic auth parameter is blank or empty
```json
{
"code": "invalid_field",
"message": "client_id basic auth parameter must not be blank or empty"
}
```
##### secret basic auth parameter is blank or empty
```json
{
"code": "invalid_field",
"message": "secret basic auth parameter must not be blank or empty"
}
```
##### Request body too large
```json
{
"code": "bad_request_body",
"message": "Request body too large"
}
```
##### The token supplied is neither an access token nor a refresh token.
```json
{
"code": "bad_request_params",
"message": "Token is neither an access or refresh token"
}
```
##### The request is invalid.
```json
{
"code": "invalid_request",
"message": "Invalid request"
}
```
### 401 Unauthorized
A short string indicating what failed. This field can be used to handle errors programmatically. For a complete list of error codes, see [Error responses](/docs/apps/rest-apis/error-responses/).
A human-readable description of what went wrong.
#### Example error responses
##### Client secret is invalid (Unauthorized)
```json
{
"code": "invalid_access_token",
"message": "Client secret is invalid for {clientAppId}"
}
```
##### Access token is missing
```json
{
"code": "invalid_access_token",
"message": "Access token is missing"
}
```