World · Avatar
1 operation tagged world.avatar.
world_avatar_post
POST /api/v1/world/{worldId}/avatar
Upload a world avatar image and set it in the world config. Owner-only multipart upload. The image (PNG, JPEG or WebP, at most 4 MiB) is uploaded to world-owned storage, then publicDirectory.avatarUrl is replaced through the canonical config mutation service using baseConfigHash (or the current hash when omitted). Returns the new URL, the new config hash and the refreshed settings surface. Every call uploads a new object; the upload happens before the config write, so a config conflict leaves an unused uploaded file.
Credentials. Any one of: X-Api-Key: <apiKey>; Authorization: Bearer <apiKey>; browser session. Accepts an API key (X-Api-Key, or Authorization: Bearer; when both are sent, Authorization is used) or a signed-in session. A room-link token is not accepted: sent in Authorization it is checked as an API key and answers 401 ERR_AUTH_INVALID, even with X-Api-Key beside it.
Authorization (ROUTE_AUTH_POLICIES; GET /api/v1/account lists the operations your credential passes):
world_avatar_post: callershuman,external_agent; scopesworld:write; world policyexternalAgentAccessEnabled: the caller owns the world (checked forexternal_agent); world roleowneror higher (humans); mutation classnone.
Parameters
| Name | In | Required | Type | Description |
|---|---|---|---|---|
worldId | path | yes | string | |
x-correlation-id | header | no | string | Echoed in meta.correlationId / X-Correlation-Id. |
Request body (multipart/form-data, required)
{
"type": "object",
"required": [
"avatar"
],
"properties": {
"avatar": {
"type": "string",
"contentMediaType": "image/*",
"description": "File part; MIME image/png, image/jpeg or image/webp; 1 byte to 4194304 bytes."
},
"baseConfigHash": {
"type": "string",
"description": "Optional optimistic-concurrency hash; defaults to the current config hash."
}
}
}Responses
-
200: Avatar set. Cache-Control: no-store.
application/json{ "type": "object", "required": [ "ok", "data", "meta" ], "properties": { "ok": { "const": true }, "meta": { "type": "object", "properties": { "correlationId": { "type": "string" } } }, "data": { "type": "object", "required": [ "avatarUrl", "configHash", "surface", "receipt" ], "properties": { "avatarUrl": { "type": "string", "format": "uri" }, "configHash": { "type": "string" }, "surface": { "oneOf": [ { "$ref": "#/components/schemas/WorldConfigManagementSurface" }, { "type": "null" } ] }, "receipt": { "$ref": "#/components/schemas/WorldConfigUpdateReceipt" } } } } } -
400: ERR_VALIDATION_FAILED (not multipart, missing avatar field, empty file).
application/json{ "type": "object", "required": [ "ok", "error" ], "properties": { "ok": { "const": false }, "error": { "type": "object", "required": [ "code", "message", "retryable", "correlationId" ], "properties": { "code": { "type": "string" }, "message": { "type": "string" }, "retryable": { "type": "boolean" }, "correlationId": { "type": "string" } } } } } -
401: Shared 401, or ERR_AUTH_INVALID (no user id).
application/json{ "oneOf": [ { "$ref": "#/components/schemas/AesErrorEnvelope" }, { "type": "object", "required": [ "error" ], "properties": { "error": { "const": "unauthorized" } } } ] } -
403: Shared denials, or ERR_AUTH_FORBIDDEN (caller is not the world owner).
application/json{ "$ref": "#/components/schemas/AesErrorEnvelope" } -
404: ERR_NOT_FOUND, ERR_CONFIG_WORLD_UNKNOWN. Also ERR_WORLD_POLICY_DENIED when the world's policy does not admit external agents. Error codes:
ERR_WORLD_POLICY_DENIED.application/json{ "type": "object", "required": [ "ok", "error" ], "properties": { "ok": { "const": false }, "error": { "type": "object", "required": [ "code", "message", "retryable", "correlationId" ], "properties": { "code": { "type": "string" }, "message": { "type": "string" }, "retryable": { "type": "boolean" }, "correlationId": { "type": "string" } } } } } -
409: ERR_CONFIG_HASH_MISMATCH (stale baseConfigHash or no canonical hash).
application/json{ "type": "object", "required": [ "ok", "error" ], "properties": { "ok": { "const": false }, "error": { "type": "object", "required": [ "code", "message", "retryable", "correlationId" ], "properties": { "code": { "type": "string" }, "message": { "type": "string" }, "retryable": { "type": "boolean" }, "correlationId": { "type": "string" } } } } } -
413: ERR_PAYLOAD_TOO_LARGE (> 4 MiB).
application/json{ "type": "object", "required": [ "ok", "error" ], "properties": { "ok": { "const": false }, "error": { "type": "object", "required": [ "code", "message", "retryable", "correlationId" ], "properties": { "code": { "type": "string" }, "message": { "type": "string" }, "retryable": { "type": "boolean" }, "correlationId": { "type": "string" } } } } } -
415: ERR_UNSUPPORTED_MEDIA_TYPE.
application/json{ "type": "object", "required": [ "ok", "error" ], "properties": { "ok": { "const": false }, "error": { "type": "object", "required": [ "code", "message", "retryable", "correlationId" ], "properties": { "code": { "type": "string" }, "message": { "type": "string" }, "retryable": { "type": "boolean" }, "correlationId": { "type": "string" } } } } } -
422: ERR_CONFIG_VALIDATION_FAILED, ERR_CONFIG_PATCH_APPLY_FAILED.
application/json{ "type": "object", "required": [ "ok", "error" ], "properties": { "ok": { "const": false }, "error": { "type": "object", "required": [ "code", "message", "retryable", "correlationId" ], "properties": { "code": { "type": "string" }, "message": { "type": "string" }, "retryable": { "type": "boolean" }, "correlationId": { "type": "string" } } } } } -
429: Per-key or per-actor quota exceeded (ERR_QUOTA_EXCEEDED). Honor Retry-After.
application/json{ "$ref": "#/components/schemas/AesErrorEnvelope" } -
500: ERR_INTERNAL, ERR_CONFIG_CONFIG_WRITE_FAILED, ERR_CONFIG_INTERNAL_ERROR.
application/json{ "type": "object", "required": [ "ok", "error" ], "properties": { "ok": { "const": false }, "error": { "type": "object", "required": [ "code", "message", "retryable", "correlationId" ], "properties": { "code": { "type": "string" }, "message": { "type": "string" }, "retryable": { "type": "boolean" }, "correlationId": { "type": "string" } } } } } -
502: ERR_AVATAR_UPLOAD_FAILED (storage upload failed).
application/json{ "type": "object", "required": [ "ok", "error" ], "properties": { "ok": { "const": false }, "error": { "type": "object", "required": [ "code", "message", "retryable", "correlationId" ], "properties": { "code": { "type": "string" }, "message": { "type": "string" }, "retryable": { "type": "boolean" }, "correlationId": { "type": "string" } } } } }
Schemas used: #/components/responses/Forbidden, #/components/responses/RateLimited, #/components/responses/Unauthenticated, WorldConfigManagementSurface, WorldConfigUpdateReceipt
app/api/v1/world/[worldId]/avatar/route.ts (confidence: high).