/o/reports/send
Overview
Triggers immediate sending of a scheduled report via email. Bypasses the normal schedule and sends the report now, regardless of time-of-day settings. Useful for urgent distribution or testing report content before scheduling.
Endpoint
/o/reports/send
Authentication
- Required: API key with read permission
- HTTP Method: GET recommended
- Permission: Standard read access to reports feature
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
api_key | String | Yes | API key with read permissions |
app_id | String | Yes | Application ID (for permission check) |
args | String | Yes | JSON string containing report _id |
args Parameter Format
{
"_id": "6262742dbf7392a8bfd8c1f6"
}
Response
Success Response - Report Sent
Status Code: 200 OK
Body:
Success Response
{"result": "Success"}
Report Not Found
Status Code: 200 OK
Body:
{"result": "Report not found"}
No Data to Report
Status Code: 200 OK
Body:
{"result": "No data to report"}
Response Fields
| Field | Type | Description |
|---|---|---|
* | Varies | Fields returned by this endpoint. See Success Response example. |
Error Responses
{
"result": "Error"
}
Permissions
- Required: API key with read permission
Database Collections
| Collection | Used for | Data touched by this endpoint |
|---|---|---|
countly.reports | Reports storage | Stores report definitions, snapshots, or generated artifacts handled by this endpoint. |
Examples
Example 1: Send report immediately
Description: Trigger instant delivery of scheduled report
Request (GET):
curl "https://your-server.com/o/reports/send?api_key=YOUR_API_KEY&app_id=507f1f77bcf86cd799439011&args=%7B%22_id%22%3A%226262742dbf7392a8bfd8c1f6%22%7D"
Response (200):
{"result": "Success"}
Note: The args parameter is URL-encoded JSON: {"_id":"6262742dbf7392a8bfd8c1f6"}
Example 2: Send with POST method
Description: Same request using POST
Request (POST):
curl -X POST "https://your-server.com/o/reports/send" \
-d "api_key=YOUR_API_KEY" \
-d "app_id=507f1f77bcf86cd799439011" \
-d 'args={"_id":"6262742dbf7392a8bfd8c1f6"}'
Response (200):
{"result": "Success"}
Example 3: Report not found
Description: Attempt to send non-existent report
Request (GET):
curl "https://your-server.com/o/reports/send?api_key=YOUR_API_KEY&app_id=507f1f77bcf86cd799439011&args=%7B%22_id%22%3A%22invalid_id%22%7D"
Response (200):
{"result": "Report not found"}
Behavior/Processing
Send Process
- Parse
argsJSON string - Validate report exists and user has access
- Check report ownership
- Non-admin: Can send own reports only
- Admin: Can send any report
- Generate report content
- Query data for specified date range
- Generate HTML from metrics/dashboards
- Render EJS templates for custom reports
- Send emails to all recipients in
emailsarray - Return success or error message
Permission Checking
Non-Admin Users:
- Can only send reports they created
- Checked via
userfield match - Returns "Report not found" if not owner
Global Admins:
- Can send any report
- No ownership check applied
Report Generation
Steps executed internally:
- Load report configuration from database
- Query data based on
apps,date_range,metrics - Generate HTML/PDF based on
sendPdfflag - Compose email with attachments
- Send to all recipients in
emailsarray
Email Delivery
- Recipients: Exact list in
emailsfield - Subject: Report title used in email subject
- Attachment: Optional PDF based on
sendPdfflag - Content-Type: HTML or text based on template
- Retry: Built-in mail service retry logic
- No notification: No confirmation sent to requestor
Data Included
Report sends data for:
- Apps: All apps listed in report config
- Metrics: Enabled metrics from
metricsobject - Events: Custom events from
selectedEventsarray - Dashboards: Dashboard data if configured
- Date: Last 30 days (default) or custom
date_range
Technical Notes
Database Operations
Read Operations:
- Collection:
reports - Query:
{_id: ObjectID(_id), user: current_user_id OR global_admin} - Operation: Find single report configuration
Send Operations:
- Email service: Sends to configured mail server
- No database write: Only read operation (query-only)
- Temporary files: PDF created in /tmp directory
Report Type Handling
Core Reports:
- Standard metric collection
- SQL-based data aggregation
- Standard HTML template rendering
Feature Reports:
- Dispatch to feature for content generation
- Feature returns HTML/data
- EJS template rendering applied
- Feature verification run first
Error Handling
- No strict validation: Returns generic messages
- Mail failures: Logged but success returned to API
- Missing data: Still sends without metrics (informational)
- User errors: Treated as "not found" for security
Related Endpoints
- Get All Reports - List all reports
- Create Report - Create scheduled report
- Report Preview - HTML preview
- Report PDF - PDF download
Error Handling
| Status Code | Condition | Response |
|---|---|---|
200 | Success - report sent | {"result": "Success"} |
200 | Report not found/access denied | {"result": "Report not found"} |
200 | No data available for report | {"result": "No data to report"} |
400 | Invalid JSON in args | {"result": 400, "message": "Invalid JSON in args"} |
401 | Invalid API key | Authentication error |
Implementation Notes
- Asynchronous sending: Mail sent in background, immediate response
- Access control: Non-admins can only send own reports
- No validation: Report config not re-validated
- Error messages: Generic to avoid information leakage
- Email list exact: Uses stored recipient list, no additions
- PDF generation: Based on
sendPdfflag in report config - Date range: Uses report's configured range (not current date)
- Frequency override: Ignores schedule, sends immediately
- Feature dispatch: Non-core reports sent through feature system
- Email headers: Standard mail headers with report title
- CC/BCC: Not supported, direct recipient list only
- Template rendering: EJS templates rendered on send, not cached
Last Updated
February 2026