# Create Analytics Publication

Send a page on a schedule. Pick a channel, its recipients or destination, and a schedule. It starts paused; send isActive: true to schedule it right away. externalRecipients get the page by email from outside your organization, so add them only when that is meant.

`POST https://connect.mindcloud.co/v2/analytics/pages/:pageId/publications`

Permissions: `analytics:page:create`.

## Parameters

### Path

- `pageId` (string, required): The page id, from List Analytics Pages.

### Headers

- `X-Company-Id` (string): Optional. The id of the organization to act in. Leave it out to act in the API key's own organization. Here a key acts in another organization only as one of its members: with "Use this key across all of your organizations" on, in an organization its creator belongs to with a role. Child organizations and MindCloud staff access do not reach this endpoint. Every response's X-Company-Id header names the organization it acted in. See [Organizations](https://mindcloud.co/docs/api/rest/introduction/organizations).

### Body

- `name` (string): What it is called.
  What it is called, such as "Weekly revenue".
- `channel` (string): Where it sends: email, slack or teams. Defaults to email on create.
  Where it sends. Changing it clears the connection and destination; the recipients stay.
  Allowed values:
    - `email`: Email to the recipients, from MindCloud or from a Gmail or Outlook connection.
    - `slack`: A message in a Slack channel, sent with a Slack connection.
    - `teams`: A message in a Microsoft Teams channel, sent with a Microsoft Teams connection.
- `scheduleType` (string): fixed, interval, monthly or once.
  How the schedule is set.
  Allowed values:
    - `fixed`: On the weekdays in days, at each time in runTimes.
    - `interval`: Every intervalMinutes, starting at the first time in runTimes.
    - `monthly`: On the days of the month in monthDays, at each time in runTimes.
    - `once`: Once, on the date in runDates, at the time in runTimes.
- `intervalMinutes` (number): For interval: minutes between sends, 360 to 43200.
  For interval: minutes between sends, 360 (six hours) to 43200 (thirty days).
- `days` (array): For fixed: weekdays, 0 (Sunday) to 6 (Saturday).
- `monthDays` (array): For monthly: days of the month, 1 to 30, or -1 for the last day.
- `runDates` (array): For once: the date, as YYYY-MM-DD.
- `runTimes` (array): Times of day, as HH:MM in timeZone.
  Times of day, zero-padded HH:MM in timeZone, like 09:00. Activating needs at least one.
- `timeZone` (string): An IANA time zone, or null to follow the organization's.
  An IANA time zone, such as America/New_York, or null to follow the organization's time zone (the default).
- `recipientUserIds` (array): Member recipients by user id, from List Members. Replaces the list.
  Member recipients by user id, from List Members. Replaces the list. At most 50.
- `externalRecipients` (array): Addresses outside your organization. Each gets the page by email. Replaces the list.
  Email addresses outside the organization. Each one gets the page by email, from outside your organization. Replaces the list. At most 50.
- `subject` (string): The email subject. Defaults to the page's name.
  The email subject. Leave it out to use the page's name.
- `connectionId` (string): The connection to send through, from List Connections. Email: Gmail or Outlook, or null for MindCloud's sender. Slack and teams: one of that app.
  The connection to send through, from List Connections, or null. Email: a Gmail or Outlook connection, or null for MindCloud's own sender. Slack and teams need one of that app. Its owner must let the key's creator use it.
- `destination` (object): For slack and teams: where it posts, with ids from Resolve Universal Lookup.
  For slack and teams: where it posts. Find the ids with Resolve Universal Lookup on the app. Replaces the stored destination.
  - `channelId` (string): Slack and Teams: the channel id to post in.
  - `channelLabel` (string): Slack and Teams: the channel name, shown in the app.
  - `teamId` (string): Teams: the team id.
  - `teamLabel` (string): Teams: the team name, shown in the app.
- `variables` (object): Its own filter values, by page variable name (from Get Analytics Page). Replaces the stored map; {} goes back to the page's defaults.
  Its own filter values, by page variable name (see Get Analytics Page), each as the page's link carries it. Replaces the stored map; {} goes back to the page's defaults.
- `isActive` (boolean): true schedules it, false pauses it.
  true schedules it, false pauses it. Activating needs a complete schedule and, for slack and teams, a connection and destination.

## Example request

```bash
curl --request POST \
  --url 'https://connect.mindcloud.co/v2/analytics/pages/Pq7Lm2Xc9RtA/publications' \
  --header 'Authorization: Bearer $MINDCLOUD_API_TOKEN' \
  --header 'Content-Type: application/json' \
  --data '{
  "name": "Weekly revenue",
  "channel": "email",
  "scheduleType": "fixed",
  "intervalMinutes": 1440,
  "days": [
    1
  ],
  "monthDays": [
    1,
    -1
  ],
  "runDates": [
    "2026-12-01"
  ],
  "runTimes": [
    "09:00"
  ],
  "timeZone": "America/New_York",
  "recipientUserIds": [
    "user_2wXk9Lm4Pq7Rz3Ts8Vb1Nc6Hd"
  ],
  "externalRecipients": [
    "cfo@client.com"
  ],
  "subject": "Weekly revenue",
  "connectionId": "Cn6vH3jW8qYt",
  "destination": {
    "channelId": "C04ABC123",
    "channelLabel": "#revenue"
  },
  "variables": {
    "region": "west"
  },
  "isActive": true
}'
```

## Response fields

- `id` (string): The publication's id.
- `pageId` (string): The page it sends, from List Analytics Pages.
- `name` (string): Its name. Null until one is given.
- `isActive` (boolean): True when it sends on its schedule. A new publication starts paused.
- `channel` (string): Where it sends.
  Allowed values:
    - `email`: Email to the recipients, from MindCloud or from a Gmail or Outlook connection.
    - `slack`: A message in a Slack channel, sent with a Slack connection.
    - `teams`: A message in a Microsoft Teams channel, sent with a Microsoft Teams connection.
- `scheduleType` (string): How its schedule is set.
  Allowed values:
    - `fixed`: On the weekdays in days, at each time in runTimes.
    - `interval`: Every intervalMinutes, starting at the first time in runTimes.
    - `monthly`: On the days of the month in monthDays, at each time in runTimes.
    - `once`: Once, on the date in runDates, at the time in runTimes.
- `intervalMinutes` (number): For interval: minutes between sends, 360 (six hours) to 43200 (thirty days).
- `days` (array of number): For fixed: the weekdays it sends on, 0 (Sunday) to 6 (Saturday).
- `monthDays` (array of number): For monthly: the days of the month it sends on, 1 to 30, or -1 for the last day.
- `runDates` (array of string): For once: the date it sends on, as YYYY-MM-DD.
- `runTimes` (array of string): The times of day it sends at, as HH:MM in timeZone.
- `timeZone` (string): The IANA time zone its times are in, such as America/New_York.
- `isOrganizationTimeZone` (boolean): True when timeZone is the organization's time zone and changes with it; false when one was set for this publication.
- `nextRunOn` (date): When it sends next. Null while it is paused or has nothing left to send.
- `autoPausedOn` (date): When MindCloud paused it after failed sends. Null when it was not.
- `autoPauseReason` (string): Why MindCloud paused it. Null when it was not.
- `recipientUserIds` (array of string): Member recipients, by user id (from List Members).
- `externalRecipients` (array of string): Recipients outside the organization, by email address.
- `unsubscribedRecipientUserIds` (array of string): Members who unsubscribed with the link in its email, by user id. They get nothing until resubscribed.
- `unsubscribedExternalRecipients` (array of string): Outside addresses that unsubscribed with the link in its email.
- `subject` (string): The email subject. Null uses the page's name.
- `connectionId` (string): The connection it sends through, from List Connections. Null for email from MindCloud's own sender.
- `destination` (object): For slack and teams: where it posts. Null for email.
  - `channelId` (string): Slack and Teams: the channel id it posts in. Null for email.
  - `channelLabel` (string): Slack and Teams: the channel name, as picked. Null for email.
  - `teamId` (string): Teams: the team id. Null otherwise.
  - `teamLabel` (string): Teams: the team name, as picked. Null otherwise.
- `variables` (object): Its own filter values, by page variable name, as the page's link carries them. Empty uses the page's defaults.
- `createdOn` (date): When it was created.
- `updatedOn` (date): When it last changed.
