Get mail metrics
cooper_get_metricsUse this when you need counts of mail over time, current usage, or bounce and complaint rates for this account. Read-only; requires auth and message_read. Inputs: kind (required; events, usage, or rates), inbox_id (optional; inbox id, username, or email), start and end (optional ISO-8601 timestamps; default the last 30 days; used by events and rates), period (optional; hour or day; default day; events only), types (optional comma-separated message.received, message.sent, message.bounced, message.complained; default message.received,message.sent; events only). events returns {object:"metrics", period, data:[{bucket_start, counts}]}. Buckets are UTC. received and sent follow messages.direction inbound and outbound. bounced and complained follow those labels and are zero when the label is absent. usage returns {inbox_count, message_count, thread_count, storage_bytes} and, when the key is not inbox-scoped and inbox_id is omitted, domain_count and workspace_count for this account only. storage_bytes is the UTF-8 size of text plus html plus attachment bytes. It is not the message body. rates returns {sent, bounced, complained, bounce_rate, complaint_rate}. Rates are 0 when sent is 0. A range over 90 days, or a start that is not before end, returns 400 invalid_range. A bad timestamp returns 400 invalid_date. A bad period returns 400 invalid_period. An unknown type returns 400 invalid_type. An unknown kind returns 400 invalid_kind. Another account's inbox, or a different inbox for an inbox-scoped key, returns 404 inbox_not_found. A key without message_read returns 403 permission_denied. A sub-account sees only its own mail, inboxes, domains, and workspaces. Held message bodies are not included.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| end | No | ISO-8601 end, exclusive. Defaults to now. The span from start to end cannot exceed 90 days. | |
| kind | Yes | events for time buckets, usage for current totals, or rates for bounce and complaint rates. | |
| start | No | ISO-8601 start, inclusive. Defaults to 30 days before end. Used by events and rates. | |
| types | No | Comma-separated events series: message.received, message.sent, message.bounced, message.complained. Default message.received,message.sent. | |
| period | No | Bucket size for events. hour or day. Default day. Ignored for usage and rates. | |
| inbox_id | No | Inbox id (inb_…), username, or full email address on this account. Omit for the whole account. An inbox-scoped key is limited to its inbox. |