Skip to content

Unity SDK

com.onlyworlds.sdk reads and writes OnlyWorlds worlds from Unity, on onlyworlds.com or in a world folder on disk. For what that gives a game, see Games. It has three parts:

Part C# assembly What it is
Bridge OnlyWorlds.Sdk Typed models for the 22 element types, a client for the REST API v2, and sync from the changes feed. This is what game code links against.
Cache OnlyWorlds.Sdk A world as a ScriptableObject asset: inspectable, offline, and kept across domain reloads. Filled from the API or from a world folder on disk.
Viewer OnlyWorlds.Sdk.Editor A world browser in the Editor: Window → OnlyWorlds → World Browser.

The models are generated from schema-dist at a pinned tag, never written by hand. The source is OnlyWorlds/unity-sdk, under the MIT licence.

Unity 6 (6000.0) or later, with Git installed: the Package Manager needs it to add a package from a git URL. In the Package Manager: + → Add package from git URL, and paste:

https://github.com/OnlyWorlds/unity-sdk.git?path=/Packages/com.onlyworlds.sdk

To pin a release, add a tag from the repository’s tags to the end of the URL (…com.onlyworlds.sdk#v<version>). The package depends on Newtonsoft JSON (com.unity.nuget.newtonsoft-json), which the Package Manager resolves for you.

Platforms: the requests go through UnityWebRequest, and the JSON converters are marked to survive IL2CPP code stripping. A world archive loads in Android (IL2CPP) and WebGL builds at Minimal stripping. Before you raise the stripping level, or ship to phones, try a build on a real device. In a web player, every call returns since v0.35.0 (before it, each call after the first answer hung). A web player built with the DiskSizeLTO code optimization halts when it reads a deflated .owworld (its zlib traps on a DeflateStream; measured on Unity 6000.4.0f1): pack the world for it with StoreForWebPlayers (Ship a world with your game).

The package ships a Quick Start sample (Package Manager → OnlyWorlds SDK → Samples). It reads a world at runtime, from the API or from a cache asset, and shows nullable fields, link resolution and error handling.

No account yet? The demo key 0000000001 reads Moppetopia, a public sample world, with no PIN. It’s the same key the other SDKs start with, so the output matches theirs.

using OnlyWorlds.Sdk;
using UnityEngine;
public class ReadWorld : MonoBehaviour
{
// A read key (ow_r_) needs no PIN. A key in a build can be extracted from it,
// so ship only a read key, and only for a world your players may read.
[SerializeField] private string apiKey = "0000000001";
private async void Start()
{
var client = new OWClient(new OWClientConfig
{
ApiKey = apiKey,
Transport = new UnityWebRequestTransport(),
});
var characters = await client.ListAllAsync<OWCharacter>("character");
foreach (var c in characters)
{
var level = c.Level.HasValue ? c.Level.Value.ToString() : "unset";
Debug.Log($"{c.Name}: level {level}");
}
}
}

ListAllAsync follows the cursor through every page. ListAsync returns one page, and GetAsync one element by id. See Keys and PINs for the kinds of key.

List by a link (since v0.26.0). OWListParams.Filter filters on the type’s single links, by field name: {"parent_location": id} lists a place’s rooms, and an empty value lists the rows with none (filters). A key not shaped like a field name (a lowercase letter, then lowercase letters, digits and _) throws ArgumentException before anything is sent; a field the type does not filter on is the server’s 422, which names every filter it takes.

Links are ids. c.Location is a location’s id, or null when unset, and c.Species is a list of ids. A cache resolves them: cache.Get<OWLocation>(c.Location), cache.Resolve<OWSpecies>(c.Species). Without a cache, you fetch each by id.

Errors come in two kinds. OWApiError means the server answered and refused: it carries StatusCode, Code, Param, DocUrl (a link into Errors), IsRetryable and RetryAfter (seconds to wait, or null); the client never retries on its own. Since v0.48.0 OWApiError.FieldsRefusal holds what a 422 on fields says (sparse fields): every unknown name in the order sent, the types that have each one, and the names this type takes, so a read is corrected in one try. OWTransportError means no answer arrived at all.

Dates on the world’s own calendar. OWCalendar reads a world’s calendar (the atlas_calendar field Atlas writes) and formats and parses dates the way Atlas and the TypeScript SDK do; OWCalendarLens.WorldCalendars finds the calendars a world holds. A missing or malformed calendar reads as null. Since v0.5.0; since v0.8.0 it follows the atlas_calendar profile and passes the profile’s conformance fixture, as the TypeScript SDK does. Since v0.20.0 it reads the profile’s version 2: a leap rule’s except (every 4 years, not every 100, yet every 400) and offset (1 for a calendar with no year 0), so Gregorian and Harptos read exact, and an era with no end runs to the next counting-up era whatever order the eras are listed in. OWCalendar.IntercalaryInYear says whether a leap day falls in a year. Since v0.36.0 it replays the TypeScript SDK’s own answers (labels, parses, durations, validations); OWCalendar.ValidateValue checks a raw atlas_calendar value and names what is wrong in the TypeScript SDK’s words, FormatDuration takes a span that need not be whole, and an era whose year_base is not 0 or 1 is refused.

Messages between members. OWMessage reads the message profile: IsMessage, RecipientsOf, IsAddressedTo and IsToEveryone (an empty list is everyone; since v0.41.0 each answers only for a message, a Character named twice is one recipient, and a body that is no message is addressed to nobody), IsSentBy (the claim), SenderStatus(message, members) (Verified, Mismatch with the author’s Character, or Unverifiable: show anything but verified as a claim), ReadMarkOf (a reader’s own-hand read mark), UnreadFor and ThreadOf, held to the profile’s shared fixture as the TypeScript and Python readers are; IsReadMark (v0.22.0) tells a read mark from other Relations. Since v0.23.0 it reads a list trimmed for its reader (serial 76): HasUnseenRecipients(message, keyless) (someone you cannot see is a recipient; never who or how many), IsToEveryone takes keyless, OWSenderStatus.Unseen (a sender you cannot see), EditedBy(message, members) (an edit by another hand), and IsNote and NoteOf (a member’s own Note, never a message); OWApiError.IsServedTrimmedNotWritable names a write that carried the mark back. OWFrontDoor.MySeats lists the AI and player seats a person’s key answers for, and OWApiError.IsCharacterPlayed names a refused delete of a Character someone plays. Since v0.21.0.

Addresses, lenses and the Charter (since v0.24.0). OWAddress reads and writes an element’s address and its ow:// links, by the address profile, and passes the profile’s shared test cases. Since v0.40.0 OWAddress.ReadLinkAt(text, index) finds an address in prose, as the TypeScript SDK’s readOwLinkAt does (since v0.40.1 none that begins inside a word): the address that starts exactly at index, as an OWAddressAt (Reading, and End, the index just past it), or null when none starts there. index and End count UTF-16 code units, as string.IndexOf does. Since v0.41.0 OWAddress.FindLinks(text) finds every address in a text, in order, as findOwLinks does: each an OWAddressFound (Start, End, Reading), the search going on from the end of each one found, so no two overlap. OWLens.Resolve(world, lens, reader) reads a world through a lens, as onlyworlds.com serves each reader, and OWGraph reads the world, or a lens’s reading of it, as nodes and edges. OWCharter reads a world’s Charter, Guide and Domains by the charter profile. The client also calls the server’s lens routes, and an account token reads the world it names. A graph node’s Family, like OWPresentation.FamilyOf, is the type’s colour group by its colour word, blue, green, pink or amber (since v0.25.0; Construct is pink, Ability amber). A colour word the presentation file cannot draw throws OWPresentationException, naming the word and the type, rather than drawing a default. Since v0.26.0 OWReadingAids.Of(answer) reads the world’s reading aids from a GET /me answer (OWClient.GetMeAsync): the Charter, the Guide and the Domains as onlyworlds.com serves them for the key, not recomputed, and null from an older server. An agent’s join answer carries the same as OWJoined.ReadingAids. Since v0.27.0 the packet carries the world’s strand as OWReadingAids.Strand, each slot {id, name} or null (IsEmpty when the world has none in the key’s view), and OWStrand.Of(world, elements, reader, open, hiddenIds) reads the same strand from a world you hold. Since v0.32.0 OWGraphOptions.ReadingAids brings the reading aids back into an unlensed graph, each node marked reading_aid (OWGraphMark.ReadingAid); any signed reader may ask it, a public reader is refused by name, and a flag never widens a lens. Since v0.45.0 a co-builder has its own rung, OWLensReader.CoBuilder() (OWLensRung.CoBuilder): the whole world as the owner reads it, hidden elements included, with none of the owner’s two counts, and OWGraph.Read answers a co-builder’s graph as a keeper’s (the Hidden and Proposed flags and their counts, OWGraphCut.KeeperOnly; not_visible and anchor_not_visible stay the owner’s, OWGraphCut.OwnerOnly). OWLensReader.Contributor takes an optional whole, the hidden elements that contributor made: each is in its view, its body marked hidden: true.

Open with, and ow:// links (since v0.26.0). OWOpeners.For(tools, kind, address, surface) gives the rows of an Open with menu for a world or one of its elements, as the TypeScript SDK’s openersFor does and on the same shared fixture: onlyworlds.com first, then each listed tool with a link for that kind, in the list’s order. Since v0.31.0, OWOpeners.For(..., surface, new OWOpenersOptions { Element = body }) leaves out a tool that cannot open that element: the list’s element_skips names what a tool’s element door skips (room, hidden, proposed, map_space, reading_aid), each read as OWGraph.Read reads it. Since v0.34.0 a tool that opens one kind of element is offered only on that kind: the list’s element_types (OWToolOpen.ElementTypes, null for every type), read from the address’s type word, so Tactical Tangle is offered on a Character and on no other type. Since v0.33.0 a signed-out visitor (the public audience) is given the tools that need an account, each a row with OWOpenerState.NeedsAnAccount (“Needs an account”) that opens nothing: draw it disabled. Since v0.35.0 a row whose list entry carries open.opens_public (OWToolOpen.OpensPublic) is live there instead, since such a tool opens a public world with no account; anywhere else it reads as its needs says. OWTools.All is the tools list baked in at the release, so a tool listed later is offered from the next one. OWLinkListener listens only on the machine’s loopback address for a link clicked outside Unity, reads it with OWAddress.TryParseLink, and hands the reading to your callback on the main thread (or through a dispatch you pass); since v0.29.0 a second constructor also hands the link as received, for a reading that cannot be written back as an address (a site address naming its world by slug), and a dispatch declines by returning false; a taken port is reported as port_taken, so two Editors can run side by side. Tools~/ow-link is an opt-in forwarder for Windows that the system runs for ow:// links: it offers the link to the ports in its config, in order (a running Editor, then a running player), and starts the configured player with it when none takes it. Its install.ps1 registers it for the current user only, with no administrator rights, and nothing is registered unless you run it. Since v0.30.0 install.ps1 -Scheme mygame registers your game’s own scheme instead (mygame: links, the config’s scheme naming the same); such a link reaches the listener as the ow: address it carries, and ow: stays the default.

A world’s own words for the types. OWNames.TypeWord(world, type, supertype, many) reads the World’s x_names (the names profile) and returns the word to show for a type, Employee for a Character in a work world, or null for the standard’s name; the supertype’s word comes first, and many asks for the plural. A display lookup only: routes, folders and field names keep the standard’s. Since v0.14.0, on the profile’s shared fixture.

The strand (since v0.27.0). OWStrand.Of(world, elements, reader) reads a world’s story in miniature by the strand profile, through the lens reader’s own view: the story the World’s x_strand names (Narrative), one of its events (Event), that event’s place (Location), the story’s protagonist (Character), where the hero is now (Now), and whether then and now are one place (Same), each slot {id, name} or null, as the TypeScript SDK’s strandOf reads it. OWReadingAids.Strand is the strand keel serves on the front door (GET /me and an agent’s join answer), read as served.

Records (since v0.30.0). OWRecord.Of(characterId, elements) lists one Character’s records by the record profile, the game runs they took part in, newest first, as the TypeScript SDK’s recordsOf does and on the profile’s own fixture. A record is an Event whose x_record names the game (Tool) and when it was played (PlayedAt), with optional Version, Seed and Outcome. Each entry carries the Event’s id and name, this Character’s Seat when the mark names one, and its Stories, the Narratives that list the run and name the Character as protagonist, narrator or both. A run or a story still proposed is not read; since v0.32.0 an empty review mark reads as settled, as the other readers read it. OWRecord.MarkOf(element) reads one Event’s mark, or null when its shape is not the profile’s.

Reports as threads, and how an element is shown (since v0.39.0). OWReport.ThreadsOf(narratives) reads the report profile’s threads from the Narratives as you were served them, as the TypeScript SDK’s reportThreadsOf does: what each report’s parent is (Parents), the reports grouped under the report or board entry they name, in created_at order (Groups), and a chain or a report that names itself (Lints). OWViews.ViewOf(element) reads the distribution’s views table, as the TypeScript SDK’s viewOf does: the row that matches, the one sentence a card or a list row shows, the marks at the head of its page, and the fields its page draws, in order.

A report’s lines (since v0.43.0). OWReport.ReadLines(text, world) reads a report’s consequences line by line as the report profile’s rule 10 reads them, and OWReport.ReadLine(line, world) reads one line, each as the TypeScript SDK’s readReportLine does. An OWReportLine gives the Line, the Words a reader shows, and the line’s Address with its Reading, Start and End (null when the line names no element of this world). The profile’s lines fixture runs whole in the package’s tests.

Work items (since v0.48.0). OWPacket reads the packet profile’s work items (a Relation with supertype Work item), as the TypeScript SDK’s readers do: WorkStateOf(item) (open, taken, done or standing, else null), IsOpenWork(item) (true for open and taken only), AskerOf(item, world) (the Character its x_packet_from names) and WorkOf(items, world, sourceWorld), every item’s state, its elements and what each Character is waiting on. The profile’s fixture is replayed in the package’s tests.

Names in the profiles’ order (since v0.48.0). OWText.TrimAndFold(text) trims Unicode’s white space at both ends and folds case by Unicode 15.1’s simple folding, and OWText.ByCodePoint compares two strings by code point, never by UTF-16 unit or a culture’s collation: names sort by their fold in that order, ties by id, as the TypeScript SDK’s trimAndFold and byCodePoint do. A plain trim and an invariant lower-casing are neither.

Talks and design parts (since v0.45.0). OWRoom.TalksOf(element) answers the talks a line in the room is in, each Object in its objects and each Construct in its constructs, as the TypeScript SDK’s talksOf does, and OWReport.TalksOf(element) the talks a report is shown with, as reportTalksOf does; anything that is no line in the room, or no report, answers none. OWCharter.DesignPartsOf(world, reader) answers the design parts that reader reads, each an OWDesignPart (its type, id and state): an Object or a Construct it is served whole whose subtype, trimmed and folded, is in design or locked, only where CharterOf finds a Charter for the same reader, as designPartsOf does.

The landing and map space (since v0.32.0). OWLanding.Of(graph, options) reads the first picture of a world where a visitor arrives, by the landing profile, from the graph OWGraph.Read answers for the visitor: Mode, Size, Clusters (the most-linked Characters, each with the nodes within Hops steps), Unclustered and Gaps (orphan, near_orphan, no_place, nobody_here), with Heads 5, Hops 1 and Size 24 by default, as the TypeScript SDK’s landingOf does. OWMapSpace.Of(elements) reads a world’s Maps, Zones, Markers and Pins as geometry by the map-space profile, from the elements as the reader is served them: Maps, Zones, Pins and Out, each answer’s ToJson() in the profile’s own words and order, as mapSpace does. Since v0.33.0 it reads serial 106’s rules too: two rows of one type with one id read as the last one served. Since v0.38.0 OWMapSpace.LayoutOf(map, maps, pins) reads one Map’s layout keys, as the TypeScript SDK’s layoutOf does: Layout is the Map’s x_layout.method (OWMapLayout.Board for a board, null on a Map that is not a layout map), Ground the id of the Map it stands on when that Map is among maps (its size is the served Map’s own), and Hand the Pins a new lay-out keeps where they are, in code point order; ToJson() is the profile’s {layout, ground, hand}, and OWMapSpace.Of reads neither key. Since v0.48.0 OWMapSpace.CarryOf(map, x, y, maps) carries a point on a child Map to its parent and each Map above it, one level at a time by each Map’s x_parent_frame (the map-space profile’s frame reading, as the TypeScript SDK’s carryOf); its Stop says why the walk ended and Lint what is wrong with a frame. Each passes its profile’s fixture case by case.

A world’s default picture (since v0.42.0). OWLayout.LayoutByKind(graph) lays out a world nobody laid out, from an OWWorldGraph (or a JObject {nodes, edges}), and OWLayout.LayoutAround(graph, focus, steps = 1) draws one element at 0, 0 with its neighbours on rings, as the TypeScript SDK’s layoutByKind and layoutAround do: the same points, by kind to the last bit and around within 1e-12, whatever order the graph is handed in. Each answers Method, Version 1 and Points in the order the nodes were given; a graph it cannot read is an ArgumentException. Since v0.45.0 OWLayout.LayoutByLinks3d(graph, elements, held, heldUnit) lays a whole world out in three dimensions by its links, as the TypeScript SDK’s layoutByLinks3d does, on all 116 cases of its fixture (to the last bit, and within 6e-8 where the page allows it); held and heldUnit keep elements where an earlier answer put them, and a refused call throws OWLayoutRefusedException with the page’s code. OWLayout.UnplacedByKind(graph, placed), UnplacedAround(graph, focus, placed, steps) and UnplacedByLinks3d(graph, placed) answer which elements a saved layout map has no Pin for, by id in code point order, from the graph and placed, the element ids of the Map’s Pins, as unplacedByKind and its two kin do.

A cache is a world stored as an asset in your project. Fill it in the Editor, and the build carries it: no network, no key and no waiting at runtime.

  1. Set a key in Window → OnlyWorlds → World Browser → Settings. It is stored in EditorPrefs on this machine, for this project alone, never in the project’s files or in version control. Test Connection names the world the key opens; with a PIN beside a write key it asks /me, so a wrong PIN shows there (401 invalid_credentials) rather than at your first write, while a write key with no PIN still connects, since reads need none (since v0.16.0).
  2. Connect, then Sync to Cache. The cache asset is written under Assets/OnlyWorlds/. Open Folder… fills a cache from a world folder on disk instead.
  3. Reference the asset from your scripts:
[SerializeField] private OWWorldCache world;
void Start()
{
foreach (var c in world.All<OWCharacter>("character"))
Debug.Log($"{c.Name} lives in {world.Get<OWLocation>(c.Location)?.Name}");
}

The same steps run from code. OWSync.BaselineAsync(client, cache) fetches the whole world. OWSync.IncrementalAsync(client, cache) applies only what changed since the cache’s cursor, from the changes feed, and falls back to a full baseline when the cursor can’t be trusted. Edits to world metadata are not in the feed, so poll GetWorldAsync when those matter. A hide or an unhide reaches the readers who still see the element as a feed row whose OWChange.ChangedAt, ChangedBy and ChangedVia say when, by which membership (null for the owner) and through which door; all three are null on every other row (since v0.20.0). Since v0.40.0 a row also reads UpdatedAt (an upsert’s), DeletedAt and Reason (a delete’s: deleted, hidden or out_of_view); remove the element from the local copy whatever the reason. OWFolderLoader.LoadInto(cache, path) reads a world folder and never writes to it. A folder Atlas wrote opens whole: its pins’ and markers’ links (map_id, zone_id) and the older spatial/ layout, with an element found in both served from elements/ (since v0.6.0).

A downloaded world file. OWEnvelopeLoader.LoadInto(cache, path) fills a cache from the one-file export an owner downloads from their world’s page (format: onlyworlds-world-export), read-only: the file is a capture, with nothing to sync and no folder to write back to. OWEnvelopeReader.Read(path) returns what a folder read returns, plus the file’s SchemaVersion and ExportedAt. A file whose format is anything else is refused whole. The file carries no images, members or time settings. OWFolderExport.ExportFileAsync(path, folder) writes the same file out as a world folder. Since v0.7.0.

A world as one file, .owworld. A world folder zipped under its own extension. Drop one into Assets/ and it imports as a read-only cache; Assets → OnlyWorlds → Pack World Folder… packs a folder from anywhere on disk into the project, and OWWorldArchive.Pack(folder, archive) does the same from code. Packing writes only the archive, leaves out dot-folders and .meta files, carries records/ byte for byte, drops world.json’s api block (it holds a key) unless you ask to keep it, and gives the same bytes for the same folder. The archive is read in memory and never extracted, and an entry name that climbs out of the world refuses the whole archive. Pictures in media/ travel but are not imported yet. Since v0.8.0. From v0.11.0 the archive follows the folder format’s archive rules and agrees with its conformance set: a refusal names its cause (OWFolderFormatException.Reason, one of the twelve OWWorldArchiveReason values, the same names the TypeScript SDK uses), a mimetype marker is read when present, the default budget is the spec’s floor (500,000 entries, 2 GiB), names are strict and case-fold collisions refuse (Unicode simple case folding, pinned at 15.1.0), the api block is stripped on read, and Pack writes entries in code point order. From v0.12.1 Pack places the marker first and stored, as the other two writers do; a reader still must not require one, since older files have none. From v0.12.0 an entry whose bytes fail its CRC-32 refuses the archive (every file, media and records included), and the conformance set runs as the package’s own test (79 of 79 at schema-dist serial 40). From v0.15.0 Pack leaves out a producer’s records marked private in records/RECORDS.json unless you pass includePrivateRecords: true, keeping RECORDS.json byte for byte (folder format 0.3.15, private records); the set is at 85 on serial 49. From v0.19.0 a world file is a copy and keeps hidden elements; Pack(..., includeHidden: false) makes one to hand to someone else, leaving every element file that carries the mark (or a doubt about it: anything but absent, null or false, OWPayload.IsHidden) out whole and listing the left-out paths in hiddenLeftOut (folder format 0.3.18, the hidden mark). From v0.19.1 the reader agrees with every other: a deflate stream that does not end at its declared size refuses the archive, and names are folded with Unicode 15.1’s NFC built from Unicode’s own files, never the runtime’s; it reads all 96 cases of the set at schema-dist serial 60. From v0.35.0 OWWorldArchive.Pack(folder, path, OWWorldArchivePackOptions) takes every choice the other overloads take, and one more, StoreForWebPlayers: every entry is written stored instead of deflated, so reading the file never needs an inflater (a web player built with DiskSizeLTO reads only such a file). The file is larger by about what deflate saves; a web server’s own response compression wins most of it back. Every read rule still holds, and the defaults write the bytes the other overloads write.

A friend with no account can join a world from a player link, and an AI from an AI link. OWJoin.ParseLink(text) takes the code out of a pasted link (…/join#ow_j_…) or a bare code. OWJoin.PreviewAsync(code, transport) (no key needed: pass new UnityWebRequestTransport()) says who the code is for (Reader: player, agent or person), the world and the role, without using the code. OWJoin.RedeemAsync(code, transport, name: …) spends it: a player gets a read key (ow_r_, no PIN) and the Character they read as; an agent, with agentName, gets its seat’s write key and secret. The answer is shown once, so keep Key (and an agent’s Pin) before anything else. A person’s link is joined with an account on onlyworlds.com, not here. Every bad code (used, expired, revoked, unknown) is the same 404. Since v0.7.0.

A table of players (a party link, since v0.9.0): IsTable on the preview tells one apart, with UsesLeft, NameRequired and Characters, each an OWJoinPick with its id, name, picture and whether it is Taken. Pass the pick as character to RedeemAsync, or a name at a table that lists none. OWApiError.IsCharacterTaken, IsCharacterInvalid and IsWorldFull name the three refusals; none of them spends the code.

Writes need a write key (ow_w_) and a secret in OWClientConfig.ApiPin: best an AI seat’s own ow_s_ secret, which works in one world and can be removed, or else the account PIN. Both can be extracted from a build, so write from the Editor, a server or a tool you control, never from a game you ship to players.

Send only what changed. A PATCH replaces every field it carries, so sending back an element fetched an hour ago undoes an hour of someone else’s edits. OWEdit snapshots an element and sends the difference:

var edit = OWEdit.Begin(character);
character.Level = 12;
await edit.CommitAsync(client, "character"); // sends { "level": 12 } and nothing else

Change link lists with EditLinksAsync. A PATCH with a link list replaces the whole list. EditLinksAsync<OWCharacter>("character", id, "friends", add: new[] { friendId }) adds and removes on the server, in one atomic step.

Check every bulk write. BulkAsync answers HTTP 200 even when some items failed. Read the result’s Errors and Failed, or call ThrowIfAnyFailed(). An item with an id replaces the element the world holds under it, whole; BulkAsync(items, createOnly: true) (since v0.46.0) creates every such item instead, never replacing: an id the world already holds fails that item with 409 id_conflict and the element stays as it was.

Make a retry safe with a key. Pass idempotencyKey to CreateAsync or BulkAsync: the ids of elements sent without one come from the key, so a retry after a lost answer replays the first instead of writing twice.

Say when an agent is writing. If an AI agent drives the client, set Agent = true on OWClientConfig: element writes then carry X-OW-Agent, and onlyworlds.com records them as an AI’s. Leave it off in a tool people use. Every element reads ChangedBy and ChangedVia, and OWWriteDoor.IsAgent(el.ChangedVia) tells an AI’s work apart; OWWriteDoor.Site (since v0.20.0) is the owner’s own page on onlyworlds.com, not an agent’s door.

Name your tool, and write only on what you read (since v0.16.0). OWClientConfig.Client names your tool on every element write (X-OW-Client, lower case letters, digits and hyphens; default unity-sdk), read back as ChangedClient and a tombstone’s DeletedClient. PatchAsync, DeleteAsync and EditLinksAsync take ifMatch (the change_seq you read): a moved element is refused with IsPreconditionFailed, the element as it now stands in Current, nothing written. ChangesAsync(headOnly: true) sends the last tip’s tag back and reads Unchanged on a 304, so a quiet world costs no budget. The PIN is sent only where keel checks it (writes, /me, and every call of a ten-digit key). /me and an agent’s join carry OWFrontDoor (who answers for the seat, its Character, the world’s Charter), OWRoom.IsRoomElement keeps a parlor’s room out of a lore view, and the six proposal calls are there, a 202 raised as OWProposedError. Since v0.44.0 OWFrontDoor.CharterElement and CharterSkillElements give the Charter and its skills as elements ({type, id}), each entry of the reading aids and each filled slot of the strand carries its Type, OWSeat reads MayChangeCharacter, MayChangeCharacterNote and FollowsSponsor from the seats list, and OWApiError.IsHostBlocked names a write the host in front of onlyworlds.com refused before the API saw it (the Blocked page).

The world’s own settings (since v0.17.0). PatchWorldAsync(partial) writes to the world itself (PATCH /world): only the keys you send change, and it returns the world as the server now holds it. A GetWorldAsync body can go back whole, since the keys the server refuses there are left out (OWPayload.WorldReadOnlyFields). Where a world first came from is written as the plain keys source and producer and served back under origin; the World’s own extension keys (x_*, atlas_*, shadow_*, 64 KB in all) go as given, and null removes one. A co-builder may send only time_range_current, source, producer and extension keys (anything more is IsOwnerOnly).

A world made on an account (since v0.18.0). CreateAccountWorldAsync(OWAccountWorldCreate) makes a world on the account (POST /account/worlds) with its one write key, shown once in Key. It takes an account token (ow_a_) only. Name is required, Pin only for an account with no PIN yet, and Source and Producer are the folder’s provenance lines, served back as the world’s origin.

More of the element calls (since v0.27.0). UpsertAsync<T> creates an element under your own id or writes it whole (PUT); AdoptAsync<T> changes who made it; HideAsync, UnhideAsync and ListHiddenAsync set and read the hidden mark; SetMyCharacterAsync picks the Character that is you in the world; GetMembersAsync reads the roster; HealthAsync asks keel whether it is up, with no credential.

The account’s worlds, keys, links and seats (since v0.27.0), each on an account token (ow_a_) alone: ListAccountWorldsAsync, MintWorldKeyAsync (scope, a name trimmed and at most 80 characters, and keep, and since v0.36.0 an idempotencyKey; see keys), RevokeWorldKeyAsync, and since v0.36.0 MadeWorldKeyAsync, which finds the key a mint made when its answer was lost (a lost mint); AcceptJoinAsync for a person’s invite link; CreateWorldLinkAsync, ListWorldLinksAsync and RevokeWorldLinkAsync (since v0.31.0 a link carries LandsOn, where it opens: site, the default, or on a person link dashboard, and since v0.47.0 a person link takes Note, the inviter’s note, which the join preview’s OWJoinPreview.Note reads back, a string or null, and since v0.49.0 OWJoinPreview.Glimpse carries the glimpse, up to five Things of the world and the Links among them, null for a guest’s link; see invite links); and the seats for your own AI, CreateSeatAsync, ListSeatsAsync, RekeySeatAsync and RemoveSeatAsync.

Images and files (since v0.27.0), each in two steps, a ticket from onlyworlds.com and then the bytes to the upload host the ticket names. UploadImageAsync answers the permanent URL to set as image_url (images), and RemoveImageAsync takes one down. UploadFileAsync, ListFilesAsync, WorldFilesAsync, FileDownloadLinkAsync and RemoveFileAsync are the files on elements.

Signing in, the draught and the AI routes (since v0.28.0). SignInWithPasswordAsync signs a person in and mints an account token, named when you give tokenName; SignInWithOnlyWorlds and CompleteSignInAsync are Sign in with OnlyWorlds, the browser flow with PKCE. Since v0.40.0 a tool that only reads passes OWSignIn.ReadScope as the third argument for a read-only token: it reads what the account reads, and every write but revoking itself is refused 403. OWSignInResult.Scope says "world:read" when the server granted one, and OWAccountToken.Scope marks it in ListAccountTokensAsync. A read-only sign-in gets no AI door token: aiUses beside it is refused before the code is spent. A client with no key and no World is built, so a signed-out person can call health and sign in. DraughtAsync reads one Character’s draught from a world key, or with World set from an account token or no key. AskAsync, SortAsync and AllowanceAsync are the AI routes, on an account token. Since v0.33.0 an answer says who paid (PaidBy: OWPaidBy.Rating, or OWPaidBy.OwnKey when the account’s own AI key ran it), OWAllowance.OwnKey names a saved key’s provider or is null, and OWApiError.IsOwnKeyRefused reads the 422 own_key_refused, which is not retried: send the person to their account page. RequestAsync sends any route of the API on the client’s own rules. Since v0.30.0 ListAccountTokensAsync lists the account’s tokens as OWAccountToken rows (by name and last four, never the token itself) and RevokeAccountTokenAsync(tokenId) revokes one, so a tool done with a sign-in can end it by the id the sign-in answered; both on an account token alone. Since v0.37.0 the AI door is here: AiUsesAsync lists the uses the server runs, and AiAsync(use, body, idempotencyKey) calls one, typed for ask and sort, its answer carrying UseRemaining and WasReplay; AskAsync and SortAsync are marked obsolete and keep working. CompleteSignInAsync takes aiUses and aiLifetimeMinutes for an AI door token (OWSignInResult.AiToken), MintAiTokenAsync(uses, lifetimeMinutes, name) trades an account token down to one, and OWSignInError.Param names the field a refused exchange named (ai_uses or ai_lifetime_minutes). Since v0.38.0 each AiUsesAsync row carries CanPay, true when a call by this account would be paid now: offer a use only when it is. The server’s lens use is reached through AiAsync("lens", body) and answers as served, untyped.

Elements an AI wrote as proposed (since v0.18.0; proposed changes). WorldProposalsAsync lists two kinds of row, told apart by OWProposal.Kind: a proposed change to an element, and a new element carrying the review mark x_review_proposed (IsNewElement). A keeper settles a new one with ReviewNewElementAsync(type, id, decision, reason): "accept" clears the mark, "decline" deletes the element. To read the mark, OWPayload.IsProposed(body) is what a viewer uses: it shows the element with its mark. A tool that hands a world on, such as a context pack for an AI, uses IsProposedOrInDoubt and leaves those elements out unless asked. An empty mark ({}, "", white space only, []) is no mark, so both read the element as settled (since v0.25.0), and a write carrying one is refused 422 review_mark_empty (OWApiError.IsReviewMarkEmpty). Since v0.48.0 OWProposal.House names the part of the house rules a row would change (charter, skill or new_charter), and is null for any other row; onlyworlds.com works it out only for the owner and co-builders.

Other tools’ data survives. Extension fields (x_*) that the models don’t know are kept verbatim through a read, an edit and a write, in the cache, and through Unity’s serializer. The five fields the server owns (world, type, created_at, updated_at, change_seq) are stripped from every write, so a body you read can be written straight back.

OWFolderWriter writes elements and the world into a world folder, byte for byte as the format specifies, so a folder kept in git doesn’t change from one machine to the next. OWFolderExport.ExportAsync(client, folder) writes a whole account world into a world folder, map images included, the same files the Python package’s export_world writes. Its world.json says where it came from (source) and, when the key’s GET /me can say, which slice it is (exported_as), as the folder format asks; since v0.7.0. An export declares folder format 0.3.24 (since v0.41.0; 0.3.22 from v0.39.0; 0.3.21 from v0.26.0; 0.3.20 from v0.24.0; 0.3.18 from v0.19.0; 0.3.17 from v0.18.1; 0.3.16 from v0.17.0, carrying the world’s origin as the server serves it; 0.3.15 from v0.16.0, 0.3.14 from v0.12.0) and writes the producer line as the folder’s maker, {"tool": "com.onlyworlds.sdk", "version": "0.49.0", "input": "server"}, version the package’s own; a file export carries keel’s line as it is and writes none when the file has none. It writes a known-of stub as the server hands it: the keys a stub keeps, every field it was served with a value, and known_of: true, never its unset fields. OWPayload.IsKnownOf(body) and OWElement.IsKnownOf tell a stub from a whole element, and the client refuses to write one back. A typed calendar era refuses a date it does not hold (the same rule as @onlyworlds/sdk 4.42.4).

  • "" is how a string field is unset. The API never sends null for text. Test with string.IsNullOrEmpty, never == null. A single link is different: its unset value is null.
  • null is not 0. Nullable numbers are SerializableNullable<T>, which keeps unset, a deliberate zero and absent apart. You can assign a plain T, but reading one makes you handle the unset case. The Inspector shows unset as --, never as 0.
  • UnityWebRequest runs on the main thread only. The client routes every request there, including the pages it fetches after an await. Never block on a request with .Result or .Wait() in the Editor: the completion arrives on the update loop, so blocking it deadlocks.
  • A transport of your own sends OWRequest.BodyBytes (since v0.27.0). An upload carries raw bytes there instead of a JSON Body; a transport that sends only Body uploads nothing.
  • An id is one path segment (since v0.30.0). Every type, id and field a call puts in a request path is checked first: a type is a lower-case word, anything else letters, digits, _, . and -, not starting with a dot or a dash. Anything else, an empty string or null included, throws an ArgumentException named for the value, and nothing is sent.
  • Only name is required. Every other field can be empty, and the API sends the empty value (null, "" or []) rather than leaving the key out.

A drift check in the repository keeps the generated models in step with the pinned schema. The package README holds more on each rule above, and the repository’s README explains how to work on the SDK itself and run its tests.