Get Policy - Barndoor Documentation

Get Policy

cURL

curl --request GET \
  --url https://your-org.platform.barndoor.ai/api/v2/policies/{policy_id} \
  --header 'Authorization: Bearer <token>'

Python

import requests

url = "https://your-org.platform.barndoor.ai/api/v2/policies/{policy_id}"

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

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

print(response.text)

JavaScript

const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};

fetch('https://your-org.platform.barndoor.ai/api/v2/policies/{policy_id}', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));

PHP

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://your-org.platform.barndoor.ai/api/v2/policies/{policy_id}",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer <token>"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}

Go

package main

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

func main() {
    url := "https://your-org.platform.barndoor.ai/api/v2/policies/{policy_id}"

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(string(body))
}

Unirest

HttpResponse<String> response = Unirest.get("https://your-org.platform.barndoor.ai/api/v2/policies/{policy_id}")
  .header("Authorization", "Bearer <token>")
  .asString();

Ruby

require 'uri'
require 'net/http'

url = URI("https://your-org.platform.barndoor.ai/api/v2/policies/{policy_id}")

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

Response

200

{
  "policy": {
    "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
    "organization_id": "<string>",
    "name": "<string>",
    "status": "<string>",
    "mcp_server_id": "<string>",
    "created_at": "2023-11-07T05:31:56Z",
    "updated_at": "2023-11-07T05:31:56Z",
    "created_by_user_id": "<string>",
    "updated_by_user_id": "<string>",
    "support_contact": "<string>",
    "description": "<string>",
    "application_ids": [
      "<string>"
    ],
    "tags": [
      "<string>"
    ],
    "rules": [
      {
        "name": "",
        "authorized": false,
        "actions": [
          "<string>"
        ],
        "roles_groups": [
          "<string>"
        ],
        "condition": {
          "match": {
            "expr": "<string>"
          }
        }
      }
    ]
  }
}

422

{
  "detail": [
    {
      "loc": [
        "<string>"
      ],
      "msg": "<string>",
      "type": "<string>",
      "input": "<unknown>",
      "ctx": {}
    }
  ]
}

Authorizations

Authorization
Type: String
Location: Header
Required: Yes
Format: Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

policy_id
Type: String (UUID)
Required: Yes

Response Details