Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions apps/docs/api-reference/keys/verifications.mdx

This file was deleted.

6 changes: 4 additions & 2 deletions apps/docs/docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,6 @@
"api-reference/keys/update",
"api-reference/keys/update-remaining",
"api-reference/keys/delete",
"api-reference/keys/verifications",
"api-reference/keys/add-permissions",
"api-reference/keys/remove-permissions",
"api-reference/keys/set-permissions",
Expand Down Expand Up @@ -315,7 +314,6 @@
"libraries/ts/sdk/keys/update",
"libraries/ts/sdk/keys/update-remaining",
"libraries/ts/sdk/keys/delete",
"libraries/ts/sdk/keys/verifications",
"libraries/ts/sdk/keys/add-permission",
"libraries/ts/sdk/keys/remove-permission",
"libraries/ts/sdk/keys/set-permission",
Expand All @@ -324,6 +322,10 @@
"libraries/ts/sdk/keys/set-roles"
]
},
{
"group": "Analytics",
"pages": ["libraries/ts/sdk/analytics/get"]
},
{
"group": "APIs",
"pages": [
Expand Down
173 changes: 173 additions & 0 deletions apps/docs/libraries/ts/sdk/analytics/get.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
---
title: "Get Verifications"
description: "Retrieve usage data from unkey to power your dashboards, reports or usage-based billing."
---

<RequestExample>
```ts
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)

```
</RequestExample>

<ResponseExample>
```json
{
"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"
}
}
]
}
```
</ResponseExample>


<Note>
To use this function, your root key must have the `api.*.read_api permission`.
</Note>

## Request

<ParamField body="apiId" type="string" required>
Select the API. Only keys belonging to this API will be included.
</ParamField>
<ParamField body="externalId" type="string">
Filtering by externalId allows you to narrow down the search to a specific user or organisation.
</ParamField>
<ParamField body="keyId" type="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.
</ParamField>
<ParamField body="tag" type="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.
</ParamField>

<ParamField body="start" type="int">
The start of the period to fetch usage for as unix milliseconds timestamp.
</ParamField>

<ParamField body="end" type="int">
The end of the period to fetch usage for as unix milliseconds timestamp.
</ParamField>

<ParamField body="groupBy" type="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.

</ParamField>

<ParamField body="limit" type="int">
Limit the number of returned datapoints.
This may become useful for querying the top 10 identities based on usage.
</ParamField>

<ParamField body="orderBy" type="enum<string>">
Sort the output by a specific value. You can use this in combination with the order param.

</ParamField>

<ParamField body="order" type="enum<string>">
Define the order of sorting. Use this in combination with orderBy
</ParamField>

## Response

<ResponseField name="total" type="int" required>
Total number of verifications in the current time slice, regardless of outcome.
</ResponseField>

<ResponseField name="time" type="int">
Unix timestamp in milliseconds of the start of the current time slice.
</ResponseField>

<ResponseField name="valid" type="int">
Total number of valid verifications in the current time slice
</ResponseField>

<ResponseField name="notFound" type="int">
Total number of not found responses in the current time slice
</ResponseField>
<ResponseField name="forbidden" type="int">
Total number of forbidden requests in the current time slice
</ResponseField>
<ResponseField name="usageExceeded" type="int">
Total number of usage exceeded verifications in the current time slice
</ResponseField>
<ResponseField name="rateLimited" type="int">
Total number of rateLimited verifications in the current time slice
</ResponseField>
<ResponseField name="unauthorized" type="int">
Total number of unauthorized verifications in the current time slice
</ResponseField>
<ResponseField name="disabled" type="int">
Total number of disabled verifications in the current time slice
</ResponseField>
<ResponseField name="insufficientPermissions" type="int">
Total number of insufficient permissions verifications in the current time slice
</ResponseField>
<ResponseField name="expired" type="int">
Total number of expired verifications in the current time slice
</ResponseField>

<ResponseField name="tag" type="string">
Only available when grouping by tag.
</ResponseField>

<ResponseField name="tags" type="string[]">
Only available when grouping by tag.
</ResponseField>

<ResponseField name="keyId" type="string">
Only available when specifying groupBy=key in the query.
In this case there would be one datapoint per time and groupBy target.
</ResponseField>

<ResponseField name="identity" type="object">
Only available when specifying groupBy=identity in the query.
In this case there would be one datapoint per time and groupBy target.
<Expandable>
<ResponseField name="id" type="string">
The id of the identity
</ResponseField>
<ResponseField name="externalId" type="string" required>
The external id of the identity
</ResponseField>
</Expandable>
</ResponseField>
1 change: 1 addition & 0 deletions apps/docs/libraries/ts/sdk/keys/verifications.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ title: "Verifications"
description: "Get usage information about your API keys"
---

<Warning> This is deprecated, please use the `analytics.getVerifications` function instead.</Warning>

<RequestExample>

Expand Down
Loading