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

# Reject a pending access request

POST https://api.usepassport.ai/public/v1/access-requests/{accessRequestId}/reject
Content-Type: application/json

Reject the request; no access is granted. Admin key only (403 for a member key). Only pending requests change; a decided or cancelled request is a 409.


Reference: https://docs.usepassport.ai/api-reference/access-requests/reject-access-request

## Authentication

- `Authorization` header (bearer token, required) — WorkOS API key (Authorization: Bearer sk_...). Scope comes from the key's permissions: a key carrying `passport:admin` has admin scope (full catalog CRUD), any other key has member scope (reads + access requests). Organization-owned keys are admin by ownership and carry no associated user; keys minted for a user carry theirs, which is what access requests and `createdBy` are attributed to.

## Request

### Path parameters

- `accessRequestId` (string, required)

### Headers

- `Idempotency-Key` (string, optional) — Optional idempotency key, retained 24h and bound to the request that first used it. Resending the same request replays the stored response (with `Idempotent-Replayed: true`); reusing the key with a different body or path returns 422; retrying while the original is still in flight returns 409 with `Retry-After`. A failed request releases its key.

### Body (application/json)

This endpoint expects an AccessRequestDecision.

- `reason` (string, optional, nullable) — Optional note recorded as the request's decisionReason.

## Response

### 200

OK

- `data` (AccessRequest, required)

## Errors

### 400 Bad Request Error

The request body or query is invalid.

- `error` (ErrorError, required)

### 401 Unauthorized Error

Missing or invalid API key. Unlike every other response, this one carries no `RateLimit-*` headers: the request is rejected before a key is resolved, so there is no per-key window to report. Rejection happens at the gateway, which renders this same schema (and negotiates `application/problem+json` identically).

- `error` (ErrorError, required)

### 403 Forbidden Error

Authenticated but lacking required role (e.g. member key on a catalog mutation).

- `error` (ErrorError, required)

### 404 Not Found Error

Access request not found (or not visible to the caller).

- `error` (ErrorError, required)

### 409 Conflict Error

The access request is not pending, so it cannot transition.

- `error` (ErrorError, required)

### 422 Unprocessable Entity Error

This `Idempotency-Key` was already used with a different request body or path. The first request's response is never substituted — use a new key, or resend the original request unchanged.

- `error` (ErrorError, required)

### 429 Too Many Requests Error

Rate limit exceeded.

- `error` (ErrorError, required)

### 500 Internal Server Error

Unexpected server error.

- `error` (ErrorError, required)

### 503 Service Unavailable Error

Temporary unavailability (auth dependency down, encryption-config resolution failure, or discovery document unloadable).

- `error` (ErrorError, required)

## Types

### AccessRequest

- `id` (string, optional)
- `requesterId` (string, optional)
- `namespaceId` (string, optional)
- `namespaceName` (string, optional, nullable) — Resolved namespace name (soft-delete-inclusive); null when unresolvable or when names were not hydrated, which is the case on the create and cancel responses.
- `status` (enum, optional)
  - Allowed values: `pending`, `approved`, `rejected`, `cancelled`
- `message` (string, optional, nullable)
- `durationDays` (enum, optional) — Requested access lifetime. `null` means unlimited.
  - Allowed values: `7`, `30`, `90`
- `entities` (list of AccessRequestEntityView, optional)
- `decisionReason` (string, optional, nullable)
- `decidedBy` (string, optional, nullable)
- `decidedAt` (datetime, optional, nullable)
- `autoApproved` (boolean, optional) — True when the system (not a human admin) decided this request.
- `createdAt` (datetime, optional, nullable)
- `updatedAt` (datetime, optional, nullable)

### ErrorError

- `code` (enum, required) — The machine-readable failure reason. Treat a value not listed here as a generic failure of the class implied by the HTTP status, and do not assume retry behaviour for it — new codes may be added.
  - Allowed values: `VALIDATION_ERROR`, `MALFORMED_JSON`, `UNAUTHORIZED`, `FORBIDDEN`, `NOT_FOUND`, `CONFLICT`, `UNPROCESSABLE_ENTITY`, `PAYLOAD_TOO_LARGE`, `RATE_LIMITED`, `INTERNAL_ERROR`, `SERVICE_UNAVAILABLE`
- `message` (string, required)
- `details` (list of FieldError, optional)

### AccessRequestEntityView

An entity as returned in a response. Extends the request shape with resolved display data: `name` for a resource group, `endpoint` for a resource endpoint. Only one of the two is ever populated, and both are null when the id cannot be resolved or when names were not hydrated (the write paths — create and cancel — do not hydrate them; list and get do). Resolution is soft-delete-inclusive, so a request can outlive the entity it names.

- `type` (enum, required)
  - Allowed values: `resource_group`, `resource_endpoint`
- `id` (string, required)
- `name` (string, optional, nullable) — Resource group name. Always null for a `resource_endpoint`.
- `endpoint` (AccessRequestEntityViewEndpoint, optional, nullable) — Endpoint method/host/path. Always null for a `resource_group`.

### FieldError

- `field` (string, optional)
- `message` (string, optional)

### AccessRequestEntityViewEndpoint

Endpoint method/host/path. Always null for a `resource_group`.

- `method` (string, required)
- `host` (string, required)
- `path` (string, required)

## Examples

**Request**

```json
{}
```

**Response**

```json
{
  "data": {
    "id": "d4e5f6a7-4444-5555-6666-777788889999",
    "status": "rejected"
  }
}
```

**SDK Code**

```python default
import requests

url = "https://api.usepassport.ai/public/v1/access-requests/accessRequestId/reject"

payload = {}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript default
const url = 'https://api.usepassport.ai/public/v1/access-requests/accessRequestId/reject';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{}'
};

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

```go default
package main

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

func main() {

	url := "https://api.usepassport.ai/public/v1/access-requests/accessRequestId/reject"

	payload := strings.NewReader("{}")

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

	req.Header.Add("Authorization", "Bearer <token>")
	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 default
require 'uri'
require 'net/http'

url = URI("https://api.usepassport.ai/public/v1/access-requests/accessRequestId/reject")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{}"

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

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

HttpResponse<String> response = Unirest.post("https://api.usepassport.ai/public/v1/access-requests/accessRequestId/reject")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.usepassport.ai/public/v1/access-requests/accessRequestId/reject', [
  'body' => '{}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp default
using RestSharp;

var client = new RestClient("https://api.usepassport.ai/public/v1/access-requests/accessRequestId/reject");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift default
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.usepassport.ai/public/v1/access-requests/accessRequestId/reject")! 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()
```