---
title: "Publish a new report"
method: POST
path: "/datainsights/v1.1/stock_reports"
tags: ["Stock reports"]
---

# Publish a new report

`POST /datainsights/v1.1/stock_reports`

Publish a single report to a stock report with optional rules.

The API returns a 201 CREATED if the creation was successful.

## Headers

- `X-PROPERTY-ID` integer, required

## Request body

- StockReportPublish
  - `report_id` integer, required — Report Id
  - `rules` StockReportRules
    - `feature_ids` string[], nullable — Stock Report Feature ids, one to many relationship to associate a stock report with all properties with any number of Feature.
    - `property_ids` integer[], nullable — Stock Report Property ids, one to many relationship to associate a stock report with any number of property ID.
    - `country_codes` string[], nullable — Stock Report Country Codes, one to many relationship to associate a stock report with any number of country codes.
    - `property_types` string[], nullable — Property Type

## Response `201`

Created

- StockReport
  - `id` integer, required — Report id
  - `title` string, required — Report title
  - `description` string, nullable — Report description
  - `dataset_id` 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9, required — Dataset id
  - `columns` ReportColumns[], required — Report columns
    - `cdf` ReportCDF, required
      - `type` 'default' | 'custom' — Report cdf type
      - `column` string, required — Report cdf name
      - `multi_level_id` 1 | 2 | 3 | 4 — Multi-level where CDF is located
    - `metrics` string[] — Report column metrics
  - `group_rows` ReportGroup[], nullable — Report group rows
    - `cdf` ReportCDF, required
      - `type` 'default' | 'custom' — Report cdf type
      - `column` string, required — Report cdf name
      - `multi_level_id` 1 | 2 | 3 | 4 — Multi-level where CDF is located
    - `modifier` 'second' | 'minute' | 'hour' | 'day' | 'month' | 'year' | 'week' | 'weekday' | 'd' | 'm' | 'time_hour' | 'time_minute' | 'time_second' — Report group modifier
  - `group_columns` ReportGroup[], nullable — Report group columns
    - `cdf` ReportCDF, required
      - `type` 'default' | 'custom' — Report cdf type
      - `column` string, required — Report cdf name
      - `multi_level_id` 1 | 2 | 3 | 4 — Multi-level where CDF is located
    - `modifier` 'second' | 'minute' | 'hour' | 'day' | 'month' | 'year' | 'week' | 'weekday' | 'd' | 'm' | 'time_hour' | 'time_minute' | 'time_second' — Report group modifier
  - `periods` ReportPeriod[], nullable — Periods to compare
    - `cdf` ReportCDF, required
      - `type` 'default' | 'custom' — Report cdf type
      - `column` string, required — Report cdf name
      - `multi_level_id` 1 | 2 | 3 | 4 — Multi-level where CDF is located
    - `name` string, required — Label for a period
    - `id` string — machine name of period (auto-generated)
    - `start` string, required — The beginning date or relative date of a period. When both start and end dates are relative dates, the difference between today and the end date is subtracted from the start date.
    - `end` string, required — The beginning date or relative date of a period
    - `start_relative_to_end` boolean — If true, relative start date will be relative to the end date instead of today,e.g. if end date is 2023-01-01, a start date of yesterday would be 2022-12-31
  - `comparisons` ReportComparison[], nullable — A list of up to 5 Comparisons, each containing 'name' and 'filters' properties. The 'filters' are the same structure as those in report.filters.
    - `name` string, required — Label for a Comparison
    - `id` string — machine name of comparison (auto-generated)
    - `filters` ReportComparisonFilters
      - `and` ReportFilter[]
        - `and` ReportFilter[]
        - `or` ReportFilter[]
        - `cdf` ReportCDF
          - `type` 'default' | 'custom' — Report cdf type
          - `column` string, required — Report cdf name
          - `multi_level_id` 1 | 2 | 3 | 4 — Multi-level where CDF is located
        - `operator` 'begins' | 'not_begins' | 'ends' | 'not_ends' | 'contains' | 'not_contains' | 'list_contains' | 'not_list_contains' | 'is_null' | 'is_not_null' | 'is_empty' | 'is_not_empty' | 'equals' | 'not_equals' | 'greater_than' | 'less_than' | 'less_than_or_equal' | 'greater_than_or_equal' — Filter operator value
        - `value` unknown
  - `filters` ReportFilters
    - `and` ReportFilter[]
      - `and` ReportFilter[]
      - `or` ReportFilter[]
      - `cdf` ReportCDF
        - `type` 'default' | 'custom' — Report cdf type
        - `column` string, required — Report cdf name
        - `multi_level_id` 1 | 2 | 3 | 4 — Multi-level where CDF is located
      - `operator` 'begins' | 'not_begins' | 'ends' | 'not_ends' | 'contains' | 'not_contains' | 'list_contains' | 'not_list_contains' | 'is_null' | 'is_not_null' | 'is_empty' | 'is_not_empty' | 'equals' | 'not_equals' | 'greater_than' | 'less_than' | 'less_than_or_equal' | 'greater_than_or_equal' — Filter operator value
      - `value` unknown
    - `or` ReportFilter[]
      - `and` ReportFilter[]
      - `or` ReportFilter[]
      - `cdf` ReportCDF
        - `type` 'default' | 'custom' — Report cdf type
        - `column` string, required — Report cdf name
        - `multi_level_id` 1 | 2 | 3 | 4 — Multi-level where CDF is located
      - `operator` 'begins' | 'not_begins' | 'ends' | 'not_ends' | 'contains' | 'not_contains' | 'list_contains' | 'not_list_contains' | 'is_null' | 'is_not_null' | 'is_empty' | 'is_not_empty' | 'equals' | 'not_equals' | 'greater_than' | 'less_than' | 'less_than_or_equal' | 'greater_than_or_equal' — Filter operator value
      - `value` unknown
  - `sort` ReportSort[], nullable — Report sort
    - `cdf` ReportCDF, required
      - `type` 'default' | 'custom' — Report cdf type
      - `column` string, required — Report cdf name
      - `multi_level_id` 1 | 2 | 3 | 4 — Multi-level where CDF is located
    - `direction` 'asc' | 'desc', required — Report sort direction
  - `settings` ReportSettings
    - `details` boolean, required — Report details
    - `totals` boolean, required — Report totals
    - `transpose` boolean — Transpose Report
  - `formats` ReportFormats
    - `date` 'YYYY-MM-DD' | 'YYYY.MM.DD' | 'YYYY/MM/DD' | 'YYYY-DD-MM' | 'YYYY.DD.MM' | 'YYYY/DD/MM' | 'MM-YYYY-DD' | 'MM.YYYY.DD' | 'MM/YYYY/DD' | 'MM-DD-YYYY' | 'MM.DD.YYYY' | 'MM/DD/YYYY' | 'DD-YYYY-MM' | 'DD.YYYY.MM' | 'DD/YYYY/MM' | 'DD-MM-YYYY' | 'DD.MM.YYYY' | 'DD/MM/YYYY' | 'null', nullable — Date Format that will be applied in the export. The default is YYYY-MM-DD
  - `type` 'List' | 'Summary' | 'Pivot', required — Report type
  - `folder_id` integer, nullable, required — Folder id
  - `tags` Tag[], required — Report tags
    - `id` integer, required — Tag Id
    - `name` string, required — Tag Name
  - `schedule_ids` integer[], required — Report schedule ids
  - `updated_at` string — Report updated at
  - `property_ids` integer[] — Report property ids
  - `user_id` integer, required — User id
  - `custom_cdfs` StockReportCustomCdf[], nullable — Report custom cdfs
    - `id` integer — Report custom cdf id
    - `column` string — Report custom cdf column
    - `name` string, required — Report custom cdf name
    - `description` string, nullable — Report custom cdf description
    - `formula` CustomCdfFormula[], required
      - `kind` 'cdf' | 'separator' | 'operator' | 'operand' | 'parenthesis', required
      - `value` string, required — - If the kind is *cdf* the value must be a valid cdf. - If the kind is *separator* the supported values are any. - If the kind is *operator* the supported values are: ['+', '-', '*', '/']. - If the kind is *operand* the supported values are numbers. - If the kind is *parenthesis* the supported values are: ( or ).
      - `metric` 'sum' | 'mean' | 'max' | 'min' | 'count' | 'std' | 'var' | 'null', nullable
    - `kind` 'String' | 'Number' | 'Dynamic', required — Report custom cdf kind
    - `created_at` string — Report custom cdf created at
    - `updated_at` string — Report custom cdf updated at
    - `format` 'number' | 'currency' | 'percentage' | 'null', nullable — Custom Cdf Numeric format (valid for Number and Dynamic only)
  - `published` boolean — Published status of the report
  - `rules` StockReportRules
    - `feature_ids` string[], nullable — Stock Report Feature ids, one to many relationship to associate a stock report with all properties with any number of Feature.
    - `property_ids` integer[], nullable — Stock Report Property ids, one to many relationship to associate a stock report with any number of property ID.
    - `country_codes` string[], nullable — Stock Report Country Codes, one to many relationship to associate a stock report with any number of country codes.
    - `property_types` string[], nullable — Property Type
  - `created_by` User
    - `id` integer
    - `name` string
    - `email` string

## Other responses

- `400` — Bad Request
- `401` — Unauthorized
- `500` — Internal Server Error

---

[API](https://skmtc.net/cloudbeds/apis/cloudbeds-api.md) · [All operations](https://skmtc.net/cloudbeds/apis/cloudbeds-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/cloudbeds/cloudbeds-api/versions/2faa857793e8/schema)
