> ## Documentation Index
> Fetch the complete documentation index at: https://docs.getinboxzero.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Get stats by period

> Get email statistics grouped by time period. Returns counts of emails by status (all, sent, read, unread, archived, unarchived) for each period.



## OpenAPI

````yaml GET /stats/by-period
openapi: 3.1.0
info:
  title: Inbox Zero API
  version: 1.0.0
  description: >-
    Programmatic access to Inbox Zero inbox stats and automation rules. Docs:
    https://docs.getinboxzero.com/api-reference/introduction Machine-readable
    schema: /openapi.json Authenticate with an account-scoped API key via the
    API-Key header. Errors return JSON with error.code, error.message, and
    error.hint.
servers:
  - url: https://www.getinboxzero.com/api/v1
    description: Primary server
security:
  - ApiKeyAuth: []
paths:
  /stats/by-period:
    get:
      description: >-
        Get email statistics grouped by time period. Returns counts of emails by
        status (all, sent, read, unread, archived, unarchived) for each period.
      operationId: getStatsByPeriod
      parameters:
        - schema:
            type: string
            enum:
              - day
              - week
              - month
              - year
            default: week
          required: false
          name: period
          in: query
        - schema:
            type:
              - number
              - 'null'
          required: false
          name: fromDate
          in: query
        - schema:
            type:
              - number
              - 'null'
          required: false
          name: toDate
          in: query
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  result:
                    type: array
                    items:
                      type: object
                      properties:
                        startOfPeriod:
                          type: string
                        All:
                          type: number
                        Sent:
                          type: number
                        Read:
                          type: number
                        Unread:
                          type: number
                        Unarchived:
                          type: number
                        Archived:
                          type: number
                      required:
                        - startOfPeriod
                        - All
                        - Sent
                        - Read
                        - Unread
                        - Unarchived
                        - Archived
                  allCount:
                    type: number
                  inboxCount:
                    type: number
                  readCount:
                    type: number
                  sentCount:
                    type: number
                required:
                  - result
                  - allCount
                  - inboxCount
                  - readCount
                  - sentCount
        '400':
          description: Invalid query, path, or request body
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiError'
        '401':
          description: Missing, invalid, or expired API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiError'
        '403':
          description: API key lacks a required scope or is not account-scoped
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiError'
        '405':
          description: HTTP method is not supported for this route
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiError'
        '429':
          description: Rate limited by the API or email provider
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiError'
        '500':
          description: Unexpected server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiError'
      security:
        - ApiKeyAuth:
            - STATS_READ
components:
  schemas:
    PublicApiError:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              enum:
                - BAD_REQUEST
                - UNAUTHORIZED
                - FORBIDDEN
                - NOT_FOUND
                - METHOD_NOT_ALLOWED
                - RATE_LIMITED
                - INTERNAL_ERROR
            message:
              type: string
            hint:
              type: string
          required:
            - code
            - message
            - hint
      required:
        - error
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: API-Key
      description: >-
        Account-scoped API key created in Settings.

        Operations declare the scopes they require.

        Available scopes:

        - RULES_READ: List and inspect automation rules for this inbox.

        - RULES_WRITE: Create, update, and delete automation rules for this
        inbox.

        - STATS_READ: Read aggregated inbox statistics for this inbox.
      x-scopes:
        RULES_READ: List and inspect automation rules for this inbox.
        RULES_WRITE: Create, update, and delete automation rules for this inbox.
        STATS_READ: Read aggregated inbox statistics for this inbox.

````