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

# Authorize a deployment request

GET https://astropods.com/api/v1/deployments/authorize

Callback used by the messaging container — and by any agent that handles its own
HTTP requests (e.g. a frontend agent) — to check whether an inbound request should
be allowed against this deployment's grants.

Authentication is the per-deployment JWT injected as `ASTRO_AUTHZ_TOKEN`. The token's
`sub` claim identifies the deployment; no other deployment ID is passed in the request.

Returns `200` with the decision on every authoritative answer. Identity fields are
only populated when `allowed: true` — denials don't leak mapping state.


Reference: https://docs.astropods.com/api-reference/astropods-api/deployments/authorize-deployment

## Authentication

- `Authorization` header (bearer token, required) — Per-deployment JWT signed by astro-server (HS256). Injected into the agent and messaging containers as the `ASTRO_AUTHZ_TOKEN` environment variable. The `sub` claim identifies the deployment.

## Request

### Query parameters

- `identity_type` (enum, optional) — `user` for a signed-in user, `slack` for a Slack user, or empty for anonymous (only valid when an `anyone` grant exists for the adapter).
  - Allowed values: `user`, `slack`
- `identity_id` (string, optional) — The user id corresponding to `identity_type` — the platform user id for `user`, the Slack user id for `slack`. Must be supplied together with `identity_type`; providing one without the other returns 400.
- `identity_scope` (string, optional) — Adapter-specific disambiguator for `identity_id`. For `slack`, this is the workspace `team_id` (Slack user ids are only unique within a team). Omit for `web`.
- `adapter` (enum, required) — The adapter handling the request.
  - Allowed values: `web`, `slack`

## Response

### 200

Authorization decision

- `allowed` (boolean, required) — Whether the request is allowed.
- `user_id` (string, optional) — Resolved platform user id. Echoed back for `identity_type=user`; looked up via Slack identity mappings for `identity_type=slack` (empty when no mapping exists). Only present when `allowed: true`.
- `slack_user_id` (string, optional) — The Slack user id from the request, echoed back so callers can attribute unlinked Slack users to a namespaced trace id. Only present when `allowed: true` and `identity_type=slack`.
- `slack_team_id` (string, optional) — The Slack workspace id (`team_id`) from the request, echoed back. Only present when `allowed: true` and `identity_type=slack`.

## Errors

### 400 Bad Request Error

Invalid request body or parameters

- `error` (string, optional)
- `details` (string, optional)

### 401 Unauthorized Error

Authentication required

- `error` (string, optional)
- `details` (string, optional)

### 500 Internal Server Error

Server error

- `error` (string, optional)
- `details` (string, optional)

## Examples

**Response**

```json
{
  "allowed": true,
  "user_id": "string",
  "slack_user_id": "string",
  "slack_team_id": "string"
}
```

**SDK Code**

```python
import requests

url = "https://astropods.com/api/v1/deployments/authorize"

querystring = {"adapter":"web"}

headers = {"Authorization": "Bearer <token>"}

response = requests.get(url, headers=headers, params=querystring)

print(response.json())
```

```javascript
const url = 'https://astropods.com/api/v1/deployments/authorize?adapter=web';
const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};

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://astropods.com/api/v1/deployments/authorize?adapter=web"

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

	req.Header.Add("Authorization", "Bearer <token>")

	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://astropods.com/api/v1/deployments/authorize?adapter=web")

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

request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'

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.get("https://astropods.com/api/v1/deployments/authorize?adapter=web")
  .header("Authorization", "Bearer <token>")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://astropods.com/api/v1/deployments/authorize?adapter=web', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://astropods.com/api/v1/deployments/authorize?adapter=web");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <token>");
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Authorization": "Bearer <token>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://astropods.com/api/v1/deployments/authorize?adapter=web")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
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()
```