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

# Facts Management

> CRUD operations for managing facts.

## Insert Facts

Add new facts to your authorization data.

**Node.js**

```javascript theme={null}
// Insert a single fact
await oso.insert([
  "has_role", 
  { type: "User", id: "bob" }, 
  "owner", 
  { type: "Organization", id: "acme" }
]);

// Insert with variables for reuse
const user = { type: "User", id: "alice" };
const repo = { type: "Repository", id: "anvils" };
await oso.insert(["has_role", user, "maintainer", repo]);
```

**Signature:** `oso.insert([name, ...args])`

```python theme={null}
from oso_cloud import Value

# Insert a single fact
oso.insert((
  "has_role", 
  Value("User", "bob"), 
  "owner", 
  Value("Organization", "acme")
))

# Insert with variables for reuse
user = Value("User", "alice")
repo = Value("Repository", "anvils")
oso.insert(("has_role", user, "maintainer", repo))
```

**Signature:** `oso.insert((name, *args))`

```go theme={null}
import oso "github.com/osohq/go-oso-cloud/v2"

// Insert a single fact
user := oso.NewValue("User", "bob")
role := oso.String("owner")
resource := oso.NewValue("Organization", "acme")
err := osoClient.Insert(oso.NewFact("has_role", user, role, resource))
if err != nil {
    log.Fatal(err)
}

// Insert with reusable variables
alice := oso.NewValue("User", "alice")
repo := oso.NewValue("Repository", "anvils")
err = osoClient.Insert(oso.NewFact("has_role", alice, oso.String("maintainer"), repo))
```

**Signature:** `osoClient.Insert(fact)`

```java theme={null}
// Insert a single fact
oso.insert(new Fact(
  "has_role", 
  new Value("User", "bob"), 
  new Value("owner"), 
  new Value("Organization", "acme")
));

// Insert with variables for reuse
Value user = new Value("User", "alice");
Value repo = new Value("Repository", "anvils");
oso.insert(new Fact("has_role", user, new Value("maintainer"), repo));
```

**Signature:** `oso.insert(Fact)`

```ruby theme={null}
# Insert a single fact
oso.tell(
  "has_role", 
  OsoCloud::Value.new(type: "User", id: "bob"), 
  "owner", 
  OsoCloud::Value.new(type: "Organization", id: "acme")
)

# Insert with variables for reuse
user = OsoCloud::Value.new(type: "User", id: "alice")
repo = OsoCloud::Value.new(type: "Repository", id: "anvils")
oso.tell("has_role", user, "maintainer", repo)

# Bulk insert multiple facts
oso.bulk_tell([
  ["has_role", user, "owner", org],
  ["has_role", user, "maintainer", repo]
])
```

**Signature:** `oso.tell(name, *args)` | `oso.bulk_tell([*[name, *args]])`

```csharp theme={null}
// Insert a single fact
await oso.Tell("has_role", new List<Value> { 
  new Value("User", "bob"), 
  new Value("String", "owner"), 
  new Value("Organization", "acme") 
});

// Insert with variables for reuse
var user = new Value("User", "alice");
var repo = new Value("Repository", "anvils");
await oso.Tell("has_role", new List<Value> { user, new Value("String", "maintainer"), repo });

// Bulk insert multiple facts
await oso.BulkTell(new List<Fact> { 
  new Fact("has_role", new List<Value> { user, new Value("String", "owner"), org }),
  new Fact("has_role", new List<Value> { user, new Value("String", "maintainer"), repo })
});
```

**Signature:** `oso.Tell(name, args)` | `oso.BulkTell(facts)`

**CLI**

```bash theme={null}
# Insert a single fact
oso-cloud tell has_role User:bob "owner" Organization:acme

# Insert with different resource types
oso-cloud tell has_role User:alice "maintainer" Repository:anvils
oso-cloud tell has_permission User:charlie "read" Issue:123
```

**Signature:** `oso-cloud tell <predicate> ([<type>:]<id>)*`

## Delete Facts

Remove facts from your authorization data using exact matches or patterns.

**Node.js**

```javascript theme={null}
// Delete specific fact
await oso.delete([
  "has_role", 
  { type: "User", id: "bob" }, 
  "maintainer", 
  { type: "Repository", id: "anvils" }
]);

// Delete using patterns (null = wildcard)
await oso.delete(["has_role", { type: "User", id: "bob" }, null, null]); // All roles for bob
await oso.delete(["has_role", null, "admin", null]); // All admin roles
```

**Signature:** `oso.delete([name, ...args])`

```python theme={null}
from oso_cloud import Value, ValueOfType

# Delete specific fact
oso.delete((
  "has_role", 
  Value("User", "bob"), 
  "maintainer", 
  Value("Repository", "anvils")
))

# Delete using patterns
oso.delete(("has_role", Value("User", "bob"), None, None))  # All roles for bob
oso.delete(("has_role", Value("User", "bob"), None, ValueOfType("Repository")))  # All repo roles for bob
```

