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

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

    ## Rate limit

    This endpoint has a rate limit of 50,000 requests per minute.
  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:
  "/campaigns/data_series":
    get:
      summary: Export campaign analytics
      operationId: get_campaigns_data_series_get_campaign_analytics
      parameters:
        - name: campaign_id
          in: query
          required: true
          description: |
            See [campaign API identifier]({{site.baseurl}}/api/identifier_types/).

            The `campaign_id` for API campaigns can be found on the [API Keys]({{site.baseurl}}/user_guide/administer/global/workspace_settings/apis_and_identifiers/) page and the **Campaign Details** page within your dashboard, or you can use the [List campaigns endpoint]({{site.baseurl}}/api/endpoints/export/campaigns/get_campaigns/).
          schema:
            type: string
          example: campaign_identifier
        - name: length
          in: query
          required: true
          description: Maximum number of days before `ending_at` to include in the returned series. Must be between 1 and 100 (inclusive).
          schema:
            type: integer
            minimum: 1
            maximum: 100
          example: 7
        - name: ending_at
          in: query
          required: false
          description: Date on which the data series should end. Defaults to time of the request.
          schema:
            type: string
            format: date-time
          example: "2020-06-28T23:59:59-05:00"
      responses:
        "200":
          description: |
            The request succeeded and the response body includes the requested data. No action needed.

            The possible message types are: `email`, `trigger_in_app_message`, `webhook`, `android_push`, `ios_push`, `kindle_push`, and `web_push`. All push message types will have the same statistics shown for `android_push`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CampaignAnalyticsResponse'
              examples:
                multichannel:
                  summary: Multichannel response
                  value:
                    message: success
                    data:
                      - time: "2020-06-28"
                        conversions_by_send_time: 0
                        conversions1_by_send_time: 0
                        conversions2_by_send_time: 0
                        conversions3_by_send_time: 0
                        conversions: 0
                        conversions1: 0
                        conversions2: 0
                        conversions3: 0
                        unique_recipients: 1
                        revenue: 0.0
                        messages:
                          ios_push:
                            - variation_api_id: ios_variation_api_identifier
                              sent: 1
                              direct_opens: 0
                              total_opens: 0
                              bounces: 0
                              body_clicks: 0
                          android_push:
                            - variation_api_id: android_variation_api_identifier
                              sent: 1
                              direct_opens: 0
                              total_opens: 0
                              bounces: 0
                              body_clicks: 0
                          webhook:
                            - variation_api_id: webhook_variation_api_identifier
                              sent: 1
                              errors: 0
                          email:
                            - variation_api_id: email_variation_api_identifier
                              sent: 1
                              opens: 1
                              unique_opens: 1
                              clicks: 0
                              unique_clicks: 0
                              unsubscribes: 0
                              bounces: 0
                              delivered: 1
                              reported_spam: 0
                          sms:
                            - variation_api_id: sms_variation_api_identifier
                              sent: 1
                              sent_to_carrier: 1
                              delivered: 1
                              rejected: 0
                              delivery_failed: 0
                              clicks: 0
                              opt_out: 0
                              help: 0
                          whats_app:
                            - variation_api_id: whats_app_variation_api_identifier
                              sent: 1
                              delivered: 1
                              failed: 0
                              read: 1
                          content_cards:
                            - variation_api_id: content_cards_variation_api_identifier
                              sent: 1
                              total_clicks: 0
                              total_dismissals: 0
                              total_impressions: 1
                              unique_clicks: 0
                              unique_dismissals: 0
                              unique_impressions: 1
                multivariate:
                  summary: Multivariate response
                  value:
                    message: success
                    data:
                      - time: "2020-06-28"
                        conversions: 2
                        revenue: 10.0
                        conversions_by_send_time: 2
                        conversions1_by_send_time: 0
                        conversions2_by_send_time: 0
                        conversions3_by_send_time: 0
                        conversions1: 0
                        conversions2: 0
                        conversions3: 0
                        unique_recipients: 30
                        messages:
                          trigger_in_app_message:
                            - variation_name: Variant 1
                              impressions: 10
                              clicks: 2
                              first_button_clicks: 1
                              second_button_clicks: 1
                              revenue: 5.0
                              unique_recipients: 10
                              conversions: 1
                              conversions_by_send_time: 1
                              conversions1: 0
                              conversions1_by_send_time: 0
                              conversions2: 0
                              conversions2_by_send_time: 0
                              conversions3: 0
                              conversions3_by_send_time: 0
                            - variation_name: Variant 2
                              impressions: 10
                              clicks: 3
                              first_button_clicks: 2
                              second_button_clicks: 1
                              revenue: 5.0
                              unique_recipients: 10
                              conversions: 1
                              conversions_by_send_time: 1
                              conversions1: 0
                              conversions1_by_send_time: 0
                              conversions2: 0
                              conversions2_by_send_time: 0
                              conversions3: 0
                              conversions3_by_send_time: 0
                            - variation_name: Control Group
                              revenue: 0.0
                              unique_recipients: 10
                              conversions: 0
                              conversions_by_send_time: 0
                              conversions1: 0
                              conversions1_by_send_time: 0
                              conversions2: 0
                              conversions2_by_send_time: 0
                              conversions3: 0
                              conversions3_by_send_time: 0
                              enrolled: 10
        "400":
          description: |
            Bad request. To resolve it:

            - **The `campaign_id` is missing or doesn't match a campaign in this workspace:** Pass a valid `campaign_id`. Find it with the [List campaigns endpoint]({{site.baseurl}}/api/endpoints/export/campaigns/get_campaigns/).
            - **The `length` is missing, isn't an integer, or is out of range:** Pass an integer `length` between 1 and 100.
            - **The `ending_at` value is improperly formatted or out of range:** Provide `ending_at` as an ISO-8601 datetime that isn't in the future or before the year 2000.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                invalid_campaign_id:
                  summary: Missing or invalid campaign_id
                  value:
                    message: campaign_id must be a valid campaign id
                length_not_integer:
                  summary: Missing or non-integer length
                  value:
                    message: an integer length must be provided
                length_out_of_range:
                  summary: Length out of range
                  value:
                    message: series range must be greater than 0 and less than 100
                ending_at_improperly_formatted:
                  summary: Improperly formatted ending_at
                  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
        "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 `campaigns.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 50000 requests per minute. 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 `campaigns.data_series` permission.
        Pass the key as `Authorization: Bearer YOUR_REST_API_KEY`.
  schemas:
    PushMessageStats:
      title: Push message stats
      type: object
      properties:
        variation_api_id:
          type: string
          description: The variation API identifier.
        sent:
          type: integer
          description: The number of sends.
        direct_opens:
          type: integer
          description: The number of direct opens.
        total_opens:
          type: integer
          description: The number of total opens.
        bounces:
          type: integer
          description: The number of bounces.
        body_clicks:
          type: integer
          description: The number of body clicks.
    InAppMessageVariationStats:
      title: In-app message variation stats
      type: object
      properties:
        variation_name:
          type: string
          description: The variation name.
        impressions:
          type: integer
          description: The number of impressions.
        clicks:
          type: integer
          description: The number of clicks.
        first_button_clicks:
          type: integer
          description: The number of first button clicks.
        second_button_clicks:
          type: integer
          description: The number of second button clicks.
        revenue:
          type: number
          description: The number of dollars of revenue (USD).
        unique_recipients:
          type: integer
          description: The number of unique recipients.
        conversions:
          type: integer
          description: The number of conversions.
        conversions_by_send_time:
          type: integer
          description: The number of conversions attributed to the date the campaign was sent.
        conversions1:
          type: integer
          description: The number of conversions for the second conversion event.
        conversions1_by_send_time:
          type: integer
          description: The number of conversions for the second conversion event attributed to the date the campaign was sent.
        conversions2:
          type: integer
          description: The number of conversions for the third conversion event.
        conversions2_by_send_time:
          type: integer
          description: The number of conversions for the third conversion event attributed to the date the campaign was sent.
        conversions3:
          type: integer
          description: The number of conversions for the fourth conversion event.
        conversions3_by_send_time:
          type: integer
          description: The number of conversions for the fourth conversion event attributed to the date the campaign was sent.
        enrolled:
          type: integer
          description: The number of enrolled users.
    CampaignAnalyticsResponse:
      title: Export campaign analytics response
      type: object
      properties:
        message:
          type: string
          description: Returns 'success' when the request completes without errors.
          example: success
        data:
          type: array
          items:
            title: Daily campaign stats
            type: object
            properties:
              time:
                type: string
                description: The date as ISO 8601 date.
              conversions_by_send_time:
                type: integer
                description: The number of conversions attributed to the date the campaign was sent.
              conversions1_by_send_time:
                type: integer
                description: The number of conversions for the second conversion event attributed to the date the campaign was sent.
              conversions2_by_send_time:
                type: integer
                description: The number of conversions for the third conversion event attributed to the date the campaign was sent.
              conversions3_by_send_time:
                type: integer
                description: The number of conversions for the fourth conversion event attributed to the date the campaign was sent.
              conversions:
                type: integer
                description: The number of conversions.
              conversions1:
                type: integer
                description: The number of conversions for the second conversion event.
              conversions2:
                type: integer
                description: The number of conversions for the third conversion event.
              conversions3:
                type: integer
                description: The number of conversions for the fourth conversion event.
              unique_recipients:
                type: integer
                description: The number of unique recipients.
              revenue:
                type: number
                description: The number of dollars of revenue (USD).
              messages:
                type: object
                description: Stats for each message type in the campaign, keyed by message type. All push message types have the same statistics as `android_push`.
                properties:
                  ios_push:
                    type: array
                    items:
                      $ref: '#/components/schemas/PushMessageStats'
                  android_push:
                    type: array
                    items:
                      $ref: '#/components/schemas/PushMessageStats'
                  kindle_push:
                    type: array
                    items:
                      $ref: '#/components/schemas/PushMessageStats'
                  web_push:
                    type: array
                    items:
                      $ref: '#/components/schemas/PushMessageStats'
                  webhook:
                    type: array
                    items:
                      type: object
                      properties:
                        variation_api_id:
                          type: string
                          description: The variation API identifier.
                        sent:
                          type: integer
                          description: The number of sends.
                        errors:
                          type: integer
                          description: The number of errors.
                  email:
                    type: array
                    items:
                      type: object
                      properties:
                        variation_api_id:
                          type: string
                          description: The variation API identifier.
                        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.
                        unique_clicks:
                          type: integer
                          description: The number of unique clicks.
                        unsubscribes:
                          type: integer
                          description: The number of unsubscribes.
                        bounces:
                          type: integer
                          description: The number of bounces.
                        delivered:
                          type: integer
                          description: The number of messages delivered.
                        reported_spam:
                          type: integer
                          description: The number of messages reported as spam.
                  sms:
                    type: array
                    items:
                      type: object
                      properties:
                        variation_api_id:
                          type: string
                          description: The variation API identifier.
                        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.
                  whats_app:
                    type: array
                    items:
                      type: object
                      properties:
                        variation_api_id:
                          type: string
                          description: The variation API identifier.
                        sent:
                          type: integer
                          description: The number of sends.
                        delivered:
                          type: integer
                          description: The number of delivered messages.
                        failed:
                          type: integer
                          description: The number of failed deliveries.
                        read:
                          type: integer
                          description: The number of opened messages.
                  content_cards:
                    type: array
                    items:
                      type: object
                      properties:
                        variation_api_id:
                          type: string
                          description: The variation API identifier.
                        sent:
                          type: integer
                          description: The number of sends.
                        total_clicks:
                          type: integer
                          description: The number of total clicks.
                        total_dismissals:
                          type: integer
                          description: The number of total dismissals.
                        total_impressions:
                          type: integer
                          description: The number of total impressions.
                        unique_clicks:
                          type: integer
                          description: The number of unique clicks.
                        unique_dismissals:
                          type: integer
                          description: The number of unique dismissals.
                        unique_impressions:
                          type: integer
                          description: The number of unique impressions.
                  trigger_in_app_message:
                    type: array
                    description: Stats for each in-app message variation.
                    items:
                      $ref: '#/components/schemas/InAppMessageVariationStats'
    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.
