const { result, error } = await unkey.analytics.getVerifications({
  apiId: "api_123",
});

if (error) {
  // handle potential network or bad request error
  // a link to our docs will be in the `error.docs` field
  console.error(error.message);
  return;
}

console.log(result)
{
  "result": [
  {
      "time": 123,
      "valid": 123,
      "notFound": 123,
      "forbidden": 123,
      "usageExceeded": 123,
      "rateLimited": 123,
      "unauthorized": 123,
      "disabled": 123,
      "insufficientPermissions": 123,
      "expired": 123,
      "total": 123,
      "tag": "path/user_123",
      "tags": [
      "path/user_123",
      "path/create",
      "path/delete/"
      ],
      "keyId": "key_123",
      "identity": {
        "id": "id_123",
        "externalId": "user_123"
      }
    }
  ]
}
const { result, error } = await unkey.analytics.getVerifications({
  apiId: "api_123",
});

if (error) {
  // handle potential network or bad request error
  // a link to our docs will be in the `error.docs` field
  console.error(error.message);
  return;
}

console.log(result)
{
  "result": [
  {
      "time": 123,
      "valid": 123,
      "notFound": 123,
      "forbidden": 123,
      "usageExceeded": 123,
      "rateLimited": 123,
      "unauthorized": 123,
      "disabled": 123,
      "insufficientPermissions": 123,
      "expired": 123,
      "total": 123,
      "tag": "path/user_123",
      "tags": [
      "path/user_123",
      "path/create",
      "path/delete/"
      ],
      "keyId": "key_123",
      "identity": {
        "id": "id_123",
        "externalId": "user_123"
      }
    }
  ]
}

To use this function, your root key must have the api.*.read_api permission.

Request

apiId
string
required

Select the API. Only keys belonging to this API will be included.

externalId
string

Filtering by externalId allows you to narrow down the search to a specific user or organisation.

keyId
string

Only include data for a specific key or keys.

When you are providing zero or more than one key ids, all usage counts are aggregated and summed up. Send multiple requests with one keyId each if you need counts per key.

tag
string

Only include data for a specific tag or tags.

When you are providing zero or more than one tag, all usage counts are aggregated and summed up. Send multiple requests with one tag each if you need counts per tag.

start
int

The start of the period to fetch usage for as unix milliseconds timestamp.

end
int

The end of the period to fetch usage for as unix milliseconds timestamp.

groupBy
string[] | enum<string>

By default, datapoints are not aggregated, however you probably want to get a breakdown per time, key or identity.

Grouping by tags and by tag is mutually exclusive.

limit
int

Limit the number of returned datapoints. This may become useful for querying the top 10 identities based on usage.

orderBy
enum<string>

Sort the output by a specific value. You can use this in combination with the order param.

order
enum<string>

Define the order of sorting. Use this in combination with orderBy

Response

total
int
required

Total number of verifications in the current time slice, regardless of outcome.

time
int

Unix timestamp in milliseconds of the start of the current time slice.

valid
int

Total number of valid verifications in the current time slice

notFound
int

Total number of not found responses in the current time slice

forbidden
int

Total number of forbidden requests in the current time slice

usageExceeded
int

Total number of usage exceeded verifications in the current time slice

rateLimited
int

Total number of rateLimited verifications in the current time slice

unauthorized
int

Total number of unauthorized verifications in the current time slice

disabled
int

Total number of disabled verifications in the current time slice

insufficientPermissions
int

Total number of insufficient permissions verifications in the current time slice

expired
int

Total number of expired verifications in the current time slice

tag
string

Only available when grouping by tag.

tags
string[]

Only available when grouping by tag.

keyId
string

Only available when specifying groupBy=key in the query. In this case there would be one datapoint per time and groupBy target.

identity
object

Only available when specifying groupBy=identity in the query. In this case there would be one datapoint per time and groupBy target.