**Signature:** `oso.delete((name, *args))`

```go theme={null}
// Delete specific fact
err := osoClient.Delete(oso.NewFact(
  "has_role", 
  oso.NewValue("User", "bob"), 
  oso.String("maintainer"), 
  oso.NewValue("Repository", "anvil")
))

// Delete using patterns
err = osoClient.Delete(oso.NewFactPattern(
  "has_role", 
  oso.NewValue("User", "alice"), 
  nil,  // Any role
  oso.NewValueOfType("Repo")  // Any repo
))
```

**Signature:** `osoClient.Delete(pattern)`

```java theme={null}
// Delete specific fact
oso.delete(new Fact(
  "has_role", 
  user, 
  new Value("maintainer"), 
  repo
));

// Delete using patterns
oso.delete(new FactPattern(
  "has_role", 
  user, 
  ValuePattern.ANY,  // Any role
  ValuePattern.ANY   // Any resource
));

oso.delete(new FactPattern(
  "has_role", 
  user, 
  new Value("member"), 
  new ValuePattern.ValueOfType("Organization")  // Any organization
));
```

**Signature:** `oso.delete(Fact/FactPattern)`

```ruby theme={null}
# Delete specific fact
oso.delete("has_role", user, "maintainer", repo)

# Delete using patterns (nil = wildcard)
oso.delete("has_role", user, nil, repo)  # All roles for user on repo

# Bulk delete multiple facts
oso.bulk_delete([
  ["has_role", user, "owner", org],
  ["has_role", user, "maintainer", repo]
])
```

**Signature:** `oso.delete(name, *args)` | `oso.bulk_delete([*[name, *args]])`

```csharp theme={null}
// Delete specific fact
await oso.Delete("has_role", new List<Value> { user, new Value("String", "maintainer"), repo });

// Delete using patterns (null = wildcard)
await oso.Delete("has_role", new List<Value> { 
  new Value("User", null),     // Any user
  new Value("String", null),   // Any role
  repo 
});

// Bulk delete multiple facts
await oso.BulkDelete(new List<Fact> { fact1, fact2 });
```

**Signature:** `oso.Delete(name, args)` | `oso.BulkDelete(facts)`

**CLI**

```bash theme={null}
# Delete specific fact
oso-cloud delete has_role User:bob "maintainer" Repository:anvil

# Delete using wildcards (_)
oso-cloud delete has_role User:_ _ Repository:anvil  # All user roles on anvil repo
oso-cloud delete has_role User:bob _ _              # All roles for bob
```

**Signature:** `oso-cloud delete <predicate> ({_, <type>}:{_, <id>})*`

## Query Facts

Retrieve facts from your authorization data using exact matches or patterns.

**Node.js**

```javascript theme={null}
// Get specific fact
const facts = await oso.get([
  "has_role", 
  { type: "User", id: "bob" }, 
  "admin", 
  { type: "Repository", id: "anvils" }
]);

// Query with patterns
const allRepoRoles = await oso.get([
  "has_role", 
  null,  // Any user
  null,  // Any role
  { type: "Repository", id: "anvils" }
]);

console.log("Facts found:", facts.length);
```

**Signature:** `oso.get([name, ...args])`

```python theme={null}
# Get specific fact
facts = oso.get((
  "has_role", 
  Value("User", "bob"), 
  "admin", 
  Value("Repository", "anvils")
))

# Query with patterns
all_repo_roles = oso.get((
  "has_role", 
  None,  # Any user
  None,  # Any role
  Value("Repository", "anvils")
))

# Query by type
repo_roles = oso.get((
  "has_role", 
  None, 
  None, 
  ValueOfType("Repository")  # Any repository
))

print(f"Facts found: {len(facts)}")
```

**Signature:** `oso.get((name, *args))`

```go theme={null}
// Get specific fact
facts, err := osoClient.Get(oso.NewFact(
  "has_role", 
  user, 
  oso.String("admin"), 
  repo
))

// Query with patterns
allRepoRoles, err := osoClient.Get(oso.NewFactPattern(
  "has_role", 
  nil,  // Any user
  nil,  // Any role
  repo
))

// Query by type
repoRoles, err := osoClient.Get(oso.NewFactPattern(
  "has_role", 
  nil, 
  nil, 
  oso.NewValueOfType("Repository")
))

fmt.Printf("Facts found: %d\n", len(facts))
```

**Signature:** `osoClient.Get(pattern)`

