{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/reportingninja-com/json-schema/reportingninja-com-reports-update-request-schema.json",
  "title": "ReportsUpdateRequest",
  "description": "Which report to change, and which of its settings. Everything the body does not carry is left exactly as it is.",
  "x-generated": "2026-11-23",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/reportingninja-com-openapi.json#/components/schemas/ReportsUpdateRequest",
  "type": "object",
  "required": [
    "report_key"
  ],
  "properties": {
    "report_key": {
      "type": "string",
      "description": "The report to change, from /v1/reports/list."
    },
    "name": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "minLength": 1,
      "maxLength": 60,
      "description": "The title of the report, 1 to 60 characters: the name the cover paints. It is what /v1/reports/get answers as `name`. Null keeps the one the report has."
    },
    "internal_name": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "minLength": 1,
      "maxLength": 100,
      "description": "The name the list of the application shows, 1 to 100 characters. Left out or null, the one the report has is kept."
    },
    "subtitle": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "maxLength": 60,
      "description": "The subtitle under the title. An empty string clears it; null, which /v1/reports/get answers for a report without one, keeps the one the report has."
    },
    "internal_notes": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "maxLength": 250,
      "description": "Notes only the account sees. An empty string clears them; null, which /v1/reports/get answers for a report without them, keeps the ones the report has."
    },
    "share": {
      "type": "object",
      "description": "The public /share link of the report. On a report that has NO link yet the block has to carry `enabled`: the id is minted by this call, and a body that only set the other fields would publish a report nobody asked to publish. Refused on a template, which has no public link.",
      "properties": {
        "enabled": {
          "type": "boolean",
          "description": "Whether the link answers. Defaults to true the first time the report is shared."
        },
        "password": {
          "description": "The password the link asks for, stored hashed exactly as it is sent, spaces and any character included, which is how the visitor's typing is compared. null removes it and leaves the link unprotected; an empty string is refused; leaving the field out keeps the password the link already had.",
          "anyOf": [
            {
              "type": "string",
              "minLength": 1
            },
            {
              "type": "null"
            }
          ]
        },
        "allow_date_range": {
          "type": "boolean",
          "description": "Whether whoever opens the link may change the period. Defaults to false."
        },
        "regenerate": {
          "type": "boolean",
          "description": "Mint a new id, which invalidates the link that was given out. Default false."
        }
      },
      "additionalProperties": false
    },
    "data_sources": {
      "type": "array",
      "description": "The report level bindings, one entry per integration, as /v1/reports/create takes them, and remove: true on an entry to take the binding of its integration away. Refused on a report that assigns a connection per widget.",
      "items": {
        "$ref": "#/$defs/DataSourceUpdateInput"
      }
    },
    "date_range": {
      "description": "The period EVERY section of the report is moved to: the same object as a section's. It writes the range and nothing else -- the flags of each section header are left as they are. What it names is written into every section of the report; what it does not name, each section keeps as its own date range settings keep it: with the same preset its comparison, the offset of a last x period and the days left out of the current month or week, with another preset the defaults of that preset; the sections that lost something chosen the body did not name are named in a COMPARISON_RESET warning. null leaves every section as it is. It is not atomic: the sections are written one after another, and the answer lists the ones it wrote. The cached results of the report are dropped. On a TEMPLATE it reaches every report built on it; on a report built on a template it is refused.",
      "anyOf": [
        {
          "$ref": "#/$defs/CompositionDateRange"
        },
        {
          "type": "null"
        }
      ]
    },
    "brand_template": {
      "type": "string",
      "description": "The brand template the report is printed with: a key of a brand template of the account, or an empty string for the system one. A template carries no brand of its own and takes only the empty string, or the key it still stores, which changes nothing."
    },
    "brand_template_name": {
      "type": "string",
      "readOnly": true,
      "description": "Published by /v1/reports/get and written by nothing. It is accepted here so the whole `settings` block a read answers can be sent straight back as a body; the key is ignored and the answer carries a READ_ONLY_FIELD_IGNORED warning naming it."
    },
    "front_cover": {
      "$ref": "#/$defs/ReportFrontCoverInput",
      "description": "The front cover of the report: its type, its texts and its date line. The uploaded PDF itself is not written by this call."
    },
    "pdf": {
      "$ref": "#/$defs/ReportPdfOptions",
      "description": "What the generated PDF carries besides the report itself."
    },
    "localization": {
      "$ref": "#/$defs/ReportLocalizationInput",
      "description": "A report either follows the localization of the ACCOUNT or carries its own, which is what `use` says. The six settings below exist only in the second case: sending one of them with `use: account` is refused instead of being ignored, and a call that WRITES this branch asks for the six together. Once they are all there each of them can be written on its own, and a block that writes none of them changes nothing. The time zone and the time format are not settings of a report: they are the account's."
    },
    "language_file": {
      "type": "string",
      "description": "The language file the report is printed with: an empty string for the system default, one of the sixteen system files (`language_file_en`, `language_file_es`, ...) or the key of a language file of the account."
    },
    "language_file_name": {
      "type": "string",
      "readOnly": true,
      "description": "Published by /v1/reports/get and written by nothing. It is accepted here so the whole `settings` block a read answers can be sent straight back as a body; the key is ignored and the answer carries a READ_ONLY_FIELD_IGNORED warning naming it."
    },
    "substitution_variables": {
      "type": "array",
      "items": {
        "type": "string",
        "maxLength": 800
      },
      "minItems": 5,
      "maxItems": 5,
      "description": "The five substitution variables of the report, positional: the list carries exactly five values, one per %%CUSTOM_VAR_n%%, and an unused one is an empty string. Each of them is at most 800 characters."
    },
    "widgets_show": {
      "$ref": "#/$defs/ReportWidgetsShow",
      "description": "What the header of every widget of the report shows."
    },
    "snapshots_with_scheduled_executions": {
      "type": "boolean",
      "description": "Whether a snapshot of the report is stored every time it is delivered by a schedule."
    },
    "ai_brief": {
      "maxLength": 2000,
      "description": "What the AI summaries of this report should know about the client. Three states: leaving the field out -- or sending null, which is what a read answers for a report that has none -- keeps the brief the report has, an empty string removes it, and a text replaces it. At most 2000 characters. A brief that could not be written comes back as an AI_BRIEF_NOT_SAVED warning of a 200, with `ai_brief` left out of `updated_fields`.",
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "dry_run": {
      "type": "boolean",
      "description": "Validate and answer what WOULD happen, without writing anything. Default false."
    },
    "idempotency_key": {
      "type": "string",
      "description": "Makes a retry safe: the answer of the first call is replayed for 24 hours to any later call with the same key and the same body.",
      "pattern": "^[A-Za-z0-9_.-]{1,128}$",
      "maxLength": 128
    }
  },
  "additionalProperties": false,
  "$defs": {
    "CompositionDateRange": {
      "type": "object",
      "description": "The period of a report or of one of its sections. Its vocabulary is not the one of /v1/query: the presets a report has no equivalent for (lastweeksunsat, lastweekmonsun, thismonthtoyesterday, thisyear, lastyear, lastyeartodate, lastxweeksiso, lastxyears) are refused with the problem code DATE_PRESET_NOT_IN_REPORTS and the list of the ones that do exist, and three presets of a report have no name in /v1/query (sinceuntillastmonth, sinceuntillastweek, sinceuntilyesterday). It is the same object /v1/reports/get publishes for each section, so a section read can be sent back as it is: that changes nothing. A key sent as null is the same as leaving it out, and any other key that carries a value is refused with UNKNOWN_PARAM; x, start and end on a preset that does not use them are accepted and have no effect. since, offset and exclude_last_days with a value on a preset that does not take them are refused with INVALID_DATE_RANGE, except 0 (offset, exclude_last_days) and, in /v1/sections/update, the value /v1/reports/get published for that section, which is ignored. What a body names is written; what it does not name, each section keeps as the date range window of the application keeps it: with the same preset, its comparison, offset and days left out; with another preset, the defaults of that preset, and the answer names the sections that lost something chosen with a COMPARISON_RESET warning.",
      "required": [
        "preset"
      ],
      "properties": {
        "preset": {
          "type": "string",
          "description": "The period of the report.",
          "enum": [
            "today",
            "yesterday",
            "lastweek",
            "thisweek",
            "lastmonth",
            "thismonth",
            "lastxdays",
            "lastxweeks",
            "lastxmonths",
            "yeartolastmonth",
            "yeartolastweek",
            "custom",
            "sinceuntillastmonth",
            "sinceuntillastweek",
            "sinceuntilyesterday"
          ]
        },
        "x": {
          "description": "How many days, weeks or months. Required by the lastx* presets.",
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ]
        },
        "start": {
          "description": "First day of a custom period, as yyyy-MM-dd.",
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "end": {
          "description": "Last day of a custom period, as yyyy-MM-dd.",
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "since": {
          "description": "First day of a since period, as yyyy-MM-dd between 1900 and 2100. Required by sinceuntillastmonth, sinceuntillastweek and sinceuntilyesterday, which run from it to the end of last month, of last week or yesterday.",
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "offset": {
          "description": "How many days, weeks or months a lastxdays, lastxweeks or lastxmonths period is shifted back. 0 by default.",
          "anyOf": [
            {
              "type": "integer",
              "minimum": 0,
              "maximum": 1000
            },
            {
              "type": "null"
            }
          ]
        },
        "exclude_last_days": {
          "description": "How many of the last days a thismonth or thisweek period leaves out. 0 by default.",
          "anyOf": [
            {
              "type": "integer",
              "minimum": 0,
              "maximum": 29
            },
            {
              "type": "null"
            }
          ]
        },
        "compare_to": {
          "description": "The period the section is compared against: the figure of the period before of a KPI and a summary table, the change column, the previous series of a trend.",
          "anyOf": [
            {
              "$ref": "#/$defs/ReportCompareTo"
            },
            {
              "type": "null"
            }
          ]
        },
        "compare_to_second": {
          "description": "The second period it is compared against, independent of the first: the (-2) columns. A common form is lastmonth with compare_to previous and compare_to_second year_ago (the month before and the same month a year ago).",
          "anyOf": [
            {
              "$ref": "#/$defs/ReportCompareTo"
            },
            {
              "type": "null"
            }
          ]
        },
        "include_current": {
          "type": "boolean",
          "description": "Accepted so a range written for /v1/query can be sent as it is. A report's period never adds the day, week or month in progress to its preset (a last x months period always ends with the month before the current one), so false is what a report does; true is refused with INVALID_DATE_RANGE in any preset (today, thisweek and thismonth are the periods in progress)."
        }
      },
      "additionalProperties": false
    },
    "DataSourceUpdateInput": {
      "type": "object",
      "description": "One report level binding to set, or to take away with remove. Every widget of the report reads its integration from here.",
      "required": [
        "integration_id"
      ],
      "properties": {
        "integration_id": {
          "type": "string",
          "description": "Which integration this binding is for. Two entries may not name the same one."
        },
        "connection_key": {
          "type": "string",
          "description": "One of the connection keys of /v1/connections. Required unless remove is true, and refused with it."
        },
        "account_id": {
          "type": "string",
          "description": "One of the account ids of that connection. Required unless remove is true, and refused with it."
        },
        "entity": {
          "type": "string",
          "description": "REQUIRED for mailchimp when binding and rejected for every other integration: which of its two levels this binding is for. A removal of mailchimp takes both levels away.",
          "enum": [
            "campaign",
            "list"
          ]
        },
        "remove": {
          "type": "boolean",
          "description": "true takes the connection of this integration away from the report, as Remove assignment in the data sources window of the application: the entry names no connection_key or account_id. Refused with 400 INVALID_VALUE when the report has no connection for it, and with 409 IN_USE, naming them in details.widget_keys, while widgets of that integration read it. Cross-platform widgets that read it stop showing its data, and the answer names them in a DATA_SOURCES_PARTIALLY_BOUND warning. Absent, false or null bind the entry as usual."
        }
      }
    },
    "ReportCompareTo": {
      "type": "object",
      "description": "A period of a report is the same period shifted back. previous is the one the range is born with: the period of the same length right before on a last x or custom period, the month, week or day before on lastmonth, thismonth, lastweek, thisweek, yesterday and today, and a year back on yeartolastmonth, yeartolastweek and the three since presets (the second period, twice as far). It is not always the previous of /v1/query, which is the same number of days right before. year_ago is 12 months back and year_ago_match_weekday 52 weeks back on any preset; custom is any other shift, with its units and cycle (365 days is custom, not year_ago). A read publishes the first name that fits, in that order, so writing year_ago on yeartolastmonth reads back previous: the stored period is the same. none is refused: to hide the comparison, show_previous_period of the section is false, or previous_period and show_change of a widget.",
      "required": [
        "preset"
      ],
      "properties": {
        "preset": {
          "type": "string",
          "enum": [
            "previous",
            "year_ago",
            "year_ago_match_weekday",
            "custom"
          ]
        },
        "units": {
          "description": "custom only, and required there: how many cycles back.",
          "anyOf": [
            {
              "type": "integer",
              "minimum": 1,
              "maximum": 1800
            },
            {
              "type": "null"
            }
          ]
        },
        "cycle": {
          "description": "custom only, and required there.",
          "anyOf": [
            {
              "type": "string",
              "enum": [
                "day",
                "week",
                "month"
              ]
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "additionalProperties": false
    },
    "ReportCoverFile": {
      "type": "object",
      "description": "The PDF file the front cover prints, by name. Its content is never published.",
      "required": [
        "name"
      ],
      "properties": {
        "name": {
          "type": "string",
          "description": "The name of the uploaded file."
        }
      }
    },
    "ReportFrontCoverInput": {
      "type": "object",
      "description": "The front cover of the report. Every key is optional and what the body does not carry is left as it is; so is a key carrying null, which is what a read answers for a text the report does not have. The uploaded PDF itself is not written here: it has a route of its own, /v1/reports/set-cover-file.",
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "none",
            "report",
            "pdf",
            "pdf_and_report",
            "custom",
            "pdf_and_custom"
          ],
          "description": "What the front cover of the PDF is. `none` prints none, `report` draws the generated cover, `pdf` prints the uploaded file and `pdf_and_report` draws the generated text block over it. The `custom` pair is the legacy cover with texts of its own: it is kept and not offered, so only a report already printed with one of them is written with it again, and a cover that prints texts of its own asks for a title and a subtitle, in the body or already stored. The type commands the file: one that prints an uploaded PDF is refused on a report that carries none, and one that prints none removes the file the report carried, which the answer reports as a COVER_FILE_REMOVED warning."
        },
        "title": {
          "maxLength": 60,
          "description": "The title a legacy custom cover prints (`custom`, `pdf_and_custom`), at most 60 characters. Every other cover prints the `name` of the report, and a title different from the stored one is refused on them with 400 INVALID_VALUE (the value the read published, and an empty string, pass). An empty string clears it; null leaves it as it is.",
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "subtitle": {
          "maxLength": 60,
          "description": "The line under it on a legacy custom cover, at most 60 characters. Every other cover prints the `subtitle` of the report, and a value different from the stored one is refused on them with 400 INVALID_VALUE (the value the read published, and an empty string, pass). An empty string clears it; null leaves it as it is.",
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "date_line": {
          "type": "string",
          "enum": [
            "none",
            "generation_date",
            "current_period",
            "current_and_past_period"
          ],
          "description": "The date line of the cover, of the hero of the public link and of the header of the client portal."
        },
        "file": {
          "readOnly": true,
          "description": "Published by a read and written by /v1/reports/set-cover-file and by nothing else: it is accepted here so the `front_cover` a read answers can be sent straight back, and the key is ignored, with a READ_ONLY_FIELD_IGNORED warning naming it.",
          "anyOf": [
            {
              "$ref": "#/$defs/ReportCoverFile"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "additionalProperties": false
    },
    "ReportLocalizationInput": {
      "type": "object",
      "description": "A report either follows the localization of the ACCOUNT or carries its own, which is what `use` says. The six settings below exist only in the second case: sending one of them with `use: account` is refused instead of being ignored, and a call that WRITES this branch asks for the six together, in the body or already stored. Once they are all there each of them can be written on its own, and a block that gives no value at all changes nothing and asks for nothing -- which is what makes the block a read answers for a legacy report, whose six may be null, a body this call takes back. A key carrying null gives no value and leaves that column exactly as it is; an empty string is refused with INVALID_VALUE (a read never publishes one), and none of the six is ever written as null. A currency made of blanks is a value, as in the settings window; blanks in any of the other five are refused with INVALID_VALUE, since none of their values is blank. The time zone and the time format are not settings of a report: they are the account's, and they are copied from it every time this branch is written.",
      "properties": {
        "use": {
          "type": "string",
          "enum": [
            "account",
            "report"
          ],
          "description": "Whether the report follows the localization of the account or carries its own."
        },
        "date_format": {
          "description": "How dates are printed: `DDMMYYYY` is dd/MM/yyyy, `MMDDYYYY` is MM/dd/yyyy and `YYYYMMDD` is yyyy/MM/dd.",
          "anyOf": [
            {
              "type": "string",
              "enum": [
                "DDMMYYYY",
                "MMDDYYYY",
                "YYYYMMDD"
              ]
            },
            {
              "type": "null"
            }
          ]
        },
        "week_starts_on": {
          "description": "The first day of a week, which decides how weekly series are bucketed.",
          "anyOf": [
            {
              "type": "string",
              "enum": [
                "monday",
                "sunday"
              ]
            },
            {
              "type": "null"
            }
          ]
        },
        "decimal_separator": {
          "description": "The separator every figure of the report is printed with.",
          "anyOf": [
            {
              "type": "string",
              "enum": [
                ".",
                ","
              ]
            },
            {
              "type": "null"
            }
          ]
        },
        "currency": {
          "minLength": 1,
          "maxLength": 3,
          "description": "The currency symbol printed beside monetary figures, 1 to 3 characters.",
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "currency_symbol_position": {
          "description": "Which side of the figure the symbol is printed on.",
          "anyOf": [
            {
              "type": "string",
              "enum": [
                "left",
                "right"
              ]
            },
            {
              "type": "null"
            }
          ]
        },
        "pdf_page_size": {
          "description": "The page size of the generated PDF.",
          "anyOf": [
            {
              "type": "string",
              "enum": [
                "A4",
                "Letter"
              ]
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "additionalProperties": false
    },
    "ReportPdfOptions": {
      "type": "object",
      "description": "What the generated PDF carries besides the report itself.",
      "properties": {
        "table_of_contents": {
          "type": "boolean",
          "description": "Whether the PDF opens with a table of contents."
        },
        "page_numbers": {
          "type": "boolean",
          "description": "Whether its pages are numbered."
        },
        "title_in_pdf": {
          "type": "boolean",
          "description": "Whether the title of the report is printed on each page."
        }
      },
      "additionalProperties": false
    },
    "ReportWidgetsShow": {
      "type": "object",
      "description": "What the header of every widget of the report shows.",
      "properties": {
        "data_source_name": {
          "type": "boolean",
          "description": "Whether the name of the data source is shown."
        },
        "data_source_icon": {
          "type": "boolean",
          "description": "Whether its icon is shown."
        },
        "date_range": {
          "type": "boolean",
          "description": "Whether the period of the widget is shown."
        }
      },
      "additionalProperties": false
    }
  }
}