@lap v0.3
# Machine-readable API spec. Each @endpoint block is one API call.
@api Twilio SendGrid Statistics API
@base https://api.sendgrid.com
@version 1.0.0
@auth Bearer bearer
@common_fields {on-behalf-of: str # The `on-behalf-of` header allows you to make API calls from a parent account on behalf of the parent's Subusers or customer accounts. You will use the parent account's API key when using this header. When making a call on behalf of a customer account, the property value should be "account-id" followed by the customer account's ID (e.g., `on-behalf-of: account-id `). When making a call on behalf of a Subuser, the property value should be the Subuser's username (e.g., `on-behalf-of: `). See [**On Behalf Of**](https://docs.sendgrid.com/api-reference/how-to-use-the-sendgrid-v3-api/on-behalf-of) for more information.}
@endpoints 10
@toc browsers(1), categories(3), clients(2), devices(1), geo(1), mailbox_providers(1), stats(1)

@group browsers
@endpoint GET /v3/browsers/stats
@desc Retrieve email statistics by browser.
@required {start_date: str # The starting date of the statistics to retrieve. Must follow format YYYY-MM-DD.}
@optional {browsers: str # The browsers to get statistics for. You can include up to 10 different browsers by including this parameter multiple times., limit: int # The number of results to return., offset: int # The point in the list to begin retrieving results., aggregated_by: str # How to group the statistics. Must be either "day", "week", or "month"., end_date: str # The end date of the statistics to retrieve. Defaults to today. Must follow format YYYY-MM-DD.}
@returns(200)

@endgroup

@group categories
@endpoint GET /v3/categories
@desc Retrieve all categories
@optional {limit: int=50 # `limit` sets the page size, i.e. maximum number of items from the list to be returned for a single API request. If omitted, the default page size is used., category: str # Allows you to perform a prefix search on this particular category., offset: int=0 # The number of items in the list to skip over before starting to retrieve the items for the requested page. The default `offset` of `0` represents the beginning of the list, i.e. the start of the first page. To request the second page of the list, set the `offset` to the page size as determined by `limit`. Use multiples of the page size as your `offset` to request further consecutive pages. E.g. assume your page size is set to `10`. An `offset` of `10` requests the second page, an `offset` of `20` requests the third page and so on, provided there are sufficiently many items in your list.}
@returns(200)
@errors {400}

@endpoint GET /v3/categories/stats
@desc Retrieve Email Statistics for Categories
@required {start_date: str # The starting date of the statistics to retrieve. Must follow format YYYY-MM-DD, categories: str # The individual categories that you want to retrieve statistics for. You may include up to 10 different categories.}
@optional {end_date: str # The end date of the statistics to retrieve. Defaults to today. Must follow format YYYY-MM-DD., aggregated_by: str # How to group the statistics. Must be either "day", "week", or "month".}
@returns(200)

@endpoint GET /v3/categories/stats/sums
@desc Retrieve sums of email stats for each category.
@required {start_date: str # The starting date of the statistics to retrieve. Must follow format YYYY-MM-DD.}
@optional {sort_by_metric: str=delivered # The metric that you want to sort by.  Must be a single metric., sort_by_direction: str=desc # The direction you want to sort., end_date: str # The end date of the statistics to retrieve. Defaults to today. Must follow format YYYY-MM-DD., limit: int=5 # Limits the number of results returned., offset: int=0 # The point in the list to begin retrieving results., aggregated_by: str # How to group the statistics. Must be either "day", "week", or "month".}
@returns(200) {date: str, stats: [map]}

@endgroup

@group clients
@endpoint GET /v3/clients/stats
@desc Retrieve email statistics by client type.
@required {start_date: str # The starting date of the statistics to retrieve. Must follow format YYYY-MM-DD.}
@optional {end_date: str # The end date of the statistics to retrieve. Defaults to today. Must follow format YYYY-MM-DD., aggregated_by: str # How to group the statistics. Must be either "day", "week", or "month".}
@returns(200)

@endpoint GET /v3/clients/{client_type}/stats
@desc Retrieve stats by a specific client type.
@required {start_date: str # The starting date of the statistics to retrieve. Must follow format YYYY-MM-DD.}
@optional {end_date: str # The end date of the statistics to retrieve. Defaults to today. Must follow format YYYY-MM-DD., aggregated_by: str # How to group the statistics. Must be either "day", "week", or "month".}
@returns(200)

@endgroup

@group devices
@endpoint GET /v3/devices/stats
@desc Retrieve email statistics by device type.
@required {start_date: str # The starting date of the statistics to retrieve. Must follow format YYYY-MM-DD.}
@optional {limit: int # The number of results to return., offset: int # The point in the list to begin retrieving results., aggregated_by: str # How to group the statistics. Must be either "day", "week", or "month"., end_date: str # The end date of the statistics to retrieve. Defaults to today. Must follow format YYYY-MM-DD.}
@returns(200)

@endgroup

@group geo
@endpoint GET /v3/geo/stats
@desc Retrieve email statistics by country and state/province.
@required {start_date: str # The starting date of the statistics to retrieve. Must follow format YYYY-MM-DD.}
@optional {country: str # The country you would like to see statistics for. Currently only supported for US and CA., limit: int # The number of results to return., offset: int # The point in the list to begin retrieving results., aggregated_by: str # How to group the statistics. Must be either "day", "week", or "month"., end_date: str # The end date of the statistics to retrieve. Defaults to today. Must follow format YYYY-MM-DD.}
@returns(200)

@endgroup

@group mailbox_providers
@endpoint GET /v3/mailbox_providers/stats
@desc Retrieve email statistics by mailbox provider.
@required {start_date: str # The starting date of the statistics to retrieve. Must follow format YYYY-MM-DD.}
@optional {mailbox_providers: str # The mail box providers to get statistics for. You can include up to 10 by including this parameter multiple times., limit: int # The number of results to return., offset: int # The point in the list to begin retrieving results., aggregated_by: str # How to group the statistics. Must be either "day", "week", or "month"., end_date: str # The end date of the statistics to retrieve. Defaults to today. Must follow format YYYY-MM-DD.}
@returns(200)

@endgroup

@group stats
@endpoint GET /v3/stats
@desc Retrieve global email statistics
@required {start_date: str # The starting date of the statistics to retrieve. Must follow format YYYY-MM-DD.}
@optional {limit: int # The number of results to return., offset: int # The point in the list to begin retrieving results., aggregated_by: str # How to group the statistics. Must be either "day", "week", or "month"., end_date: str # The end date of the statistics to retrieve. Defaults to today. Must follow format YYYY-MM-DD.}
@returns(200)

@endgroup

@end
