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

> Adds a new fact.

DEPRECATED: Prefer `POST /batch` with payload `[{"inserts": [<fact>]}]`.



## OpenAPI

````yaml /reference/openapi.json post /facts
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:
  /facts:
    post:
      tags:
        - Centralized Authorization Data
      description: |-
        Adds a new fact.

        DEPRECATED: Prefer `POST /batch` with payload `[{"inserts": [<fact>]}]`.
      operationId: post_facts
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Fact'
        required: true
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Fact'
        default:
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
      deprecated: true
      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);

            // Insert a single fact
            await oso.insert([
              "has_role", 
              { type: "User", id: "alice" }, 
              "maintainer", 
              { type: "Repository", id: "anvils" }
            ]);
        - 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))

            # Insert a single fact
            user = Value("User", "alice")
            repo = Value("Repository", "anvils")
            oso.insert(("has_role", user, "maintainer", repo))
        - 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)

                // Insert a single fact
                alice := oso.NewValue("User", "alice")
                repo := oso.NewValue("Repository", "anvils")
                err := osoClient.Insert(oso.NewFact("has_role", alice, oso.String("maintainer"), repo))
                if err != nil {
                    log.Fatal(err)
                }
            }
        - 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;
            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 {
                        // Insert a single fact
                        Value user = new Value("User", "alice");
                        Value repo = new Value("Repository", "anvils");
                        oso.insert("has_role", user, "maintainer", repo);
                    } 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)


            # Insert a single fact

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

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

            oso.tell("has_role", user, "maintainer", repo)
        - lang: csharp
          label: C#
          source: >
            using OsoCloud;


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

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


            // Insert a single fact

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

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

            await oso.Insert("has_role", user, "maintainer", repo);
components:
  schemas:
    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'
    ApiError:
      type: object
      required:
        - message
      properties:
        message:
          type: string
    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

````