# Usage of an API key

`GET /v1/keys/{key_id}/usage`

Requires role member or higher.

`resolution=hour` (default) returns 48 UTC hours; `resolution=day` returns 90 UTC days. The last point is the current, partial one.

## Authentication

A session token: `Authorization: Bearer <session token>`, or the session cookie in the browser. Requires role `member` or higher.

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `resolution` | query |  | no |  |
| `key_id` | path | string | yes |  |

## Responses

### 200

Events of one API key: 48 UTC hours or 90 UTC days, ending with the current one.

`application/json`

```json
{
  "additionalProperties": false,
  "description": "Events of one API key: 48 UTC hours or 90 UTC days, ending with the current one.",
  "properties": {
    "key_id": {
      "pattern": "^key_[0-7][0-9a-hjkmnp-tv-z]{25}$",
      "type": "string"
    },
    "name": {
      "type": "string"
    },
    "points": {
      "items": {
        "additionalProperties": false,
        "description": "Events of one API key in one UTC hour or day, starting at `at`.",
        "properties": {
          "accepted": {
            "description": "Events accepted for processing.",
            "minimum": 0,
            "type": "integer"
          },
          "at": {
            "format": "date-time",
            "type": "string"
          },
          "rejected_quota": {
            "description": "Events rejected because the monthly quota was used up.",
            "minimum": 0,
            "type": "integer"
          },
          "rejected_rate": {
            "description": "Events rejected by the per-minute rate limit.",
            "minimum": 0,
            "type": "integer"
          }
        },
        "required": [
          "at",
          "accepted",
          "rejected_quota",
          "rejected_rate"
        ],
        "type": "object"
      },
      "type": "array"
    },
    "project_id": {
      "pattern": "^prj_[0-7][0-9a-hjkmnp-tv-z]{25}$",
      "type": "string"
    },
    "resolution": {
      "anyOf": [
        {
          "enum": [
            "hour"
          ],
          "type": "string"
        },
        {
          "enum": [
            "day"
          ],
          "type": "string"
        }
      ]
    },
    "revoked": {
      "type": "boolean"
    }
  },
  "required": [
    "key_id",
    "name",
    "project_id",
    "revoked",
    "resolution",
    "points"
  ],
  "type": "object"
}
```

### 401

unauthorized: no valid session, or the email is not verified.

Problem type: [unauthorized](https://docs.dlogify.com/errors/unauthorized.md).

### 404

not-found: the resource does not exist, or the caller is not a member of its organization.

Problem type: [not-found](https://docs.dlogify.com/errors/not-found.md).

### 422

validation-failed: the request does not match the schema.

Problem type: [validation-failed](https://docs.dlogify.com/errors/validation-failed.md).

### 429

rate-limited: per-user management request limit.

Problem type: [rate-limited](https://docs.dlogify.com/errors/rate-limited.md).

## Example

```bash
curl -X GET "https://api.dlogify.com/v1/keys/{key_id}/usage" \
  -H "Authorization: Bearer $DLOGIFY_SESSION"
```

Source: https://docs.dlogify.com/api/usage/getApiKeyUsage
