> For clean Markdown content of this page, append .md to this URL. For the complete documentation index, see https://learning.postman.com/llms.txt.

# Revoke an OAuth Token

POST https://api.postman.com/oauth2/token/revoke
Content-Type: application/json

Revokes an active OAuth 2.0 access token and prevents further use of it for authentication. Once revoked, the token can't be used for any API requests.

**Note:**

- Revocation of an OAuth token is immediate and can't be undone.
- This request does not use any authorization.


Reference: https://learning.postman.com/api-docs/api-reference/o-auth-2-0/revoke-oauth-token

## Servers

- `https://api.postman.com` (https://api.postman.com, default)
- `https://api.eu.postman.com` (https://api.eu.postman.com)

## Request

### Body (application/json)

- `token` (string, required) — The Postman OAuth 2.0 access token to revoke.

## Response

### 200

Token Revoked

- `success` (string, optional) — The `true` value.

## Examples

### Token Revoked

**Request**

```json
undefined
```

**Response**

```json
{
  "success": "true"
}
```

**SDK Code**

```python Token Revoked
import requests

url = "https://api.postman.com/oauth2/token/revoke"

headers = {"Content-Type": "application/json"}

response = requests.post(url, headers=headers)

print(response.json())
```

```javascript Token Revoked
const url = 'https://api.postman.com/oauth2/token/revoke';
const options = {method: 'POST', headers: {'Content-Type': 'application/json'}, body: undefined};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Token Revoked
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://api.postman.com/oauth2/token/revoke"

	req, _ := http.NewRequest("POST", url, nil)

	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Token Revoked
require 'uri'
require 'net/http'

url = URI("https://api.postman.com/oauth2/token/revoke")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'

response = http.request(request)
puts response.read_body
```

```java Token Revoked
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.postman.com/oauth2/token/revoke")
  .header("Content-Type", "application/json")
  .asString();
```

```php Token Revoked
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.postman.com/oauth2/token/revoke', [
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Token Revoked
using RestSharp;

var client = new RestClient("https://api.postman.com/oauth2/token/revoke");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
IRestResponse response = client.Execute(request);
```

```swift Token Revoked
import Foundation

let headers = ["Content-Type": "application/json"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.postman.com/oauth2/token/revoke")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Revoke an OAuth Token

**Request**

```json
{
  "token": "PMAK-XXX"
}
```

**Response**

```json
{
  "success": "true"
}
```

**SDK Code**

```python Revoke an OAuth Token
import requests

url = "https://api.postman.com/oauth2/token/revoke"

payload = { "token": "PMAK-XXX" }
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Revoke an OAuth Token
const url = 'https://api.postman.com/oauth2/token/revoke';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: '{"token":"PMAK-XXX"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Revoke an OAuth Token
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.postman.com/oauth2/token/revoke"

	payload := strings.NewReader("{\n  \"token\": \"PMAK-XXX\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Revoke an OAuth Token
require 'uri'
require 'net/http'

url = URI("https://api.postman.com/oauth2/token/revoke")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n  \"token\": \"PMAK-XXX\"\n}"

response = http.request(request)
puts response.read_body
```

```java Revoke an OAuth Token
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.postman.com/oauth2/token/revoke")
  .header("Content-Type", "application/json")
  .body("{\n  \"token\": \"PMAK-XXX\"\n}")
  .asString();
```

```php Revoke an OAuth Token
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.postman.com/oauth2/token/revoke', [
  'body' => '{
  "token": "PMAK-XXX"
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Revoke an OAuth Token
using RestSharp;

var client = new RestClient("https://api.postman.com/oauth2/token/revoke");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"token\": \"PMAK-XXX\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Revoke an OAuth Token
import Foundation

let headers = ["Content-Type": "application/json"]
let parameters = ["token": "PMAK-XXX"] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.postman.com/oauth2/token/revoke")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```