Open records and files
client.objects, an Objects, is where plaintext enters your application. Each open of a record or a file is one call, with one decision and one access event. The SDK fetches the stored object, checks it and decrypts it in memory. Your application renders the result and calls close() to discard the plaintext and every key. You cannot store anything the SDK returns and open it again later. No key remains to do it with.
Open by reference
An ObjectRef names a locator and, optionally, an earlier version. Leave version out for the current one. OpenAction says what the person is doing. Use view to show the object on screen. Use access-record when you open a record to give its subject a copy. Use download-file for a file the person is about to save outside your surface.
const opened = await allowed(await client.objects.open({ locator }, { action: 'view' }));let opened = try await allowed(client.objects.open(ObjectRef(locator: locator), action: .view))val opened = allowed(client.objects.open(ObjectRef(locator), action = OpenAction.VIEW))opened is an Opened: an OpenedRecord for a record ObjectKind, or an OpenedFile for a file. Both extend OpenedBase, as does Opened itself. opened.version and opened.close() need no case. OpenedBase carries:
- the object’s own data:
name,type,sizeandtimes(created and saved) baseVersion: the version it was last saved frompending: whether the version still waits for an AI agent’s delegatorwriter: the recipient id of the device that saved this versionepoch: the epoch this version belongs tooffline: true when the copy came from the offline lease
if (opened?.kind === 'record') renderRecord(opened.fields, opened.masked);else if (opened) renderFile(opened.name, opened.stream());switch opened {case .record(let record): renderRecord(record.fields, record.masked)case .file(let file): renderFile(file.name, file.stream())case nil: break}when (opened) { is Opened.Record -> renderRecord(opened.record.fields, opened.record.masked) is Opened.File -> renderFile(opened.name, opened.file.stream()) null -> {}}An OpenedRecord carries fields, a map of FieldValue. It also carries masked, the fields the policies withheld. Each masked field carries the DenyReason and the text to show beside it. The rest of the record still renders. An OpenedFile gives you the bytes two ways:
bytes()returns the whole file at once.stream()returns aReadableStreamyou can pipe to a viewer or a download.
Always call close() once you are done rendering. It discards the plaintext and every key this open used.
opened?.close();opened?.close()opened?.close()Open one field alone
To open a single field, call openField. It opens only that field and gets its own decision, recorded as a View Field access event. It returns an OpenedField with the locator, version, field name, value and its own close().
const field = await allowed(await client.objects.openField({ locator }, 'mrn'));field?.close();let field = try await allowed(client.objects.openField(ObjectRef(locator: locator), field: "mrn"))field?.close()val field = allowed(client.objects.openField(ObjectRef(locator), "mrn"))field?.close()Ask for a further action
Copy, Print, a later download and a later access-record open each get their own decision. Once something is open, call request with a FurtherAction: copy, print, download-file or access-record. On allow, your application carries out the action with the plaintext it already holds.
if (opened?.kind === 'record') { const decision = await allowed(await opened.request('copy')); if (decision) copyToClipboard(opened.fields);}if case .record(let record) = opened, try await allowed(record.request(.copy)) != nil { copyToClipboard(record.fields)}if (opened is Opened.Record && allowed(opened.request(FurtherAction.COPY)) != null) { copyToClipboard(opened.record.fields)}What the SDK does for you
- Fetches the stored object and verifies it in full before decrypting anything.
- Decrypts in memory only, never writing plaintext to disk on your behalf.
- Records one access event per open, per field open, and per further action.
- Returns the copy the offline lease covers when the Seald Healthcare Cloud is unreachable, with
offline: true.
Decisions and errors you may see
Outcome or ErrorCode | When | What to do |
|---|---|---|
deny | The policies refuse the action. reason and text say why. | Show text and who can give access. |
challenge | The policies require a fresh multi-factor sign-in first. | Call stepUp(), or use the allowed helper. |
container-invalid | The stored object is damaged, or its key does not open it. | Do not retry. Report the object as unreadable. |
storage-unreachable | The storage behind the object refused the request or could not be reached. | Retry once storage is back. |
Next
- Save and handle conflicts for saving the next version.
- List and search to find a locator before opening it.
- Access decisions for the full shape of
allowed. - AI agent versions for what
pendingmeans on an open.