All content methods live on client.content. They are all async and return a Promise.
TypeScriptimport { Keyset } from "keysetapp"; const client = new Keyset({ apiKey: "pkey_…", cacheTTL: 60000 });
getAll(options?)Fetches all remote config entries as a flat key-value map.
TypeScriptconst data = await client.content.getAll(); // { hero_title: "Welcome", show_banner: true, max_retries: 3 }
Pass { typed: true } to receive the full typed response (includes type metadata per entry):
TypeScriptconst typed = await client.content.getAll({ typed: true }); // { // hero_title: { value: "Welcome", type: "string" }, // show_banner: { value: true, type: "boolean" }, // }
Signature
TypeScriptgetAll(options?: { typed?: boolean }): Promise<Record<string, unknown> | TypedContentResponse>
Caching — responses are cached under the key "content" (or "content:typed" when typed: true). Cache is shared across calls.
getTypedAll()Shorthand for getAll({ typed: true }). Returns the full typed response.
TypeScriptconst all = await client.content.getTypedAll(); // Record<string, { value: unknown; type: ContentType }>
Signature
TypeScriptgetTypedAll(): Promise<TypedContentResponse>
getTyped(key)Returns the typed entry for a single key, or null if it does not exist.
TypeScriptconst entry = await client.content.getTyped("hero_title"); // { value: "Welcome", type: "string" } | null
Signature
TypeScriptgetTyped(key: string): Promise<TypedContentEntry | null>
getString(key, defaultValue?)Returns the string value for a key. Accepts entries of type string, url, or image.
Falls back to defaultValue (default "") if the key is missing or has the wrong type.
TypeScriptconst title = await client.content.getString("hero_title", "Default Title");
Signature
TypeScriptgetString(key: string, defaultValue?: string): Promise<string>
getNumber(key, defaultValue?)Returns the numeric value for a key. Falls back to defaultValue (default 0).
TypeScriptconst limit = await client.content.getNumber("max_results", 10);
Signature
TypeScriptgetNumber(key: string, defaultValue?: number): Promise<number>
getBoolean(key, defaultValue?)Returns the boolean value for a key — ideal for feature flags.
Falls back to defaultValue (default false).
TypeScriptconst enabled = await client.content.getBoolean("dark_mode", false); if (enabled) { enableDarkMode(); }
Signature
TypeScriptgetBoolean(key: string, defaultValue?: boolean): Promise<boolean>
getJSON<T>(key, defaultValue?)Returns the parsed JSON value for a key, typed as T.
Falls back to defaultValue (default null).
TypeScriptinterface NavLink { label: string; href: string } const links = await client.content.getJSON<NavLink[]>("nav_links", []);
Signature
TypeScriptgetJSON<T>(key: string, defaultValue?: T | null): Promise<T | null>
getURL(key, defaultValue?)Returns the URL string for a key (type must be "url").
Falls back to defaultValue (default "").
TypeScriptconst docsUrl = await client.content.getURL("docs_url", "https://docs.example.com");
Signature
TypeScriptgetURL(key: string, defaultValue?: string): Promise<string>
getImage(key, defaultValue?)Returns the image URL string for a key (type must be "image").
Falls back to defaultValue (default "").
TypeScriptconst logoUrl = await client.content.getImage("logo_url", "/default-logo.png");
Signature
TypeScriptgetImage(key: string, defaultValue?: string): Promise<string>
Requires a secret key (skey_…). Calling any write method with a public key throws "This operation requires a secret key".
create(entry)Creates a new content entry.
TypeScriptawait client.content.create({ key: "promo_banner", value: "Summer sale — 20% off", type: "string", });
Signature
TypeScriptcreate(entry: ContentEntry): Promise<KeysetResponse<unknown>>
| Field | Type | Description |
|---|---|---|
key | string | Unique identifier for the entry |
value | unknown | The value to store |
type | ContentType | One of "string", "number", "boolean", "json", "url", "image" |
Cache — invalidates both "content" and "content:typed" cache keys on success.
update(key, entry)Updates an existing content entry by key.
TypeScriptawait client.content.update("promo_banner", { value: "Winter sale — 30% off", type: "string", });
Signature
TypeScriptupdate(key: string, entry: Omit<ContentEntry, "key">): Promise<KeysetResponse<unknown>>
Cache — invalidates both cache keys on success.
delete(key)Deletes a content entry by key.
TypeScriptawait client.content.delete("promo_banner");
Signature
TypeScriptdelete(key: string): Promise<KeysetResponse<unknown>>
Cache — invalidates both cache keys on success.
dashboardList(projectId)Returns all content entries for a project in the full dashboard format (includes id, createdAt, updatedAt). Intended for admin dashboards.
TypeScriptconst entries = await client.content.dashboardList("proj_abc123");
Signature
TypeScriptdashboardList(projectId: string): Promise<KeysetResponse<DashboardContentEntry[]>>
Requires a secret key.
ContentType | TypeScript type | Getter method |
|---|---|---|
"string" | string | getString |
"number" | number | getNumber |
"boolean" | boolean | getBoolean |
"json" | T (generic) | getJSON<T> |
"url" | string | getURL |
"image" | string | getImage |