> ## Documentation Index
> Fetch the complete documentation index at: https://learn.nexudus.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create ReportSubscription

> Create a new ReportSubscription record.

A scheduled email delivery of a saved report or dashboard: the data is attached as CSV, the body carries an AI summary and a link to open it in the dashboard. Use report\_definition\_list / report\_dashboard\_list to find the report or dashboard to schedule.

## Authentication

<Note>
  This endpoint requires OAuth2 authentication. Include a valid bearer token in the `Authorization` header.
  The authenticated user must be a full unrestricted administrator or have the **`ReportSubscription-Create`** role.
</Note>

## Request Body

### Required Fields

<ParamField body="BusinessId" type="integer" required>
  ID of the business the schedule belongs to.
</ParamField>

<ParamField body="Name" type="string" required>
  Name of the schedule, e.g. Weekly revenue to finance.
</ParamField>

<ParamField body="Recipients" type="string" required>
  Email addresses separated by commas or semicolons.
</ParamField>

<ParamField body="Frequency" type="integer" required>
  Daily, Weekly or Monthly.
</ParamField>

<ParamField body="DayOfWeek" type="integer" required>
  Weekly schedules: 1 = Monday ... 7 = Sunday.
</ParamField>

<ParamField body="DayOfMonth" type="integer" required>
  Monthly schedules: day of the month (1-28).
</ParamField>

<ParamField body="HourOfDay" type="integer" required>
  Hour of the day to send (0-23) in the business time zone.
</ParamField>

### Optional Fields

<ParamField body="ReportDefinitionId" type="integer">
  Saved report to send (exactly one of ReportDefinitionId, ReportDashboardId, TemplateKey or DashboardTemplateKey).
</ParamField>

<ParamField body="ReportDashboardId" type="integer">
  Saved dashboard to send: every report tile is attached as CSV (set either ReportDefinitionId or ReportDashboardId).
</ParamField>

<ParamField body="TemplateKey" type="string">
  Built-in report template to send (key from report\_templates), instead of a saved report.
</ParamField>

<ParamField body="DashboardTemplateKey" type="string">
  Built-in dashboard template to send (key from report\_templates kind=dashboard), instead of a saved dashboard.
</ParamField>

<ParamField body="Subject" type="string">
  Optional email subject; defaults to the report or dashboard name.
</ParamField>

<ParamField body="IncludeAttachment" type="boolean">
  Attach the report data as CSV files.
</ParamField>

<ParamField body="IncludeSummary" type="boolean">
  Include an AI-written summary of the results in the email body.
</ParamField>

<ParamField body="ParametersJson" type="string">
  Optional JSON: for reports an array of prompt filter overrides \[\{field, op, value}], for dashboards an object of parameter values keyed by parameter id.
</ParamField>

<ParamField body="Active" type="boolean">
  Paused schedules are kept but not sent.
</ParamField>

<ParamField body="OwnerId" type="integer">
  User who created the schedule; reports run with this user's permissions (set automatically).
</ParamField>

## Code Examples

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST \
    "https://spaces.nexudus.com/api/sys/reportsubscriptions" \
    -H "Authorization: Bearer YOUR_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{
      "BusinessId": 0,
      "Name": "",
      "Recipients": "",
      "Frequency": 0,
      "DayOfWeek": 0,
      "DayOfMonth": 0,
      "HourOfDay": 0
  }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    'https://spaces.nexudus.com/api/sys/reportsubscriptions',
    {
      method: 'POST',
      headers: {
        'Authorization': 'Bearer YOUR_TOKEN',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        BusinessId: 0,
        Name: '',
        Recipients: '',
        Frequency: 0,
        DayOfWeek: 0,
        DayOfMonth: 0,
        HourOfDay: 0
      })
    }
  );

  const data = await response.json();
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      'https://spaces.nexudus.com/api/sys/reportsubscriptions',
      headers={
          'Authorization': 'Bearer YOUR_TOKEN',
          'Content-Type': 'application/json'
      },
      json={
          'BusinessId': 0,
          'Name': '',
          'Recipients': '',
          'Frequency': 0,
          'DayOfWeek': 0,
          'DayOfMonth': 0,
          'HourOfDay': 0
      }
  )

  data = response.json()
  ```
</CodeGroup>

## Response

### 200

<ResponseField name="Status" type="integer">
  HTTP status code. `200` on success.
</ResponseField>

<ResponseField name="Message" type="string">
  A human-readable message confirming the creation.
</ResponseField>

<ResponseField name="Value" type="object">
  Contains the `Id` of the newly created record.
</ResponseField>

<ResponseField name="WasSuccessful" type="boolean">
  `true` if the reportsubscription was created successfully.
</ResponseField>

<ResponseField name="Errors" type="array">
  `null` on success.
</ResponseField>

```json Example Response theme={null}
{
  "Status": 200,
  "Message": "ReportSubscription was successfully created.",
  "Value": {
    "Id": 87654321
  },
  "OpenInDialog": false,
  "OpenInWindow": false,
  "RedirectURL": null,
  "JavaScript": null,
  "UpdatedOn": "2025-01-15T10:30:00Z",
  "UpdatedBy": "admin@example.com",
  "Errors": null,
  "WasSuccessful": true
}
```

### 400

<ResponseField name="Message" type="string">
  A summary of the validation error(s), in the format `PropertyName: error message`.
</ResponseField>

<ResponseField name="Value" type="any">
  `null` on validation failure.
</ResponseField>

<ResponseField name="Errors" type="object[]">
  Array of validation errors.

  <Expandable>
    <ResponseField name="AttemptedValue" type="any">
      The value that was submitted for the field, or `null` if missing.
    </ResponseField>

    <ResponseField name="Message" type="string">
      The validation error message.
    </ResponseField>

    <ResponseField name="PropertyName" type="string">
      The name of the property that failed validation.
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="WasSuccessful" type="boolean">
  `false` when the request fails validation.
</ResponseField>

```json Example Response theme={null}
{
  "Message": "Name: is a required field",
  "Value": null,
  "Errors": [
    {
      "AttemptedValue": null,
      "Message": "is a required field",
      "PropertyName": "Name"
    }
  ],
  "WasSuccessful": false
}
```