```java theme={null}
// Get specific fact
Fact[] specificFacts = oso.get(new FactPattern(
  "has_role", 
  user, 
  new Value("admin"), 
  repo
));

// Query with patterns
Fact[] userRoles = oso.get(new FactPattern(
  "has_role", 
  user, 
  ValuePattern.ANY,  // Any role
  ValuePattern.ANY   // Any resource
));

Fact[] repoRoles = oso.get(new FactPattern(
  "has_role", 
  new ValuePattern.ValueOfType("User"),  // Any user
  ValuePattern.ANY, 
  repo
));

System.out.println("Facts found: " + specificFacts.length);
```

**Signature:** `oso.get(FactPattern)`

```ruby theme={null}
# Get specific fact
facts = oso.get("has_role", user, "admin", repo)

# Query with patterns (nil = wildcard)
all_user_roles = oso.get("has_role", user, nil, nil)  # All roles for user
repo_roles = oso.get("has_role", nil, nil, repo)      # All roles on repo

puts "Facts found: #{facts.length}"
```

**Signature:** `oso.get(name, *args)`

```csharp theme={null}
// Get specific fact
var facts = await oso.Get("has_role", new List<Value> { user, new Value("String", "admin"), repo });

// Query with patterns
var allUserRoles = await oso.Get("has_role", new List<Value> { 
  user, 
  new Value("String", null),  // Any role
  new Value(null, null)       // Any resource
});

Console.WriteLine($"Facts found: {facts.Count}");
```

**Signature:** `oso.Get(name, args)`

**CLI**

```bash theme={null}
# Get specific facts
oso-cloud get has_role _ "maintainer" Repository:_

# Query all facts for a user
oso-cloud get has_role User:bob _ _

# Inspect all facts for an object
oso-cloud inspect User:bob
```

**Signature:** `oso-cloud get {_, <predicate>} ({_, <type>}:{_, <id>})*`

## Batch Operations

Perform multiple fact operations atomically for better performance and consistency.

**Node.js**

```javascript theme={null}
// Batch multiple operations
await oso.batch((tx) => {
  // Insert new facts
  tx.insert(["has_role", user, "owner", org]);
  tx.insert(["has_permission", user, "admin", repo]);
  
  // Delete old facts
  tx.delete(["has_role", user, "maintainer", repo]);
  tx.delete(["has_role", user, "member", org]);
});
```

**Signature:** `oso.batch((tx) => { })`

```python theme={null}
# Batch multiple operations
with oso.batch() as tx:
    # Insert new facts
    tx.insert(("has_role", user, "owner", org))
    tx.insert(("has_permission", user, "admin", repo))
    
    # Delete old facts
    tx.delete(("has_role", user, "maintainer", repo))
    tx.delete(("has_role", user, "member", org))
```

**Signature:** `oso.batch()`

```go theme={null}
// Batch multiple operations
err := osoClient.Batch(func(tx oso.BatchTransaction) {
    // Insert new facts
    tx.Insert(oso.NewFact("has_role", user, oso.String("owner"), org))
    tx.Insert(oso.NewFact("has_permission", user, oso.String("admin"), repo))
    
    // Delete old facts
    tx.Delete(oso.NewFact("has_role", user, oso.String("maintainer"), repo))
    tx.Delete(oso.NewFactPattern("has_role", user, nil, org))
})
```

**Signature:** `osoClient.Batch(fn)`

```java theme={null}
// Batch multiple operations
oso.batch(tx -> {
    // Insert facts from collections
    factsToInsert.forEach(tx::insert);
    
    // Delete specific facts
    factsToDelete.forEach(tx::delete);
    
    // Delete using patterns
    tx.delete(patternToDelete);
});
```

**Signature:** `oso.batch(Consumer<BatchTransaction>)`

```ruby theme={null}
# Batch operations using bulk methods
oso.bulk(
  delete: [
    ["has_role", user, nil, repo],      # Delete all user roles on repo
    ["has_role", user, "owner", org]    # Delete specific role
  ],
  tell: [
    ["has_role", user, "member", repo], # Insert new role
    ["has_permission", user, "read", repo] # Insert permission
  ]
)
```

**Signature:** `oso.bulk(delete: [*facts], tell: [*facts])`

```csharp theme={null}
// Batch operations
await oso.Bulk(
  delete: new List<Fact> { deleteFactPattern },
  tell: new List<Fact> { 
    new Fact("has_role", new List<Value> { user, new Value("String", "member"), repo }),
    new Fact("has_permission", new List<Value> { user, new Value("String", "read"), repo })
  }
);
```

**Signature:** `oso.Bulk(delete, tell)`

**CLI**

```bash theme={null}
# Sync data from configuration file
oso-cloud reconcile config.yaml

# Perform updates with timeout
oso-cloud reconcile --perform-updates --timeout 1200 config.yaml

# Get summarized output
oso-cloud reconcile --summarized-output config.yaml
```

**Signature:** `oso-cloud reconcile <config-file>`


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.