# Logout user

`POST /api/auth/logout`

Revokes the provided refresh token. If no token is supplied, the token from the current request context is used. Individual revocation failures are logged but do not cause the request to fail.

Authentication: no security requirement declared for this operation.

Request body: application/json

Optional token pair to revoke.

Type: object

- `refresh_token` (optional)
  Type: string
  
  Refresh token to revoke.

Responses:

- 200: Successfully logged out. The provided token has been revoked.

- 400: Request body is malformed or contains unrecognized fields.

## Examples

### cURL

```bash
curl -X POST 'http://localhost:3000/api/auth/logout' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "refresh_token": "string"
}'
```

### JavaScript

```javascript
const body = `{
  "refresh_token": "string"
}`;

const response = await fetch('http://localhost:3000/api/auth/logout', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
  },
  body,
});

const data = await response.text();
```

### Python

```python
import requests

body = '''{
  "refresh_token": "string"
}'''

response = requests.post(
    'http://localhost:3000/api/auth/logout',
    data=body.encode('utf-8'),
    headers={
        'Content-Type': 'application/json',
    },
)
print(response.text)
```
