> ## 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.

# Post actions

> Fetches a list of actions which an actor can perform on a particular resource.



## OpenAPI

````yaml post /actions
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:
  /actions:
    post:
      tags:
        - Check API
      description: >-
        Fetches a list of actions which an actor can perform on a particular
        resource.
      operationId: post_actions
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ActionsQuery'
        required: true
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ActionsResult'
        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 all actions user can perform on repository
            const user = { type: "User", id: "alice" };
            const repository = { type: "Repository", id: "anvils" };
            const actions = await oso.actions(user, repository);
            console.log("Available actions:", actions);

            // With context facts
            const issue = { type: "Issue", id: "123" };
            const contextActions = await oso.actions(
              user, 
              issue, 
              [["has_relation", issue, "parent", repository]]
            );
        - lang: python
          label: Python
          source: |
            import os
            from oso_cloud import Oso, Value

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

            # Get all actions user can perform on repository
            alice = Value("User", "alice")
            repository = Value("Repository", "anvils")
            actions = oso.actions(alice, repository)
            print(f"Available actions: {actions}")

            # With context facts
            issue = Value("Issue", "123")
            actions = oso.actions(
                alice, 
                issue, 
                context_facts=[("has_relation", issue, "parent", repository)]
            )
        - 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 all actions user can perform on repository

            user := oso.NewValue("User", "alice")

            repository := oso.NewValue("Repository", "anvils")

            actions, err := osoClient.Actions(user, repository)

            if err != nil {
                log.Fatal(err)
            }

            fmt.Printf("Available actions: %v\n", actions)


            // With context facts

            issue := oso.NewValue("Issue", "123")

            contextFacts := []oso.Fact{
                oso.NewFact("has_relation", issue, oso.String("parent"), repository),
            }

            actions, err = osoClient.ActionsWithContext(user, issue,
            contextFacts)

            }
        - lang: java
          label: Java
          source: |
            package com.mycompany;

            import java.io.IOException;
            import java.util.Arrays;
            import java.util.List;
            import com.osohq.oso_cloud.Oso;
            import com.osohq.oso_cloud.api.ApiException;
            import com.osohq.oso_cloud.api.Value;

            public class App {
                public static void main(String[] args) {
                    String apiKey = System.getenv("OSO_CLOUD_API_KEY");
                    Oso oso = new Oso(apiKey);
                    
                    try {
                        // Get all actions user can perform on repository
                        Value user = new Value("User", "alice");
                        Value repository = new Value("Repository", "anvils");
                        List<String> actions = oso.actions(user, repository);
                        System.out.println("Available actions: " + actions);
                        
                        // With context facts
                        Value issue = new Value("Issue", "123");
                        List<String> contextActions = oso.actions(user, issue,
                            Arrays.asList(Arrays.asList("has_relation", issue, "parent", repository)));
                    } catch (IOException | ApiException e) {
                        System.err.println("Error: " + 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 all actions user can perform on repository

            user = OsoCloud::Value.new(type: "User", id: "alice")

            repository = OsoCloud::Value.new(type: "Repository", id: "anvils")

            actions = oso.actions(user, repository)

            puts "Available actions: #{actions}"


            # With context facts

            issue = OsoCloud::Value.new(type: "Issue", id: "123")

            context_actions = oso.actions(user, issue,
              context_facts: [["has_relation", issue, "parent", repository]])
        - 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 all actions user can perform on repository

            var user = new Value("User", "alice");

            var repository = new Value("Repository", "anvils");

            var actions = await oso.Actions(user, repository);

            Console.WriteLine($"Available actions: {string.Join(", ",
            actions)}");


            // With context facts

            var issue = new Value("Issue", "123");

            var contextActions = await oso.Actions(user, issue,
                contextFacts: new[] { new[] { "has_relation", issue, "parent", repository } });
components:
  schemas:
    ActionsQuery:
      type: object
      required:
        - actor_id
        - actor_type
        - resource_id
        - resource_type
      properties:
        actor_type:
          type: string
        actor_id:
          type: string
        resource_type:
          type: string
        resource_id:
          type: string
        context_facts:
          default: []
          type: array
          items:
            $ref: '#/components/schemas/Fact'
    ActionsResult:
      type: object
      required:
        - results
      properties:
        results:
          type: array
          items:
            type: string
    ApiError:
      type: object
      required:
        - message
      properties:
        message:
          type: string
    Fact:
      description: 'A pattern object for matching authorization-relevant data, ie: facts.'
      type: object
      required:
        - args
        - predicate
      properties:
        predicate:
          type: string
        args:
          type: array
          items:
            $ref: '#/components/schemas/Value'
    Value:
      type: object
      properties:
        type:
          type: string
          nullable: true
        id:
          type: string
          nullable: true
  securitySchemes:
    ApiKey:
      description: Requires an API key to access.
      type: http
      scheme: bearer
      bearerFormat: Bearer e_0123_123_token0123

````