> ## Documentation Index
> Fetch the complete documentation index at: https://www.osohq.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Get policy metadata

> Returns metadata about the currently active policy.



## OpenAPI

````yaml /reference/openapi.json get /policy_metadata
openapi: 3.1.0
info:
  title: Oso Cloud HTTP API
  version: 0.1.0
  description: >-
    <p>Oso Cloud exposes an HTTP API that you can use to make queries directly,
    without using one of the clients.</p><p>For endpoints that require
    authentication, pass your API key as an HTTP Bearer Auth payload.</p><p>For
    example, using curl: <code>curl -H &quot;Authorization: Bearer
    $OSO_AUTH&quot; https://cloud.osohq.com/api/</code></p>
servers:
  - url: https://api.osohq.com/api/
security: []
paths:
  /policy_metadata:
    get:
      tags:
        - Policy
      description: Returns metadata about the currently active policy.
      operationId: get_policy_metadata
      parameters:
        - name: id
          in: query
          schema:
            type: integer
            format: int64
            nullable: true
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GetPolicyMetadataResult'
        default:
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
      security:
        - ApiKey: []
      x-codeSamples:
        - lang: javascript
          label: Node.js
          source: >
            import { Oso } from 'oso-cloud';


            const apiKey = process.env.OSO_CLOUD_API_KEY;

            const oso = new Oso("https://cloud.osohq.com", apiKey);


            // Get policy metadata

            const metadata = await oso.getPolicyMetadata();


            // Access resource information

            console.log(metadata.resources.keys());        // List all resources

            console.log(metadata.resources.get("Repository")); // Get specific
            resource metadata
        - lang: python
          label: Python
          source: >
            import os

            from oso_cloud import Oso


            oso = Oso(api_key=os.environ.get('OSO_CLOUD_API_KEY', None))


            # Get policy metadata

            metadata = oso.get_policy_metadata()


            # Access resource information

            print(metadata.resources.keys())               # List all resources

            print(metadata.resources["Repository"])        # Get specific
            resource metadata
        - lang: go
          label: Go
          source: |
            package main

            import (
                "log"
                "os"
                oso "github.com/osohq/go-oso-cloud/v2"
            )

            func main() {
                apiKey := os.Getenv("OSO_CLOUD_API_KEY")
                osoClient := oso.NewClient("https://cloud.osohq.com", apiKey)

            // Get policy metadata
                metadata, err := osoClient.GetPolicyMetadata()
                if err != nil {
                    log.Fatal(err)
                }
            }

            // Access resource information
            for resourceName := range metadata.Resources {
                fmt.Printf("Resource: %s\n", resourceName)
            }
        - lang: java
          label: Java
          source: |
            package com.mycompany;

            import java.io.IOException;
            import com.osohq.oso_cloud.Oso;
            import com.osohq.oso_cloud.api.ApiException;

            public class App {
                public static void main(String[] args) {
                    String apiKey = System.getenv("OSO_CLOUD_API_KEY");
                    Oso oso = new Oso(apiKey);

                    // Get policy metadata
                    try {
                        PolicyMetadata metadata = oso.getPolicyMetadata();
                        
                        // Access resource information
                        System.out.println(metadata.getResources().keySet());
                    } catch (IOException | ApiException e) {
                        System.err.println("Error getting policy metadata: " + e.getMessage());
                    }
                }
            }
        - lang: ruby
          label: Ruby
          source: >
            require 'oso-cloud'


            api_key = ENV.fetch('OSO_CLOUD_API_KEY', nil)

            oso = OsoCloud::Oso.new(url: "https://cloud.osohq.com", api_key:
            api_key)


            # Get policy metadata

            metadata = oso.get_policy_metadata


            # Access resource information

            puts metadata.resources.keys
        - lang: csharp
          label: C#
          source: >
            using OsoCloud;


            string? apiKey =
            Environment.GetEnvironmentVariable("OSO_CLOUD_API_KEY");

            var oso = new Oso("https://api.osohq.com", apiKey);


            // Get policy metadata

            var metadata = await oso.GetPolicyMetadata();


            // Access resource information

            Console.WriteLine(string.Join(", ", metadata.Resources.Keys));
components:
  schemas:
    GetPolicyMetadataResult:
      type: object
      required:
        - metadata
      properties:
        metadata:
          $ref: '#/components/schemas/PolicyMetadata'
    ApiError:
      type: object
      required:
        - message
      properties:
        message:
          type: string
    PolicyMetadata:
      type: object
      required:
        - resources
      properties:
        resources:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/ResourceBlockData'
    ResourceBlockData:
      type: object
      required:
        - permissions
        - relations
        - roles
      properties:
        roles:
          type: array
          items:
            type: string
        permissions:
          type: array
          items:
            type: string
        relations:
          type: object
          additionalProperties:
            type: string
  securitySchemes:
    ApiKey:
      description: Requires an API key to access.
      type: http
      scheme: bearer
      bearerFormat: Bearer e_0123_123_token0123

````