Share links
Turn a view-only share link on or off with client.shares in the Nodaro SDK, and read what a link shows from a client with no token, a page at a time.
client.shares manages view-only share links to one of your results (a job), a generation session or a project. A link shows the results, the prompt as it was written, the model and the settings. With allowCopy, it also shows the reference files the result was made from. The methods call the Share links REST API.
Each item has one link. Turned off, the link answers 404. Turned on again, it brings back the same token.
Methods
| Method | What it does |
|---|---|
get(params) | Read your link for one of your items |
set(input) | Turn the link of one of your items on or off |
getPublic(token) | Read what a link shows, signed in or not |
publicItems(token, params?) | List the results of a shared session or project, signed in or not |
client.shares
Share a result by link
import { createClient, CallbackAuth } from "@nodaro/sdk"
// locale: the interface language the item is shared in. The link's preview card is written in it.
const share = await client.shares.set({ kind: "job", targetId: jobId, shared: true, allowCopy: false, locale: "de" })
// A page opened by someone who is not signed in reads the link with a client that has no token.
const guest = createClient({ baseUrl: "https://app.nodaro.ai", auth: new CallbackAuth(() => null) })
const { job } = await guest.shares.getPublic(share.token)
console.log(job?.outputUrl, job?.prompt, job?.model?.name, job?.settings)
// Off: the link answers 404. On again later: the same token works again.
await client.shares.set({ kind: "job", targetId: jobId, shared: false })get(params)
Reads your link for one of your items (GET /v1/shares). It returns null when the item was never shared. It throws a 404 NodaroError when the item is not yours.
get(params: GetShareParams): Promise<Share | null>Prop
Type
set(input)
Turns the link of one of your items on or off (PUT /v1/shares). The first call makes the link. Later calls keep its token.
set(input: SetShareInput): Promise<Share>Prop
Type
Turning on an item that cannot be shared now throws a 422 NodaroError with the code share_not_allowed and a reason: not_completed, no_media, private_output, content_filtered, restricted, workspace or sharing_disabled. What a link never shows explains each reason. Turning a link off always works, also for a job in the Trash.
An OAuth app needs the scopes assets:write and jobs:read.
getPublic(token)
Reads what a link shows (GET /v1/public/shares/:token). It works signed out.
getPublic(token: string): Promise<PublicShare>The answer is { kind, allowCopy, job? | session? | project? }. It throws a 404 NodaroError for a link that is unknown or turned off, or whose item is gone or may no longer be shown.
publicItems(token, params?)
Lists the results of a shared session, newest first (GET /v1/public/shares/:token/items). It works signed out.
publicItems(token: string, params?: PublicShareItemsParams): Promise<PublicShareItemsPage>Prop
Type
The answer is { data: SharedJob[], nextCursor }. A page may hold fewer results than limit. Follow nextCursor until it is null.
const shown = await client.shares.getPublic(share.token)
if (shown.kind === "session") {
const { data: results, nextCursor } = await client.shares.publicItems(share.token)
}Types
type ShareKind = "job" | "session" | "project"
interface Share { token: string; kind: ShareKind; targetId: string; shared: boolean; allowCopy: boolean; createdAt: string; updatedAt: string; locale?: string | null }
interface SharedJob {
id: string; type: string; mediaKind: "image" | "video" | "audio"
outputUrl: string; outputUrls?: string[]; width?: number; height?: number; durationSec?: number
title: string | null; createdAt: string
songTitle?: string // a song's own title, when it has one
toolName?: string | null // what a person calls the tool: "Song Mashup", "Text to Speech"
coverUrl?: string | null // the result's cover picture, see client.jobs.update
prompt: string | null // as written; null for a trend run
displayPrompt?: string | null // as a person reads it: @maya:1 → @Maya, {video:1:clip} → @clip
negativePrompt?: string | null
model: { id: string; name: string } | null // the public model name
settings: Record<string, SharedSettingValue> // never an address or an id
references?: Array<{ url: string; kind: "image" | "video" | "audio" }> // only with allowCopy
trend?: { slug: string; name: string } // a trend run: no prompt or settings
}
interface SharedSession { title: string | null; tool: string | null; createdAt: string; itemCount: number }
interface SharedProject { name: string; sessions: Array<{ id: string; title: string | null; tool: string | null; itemCount: number; coverUrl: string | null }> }What a link shows
A link shows only finished results of its owner that the platform would let anyone see. It never shows a result in the Trash, removed from its session, restricted, kept private or tripping the content filter, and nothing of a workspace. This is decided again on every read, so a result moved to the Trash after it was shared stops showing at once.
The address to share
For previews on social networks and in chats, hand out the share card, https://nodaro.ai/s/<token>. Its HTML carries the Open Graph and Twitter tags, and it sends people on to https://nodaro.ai/shared/<token>, the page that shows the link. See The share card for link previews.
Frequently asked questions
How do I share a result by link with the Nodaro SDK?
Call client.shares.set with kind job, the job's id as targetId and shared true. The returned Share holds the token. Build your share address from the token.
Can a visitor who is not signed in read a share link?
Yes. client.shares.getPublic and client.shares.publicItems work signed out. Create a client whose auth returns no token, for example new CallbackAuth(() => null), and call them with the token.
Why does client.shares.set throw share_not_allowed?
The item cannot be shared now. The error is a 422 NodaroError with a reason, such as not_completed, no_media or workspace. Turning a link off always works.
Does turning a link off and on again change its token?
No. Each item has one link. Off, the link answers 404. On again, the same token works again.
Related
Share links
Jobs and executions
Authentication
Errors
Last updated on
LLM and Reduce
Get validated JSON from a language model with client.llm, and choose the best of many results, vote, join or merge them with client.reduce.
Media and uploads
Upload files, list your media library, import videos from links, trim clips, burn captions and composite images and videos from TypeScript with the Nodaro SDK.