Skip to main content
The ablo.layers namespace manages the individual content elements — text, charts, tables, images, shapes, and icons — that live on a slide. Layers are addressed by id; capture the id returned by create and pass it directly to update, applyOp, or delete without an intermediate lookup. For read-modify-write edits to chart, table, or text content, use applyOp rather than update — it applies a typed operation against the current stored content so only the targeted fields change.

ablo.layers.create(slideId, layer, options?)

Adds a single layer to a slide. The layer argument is a flat, discriminated-union object; the SDK validates and compiles it before committing.

Parameters

slideId
string
required
The id of the slide to add the layer to.
layer
LayerInput
required
A flat object describing the layer to create. The type field discriminates the union. Common fields shared by all layer types:
options
RequestOptions

Returns

id
string
Client-minted UUID for the new layer.
slideId
string
The parent slide id.
type
string
The layer type, e.g. "text", "bar", "table".

Example

import { Decks } from '@abloatai/decks';

const ablo = new Decks(process.env.ABLO_API_KEY!);

const layer = await ablo.layers.create('slide_xyz789', {
  type: 'bar',
  data: [
    { label: 'Q1', value: 120 },
    { label: 'Q2', value: 180 },
    { label: 'Q3', value: 252 },
  ],
  orientation: 'vertical',
  at: { x: 160, y: 300, w: 900, h: 600 },
});

console.log(layer.id); // save this to update the chart data later

ablo.layers.createRaw(params, options?)

Advanced escape hatch for creating a layer from raw CreateLayerParams. Use this when you need to supply a fully-constructed data or contentJson payload that the higher-level LayerInput builders do not expose.

Parameters

params
CreateLayerParams
required
options
RequestOptions

Returns

id
string
Client-minted UUID for the new layer.
slideId
string
The parent slide id.
type
string
The layer type.

Example

const layer = await ablo.layers.createRaw({
  slideId: 'slide_xyz789',
  type: 'text',
  position: { x: 160, y: 120, width: 1600, height: 160 },
  contentJson: myPrebuiltContentDoc,
});

console.log(layer.id);

ablo.layers.retrieve(id)

Fetches the full stored record for a layer by id. Requires a readable client.

Parameters

id
string
required
The layer id.

Returns

id
string
The layer UUID.
slideId
string
The parent slide id.
type
string
The layer type.
position
LayerPosition
Geometry: { x, y, width, height, rotation? } in the 1920×1080 coordinate space.
data
unknown
Type-specific payload (chart document, table data, shape descriptor).
contentJson
unknown
Rich text content for text-bearing layers. null for non-text types.
style
Record<string, unknown> | null
Layer-level style overrides.
zIndex
number
Stacking order.
visible
boolean
Whether the layer is visible.
imageFill
LayerImageFill | null
Picture fill, or null.
layoutLayerId
string | null
The layout layer this slide layer is bound to, or null for free layers.

Example

const layer = await ablo.layers.retrieve('layer_def456');
console.log(layer.type, layer.position);

ablo.layers.list({ slideId })

Returns all layers on a slide. Requires a readable client.

Parameters

slideId
string
required
The slide whose layers you want to list.

Returns

An array of LayerRecord objects. Each entry has the same shape as the return value of retrieve.

Example

const layers = await ablo.layers.list({ slideId: 'slide_xyz789' });

for (const layer of layers) {
  console.log(layer.zIndex, layer.type, layer.position);
}

ablo.layers.update(params, options?)

Applies a field-level patch to an existing layer. Each field you include overwrites the entire stored value for that field; fields you omit are left unchanged. Use applyOp instead when you want to surgically modify chart series, table cells, or text styles.

Parameters

params
UpdateLayerParams
required
options
RequestOptions

Returns

id
string
The commit UUID.
status
'queued' | 'confirmed'
The acknowledgement level reached.
lastSyncId
number
Monotonic sync cursor for real-time clients.

Example

// Move a layer and hide it in one commit
const receipt = await ablo.layers.update({
  id: 'layer_def456',
  position: { x: 320, y: 200 },
  visible: false,
});

console.log(receipt.status); // 'confirmed'

ablo.layers.applyOp(id, op, options?)

Applies a typed operation to a chart, table, or text layer using a read-modify-write cycle. The SDK reads the layer’s current document from the server, applies the op through the same reducers used by the editor and the AI, and writes only the changed fields back — so unrelated parts of the document are never overwritten. This method requires a readable client. If your client is commit-only, it throws with a clear error.

Parameters

id
string
required
The layer id to modify.
op
LayerOp
required
A typed operation. The op type must match the layer type:
options
RequestOptions

Returns

id
string
The commit UUID.
status
'queued' | 'confirmed'
The acknowledgement level reached.
lastSyncId
number
Monotonic sync cursor for real-time clients.

Example

// On first run, create the deck and capture the layer id
const deck = await ablo.decks.create({
  title: 'Live Dashboard',
  slides: [
    {
      title: 'Revenue',
      layers: [
        {
          type: 'table',
          columns: ['Quarter', 'Revenue'],
          rows: [['Q1', '$1.2M']],
          at: { x: 160, y: 300, w: 1200, h: 400 },
        },
      ],
    },
  ],
});

const tableLayerId = deck.slides[0].layers[0].id;

// On subsequent runs, apply a typed op to add a row — no full rewrite needed
const receipt = await ablo.layers.applyOp(tableLayerId, {
  type: 'insertRow',
  index: 1,
  cells: [{ value: 'Q2' }, { value: '$1.5M' }],
});

console.log(receipt.status); // 'confirmed'

ablo.layers.delete(id, options?)

Permanently deletes a layer from its slide.

Parameters

id
string
required
The layer id to delete.
options
RequestOptions

Returns

id
string
The commit UUID.
status
'queued' | 'confirmed'
The acknowledgement level reached.
lastSyncId
number
Monotonic sync cursor.

Example

const receipt = await ablo.layers.delete('layer_def456');
console.log(receipt.status); // 'confirmed'