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

    This endpoint is for API campaigns only. To use this endpoint, you'll need an [API key]({{site.baseurl}}/api/basics#rest-api-key-permissions) with the `sends.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:
  "/sends/data_series":
    get:
      summary: Export send analytics
      operationId: get_sends_data_series_get_send_analytics
      parameters:
        - name: campaign_id
          in: query
          required: true
          description: See [campaign API identifier]({{site.baseurl}}/api/identifier_types/).
          schema:
            type: string
          example: campaign_identifier
        - name: send_id
          in: query
          required: true
          description: See [Send API identifier]({{site.baseurl}}/api/identifier_types/).
          schema:
            type: string
          example: send_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: 30
        - name: ending_at
          in: query
          required: false
          description: |
            Date on which the data series should end. Defaults to time of the request.

            Datetime ([ISO-8601](https://en.wikipedia.org/wiki/ISO_8601) string).
          schema:
            type: string
            format: date-time
          example: "2014-12-10T23:59:59-05:00"
      responses:
        "200":
          description: |
            The request succeeded and the response body includes the send analytics time series. No action needed.

            The following sample response shows an example of the response returned when you export send analytics.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SendAnalyticsResponse'
              examples:
                success:
                  summary: Send analytics time series
                  value:
                    data:
                      - time: "2014-12-10"
                        messages:
                          ios_push:
                            - variation_name: Variant 1
                              sent: 100
                              delivered: 95
                              undelivered: 3
                              delivery_failed: 2
                              direct_opens: 10
                              total_opens: 15
                              bounces: 2
                              body_clicks: 8
                              revenue: 50.0
                              unique_recipients: 100
                              conversions: 5
                              conversions_by_send_time: 5
                              conversions1: 1
                              conversions1_by_send_time: 1
                              conversions2: 0
                              conversions2_by_send_time: 0
                              conversions3: 0
                              conversions3_by_send_time: 0
                        conversions_by_send_time: 5
                        conversions1_by_send_time: 1
                        conversions2_by_send_time: 0
                        conversions3_by_send_time: 0
                        conversions: 5
                        conversions1: 1
                        conversions2: 0
                        conversions3: 0
                        unique_recipients: 100
                        revenue: 50.0
                    message: success
        "400":
          description: |
            Bad request. To resolve it:

            - **The `campaign_id` isn't valid:** Pass a valid `campaign_id`. Find it with the [Export campaign list endpoint]({{site.baseurl}}/api/endpoints/export/campaigns/get_campaigns/).
            - **The `send_id` is missing or isn't a string:** Pass the `send_id` returned when you created the send.
            - **No send analytics exist for the `send_id` and `campaign_id` combination:** Confirm the `send_id` belongs to the `campaign_id`, and that the send happened within the last 14 days.
            - **The `ending_at` value isn't a valid ISO-8601 datetime:** Pass `ending_at` as an ISO-8601 datetime string.
            - **The `ending_at` value is outside the allowed range:** Pass an `ending_at` that isn't in the future or too far in the past.
            - **The `length` isn't a valid integer:** Pass `length` as an integer within the allowed range.
            - **The `length` is outside the allowed range:** Pass `length` between 1 and 100.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                invalid_campaign_id:
                  summary: Invalid campaign_id
                  value:
                    message: campaign_id must be a valid campaign id
                invalid_send_id:
                  summary: Missing or non-string send_id
                  value:
                    message: send_id must be a string of the message send instance identifier
                no_data_available:
                  summary: No data for the send_id and campaign_id
                  value:
                    message: There is no data available for the provided send_id and campaign_id
                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
                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
        "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 `sends.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 `sends.data_series` permission.
        Pass the key as `Authorization: Bearer YOUR_REST_API_KEY`.
  schemas:
    SendVariationStats:
      title: Send variation stats
      type: object
      properties:
        variation_name:
          type: string
          description: Variation name.
        sent:
          type: integer
          description: The number of sends.
        delivered:
          type: integer
          description: The number of messages successfully delivered.
        undelivered:
          type: integer
          description: The number of undelivered.
        delivery_failed:
          type: integer
          description: The number of rejected.
        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.
        revenue:
          type: number
          description: The number of dollars of revenue (USD).
        unique_recipients:
          type: integer
          description: The number of unique recipients at the campaign-level.
        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.
    DailySendStats:
      title: Daily send stats
      type: object
      required: [time, messages, conversions, unique_recipients]
      properties:
        time:
          type: string
          description: The date as ISO 8601 date.
        messages:
          type: object
          description: Stats for each message type in the send, keyed by message type.
          properties:
            ios_push:
              type: array
              items:
                $ref: '#/components/schemas/SendVariationStats'
        conversions_by_send_time:
          type: integer
        conversions1_by_send_time:
          type: integer
        conversions2_by_send_time:
          type: integer
        conversions3_by_send_time:
          type: integer
        conversions:
          type: integer
        conversions1:
          type: integer
        conversions2:
          type: integer
        conversions3:
          type: integer
        unique_recipients:
          type: integer
        revenue:
          type: number
    SendAnalyticsResponse:
      title: Export send analytics response
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/DailySendStats'
        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.
