Uploads an asset (image, video, or other file) to a specific segment in a Flex document. Assets are stored in the document's reference material folder and can be retrieved later for display in editors or other contexts.
URL
(POST) /api/apps/wbflex/documents/{id}/assets/{segmentid}
PARAMETERS
|
Parameter |
Type |
Required |
Description |
|---|---|---|---|
|
id (URL) |
string |
Mandatory |
The unique Flex document identifier |
|
segmentid (URL) |
int |
Mandatory |
The unique segment identifier where the asset will be attached |
Request Body
The message body contains a JSON object with these properties:
|
Property |
Type |
Required |
Description |
|---|---|---|---|
|
filetoken |
string |
Mandatory |
The file token obtained from the media upload API (/api/media/upload). Example: "74fac397d6314cf4a2958f8318f3a9a4" |
|
locale |
string |
Optional |
Language code to associate the asset with a specific language. If provided, the asset will be stored in a language-specific subfolder. Example: "en", "de", "fr" |
|
relativePath |
string |
Optional |
Relative path within the segment's asset folder to organize files. Example: "/public/images", "documents/pdfs". If not provided, the path can be included as part of the filename |
ACCESS RIGHTS
The user must have access rights to the Flex document. The system checks document-level permissions to ensure the user can upload assets to the specified document.
EXAMPLE REQUEST
curl --location '{{URL}}/api/apps/wbflex/documents/19914/assets/27667833' \
--header 'X-Auth-Token: {{AUTH_TOKEN}}' \
--header 'X-Auth-AccountId: {{ACCOUNT_ID}}' \
--header 'Content-Type: application/json' \
--data '{
"filetoken": "{{FILE_TOKEN}}"
}'
RESULTS
The response contains a JSON object with the uploaded asset details:
|
Property |
Type |
Description |
|---|---|---|
|
projectId |
int |
The project identifier associated with the Flex document |
|
documentId |
string |
The Flex document identifier |
|
segmentId |
int |
The segment identifier where the asset was uploaded |
|
locale |
string? |
The language code if the asset was associated with a specific language |
|
relativePath |
string |
The relative path within the segment's asset folder. Empty string if the asset is stored at the root level |
|
fileName |
string |
The stored filename |
|
fileSizeInBytes |
int |
The file size in bytes |
|
contentType |
string |
The MIME type of the uploaded file |
|
createdDate |
datetime |
ISO 8601 timestamp when the asset was first created |
|
modifiedDate |
datetime |
ISO 8601 timestamp when the asset was last modified |
|
downloadUrl |
string |
Direct URL to download the asset. Includes document ID, segment ID, locale, filename, and relativePath parameters |
EXAMPLE RESPONSE
{
"projectId": 7214,
"documentId": "19914",
"segmentId": 27667833,
"locale": null,
"relativePath": "",
"fileName": "pexels-gons2.jpg",
"fileSizeInBytes": 2268156,
"contentType": "image/jpeg",
"createdDate": "2025-07-27T15:58:53.4687698Z",
"modifiedDate": "2025-07-27T15:58:33.8999983Z",
"downloadUrl": "http://{{URL}}/api/apps/wbflex/documents/19914/assets/27667833?filename=pexels-gons2.jpg"
}
PREREQUISITES
Before uploading an asset, you must first upload the file content using the media upload API:
POST /api/media/upload?filename={filename}
This returns a filetoken that you then use in the asset upload request.
NOTES
-
Assets are attached to segments within Flex documents, not to specific languages (unless explicitly specified via locale parameter)
-
Multiple assets can be uploaded to the same segment
-
Supported file types include images, videos, and other media files
-
File Path Handling: The system supports two ways to specify file paths:
-
Use the relativePath parameter to specify the folder structure
-
Include the path directly in the filename (e.g., "subfolder/image.jpg")
-
If both are provided, relativePath takes precedence
-
-
Path separators are automatically normalized by the system