> For clean Markdown content of this page, append .md to this URL. For the complete documentation index, see https://learning.postman.com/llms.txt. For full content including API reference and SDK examples, see https://learning.postman.com/llms-full.txt.

# Revoke an OAuth Token

POST https://api.getpostman.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

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: Postman API
  version: 1.0.0
paths:
  /oauth2/token/revoke:
    post:
      operationId: revokeOauthToken
      summary: Revoke an OAuth Token
      description: >
        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.
      tags:
        - oAuth20
      responses:
        '200':
          description: Token Revoked
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/revokeOauthTokenResponse'
        '404':
          description: Token Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/oauthTokenError'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/revokeOauthToken'
servers:
  - url: https://api.getpostman.com
    description: https://api.getpostman.com
  - url: https://api.eu.postman.com
    description: https://api.eu.postman.com
components:
  schemas:
    revokeOauthToken:
      type: object
      properties:
        token:
          type: string
          description: The Postman OAuth 2.0 access token to revoke.
      required:
        - token
      title: revokeOauthToken
    revokeOauthTokenResponse:
      type: object
      properties:
        success:
          type: string
          description: The `true` value.
      title: revokeOauthTokenResponse
    oauthTokenError:
      type: object
      properties:
        error:
          type: string
          description: The type of error.
        error_description:
          type: string
          description: Information about the error.
      title: oauthTokenError

```

## Examples

### Token Revoked



**Request**

```json
undefined
```

**Response**

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

**SDK Code**

```python Token Revoked
import requests

url = "https://api.getpostman.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.getpostman.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.getpostman.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.getpostman.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.getpostman.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.getpostman.com/oauth2/token/revoke', [
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Token Revoked
using RestSharp;

var client = new RestClient("https://api.getpostman.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.getpostman.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.getpostman.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.getpostman.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.getpostman.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.getpostman.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.getpostman.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.getpostman.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.getpostman.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.getpostman.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()
```