---
openapi: 3.0.3
info:
  title: Braze REST API – Export Canvas data series analytics
  description: |
    ## Prerequisites

    To use this endpoint, you'll need an [API key]({{site.baseurl}}/api/basics#rest-api-key-permissions) with the `canvas.data_series` permission.

    ## Rate limit

    We apply the default Braze rate limit of 250,000 requests per hour to this endpoint, as documented in [API rate limits]({{site.baseurl}}/api/api_limits/).
  version: 1.0.0
  contact:
    name: Braze Support
    url: https://www.braze.com/docs/braze_support/
  license:
    name: Braze Documentation
    url: https://www.braze.com/docs/api/home/
servers:
  - url: https://rest.iad-01.braze.com
    description: US-01
  - url: https://rest.iad-02.braze.com
    description: US-02
  - url: https://rest.iad-03.braze.com
    description: US-03
  - url: https://rest.iad-04.braze.com
    description: US-04
  - url: https://rest.iad-05.braze.com
    description: US-05
  - url: https://rest.iad-06.braze.com
    description: US-06
  - url: https://rest.iad-07.braze.com
    description: US-07
  - url: https://rest.iad-08.braze.com
    description: US-08
  - url: https://rest.us-10.braze.com
    description: US-10
  - url: https://rest.fra-01.braze.eu
    description: EU-01
  - url: https://rest.fra-02.braze.eu
    description: EU-02
  - url: https://rest.au-01.braze.com
    description: AU-01
  - url: https://rest.id-01.braze.com
    description: ID-01
  - url: https://rest.jp-01.braze.com
    description: JP-01
  - url: https://rest.kr-01.braze.com
    description: KR-01
