Uploading one
Post the image toPOST /assets/backgrounds as the multipart field image, or to POST /assets/foregrounds for a foreground.
201
id: it’s what background_id, foreground_id, BG_ and FG_ take. The image is stored as a PNG, and size_bytes is that PNG’s size.
The image must be:
- a JPEG, PNG or WEBP, under 5MB;
- in one of the streaming canvases’ shapes, 16:9, 9:16 or 1:1, and no other;
- at least 512 pixels on its shorter side, and at most 1920x1080 (16:9), 1080x1920 (9:16) or 1080x1080 (1:1).
Listing and deleting them
GET /assets/backgrounds (or /assets/foregrounds) lists your uploads, newest first. Each has a url that reads the image, a PNG, until url_expires_at (Unix time in seconds, an hour on). You can use it as an <img> src. Anyone holding the URL can read that one image until then, so keep it to your own app. List again for fresh URLs. url is null if one couldn’t be made just then.
DELETE /assets/backgrounds/{id} (or /assets/foregrounds/{id}) deletes one. This can’t be undone. A token or agent that names it starts with the avatar’s own instead. You get a 204, or a 404 if it isn’t one of yours.
Starting a session with one
Put its id inbackground_id (and a foreground’s in foreground_id), next to the framing fields, in any of these:
POST /compose/token
warnings gets an entry for it. The token or video is still made, with the avatar’s own.
Simli Auto agents don’t store a background. Put
background_id in the agent’s POST /auto/token request, and its session starts with it.Swapping it during a session
Both session WebSockets,/compose/webrtc/p2p and /compose/webrtc/livekit, accept a BG_ message: the ASCII prefix BG_ and the background’s id, 36 characters with its hyphens, in either case. Send it as text or binary. It is 39 characters in all, and nothing else is accepted. FG_ and a foreground’s id does the same for the foreground.
BG_ with the nil UUID. It applies at once, and cancels a background that’s still loading. FG_ with the nil UUID takes the foreground away.
Foreground messages get the same replies, with
foreground in place of background.
In a Simli Auto session
A Simli Auto session’s avatar is in a Daily room with your app. To swap the background, send the room an app message:{"type": "simli-foreground", "id": "<foreground id>"}. An id of null goes back to the avatar’s own background, or takes the foreground away: