How-To Guides
Add Data

Adding Data to Oso Cloud

Oso Cloud stores facts to represent authorization-relevant data in your app. To add and update facts stored in Oso Cloud, your applications can write facts using the API.

Clients

Add facts to Oso Cloud using the tell method: ``

CLINodePythonGoRuby
oso-cloud tell has_role User:bob owner Organization:acme

If you need to add multiple facts at once, you can use the corresponding bulk_tell method in every SDK (bulk_tell is not currently available in the CLI):

NodePythonGoRuby
await oso.bulkTell([
  ["has_role", {type: "User", id: "bob"}, "owner", {type: "Organization", id: "acme"}], 
  ["has_relation", {type: "Repository", id: "anvil"}, "parent", {type: "Organization", id: "acme"}]
]);

The bulk_tell method is more than just a convenient way of avoiding a for-loop, it also writes the full set of facts simultaneously. This is useful if you need to write a set of related facts and want to ensure that no authorize requests are made using only a subset of those facts.

In the dashboard

You can also add facts from the facts page of the dashboard by clicking "Add a Fact".

Fact Syntax

Facts are represented slightly differently depending on which of the above methods you are using.

If we wanted to add the fact has_role(User:bob, String:owner, Organization:acme) with the cli or on the dashboard, we'd represent it with spaces as: has_role User:bob "owner" Organization:acme.

For convenience and safety, the tell methods in Oso Cloud clients take language objects rather than strings. The details are different depending on the client. You can refer to the examples on this or check out the docs for your client library for more detail.