Overview
Attachments are files uploaded to Memos and associated with memos. Supported file types include images, videos, audio, documents, and more. Attachments can be stored locally or in S3-compatible storage.Create Attachment
Uploads a new file attachment. The file content is provided as base64-encoded bytes in the request.
POST /api/v1/attachments
Request Body
The attachment to create
Optional custom ID for the attachment. If not provided, a unique ID will be generated.
File Upload Limits
- Maximum file size determined by instance settings (default: 32 MB)
- Configurable via
upload_size_limit_mbin storage settings - Files exceeding the limit will return a
400 Invalid Argumenterror
EXIF Metadata Stripping
For privacy protection, EXIF metadata is automatically stripped from uploaded images:- Affected formats: JPEG, JPG, TIFF, WebP, HEIC, HEIF
- Removed data: GPS location, camera settings, device information, timestamps
- Quality: Images are re-encoded at 95% JPEG quality to maintain visual fidelity
Response
The resource name of the attachment. Format:
attachments/{attachment_id}The creation timestamp
The filename of the attachment
The MIME type of the attachment
The size of the attachment in bytes
The associated memo resource name, if any. Format:
memos/{memo_id}The external link, if provided
Error Responses
Invalid Argument
- Missing required fields (filename, content)
- Filename contains invalid characters
- Invalid MIME type format
- File size exceeds limit
Unauthenticated - User not authenticated
Example Response
List Attachments
Retrieves a paginated list of attachments with optional filtering and sorting.
GET /api/v1/attachments
Query Parameters
Maximum number of attachments to return. Default: 50, Maximum: 1000
Token for retrieving the next page of results (from previous response)
CEL expression to filter attachments. Examples:
mime_type == "image/png"filename.contains("report")create_time > timestamp("2024-01-01T00:00:00Z")memo == "memos/abc123"
==, !=, <, <=, >, >=, : (contains), inSupported fields: filename, mime_type, create_time, memoSort order. Examples:
"create_time desc"(default)"filename asc""size desc"
Response
Array of attachment objects (same structure as Create Attachment response)
Token for retrieving the next page. Omitted if no more pages.
Total count of attachments (may be approximate)
Example Response
Get Attachment
Retrieves metadata for a single attachment by ID. To download the actual file, use the file server endpoint.
GET /api/v1/attachments/{attachment_id}
Path Parameters
The ID of the attachment to retrieve
Response
Returns an attachment object (same structure as Create Attachment response).Error Responses
Invalid Argument - Invalid attachment ID format
Not Found - Attachment does not exist
Update Attachment
Updates specific fields of an attachment using field masks. Typically used to update the associated memo or external link.
PATCH /api/v1/attachments/{attachment_id}
Path Parameters
The ID of the attachment to update
Request Body
The attachment object with updated fields. Must include
name field.Specifies which fields to update.
Updatable Fields
memo- Associated memo resource nameexternal_link- External URLfilename- Filename (metadata only, doesn’t rename actual file)
Response
Returns the updated attachment object.Error Responses
Invalid Argument - Invalid update_mask or field values
Unauthenticated - User not authenticated
Permission Denied - User doesn’t own the attachment
Not Found - Attachment does not exist
Delete Attachment
Deletes an attachment and its associated file. This operation is permanent and cannot be undone.
DELETE /api/v1/attachments/{attachment_id}
Path Parameters
The ID of the attachment to delete
Response
Returns empty response on success.Error Responses
Unauthenticated - User not authenticated
Permission Denied - User doesn’t own the attachment
Not Found - Attachment does not exist
Downloading Files
To download the actual file content, use the file server endpoint (separate from the API).
GET /file/{attachment_id}/{filename}
- Returns the raw file content with appropriate
Content-Typeheader - Supports range requests for streaming large files
- Sets
Content-Dispositionheader for proper filename handling - Works without authentication for attachments linked to public memos
Thumbnail Generation
Thumbnails are automatically generated for supported image formats.
Supported Formats
image/pngimage/jpeg
- Generated on-demand when first requested
- Cached in
.thumbnail_cache/directory - Limited to 3 concurrent generation operations
- Automatically sized (typically 512px width, maintaining aspect ratio)
Accessing Thumbnails
?thumbnail=1 query parameter to request the thumbnail version.
Storage Backends
Local Storage (Default)
Attachments are stored in the data directory:S3-Compatible Storage
Configure via instance storage settings to use:- Amazon S3
- MinIO
- Cloudflare R2
- Any S3-compatible service
- Automatic pre-signed URL generation
- Configurable expiration times
- Support for custom endpoints
- Bucket and region configuration
Common MIME Types
Images
image/png- PNG imagesimage/jpeg- JPEG imagesimage/gif- GIF animationsimage/webp- WebP imagesimage/svg+xml- SVG vector graphics
Documents
application/pdf- PDF documentsapplication/msword- Microsoft Word (.doc)application/vnd.openxmlformats-officedocument.wordprocessingml.document- Word (.docx)text/plain- Plain text filestext/markdown- Markdown files
Audio/Video
audio/mpeg- MP3 audioaudio/wav- WAV audiovideo/mp4- MP4 videovideo/webm- WebM video
Archives
application/zip- ZIP archivesapplication/x-tar- TAR archivesapplication/gzip- GZIP compressed files
Best Practices
File Naming
- Use descriptive filenames with proper extensions
- Avoid special characters that may cause issues on different filesystems
- Keep filenames reasonably short (under 255 characters)
Performance
- Use thumbnails for image previews instead of loading full-size images
- Consider using external_link for very large files hosted elsewhere
- Implement pagination when listing many attachments
Security
- Attachments inherit visibility from their associated memo
- EXIF data is automatically stripped from images to protect privacy
- Validate file types on upload to prevent malicious content
Storage Management
- Regularly review and delete unused attachments
- Configure S3 lifecycle policies for automatic archival/deletion
- Monitor storage usage through instance settings