security:
- BearerAuth: []
paths:
  "/canvas/data_series":
    get:
      summary: Export Canvas data series analytics
      operationId: get_canvas_data_series_get_canvas_analytics
      parameters:
        - name: canvas_id
          in: query
          required: true
          description: See [Canvas API identifier]({{site.baseurl}}/api/identifier_types/).
          schema:
            type: string
          example: canvas_identifier
        - name: ending_at
          in: query
          required: true
          description: Date on which the data export should end. Defaults to time of the request.
          schema:
            type: string
            format: date-time
          example: "2018-05-30T23:59:59-05:00"
        - name: starting_at
          in: query
          required: false
          description: |
            Date on which the data export should begin.

            Either `length` or `starting_at` is required.
          schema:
            type: string
            format: date-time
          example: "2018-05-28T23:59:59-05:00"
        - name: length
          in: query
          required: false
          description: |
            Maximum number of days before `ending_at` to include in the returned series. Must be between 1 and 14 (inclusive).

            Either `length` or `starting_at` is required.
          schema:
            type: integer
            minimum: 1
            maximum: 14
        - name: include_variant_breakdown
          in: query
          required: false
          description: Whether or not to include variant statistics (defaults to `false`).
          schema:
            type: boolean
            default: false
          example: true
        - name: include_step_breakdown
          in: query
          required: false
          description: Whether or not to include step statistics (defaults to `false`).
          schema:
            type: boolean
            default: false
          example: true
        - name: include_deleted_step_data
          in: query
          required: false
          description: Whether or not to include step statistics for deleted steps (defaults to `false`).
          schema:
            type: boolean
            default: false
          example: true
      responses:
        "200":
          description: The request succeeded and the response body includes the Canvas time series. No action needed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CanvasAnalyticsResponse'
              examples:
                success:
                  summary: Canvas data series with variant and step breakdowns
                  value:
                    data:
                      name: Example Canvas
                      stats:
                        - time: "2018-05-28"
                          total_stats:
                            revenue: 25.0
                            conversions: 5
                            conversions_by_entry_time: 5
                            entries: 100
                          variant_stats:
                            00000000-0000-0000-0000-0000000000000:
                              name: Variant 1
                              revenue: 25.0
                              conversions: 5
                              conversions_by_entry_time: 5
                              entries: 100
                          step_stats:
                            00000000-0000-0000-0000-0000000000000:
                              name: Welcome step
                              revenue: 25.0
                              conversions: 5
                              conversions_by_entry_time: 5
                              messages:
                                email:
                                  - sent: 100
                                    opens: 40
                                    unique_opens: 35
                                    clicks: 10
                                sms:
                                  - sent: 50
                                    sent_to_carrier: 50
                                    delivered: 48
                                    rejected: 1
                                    delivery_failed: 1
                                    clicks: 5
                                    opt_out: 0
                                    help: 0
                    message: success
        "400":
          description: |
            Bad request. To resolve it:

            - **The `canvas_id` is missing or isn't a string:** Pass a valid `canvas_id` string. Find it with the [Export Canvas list endpoint]({{site.baseurl}}/api/endpoints/export/canvas/get_canvases/).
            - **The `ending_at` value isn't a valid datetime:** Pass `ending_at` as an ISO 8601 datetime.
            - **The `ending_at` value is out of range:** Pass an `ending_at` within the allowed range.
            - **The `length` isn't an integer:** Pass `length` as an integer between 1 and 14.
            - **The `length` is outside the allowed range:** Pass `length` between 1 and 14.
            - **Neither a valid `starting_at` nor a `length` was provided:** Include `length`, or a valid `starting_at`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                invalid_canvas_id:
                  summary: Missing or invalid canvas_id
                  value:
                    message: canvas_id must be a string of the Canvas api identifier
                ending_at_improperly_formatted:
                  summary: ending_at isn't a valid datetime
                  value:
                    message: ending_at time is improperly formatted
                ending_at_out_of_range:
                  summary: ending_at out of range
                  value:
                    message: ending_at time is out of range
                length_not_integer:
                  summary: length isn't an integer
                  value:
                    message: an integer length must be provided
                length_out_of_range:
                  summary: length outside the allowed range
                  value:
                    message: series range must be greater than 0 and less than 14
                missing_start:
                  summary: Neither starting_at nor length
                  value:
                    message: either a properly formatted starting time OR length must be provided
        "401":
          description: |
            Unauthorized. The REST API key is missing, malformed, or sent to the wrong REST endpoint. Send the key as `Authorization: Bearer YOUR_REST_API_KEY` to the correct [REST endpoint]({{site.baseurl}}/api/basics/#endpoints). For more causes, see [Errors and responses]({{site.baseurl}}/api/errors/#fatal-errors).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                invalid_api_key:
                  summary: Invalid API key
                  value:
                    message: 'Invalid API key: YOUR_REST_API_KEY'
        "403":
          description: Access denied. The REST API key doesn't have the required permission. Use a REST API key that has the `canvas.data_series` permission.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                access_denied:
                  summary: Missing permission
                  value:
                    message: Access Denied
        "429":
          description: |
            Rate limited. You exceeded the rate limit for this endpoint. Slow your request rate and retry with exponential backoff. See [API rate limits]({{site.baseurl}}/api/api_limits/).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                over_rate_limit:
                  summary: Over rate limit
                  value:
                    message: You have exceeded your limit of 250000 requests per hour. Please contact your account executive to increase your limit. If you do not have their info, you may contact Braze directly at https://www.braze.com/contact/.
        5XX:
          description: |
            Internal server error. An unexpected error occurred on the Braze server. Retry with exponential backoff. If the error persists, contact [Support]({{site.baseurl}}/braze_support/).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: REST API key
      description: |
        REST API keys are created in the Braze dashboard at **Settings → APIs and
        Identifiers → API Keys**. The key must include the `canvas.data_series` permission.
        Pass the key as `Authorization: Bearer YOUR_REST_API_KEY`.
  schemas:
    CanvasVariantStats:
      title: Canvas variant stats
      type: object
      properties:
        name:
          type: string
          description: The name of variant.
        revenue:
          type: number
          description: The number of dollars of revenue (USD).
        conversions:
          type: integer
          description: The number of conversions.
        conversions_by_entry_time:
          type: integer
          description: The number of conversions for the conversion event by entry time.
        entries:
          type: integer
          description: The number of entries.
    CanvasStepStats:
      title: Canvas step stats
      type: object
      properties:
        name:
          type: string
          description: The name of step.
        revenue:
          type: number
          description: The number of dollars of revenue (USD).
        conversions:
          type: integer
          description: The number of conversions.
        conversions_by_entry_time:
          type: integer
          description: The number of conversions for the conversion event by entry time.
        messages:
          type: object
          description: Message stats for the step, keyed by channel. The response can include more channels and more stats than shown.
          properties:
            email:
              type: array
              items:
                type: object
                properties:
                  sent:
                    type: integer
                    description: The number of sends.
                  opens:
                    type: integer
                    description: The number of opens.
                  unique_opens:
                    type: integer
                    description: The number of unique opens.
                  clicks:
                    type: integer
                    description: The number of clicks.
            sms:
              type: array
              items:
                type: object
                properties:
                  sent:
                    type: integer
                    description: The number of sends.
                  sent_to_carrier:
                    type: integer
                    description: The number of messages sent to the carrier.
                  delivered:
                    type: integer
                    description: The number of delivered messages.
                  rejected:
                    type: integer
                    description: The number of rejected messages.
                  delivery_failed:
                    type: integer
                    description: The number of failed deliveries.
                  clicks:
                    type: integer
                    description: The number of clicks on shortened links.
                  opt_out:
                    type: integer
                    description: The number of opt outs.
                  help:
                    type: integer
                    description: The number of help messages received.
    CanvasAnalyticsResponse:
      title: Export Canvas data series analytics response
      type: object
      properties:
        data:
          type: object
          properties:
            name:
              type: string
              description: The Canvas name.
            stats:
              type: array
              description: Stats for each date in the series.
              items:
                type: object
                properties:
                  time:
                    type: string
                    description: The date as ISO 8601 date.
                  total_stats:
                    type: object
                    properties:
                      revenue:
                        type: number
                        description: The number of dollars of revenue (USD).
                      conversions:
                        type: integer
                        description: The number of conversions.
                      conversions_by_entry_time:
                        type: integer
                        description: The number of conversions for the conversion event by entry time.
                      entries:
                        type: integer
                        description: The number of entries.
                  variant_stats:
                    type: object
                    description: Optional. Stats for each variant, keyed by the API identifier for the variant. See `include_variant_breakdown`.
                    additionalProperties:
                      $ref: '#/components/schemas/CanvasVariantStats'
                  step_stats:
                    type: object
                    description: Optional. Stats for each step, keyed by the API identifier for the step. See `include_step_breakdown`.
                    additionalProperties:
                      $ref: '#/components/schemas/CanvasStepStats'
        message:
          type: string
          description: Returns 'success' when the request completes without errors.
          example: success
    ErrorResponse:
      title: Error
      type: object
      properties:
        message:
          type: string
          description: The error message describing why the request failed.
        errors:
          type: array
          description: Non-fatal errors encountered while processing the request. Data unaffected by these errors is still processed.
          items:
            type: object
            properties:
              type:
                type: string
                description: The error type.
