> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://developer.crehana.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://developer.crehana.com/_mcp/server.

# Token revocation (RFC 7009)

POST https://www.crehana.com/api/v5/rest/auth/oauth2/revoke
Content-Type: application/x-www-form-urlencoded

Revokes an access or refresh token. Accepts application/x-www-form-urlencoded. Idempotent: an unknown token also returns 200 with an empty body.

Reference: https://developer.crehana.com/api-reference/endpoints/o-auth-2/revoke

## Authentication

- `Api-Key` header (required) — API key of the organization. Always sent together with the `Secret-Access` header.

## Servers

- `https://www.crehana.com` (Production, default)
- `https://qa.creha.co` (QA)

## Request

### Body (application/x-www-form-urlencoded)

This endpoint expects a Body_revoke.

- `token` (string, required)
- `token_type_hint` (enum, optional) — An enumeration.
  - Allowed values: `access_token`, `refresh_token`
- `client_id` (string, optional)
- `client_secret` (string, optional)

## Response

### 200

Token revoked (empty body)

- `any`

## Errors

### 400 Bad Request Error

Bad Request

- `error` (string, required) — OAuth error code (RFC 6749 §5.2)
- `error_description` (string, optional) — Human-readable error description
- `state` (string, optional) — State echoed back on the /authorize error path

### 422 Unprocessable Entity Error

Validation Error

- `detail` (list of ValidationError, optional)

## Types

### ValidationError

- `loc` (list of ValidationErrorLocItems, required)
- `msg` (string, required)
- `type` (string, required)

### ValidationErrorLocItems

- string
- integer

## Examples

**Request**

```json
{
  "token": "string"
}
```

**SDK Code**

```python
import requests

url = "https://www.crehana.com/api/v5/rest/auth/oauth2/revoke"

payload = ""
headers = {
    "Secret-Access": "Secret-Access",
    "Api-Key": "<apiKey>",
    "Content-Type": "application/x-www-form-urlencoded"
}

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

print(response.json())
```

```javascript
const url = 'https://www.crehana.com/api/v5/rest/auth/oauth2/revoke';
const options = {
  method: 'POST',
  headers: {
    'Secret-Access': 'Secret-Access',
    'Api-Key': '<apiKey>',
    'Content-Type': 'application/x-www-form-urlencoded'
  },
  body: new URLSearchParams('')
};

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

```go
package main

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

func main() {

	url := "https://www.crehana.com/api/v5/rest/auth/oauth2/revoke"

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

	req.Header.Add("Secret-Access", "Secret-Access")
	req.Header.Add("Api-Key", "<apiKey>")
	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(res)
	fmt.Println(string(body))

}
```

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

url = URI("https://www.crehana.com/api/v5/rest/auth/oauth2/revoke")

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

request = Net::HTTP::Post.new(url)
request["Secret-Access"] = 'Secret-Access'
request["Api-Key"] = '<apiKey>'
request["Content-Type"] = 'application/x-www-form-urlencoded'

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

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

HttpResponse<String> response = Unirest.post("https://www.crehana.com/api/v5/rest/auth/oauth2/revoke")
  .header("Secret-Access", "Secret-Access")
  .header("Api-Key", "<apiKey>")
  .header("Content-Type", "application/x-www-form-urlencoded")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://www.crehana.com/api/v5/rest/auth/oauth2/revoke', [
  'form_params' => null,
  'headers' => [
    'Api-Key' => '<apiKey>',
    'Content-Type' => 'application/x-www-form-urlencoded',
    'Secret-Access' => 'Secret-Access',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://www.crehana.com/api/v5/rest/auth/oauth2/revoke");
var request = new RestRequest(Method.POST);
request.AddHeader("Secret-Access", "Secret-Access");
request.AddHeader("Api-Key", "<apiKey>");
request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Secret-Access": "Secret-Access",
  "Api-Key": "<apiKey>",
  "Content-Type": "application/x-www-form-urlencoded"
]

let request = NSMutableURLRequest(url: NSURL(string: "https://www.crehana.com/api/v5/rest/auth/oauth2/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()
```