How to set a custom sampler to a dynamicly generated atlas?

Hello im trying to set a sprite to a runtime created atlas, which is created from an image downloaded from the web at runtime, and this works. However when i try to set a sprite that has 2 custom samplers in the material it gives this error

 the property 'ART' of 'art#sprite' must be a number

This is my sprite

And material

And code

local buffer = image.load_buffer(http_res.response, { flip_vertically: true })
local atlasHash = createAtlasFromBuffer(buffer)
go.set("art#sprite", "ART", atlasHash) -- errors here

Note that this code works fine but the stencil image sampler is scaled wrong

local buffer = image.load_buffer(http_res.response, { flip_vertically: true })
local atlasHash = createAtlasFromBuffer(buffer)
go.set("art#sprite", "image", atlasHash) -- no error

Atlas creation function (in typescript)

export function createAtlasFromBuffer(id: string, img: ImageRes) {
	const width = img.width;
	const height = img.height;

	const tex = {
		width,
		height,
		type: graphics.TEXTURE_TYPE_2D,
		format: graphics.TEXTURE_FORMAT_RGBA,
		// x: -img.width / 2,
		// y: -img.height / 2,
	};

	const texture = resource.create_texture(`#${id}.texturec`, tex, img.buffer);

	const atlasParams = {
		texture: texture,
		animations: [
			{
				id: "item",
				width: width,
				height: height,
				frame_start: 1,
				frame_end: 2,
			},
		],
		geometries: [
			{
				width: width,
				height: height,
				pivot_x: 0.5,
				pivot_y: 0.5,
				vertices: [0, height, 0, 0, width, 0, width, height],
				uvs: [0, height, 0, 0, width, 0, width, height],
				indices: [0, 1, 2, 0, 2, 3],
			},
		],
	};

	const atlas = resource.create_atlas(`#${id}.texturesetc`, atlasParams);
	return atlas;
}

Card stencil is a tilesource with a single tile in it

AFAIK it is not possible to set textures by name like this but should be possible like this::

go.set("art#sprite", "texture0", atlasHash)
go.set("art#sprite", "texture1", atlasHash)

According to this doc you can set samplers by name if you have custom ones defined in the material? Showing 2D images