[{"data":1,"prerenderedAt":7},["ShallowReactive",2],{"docs-entities\u002Fpages\u002Fblock-files":3,"docs-tabs-entities\u002Fpages\u002Fblock-files":6},{"content":4,"lastmod":5},"## Upload an image to a block\n\n`POST \u002Fv1\u002Fpages\u002F:pageId\u002Fblocks\u002F:blockId\u002Ffiles`\n\nUploads an image file for a page block and returns its URL. The file is passed in the request body as Base64. Upload by URL is not supported.\n\n## Parameters\n\n| Parameter | Type | Required | Description |\n|----------|-----|:-----:|----------|\n| `pageId` (path) | number | yes | Page ID. List: [`GET \u002Fv1\u002Fpages`](\u002Fdocs\u002Fentities\u002Fpages\u002Flist) |\n| `blockId` (path) | number | yes | ID of a block on this page. List: [`GET \u002Fv1\u002Fpages\u002F:pageId\u002Fblocks`](\u002Fdocs\u002Fentities\u002Fpages\u002Fblocks\u002Flist) |\n| `scope` (query) | string | no | Site area: `KNOWLEDGE` — knowledge base, `GROUP` — workgroup pages, `MAINPAGE` — main pages. Omit the parameter for pages of all other sites |\n\n## Request fields (body)\n\n| Field | Type | Required | Description |\n|------|-----|:-----:|----------|\n| `fileName` | string | yes | File name with an extension, for example `pixel.png`. An empty string is not accepted |\n| `contentBase64` | string | yes | The image file content in standard Base64: the alphabet with `+` and `\u002F`, length a multiple of 4, no line breaks and no `data:` prefix. A file URL instead of the content is not accepted. The whole JSON body is up to 40 MiB, which is about 30 MiB of the source file |\n\nThe body must contain no other fields.\n\n## Examples\n\n### curl — personal key\n\n```bash\ncurl -X POST \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fpages\u002F42\u002Fblocks\u002F7\u002Ffiles\" \\\n  -H \"X-Api-Key: YOUR_API_KEY\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\n    \"fileName\": \"pixel.png\",\n    \"contentBase64\": \"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8\u002Fx8AAwMCAO+jRZkAAAAASUVORK5CYII=\"\n  }'\n```\n\n### curl — OAuth application\n\n```bash\ncurl -X POST \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fpages\u002F42\u002Fblocks\u002F7\u002Ffiles\" \\\n  -H \"X-Api-Key: YOUR_APP_KEY\" \\\n  -H \"Authorization: Bearer USER_SESSION_TOKEN\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\n    \"fileName\": \"pixel.png\",\n    \"contentBase64\": \"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8\u002Fx8AAwMCAO+jRZkAAAAASUVORK5CYII=\"\n  }'\n```\n\n### JavaScript — personal key\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fpages\u002F42\u002Fblocks\u002F7\u002Ffiles', {\n  method: 'POST',\n  headers: {\n    'X-Api-Key': 'YOUR_API_KEY',\n    'Content-Type': 'application\u002Fjson',\n  },\n  body: JSON.stringify({\n    fileName: 'pixel.png',\n    contentBase64: 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8\u002Fx8AAwMCAO+jRZkAAAAASUVORK5CYII=',\n  }),\n})\n\nconst { success, data } = await res.json()\n```\n\n### JavaScript — OAuth application\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fpages\u002F42\u002Fblocks\u002F7\u002Ffiles', {\n  method: 'POST',\n  headers: {\n    'X-Api-Key': 'YOUR_APP_KEY',\n    'Authorization': 'Bearer USER_SESSION_TOKEN',\n    'Content-Type': 'application\u002Fjson',\n  },\n  body: JSON.stringify({\n    fileName: 'pixel.png',\n    contentBase64: 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8\u002Fx8AAwMCAO+jRZkAAAAASUVORK5CYII=',\n  }),\n})\n\nconst { success, data } = await res.json()\n```\n\n## Response fields\n\n| Field | Type | Description |\n|------|-----|----------|\n| `success` | boolean | `true` on success |\n| `data.fileId` | number | ID of the uploaded file |\n| `data.url` | string | URL of the uploaded image. Pass it in `src` of an image node |\n\n## Response example\n\n```json\n{\n  \"success\": true,\n  \"data\": {\n    \"fileId\": 17,\n    \"url\": \"https:\u002F\u002Fcdn.example.com\u002Flanding\u002F2e8\u002Fpixel.png\"\n  }\n}\n```\n\n## Error response example\n\n400 — a file URL was passed instead of the file content:\n\n```json\n{\n  \"success\": false,\n  \"error\": {\n    \"code\": \"INVALID_PARAMS\",\n    \"message\": \"fileName and non-empty standard contentBase64 are required; URLs are not accepted\"\n  }\n}\n```\n\n## Errors\n\n| HTTP | Code | Marker in the response | Description |\n|------|-----|-----------------|----------|\n| 400 | `INVALID_PARAMS` | `pageId and blockId must be positive safe integers` | `pageId` or `blockId` is not a positive integer |\n| 400 | `INVALID_SCOPE` | `scope must be KNOWLEDGE, GROUP or MAINPAGE` | `scope` is not `KNOWLEDGE`, `GROUP` or `MAINPAGE` |\n| 400 | `MISSING_REQUIRED_FIELDS` | `Required fields: fileName, contentBase64` | The body lacks one of the fields. The message lists both fields |\n| 400 | `MISSING_REQUIRED_FIELDS` | `A JSON object is required` | The body is not a JSON object |\n| 400 | `INVALID_PARAMS` | `Unexpected body field` | The body has a field other than `fileName` and `contentBase64` |\n| 400 | `INVALID_PARAMS` | `fileName and non-empty standard contentBase64 are required; URLs are not accepted` | `fileName` is empty or whitespace only, or `contentBase64` is empty, contains a file URL or is not standard Base64: the length is not a multiple of 4 or it has a `data:` prefix |\n| 401 | `TOKEN_MISSING` | — | The API key has no Bitrix24 access tokens |\n| 403 | `SCOPE_DENIED` | — | The key has no `landing` scope |\n| 403 | `WRITE_BLOCKED_READONLY_KEY` | — | The key is read-only. The request is rejected before the Bitrix24 account is called |\n| 404 | `ENTITY_NOT_FOUND` | `Page or block not found` | The page does not exist, the block does not exist, or the block belongs to another page |\n| 409 | `LANDING_MODULE_NOT_ENABLED` | — | The Sites module is not enabled on the Bitrix24 account |\n| 409 | `PORTAL_ADDRESS_CHANGED` | — | The on-premise Bitrix24 moved to a new address, but the key's webhook was issued for the old one. Reissue the key's webhook |\n| 413 | `PAYLOAD_TOO_LARGE` | — | The JSON body is larger than 40 MiB |\n| 422 | `BITRIX_ERROR` | `b24Code`: `FILE_ERROR` | The file content is not an image. The `error.message` text comes in the Bitrix24 account language |\n| 422 | `BITRIX_ERROR` | — | The Bitrix24 account did not return the uploaded image |\n| 429 | `LARGE_BODY_BACKEND_BUSY` | — | The server is already processing several large request bodies. Retry the request after the pause given in the `Retry-After` header |\n\nFull list of common API errors — [Errors](\u002Fdocs\u002Ferrors).\n\n## Known specifics\n\n- **The uploaded image does not appear on the page by itself.** To show it in the block, pass `data.url` to an image node via [`PATCH \u002Fv1\u002Fpages\u002F:pageId\u002Fblocks\u002F:blockId\u002Fnodes`](\u002Fdocs\u002Fentities\u002Fpages\u002Fblock-nodes) as `{\"src\": url}`.\n\n## See also\n\n- [Change block text and images](\u002Fdocs\u002Fentities\u002Fpages\u002Fblock-nodes)\n- [Change block styles](\u002Fdocs\u002Fentities\u002Fpages\u002Fblock-styles)\n- [Change block attributes](\u002Fdocs\u002Fentities\u002Fpages\u002Fblock-attrs)\n- [Change a block node tag](\u002Fdocs\u002Fentities\u002Fpages\u002Fblock-tags)\n- [Set a block anchor](\u002Fdocs\u002Fentities\u002Fpages\u002Fblock-anchor)\n- [Publish a block](\u002Fdocs\u002Fentities\u002Fpages\u002Fblock-publication)\n- [Read block content](\u002Fdocs\u002Fentities\u002Fpages\u002Fblock-content)\n- [List page blocks](\u002Fdocs\u002Fentities\u002Fpages\u002Fblocks\u002Flist)\n- [Pages](\u002Fdocs\u002Fentities\u002Fpages)\n","2026-10-20",{},1795376953637]