inklet docs

Client

Constructing the inklet client — options, defaults, timeouts, resources, and the low-level request methods.

import { Inklet } from "@inklethq/sdk";

const inklet = new Inklet({ pat: process.env.INKLET_PAT! });

Inklet is an alias of InkletClient; both are exported and identical.

Options

Prop

Type

OptionDefaultNotes
pat—Personal access token. Required (or secretKey).
secretKey—Compatibility alias for pat. Do not pass both.
baseUrlhttps://dev.iminklet.comAbsolute HTTP(S) URL, no credentials, query, or fragment.
fetchglobalThis.fetchMust match the standard signature.
timeoutMs60_000How long each API request may take.
uploadTimeoutMs300_000How long each binary upload to storage may take.

Construction is validated but makes no network request. It throws ConfigurationError for a missing or malformed token, a bad baseUrl, both credentials at once, a timeout that is not a whole number from 1 to 2,147,483,647, or a runtime with no fetch; and BrowserEnvironmentError if a document exists.

See Timeouts and retries for what the two timeouts cover.

Properties

PropertyType
baseUrlstring — normalized, trailing slashes removed
assetsAssetsResource
contentsContentsResource
analysesAnalysesResource
displaysDisplaysResource
presentationsPresentationsResource
pushPushResource — see Pushing content

Shorthands

inklet.analyze(input?: AnalyzeInput): Promise<Analysis>
inklet.direct(input: DirectInput): Promise<Analysis>

Aliases for inklet.analyses.analyze() and inklet.analyses.direct().

Per-call options

Every method that talks to inklet also takes { signal, timeoutMs } — as a trailing argument, or inside the options object it already has:

Prop

Type

const controller = new AbortController();

await inklet.displays.list({ limit: 20, signal: controller.signal });
await inklet.displays.retrieve(displayId, { timeoutMs: 5_000 });
await inklet.push.auto({ assets }, { signal: AbortSignal.timeout(30_000) });

An aborted call throws OperationAbortedError; a request that runs out of time throws RequestTimeoutError. See Timeouts and retries.

Constants

import {
  DEFAULT_INKLET_BASE_URL,  // "https://dev.iminklet.com"
  MAX_ASSET_SIZE_BYTES,     // 10485760 (10 MiB)
  MAX_ASSETS_PER_CONTENT,   // 50
  MAX_CONTENT_SEARCH_LENGTH, // 200
  ALLOWED_IMAGE_CONTENT_TYPES,
  ALLOWED_FILE_CONTENT_TYPES,
  INKLET_SCENE_MEDIA_TYPE,  // "application/vnd.inklet.scene+json;version=1"
} from "@inklethq/sdk";

request()

The transport used by every resource is public, for endpoints the typed resources do not cover yet:

const data = await inklet.request<MyType>("/api/sdk/v1/displays");

Prop

Type

Pass json to send a JSON body — it sets content-type and serializes for you. Passing both json and a non-null body throws. timeoutMs overrides the client's for this request, and runs until the body has been read.

Every request automatically carries authorization: Bearer … and — unless you set your own — accept: application/json, and sets redirect: "error".

Paths must be relative to baseUrl. Absolute URLs, protocol-relative paths (//host), backslashes, and anything resolving to a different origin throw ConfigurationError rather than being sent.

Responses are parsed as JSON when the content type says so; 204, 205, HEAD, and empty bodies resolve to undefined. Non-JSON bodies resolve as text.

requestRaw()

The same transport, resolving with the raw Response without reading the body:

const response = await inklet.requestRaw("/api/sdk/v1/analyses/an_1/events/stream", {
  headers: { accept: "text/event-stream" },
});

Non-2xx responses still throw the usual typed errors, so you only ever receive a successful response. timeoutMs covers only the wait for the headers, so a body that stays open for minutes is not cut off; stop it with signal. This is for endpoints whose body must be consumed incrementally — the Analysis event stream is the one the SDK itself uses it for. request() is the right choice for everything else.

API surface

All typed resources sit under one prefix:

/api/sdk/v1
MethodPath
GET/displays
GET/displays/{id}
GET/displays/{id}/queue
GET/displays/{id}/current-presentation
POST/displays/{id}/current
POST/displays/{id}/advance
GET/presentations
GET/presentations/{id}
POST/presentations/{id}/renditions
POST/contents
GET/contents
GET/contents/{id}
POST/contents/{id}/upload-tickets
POST/analyses
GET/analyses
GET/analyses/{id}
GET/analyses/{id}/events
GET/analyses/{id}/events/stream
GET/analyses/{id}/archive

/api/app/v1 is inklet's own first-party apps' mirror of the same API, with the same handlers and the same JSON; the SDK always uses /api/sdk/v1.

An unknown path under the prefix answers 404 and a wrong method 405, both with code: "invalid_request".

On this page