{
  "openapi": "3.1.0",
  "info": {
    "title": "Chartsy Integrations API",
    "version": "1.0.0",
    "description": "Read-only API for automation platforms (Zapier and others): feeds for polling triggers, REST hooks for instant triggers, and reports. Full guide: https://chartsy.app/help/chartsy/integrations-api",
    "contact": {
      "name": "Chartsy support",
      "email": "support@chartsy.app",
      "url": "https://chartsy.app/help/chartsy/integrations-api"
    }
  },
  "servers": [
    {
      "url": "https://dashboard.chartsy.app/api/integrations/v1"
    }
  ],
  "security": [
    {
      "oauth2": [
        "chartsy:read"
      ]
    }
  ],
  "tags": [
    {
      "name": "Connection",
      "description": "Connection test and dropdown sources."
    },
    {
      "name": "Feeds",
      "description": "Newest-first lists with a stable id per item, for polling triggers."
    },
    {
      "name": "Hooks",
      "description": "REST hook subscriptions for instant triggers."
    },
    {
      "name": "Reports",
      "description": "Single objects for get/search actions."
    }
  ],
  "paths": {
    "/me/": {
      "get": {
        "tags": [
          "Connection"
        ],
        "summary": "Connection test",
        "description": "The Chartsy login the token belongs to.",
        "parameters": [],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "integer",
                      "description": "User id."
                    },
                    "email": {
                      "type": "string",
                      "description": "Login email."
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "operationId": "getMe"
      }
    },
    "/accounts/": {
      "get": {
        "tags": [
          "Connection"
        ],
        "summary": "List accounts",
        "description": "The login's active accounts. id is the account_id other endpoints take.",
        "parameters": [],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "integer",
                        "description": "Account id."
                      },
                      "name": {
                        "type": "string",
                        "description": "Display name."
                      },
                      "currency": {
                        "type": "string",
                        "description": "Default currency."
                      },
                      "payment_processor": {
                        "type": [
                          "string",
                          "null"
                        ],
                        "description": "Billing provider."
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "operationId": "getAccounts"
      }
    },
    "/sites/": {
      "get": {
        "tags": [
          "Connection"
        ],
        "summary": "List tracked sites",
        "description": "Websites tracked with the Chartsy script. id is the site_id other endpoints take.",
        "parameters": [],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "integer",
                        "description": "Site id."
                      },
                      "name": {
                        "type": "string",
                        "description": "Site name."
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "operationId": "getSites"
      }
    },
    "/events/daily-snapshots/": {
      "get": {
        "tags": [
          "Feeds"
        ],
        "summary": "Daily snapshots",
        "description": "Settled days, newest first: the 30 most recent stored days; each day is computed once and frozen. id \"<account_id>:<date>\".",
        "parameters": [
          {
            "$ref": "#/components/parameters/account_id"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/DailySummary"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "operationId": "getEventsDailySnapshots"
      }
    },
    "/events/daily-summaries/": {
      "get": {
        "tags": [
          "Feeds"
        ],
        "summary": "Daily summary",
        "description": "The most recent settled day as a one-item array. id \"<account_id>-<date>\".",
        "parameters": [
          {
            "$ref": "#/components/parameters/account_id"
          },
          {
            "$ref": "#/components/parameters/site_id"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/DailySummary"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "operationId": "getEventsDailySummaries"
      }
    },
    "/events/cancellations/": {
      "get": {
        "tags": [
          "Feeds"
        ],
        "summary": "Recent cancellations",
        "description": "Test list for the subscription_canceled hook, same shape as deliveries. Topped up with preview records when few events exist. Not cached.",
        "parameters": [
          {
            "$ref": "#/components/parameters/account_id"
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Items to return.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 25
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Cancellation"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "operationId": "getEventsCancellations"
      }
    },
    "/events/goals-reached/": {
      "get": {
        "tags": [
          "Feeds"
        ],
        "summary": "Goals reached",
        "description": "The 25 most recently achieved goals.",
        "parameters": [
          {
            "$ref": "#/components/parameters/account_id"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Goal"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "operationId": "getEventsGoalsReached"
      }
    },
    "/events/mrr-milestones/": {
      "get": {
        "tags": [
          "Feeds"
        ],
        "summary": "MRR milestones",
        "description": "Every milestone at or below current MRR, highest first. id \"<account_id>-mrr-<milestone>\".",
        "parameters": [
          {
            "$ref": "#/components/parameters/account_id"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/MrrMilestone"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "operationId": "getEventsMrrMilestones"
      }
    },
    "/events/at-risk-customers/": {
      "get": {
        "tags": [
          "Feeds"
        ],
        "summary": "At-risk customers",
        "description": "Paused subscriptions, then customers with 2+ failed payments this quarter.",
        "parameters": [
          {
            "$ref": "#/components/parameters/account_id"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/AtRiskCustomer"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "operationId": "getEventsAtRiskCustomers"
      }
    },
    "/hooks/": {
      "get": {
        "tags": [
          "Hooks"
        ],
        "summary": "List hooks",
        "description": "The caller's active hooks.",
        "parameters": [],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Hook"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "operationId": "getHooks"
      },
      "post": {
        "tags": [
          "Hooks"
        ],
        "summary": "Subscribe",
        "description": "Register a callback URL for one event on one account. At most 100 active hooks per login.",
        "parameters": [],
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Hook"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "event",
                  "target_url"
                ],
                "properties": {
                  "event": {
                    "type": "string",
                    "description": "Event to subscribe to.",
                    "enum": [
                      "subscription_canceled"
                    ]
                  },
                  "target_url": {
                    "type": "string",
                    "description": "https URL on port 443 resolving to a public address; max 2000 characters.",
                    "format": "uri"
                  },
                  "account_id": {
                    "type": "integer",
                    "description": "Required when the login has several accounts."
                  }
                }
              }
            }
          }
        },
        "callbacks": {
          "subscriptionCanceled": {
            "{$request.body#/target_url}": {
              "post": {
                "summary": "Cancellation delivery",
                "description": "Sent for each new cancellation. 2xx = delivered; 410 switches the hook off; 429, 5xx and network errors are retried after 1m, 5m, 30m, 2h, 6h with the same event id; other 4xx and redirects fail.",
                "requestBody": {
                  "content": {
                    "application/json": {
                      "schema": {
                        "$ref": "#/components/schemas/Cancellation"
                      }
                    }
                  }
                },
                "responses": {
                  "200": {
                    "description": "Delivered"
                  },
                  "410": {
                    "description": "Hook no longer exists; Chartsy deactivates it."
                  }
                }
              }
            }
          }
        },
        "operationId": "postHooks"
      }
    },
    "/hooks/{id}/": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "description": "Hook id.",
          "schema": {
            "type": "integer"
          }
        }
      ],
      "get": {
        "tags": [
          "Hooks"
        ],
        "summary": "Get hook",
        "description": "One hook belonging to the caller.",
        "parameters": [],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Hook"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "operationId": "getHooksById"
      },
      "delete": {
        "tags": [
          "Hooks"
        ],
        "summary": "Unsubscribe",
        "description": "Stops deliveries, including pending retries. Idempotent.",
        "parameters": [],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Hook"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "operationId": "deleteHooksById"
      }
    },
    "/reports/mrr/": {
      "get": {
        "tags": [
          "Reports"
        ],
        "summary": "Current MRR",
        "description": "Current MRR and ARR.",
        "parameters": [
          {
            "$ref": "#/components/parameters/account_id"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Mrr"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "operationId": "getReportsMrr"
      }
    },
    "/reports/daily-summary/": {
      "get": {
        "tags": [
          "Reports"
        ],
        "summary": "Daily summary for a date",
        "description": "One day's figures.",
        "parameters": [
          {
            "$ref": "#/components/parameters/account_id"
          },
          {
            "name": "date",
            "in": "query",
            "required": false,
            "description": "Day to summarize. Defaults to yesterday.",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "$ref": "#/components/parameters/site_id"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DailySummary"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "operationId": "getReportsDailySummary"
      }
    },
    "/reports/business-snapshot/": {
      "get": {
        "tags": [
          "Reports"
        ],
        "summary": "Business snapshot",
        "description": "Headline numbers of a business review over the window.",
        "parameters": [
          {
            "$ref": "#/components/parameters/account_id"
          },
          {
            "name": "months",
            "in": "query",
            "required": false,
            "description": "Look-back window in months.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 36,
              "default": 12
            }
          },
          {
            "$ref": "#/components/parameters/site_id"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BusinessSnapshot"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "operationId": "getReportsBusinessSnapshot"
      }
    },
    "/reports/revenue-by-source/": {
      "get": {
        "tags": [
          "Reports"
        ],
        "summary": "Revenue by marketing source",
        "description": "Signups across all tracked sites grouped by attributed source, followed into billing.",
        "parameters": [
          {
            "$ref": "#/components/parameters/start_date"
          },
          {
            "$ref": "#/components/parameters/end_date"
          },
          {
            "name": "by",
            "in": "query",
            "required": false,
            "description": "Grouping.",
            "schema": {
              "type": "string",
              "enum": [
                "source",
                "medium",
                "campaign",
                "content"
              ],
              "default": "source"
            }
          },
          {
            "name": "touch",
            "in": "query",
            "required": false,
            "description": "Attribution touch.",
            "schema": {
              "type": "string",
              "enum": [
                "last",
                "first"
              ],
              "default": "last"
            }
          },
          {
            "$ref": "#/components/parameters/site_id"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RevenueBySource"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "operationId": "getReportsRevenueBySource"
      }
    },
    "/reports/traffic-sources/": {
      "get": {
        "tags": [
          "Reports"
        ],
        "summary": "Traffic sources",
        "description": "Visits and signups grouped by a traffic dimension.",
        "parameters": [
          {
            "$ref": "#/components/parameters/start_date"
          },
          {
            "$ref": "#/components/parameters/end_date"
          },
          {
            "name": "by",
            "in": "query",
            "required": false,
            "description": "Grouping.",
            "schema": {
              "type": "string",
              "enum": [
                "source",
                "medium",
                "campaign",
                "content",
                "country",
                "referrer",
                "landing_path"
              ],
              "default": "source"
            }
          },
          {
            "$ref": "#/components/parameters/site_id"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TrafficSources"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "operationId": "getReportsTrafficSources"
      }
    }
  },
  "components": {
    "securitySchemes": {
      "oauth2": {
        "type": "oauth2",
        "description": "Authorization code with PKCE (S256). Access tokens last 1 hour; refresh tokens 90 days and rotate on every refresh (old one accepted for 2 minutes). Client credentials in the body or HTTP Basic.",
        "flows": {
          "authorizationCode": {
            "authorizationUrl": "https://dashboard.chartsy.app/o/authorize/",
            "tokenUrl": "https://dashboard.chartsy.app/o/token/",
            "refreshUrl": "https://dashboard.chartsy.app/o/token/",
            "scopes": {
              "chartsy:read": "Read-only access to your Chartsy analytics data"
            }
          }
        }
      }
    },
    "parameters": {
      "account_id": {
        "name": "account_id",
        "in": "query",
        "required": false,
        "description": "Which account to read (from /accounts/). Required only when the login has several accounts.",
        "schema": {
          "type": "integer"
        }
      },
      "site_id": {
        "name": "site_id",
        "in": "query",
        "required": false,
        "description": "Limit traffic figures to one tracked site (from /sites/).",
        "schema": {
          "type": "integer"
        }
      },
      "start_date": {
        "name": "start_date",
        "in": "query",
        "required": false,
        "description": "First day included. Defaults to 30 days ago.",
        "schema": {
          "type": "string",
          "format": "date"
        }
      },
      "end_date": {
        "name": "end_date",
        "in": "query",
        "required": false,
        "description": "Last day included. Defaults to today.",
        "schema": {
          "type": "string",
          "format": "date"
        }
      }
    },
    "responses": {
      "BadRequest": {
        "description": "Invalid parameter, or account_id missing for a multi-account login.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Unauthorized": {
        "description": "Missing, expired or revoked token. Refresh and retry.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Detail"
            }
          }
        }
      },
      "Forbidden": {
        "description": "The login cannot use integrations right now (trial ended, no payment provider), or a non-integration client token.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Detail"
            }
          }
        }
      },
      "NotFound": {
        "description": "No such hook for this login.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "ServerError": {
        "description": "Chartsy failed; retry later.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string",
            "description": "Message for the end user."
          }
        }
      },
      "Detail": {
        "type": "object",
        "properties": {
          "detail": {
            "type": "string",
            "description": "Message for the end user."
          }
        }
      },
      "DailySummary": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Stable id: \"<account_id>-<date>\" (daily-summaries, reports) or \"<account_id>:<date>\" (daily-snapshots)."
          },
          "date": {
            "type": "string",
            "description": "Day the figures cover (UTC).",
            "format": "date"
          },
          "account_id": {
            "type": "integer",
            "description": "Account id."
          },
          "account_name": {
            "type": "string",
            "description": "Account display name."
          },
          "currency": {
            "type": "string",
            "description": "ISO 4217 code of every money field."
          },
          "mrr": {
            "type": "number",
            "description": "MRR at the end of the day."
          },
          "revenue": {
            "type": "number",
            "description": "Revenue collected that day."
          },
          "revenue_previous_day": {
            "type": "number",
            "description": "Revenue the day before."
          },
          "revenue_trailing_daily_average": {
            "type": "number",
            "description": "Average daily revenue over the previous 7 days."
          },
          "revenue_change_vs_previous_day_percent": {
            "type": [
              "number",
              "null"
            ],
            "description": "Change vs the previous day."
          },
          "revenue_change_vs_trailing_average_percent": {
            "type": [
              "number",
              "null"
            ],
            "description": "Change vs the 7-day average."
          },
          "new_subscribers": {
            "type": "integer",
            "description": "New paying subscribers that day."
          },
          "new_subscribers_previous_day": {
            "type": "integer",
            "description": "New paying subscribers the day before."
          },
          "churned_customers": {
            "type": "integer",
            "description": "Customers whose paid access ended that day."
          },
          "churn_rate_percent": {
            "type": [
              "number",
              "null"
            ],
            "description": "Customer churn rate for the day."
          },
          "refund_count": {
            "type": "integer",
            "description": "Refunds issued that day."
          },
          "total_refunded": {
            "type": "number",
            "description": "Amount refunded that day."
          },
          "visits": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Website visits; null without website tracking."
          },
          "unique_visitors": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Unique visitors."
          },
          "signups": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Tracked signups."
          },
          "visits_change_vs_trailing_average_percent": {
            "type": [
              "number",
              "null"
            ],
            "description": "Visits change vs the 7-day average."
          },
          "top_source": {
            "type": [
              "string",
              "null"
            ],
            "description": "Traffic source with the most visits."
          },
          "warning_count": {
            "type": "integer",
            "description": "Number of data-quality warnings."
          },
          "warnings": {
            "type": "string",
            "description": "Warnings, one per line; empty when none."
          },
          "summary": {
            "type": "string",
            "description": "Ready-to-post multi-line summary."
          },
          "revenue_by_plan": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "plan": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "description": "Plan name."
                },
                "revenue": {
                  "type": [
                    "number",
                    "null"
                  ],
                  "description": "Revenue."
                }
              }
            }
          },
          "traffic_by_source": {
            "type": "array",
            "maxItems": 10,
            "items": {
              "type": "object",
              "properties": {
                "source": {
                  "type": "string",
                  "description": "Source."
                },
                "visits": {
                  "type": "integer",
                  "description": "Visits."
                },
                "signups": {
                  "type": "integer",
                  "description": "Signups."
                }
              }
            }
          }
        }
      },
      "Cancellation": {
        "type": "object",
        "properties": {
          "id": {
            "oneOf": [
              {
                "type": "integer"
              },
              {
                "type": "string"
              }
            ],
            "description": "Event id, identical on every delivery attempt. Preview records in the test list use \"preview-<subscription_id>\"."
          },
          "account_id": {
            "type": "integer",
            "description": "Account id."
          },
          "provider": {
            "type": "string",
            "description": "Billing provider, e.g. stripe, paddle, polar."
          },
          "subscription_id": {
            "type": "string",
            "description": "Provider's subscription id."
          },
          "customer_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "Provider's customer id."
          },
          "customer_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Customer name."
          },
          "customer_email": {
            "type": [
              "string",
              "null"
            ],
            "description": "Customer email."
          },
          "plan_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Plan or price name."
          },
          "mrr_at_risk": {
            "type": [
              "number",
              "null"
            ],
            "description": "Monthly amount of the subscription."
          },
          "currency": {
            "type": "string",
            "description": "ISO 4217 code of mrr_at_risk."
          },
          "canceled_at": {
            "type": [
              "string",
              "null"
            ],
            "description": "When the cancel was requested (UTC).",
            "format": "date-time"
          },
          "access_ends_at": {
            "type": [
              "string",
              "null"
            ],
            "description": "When paid access ends (UTC).",
            "format": "date-time"
          },
          "cancellation_reason": {
            "type": [
              "string",
              "null"
            ],
            "description": "Customer's reason, when collected."
          },
          "summary": {
            "type": "string",
            "description": "Ready-to-post sentence."
          }
        }
      },
      "Hook": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "description": "Hook id; use it to unsubscribe."
          },
          "account_id": {
            "type": "integer",
            "description": "Account the hook watches."
          },
          "event": {
            "type": "string",
            "description": "Event name.",
            "enum": [
              "subscription_canceled"
            ]
          },
          "target_url": {
            "type": "string",
            "description": "Callback URL.",
            "format": "uri"
          },
          "active": {
            "type": "boolean",
            "description": "False once unsubscribed or after a 410 response."
          },
          "created_at": {
            "type": "string",
            "description": "Creation time (UTC).",
            "format": "date-time"
          }
        }
      },
      "Goal": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "description": "Goal id."
          },
          "title": {
            "type": "string",
            "description": "Goal title."
          },
          "goal_type": {
            "type": "string",
            "description": "Goal type.",
            "enum": [
              "mrr",
              "arr",
              "total_subscribers",
              "churn_rate"
            ]
          },
          "goal_type_label": {
            "type": "string",
            "description": "Readable goal type."
          },
          "target_value": {
            "type": "number",
            "description": "Target."
          },
          "baseline_value": {
            "type": [
              "number",
              "null"
            ],
            "description": "Value when set."
          },
          "deadline": {
            "type": [
              "string",
              "null"
            ],
            "description": "Deadline.",
            "format": "date"
          },
          "achieved_at": {
            "type": "string",
            "description": "When reached.",
            "format": "date"
          },
          "account_id": {
            "type": "integer",
            "description": "Account id."
          },
          "account_name": {
            "type": "string",
            "description": "Account name."
          },
          "currency": {
            "type": "string",
            "description": "Currency."
          },
          "summary": {
            "type": "string",
            "description": "Ready-to-post sentence."
          }
        }
      },
      "MrrMilestone": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "\"<account_id>-mrr-<milestone>\"."
          },
          "milestone": {
            "type": "integer",
            "description": "Milestone passed."
          },
          "mrr": {
            "type": "number",
            "description": "Current MRR."
          },
          "currency": {
            "type": "string",
            "description": "Currency."
          },
          "account_id": {
            "type": "integer",
            "description": "Account id."
          },
          "account_name": {
            "type": "string",
            "description": "Account name."
          },
          "summary": {
            "type": "string",
            "description": "Ready-to-post sentence."
          }
        }
      },
      "AtRiskCustomer": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "\"paused-<subscription_id>\" or \"failed-<customer_id>-<quarter>\"."
          },
          "reason": {
            "type": "string",
            "description": "Why at risk.",
            "enum": [
              "paused",
              "failed_payments"
            ]
          },
          "customer_id": {
            "type": "string",
            "description": "Provider's customer id."
          },
          "subscription_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "Paused subscription id."
          },
          "failed_payments_this_quarter": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Failed payments this quarter."
          },
          "paused_date": {
            "type": [
              "string",
              "null"
            ],
            "description": "Paused since.",
            "format": "date"
          },
          "days_paused": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Days paused."
          },
          "account_id": {
            "type": "integer",
            "description": "Account id."
          },
          "account_name": {
            "type": "string",
            "description": "Account name."
          },
          "summary": {
            "type": "string",
            "description": "Ready-to-post sentence."
          }
        }
      },
      "Mrr": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "\"<account_id>-mrr-<date>\"."
          },
          "account_id": {
            "type": "integer",
            "description": "Account id."
          },
          "account_name": {
            "type": "string",
            "description": "Account name."
          },
          "mrr": {
            "type": "number",
            "description": "Current MRR."
          },
          "arr": {
            "type": "number",
            "description": "MRR x 12."
          },
          "currency": {
            "type": "string",
            "description": "Currency."
          },
          "as_of": {
            "type": "string",
            "description": "Date.",
            "format": "date"
          }
        }
      },
      "BusinessSnapshot": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Report id."
          },
          "account_id": {
            "type": "integer",
            "description": "Account id."
          },
          "account_name": {
            "type": "string",
            "description": "Account name."
          },
          "currency": {
            "type": "string",
            "description": "Currency."
          },
          "start_date": {
            "type": "string",
            "description": "Window start.",
            "format": "date"
          },
          "end_date": {
            "type": "string",
            "description": "Window end.",
            "format": "date"
          },
          "mrr": {
            "type": "number",
            "description": "Current MRR."
          },
          "new_subscribers_this_month": {
            "type": [
              "integer",
              "null"
            ],
            "description": "New subscribers this month."
          },
          "churn_rate_this_month_percent": {
            "type": [
              "number",
              "null"
            ],
            "description": "Churn rate this month."
          },
          "top_customers_share_of_mrr_percent": {
            "type": [
              "number",
              "null"
            ],
            "description": "Top 3 customers' share of MRR."
          },
          "refund_count": {
            "type": [
              "integer",
              "null"
            ],
            "description": "All-time refunds."
          },
          "total_refunded": {
            "type": [
              "number",
              "null"
            ],
            "description": "All-time amount refunded."
          },
          "at_risk_failed_payments": {
            "type": "integer",
            "description": "Customers with 2+ failed payments."
          },
          "at_risk_paused": {
            "type": "integer",
            "description": "Paused subscriptions."
          },
          "warning_count": {
            "type": "integer",
            "description": "Data-quality warnings."
          },
          "warnings": {
            "type": "string",
            "description": "Warnings, one per line."
          },
          "summary": {
            "type": "string",
            "description": "Ready-to-post summary."
          },
          "mrr_by_plan": {
            "type": "array",
            "maxItems": 50,
            "items": {
              "type": "object",
              "properties": {
                "plan": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "description": "Plan name."
                },
                "period": {
                  "type": "string",
                  "description": "Period start.",
                  "format": "date"
                },
                "mrr": {
                  "type": "number",
                  "description": "MRR of the plan in the period."
                },
                "customers": {
                  "type": "integer",
                  "description": "Paying customers on the plan."
                }
              }
            }
          },
          "traffic_by_source": {
            "type": "array",
            "maxItems": 10,
            "items": {
              "type": "object",
              "properties": {
                "source": {
                  "type": "string",
                  "description": "Source."
                },
                "visits": {
                  "type": "integer",
                  "description": "Visits."
                },
                "signups": {
                  "type": "integer",
                  "description": "Signups."
                }
              }
            }
          }
        }
      },
      "RevenueBySource": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Report id."
          },
          "by": {
            "type": "string",
            "description": "Grouping."
          },
          "touch": {
            "type": "string",
            "description": "Attribution touch."
          },
          "start_date": {
            "type": "string",
            "description": "Window start.",
            "format": "date"
          },
          "end_date": {
            "type": "string",
            "description": "Window end.",
            "format": "date"
          },
          "currency": {
            "type": [
              "string",
              "null"
            ],
            "description": "Currency."
          },
          "signups": {
            "type": "integer",
            "description": "Signups in the window."
          },
          "unattributed_paying_customers": {
            "type": "integer",
            "description": "Paying customers with no attributed visit."
          },
          "top_group": {
            "type": [
              "string",
              "null"
            ],
            "description": "Top group."
          },
          "top_group_mrr": {
            "type": [
              "number",
              "null"
            ],
            "description": "Top group MRR."
          },
          "top_group_paying_customers": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Top group paying customers."
          },
          "summary": {
            "type": "string",
            "description": "Ready-to-post summary."
          },
          "notes": {
            "type": "string",
            "description": "Caveats, one per line; always includes the low_sample note."
          },
          "groups": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "group": {
                  "type": "string",
                  "description": "Group value."
                },
                "signups": {
                  "type": "integer",
                  "description": "Signups."
                },
                "matched_signups": {
                  "type": "integer",
                  "description": "Signups matched to a customer."
                },
                "unmatched_signups": {
                  "type": "integer",
                  "description": "Signups not matched."
                },
                "paying_customers": {
                  "type": "integer",
                  "description": "Paying customers."
                },
                "signup_to_paid_rate_percent": {
                  "type": [
                    "number",
                    "null"
                  ],
                  "description": "Signup-to-paid rate."
                },
                "current_mrr": {
                  "type": [
                    "number",
                    "null"
                  ],
                  "description": "Current MRR of those customers."
                },
                "active_customers": {
                  "type": "integer",
                  "description": "Still active."
                },
                "churned_customers": {
                  "type": "integer",
                  "description": "Churned."
                },
                "churned_mrr": {
                  "type": [
                    "number",
                    "null"
                  ],
                  "description": "Churned MRR."
                },
                "retention_rate_percent": {
                  "type": [
                    "number",
                    "null"
                  ],
                  "description": "Retention rate."
                },
                "low_sample": {
                  "type": "boolean",
                  "description": "Fewer than 5 paying customers."
                }
              }
            }
          }
        }
      },
      "TrafficSources": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Report id."
          },
          "by": {
            "type": "string",
            "description": "Grouping."
          },
          "start_date": {
            "type": "string",
            "description": "Window start.",
            "format": "date"
          },
          "end_date": {
            "type": "string",
            "description": "Window end.",
            "format": "date"
          },
          "visits": {
            "type": "integer",
            "description": "Total visits."
          },
          "signups": {
            "type": "integer",
            "description": "Total signups."
          },
          "top_group": {
            "type": [
              "string",
              "null"
            ],
            "description": "Top group."
          },
          "top_group_visits": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Top group visits."
          },
          "summary": {
            "type": "string",
            "description": "Ready-to-post summary."
          },
          "groups": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "group": {
                  "type": "string",
                  "description": "Group value."
                },
                "visits": {
                  "type": "integer",
                  "description": "Visits."
                },
                "unique_visitors": {
                  "type": "integer",
                  "description": "Unique visitors."
                },
                "signups": {
                  "type": "integer",
                  "description": "Signups."
                },
                "registered_accounts": {
                  "type": "integer",
                  "description": "Registered accounts."
                },
                "signup_rate_percent": {
                  "type": [
                    "number",
                    "null"
                  ],
                  "description": "Signup rate."
                }
              }
            }
          }
        }
      }
    }
  }
}
