remagicaDocs home
API referenceSprites

Import a sprite sheet

POST
/sprites/imports

Needs a key withsprites:write

Imports a sheet you uploaded (POST /uploads): sliced on grid, its ground taken out, each row fitted to the game's canvas (one scale for the sheet, so the master's figure stands at the size class's height, and each row's lowest feet on the baseline) and made a draft take of its action in its direction, then scored against the master. With no characterId a new character is made (a Library sprite); its master comes from masterFrom, by default the first row's first frame. Rows can name the character's actions by key or any action by name (new ones are added). Charges nothing. Follow it on the studio's live feed (topic import) or with GET /sprites/imports/{importId}.

Requires scope sprites:write.

Authorization

apiKey
headerx-api-key<token>

An API key of your workspace (rmg_…), created in the web app. It acts for that workspace, not for a person, and keeps working when its creator leaves.

Request Body

application/json
  1. body
characterId?string

The game's character it goes to. Left out: a new character is made.

Length1 <= length <= 128
gameId*string
Length1 <= length <= 128
grid*

The sheet's grid: cell i of a row starts at offsetX + i × (cellW + gapX).

idempotencyKey?string

The same key returns the same import.

Length1 <= length <= 255
image*

An image you uploaded.

key?|

The background colour to take out, as #rrggbb; null keeps every pixel. Left out: the sheet's own ground is found (a flat colour round its border).

masterFrom?

The frame the master is made from. Left out: the first row's first frame for a new character, and the character's own master otherwise.

name?string

The new character's name. Left out: the file's.

Length1 <= length <= 120
rows*array<>

The rows to import, each an action (actionKey or actionName) in a direction: one take each.

Items1 <= items <= 32

Response Body

Accepted: the import is queued.

application/json
  1. response
characterId*string

The character it goes to (made by the import when new).

Length1 <= length <= 128
importId*string

The import: the live feed (GET /sprites/events, topic import) follows it.

Length1 <= length <= 128
status*string
Value in"queued""running""done""failed"
Example Request
curl -X POST 'https://api.remagica.com/api/v1/sprites/imports' \  -H 'Content-Type: application/json' \  -d '{  "gameId": "5c2a9e1d-7b3f-4a6e-8d0c-2f1e3a4b5c6d",  "grid": {    "cols": 8,    "rows": 4  },  "image": {    "key": "uploads/org_123/5d1c…/frame.png"  },  "rows": [    {      "direction": "E"    }  ]}'
Example Response
{  "characterId": "eb1fe45b-5b3d-4f60-8e2a-1d9c6b4f7e05",  "importId": "2b7d4f9a1c3e5a7b9d0f2e4c6a8b0d1f",  "status": "queued"}