List API requests
List the requests that the Unkey API served for your workspace, newest first.
Filter by time, path, method, request ID, and status. In one field, values under is, contains, startsWith, and endsWith are combined with OR. Values under isNot and notContains, and the range operators gt, gte, lt, and lte, are combined with AND. Different fields are combined with AND. Every text match is exact and case-sensitive.
To get the next page, send the pagination.cursor of the previous page together with the same filters. A cursor does not expire, but rows older than the log retention leave the listing.
Unkey returns only requests inside the log retention of your workspace. The calls to this endpoint are not logged.
Required Permissions
Your root key must have the following permission:
unkey:v1:<workspace_id>:logs/apiRequests#read
package main
import(
"context"
"os"
unkey "github.com/unkeyed/sdks/api/go/v3"
"github.com/unkeyed/sdks/api/go/v3/models/components"
"log"
)
func main() {
ctx := context.Background()
s := unkey.New(
unkey.WithSecurity(os.Getenv("UNKEY_ROOT_KEY")),
)
res, err := s.Logs.ListAPIRequests(ctx, components.V2LogsListAPIRequestsRequestBody{
Cursor: unkey.Pointer("MTc5MjAyMTg1MDEyMzpyZXFfNTY3OGVmZ2g"),
Filters: &components.V2LogsListAPIRequestsFilters{
Time: &components.TimeFilter{
Gte: unkey.Pointer[int64](1791936000000),
Lt: unkey.Pointer[int64](1792022400000),
},
Path: &components.TextFilter{
NotContains: []string{
"verifyKey",
},
StartsWith: []string{
"/v2/keys.",
},
},
Method: &components.MethodFilter{
Is: []components.HTTPMethod{
components.HTTPMethodPost,
components.HTTPMethodPut,
},
},
RequestID: &components.ExactFilter{
IsNot: []string{
"api.unkey.dev",
},
},
Status: &components.IntFilter{
IsNot: []int64{
429,
},
Gte: unkey.Pointer[int64](400),
Lt: unkey.Pointer[int64](600),
},
},
})
if err != nil {
log.Fatal(err)
}
if res.V2LogsListAPIRequestsResponseBody != nil {
for {
// handle items
res, err = res.Next()
if err != nil {
// handle error
}
if res == nil {
break
}
}
}
}from unkey.py import Unkey, models
with Unkey(
root_key="<YOUR_BEARER_TOKEN_HERE>",
) as unkey:
res = unkey.logs.list_api_requests(limit=50, cursor="MTc5MjAyMTg1MDEyMzpyZXFfNTY3OGVmZ2g", filters={
"time": {
"gte": 1791936000000,
"lt": 1792022400000,
},
"path": {
"not_contains": [
"verifyKey",
],
"starts_with": [
"/v2/keys.",
],
},
"method": {
"is_": [
models.HTTPMethod.POST,
models.HTTPMethod.PUT,
],
},
"request_id": {
"is_not": [
"api.unkey.dev",
],
},
"status": {
"is_not": [
429,
],
"gte": 400,
"lt": 600,
},
})
while res is not None:
# Handle items
res = res.next()import { Unkey } from "@unkey/api";
const unkey = new Unkey({
rootKey: process.env["UNKEY_ROOT_KEY"] ?? "",
});
async function run() {
const result = await unkey.logs.listApiRequests({
cursor: "MTc5MjAyMTg1MDEyMzpyZXFfNTY3OGVmZ2g",
filters: {
time: {
gte: 1791936000000,
lt: 1792022400000,
},
path: {
notContains: [
"verifyKey",
],
startsWith: [
"/v2/keys.",
],
},
method: {
is: [
"POST",
"PUT",
],
},
requestId: {
isNot: [
"api.unkey.dev",
],
},
status: {
isNot: [
429,
],
gte: 400,
lt: 600,
},
},
});
for await (const page of result) {
console.log(page);
}
}
run();curl --request POST \
--url https://api.unkey.com/v2/logs.listApiRequests \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"limit": 50,
"cursor": "MTc5MjAyMTg1MDEyMzpyZXFfNTY3OGVmZ2g",
"filters": {
"time": {
"gte": 1791936000000,
"lt": 1792022400000
},
"path": {
"startsWith": [
"/v2/keys."
],
"notContains": [
"verifyKey"
]
},
"method": {
"is": [
"POST",
"PUT"
]
},
"requestId": {
"isNot": [
"api.unkey.dev"
]
},
"status": {
"gte": 400,
"lt": 600,
"isNot": [
429
]
}
}
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
limit: 50,
cursor: 'MTc5MjAyMTg1MDEyMzpyZXFfNTY3OGVmZ2g',
filters: {
time: {gte: 1791936000000, lt: 1792022400000},
path: {startsWith: ['/v2/keys.'], notContains: ['verifyKey']},
method: {is: ['POST', 'PUT']},
requestId: {isNot: ['api.unkey.dev']},
status: {gte: 400, lt: 600, isNot: [429]}
}
})
};
fetch('https://api.unkey.com/v2/logs.listApiRequests', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.unkey.com/v2/logs.listApiRequests",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'limit' => 50,
'cursor' => 'MTc5MjAyMTg1MDEyMzpyZXFfNTY3OGVmZ2g',
'filters' => [
'time' => [
'gte' => 1791936000000,
'lt' => 1792022400000
],
'path' => [
'startsWith' => [
'/v2/keys.'
],
'notContains' => [
'verifyKey'
]
],
'method' => [
'is' => [
'POST',
'PUT'
]
],
'requestId' => [
'isNot' => [
'api.unkey.dev'
]
],
'status' => [
'gte' => 400,
'lt' => 600,
'isNot' => [
429
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.post("https://api.unkey.com/v2/logs.listApiRequests")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"limit\": 50,\n \"cursor\": \"MTc5MjAyMTg1MDEyMzpyZXFfNTY3OGVmZ2g\",\n \"filters\": {\n \"time\": {\n \"gte\": 1791936000000,\n \"lt\": 1792022400000\n },\n \"path\": {\n \"startsWith\": [\n \"/v2/keys.\"\n ],\n \"notContains\": [\n \"verifyKey\"\n ]\n },\n \"method\": {\n \"is\": [\n \"POST\",\n \"PUT\"\n ]\n },\n \"requestId\": {\n \"isNot\": [\n \"api.unkey.dev\"\n ]\n },\n \"status\": {\n \"gte\": 400,\n \"lt\": 600,\n \"isNot\": [\n 429\n ]\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.unkey.com/v2/logs.listApiRequests")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"limit\": 50,\n \"cursor\": \"MTc5MjAyMTg1MDEyMzpyZXFfNTY3OGVmZ2g\",\n \"filters\": {\n \"time\": {\n \"gte\": 1791936000000,\n \"lt\": 1792022400000\n },\n \"path\": {\n \"startsWith\": [\n \"/v2/keys.\"\n ],\n \"notContains\": [\n \"verifyKey\"\n ]\n },\n \"method\": {\n \"is\": [\n \"POST\",\n \"PUT\"\n ]\n },\n \"requestId\": {\n \"isNot\": [\n \"api.unkey.dev\"\n ]\n },\n \"status\": {\n \"gte\": 400,\n \"lt\": 600,\n \"isNot\": [\n 429\n ]\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"data": [],
"meta": {
"requestId": "req_1234abcd"
},
"pagination": {
"hasMore": false
}
}Authorizations
Unkey uses bearer tokens for authentication. Public integrations use root keys, while the dashboard proxy uses short-lived JWTs. To authenticate, include the token in the Authorization header of each request:
Authorization: Bearer unkey_123
Root keys have specific permissions attached to them, controlling what operations they can perform. Resource permissions use Unkey Resource Names plus actions, like unkey:v1:ws_123:projects/*/keyspaces/*/keys/*#write.
Security best practices:
- Keep root keys secure and never expose them in client-side code
- Use different root keys for different environments
- Rotate keys periodically, especially after team member departures
- Create keys with minimal necessary permissions following least privilege principle
- Monitor key usage with audit logs.
Body
Response
A page of requests, newest first. When hasMore is true, send pagination.cursor to get the next page.
Was this page helpful?
package main
import(
"context"
"os"
unkey "github.com/unkeyed/sdks/api/go/v3"
"github.com/unkeyed/sdks/api/go/v3/models/components"
"log"
)
func main() {
ctx := context.Background()
s := unkey.New(
unkey.WithSecurity(os.Getenv("UNKEY_ROOT_KEY")),
)
res, err := s.Logs.ListAPIRequests(ctx, components.V2LogsListAPIRequestsRequestBody{
Cursor: unkey.Pointer("MTc5MjAyMTg1MDEyMzpyZXFfNTY3OGVmZ2g"),
Filters: &components.V2LogsListAPIRequestsFilters{
Time: &components.TimeFilter{
Gte: unkey.Pointer[int64](1791936000000),
Lt: unkey.Pointer[int64](1792022400000),
},
Path: &components.TextFilter{
NotContains: []string{
"verifyKey",
},
StartsWith: []string{
"/v2/keys.",
},
},
Method: &components.MethodFilter{
Is: []components.HTTPMethod{
components.HTTPMethodPost,
components.HTTPMethodPut,
},
},
RequestID: &components.ExactFilter{
IsNot: []string{
"api.unkey.dev",
},
},
Status: &components.IntFilter{
IsNot: []int64{
429,
},
Gte: unkey.Pointer[int64](400),
Lt: unkey.Pointer[int64](600),
},
},
})
if err != nil {
log.Fatal(err)
}
if res.V2LogsListAPIRequestsResponseBody != nil {
for {
// handle items
res, err = res.Next()
if err != nil {
// handle error
}
if res == nil {
break
}
}
}
}from unkey.py import Unkey, models
with Unkey(
root_key="<YOUR_BEARER_TOKEN_HERE>",
) as unkey:
res = unkey.logs.list_api_requests(limit=50, cursor="MTc5MjAyMTg1MDEyMzpyZXFfNTY3OGVmZ2g", filters={
"time": {
"gte": 1791936000000,
"lt": 1792022400000,
},
"path": {
"not_contains": [
"verifyKey",
],
"starts_with": [
"/v2/keys.",
],
},
"method": {
"is_": [
models.HTTPMethod.POST,
models.HTTPMethod.PUT,
],
},
"request_id": {
"is_not": [
"api.unkey.dev",
],
},
"status": {
"is_not": [
429,
],
"gte": 400,
"lt": 600,
},
})
while res is not None:
# Handle items
res = res.next()import { Unkey } from "@unkey/api";
const unkey = new Unkey({
rootKey: process.env["UNKEY_ROOT_KEY"] ?? "",
});
async function run() {
const result = await unkey.logs.listApiRequests({
cursor: "MTc5MjAyMTg1MDEyMzpyZXFfNTY3OGVmZ2g",
filters: {
time: {
gte: 1791936000000,
lt: 1792022400000,
},
path: {
notContains: [
"verifyKey",
],
startsWith: [
"/v2/keys.",
],
},
method: {
is: [
"POST",
"PUT",
],
},
requestId: {
isNot: [
"api.unkey.dev",
],
},
status: {
isNot: [
429,
],
gte: 400,
lt: 600,
},
},
});
for await (const page of result) {
console.log(page);
}
}
run();curl --request POST \
--url https://api.unkey.com/v2/logs.listApiRequests \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"limit": 50,
"cursor": "MTc5MjAyMTg1MDEyMzpyZXFfNTY3OGVmZ2g",
"filters": {
"time": {
"gte": 1791936000000,
"lt": 1792022400000
},
"path": {
"startsWith": [
"/v2/keys."
],
"notContains": [
"verifyKey"
]
},
"method": {
"is": [
"POST",
"PUT"
]
},
"requestId": {
"isNot": [
"api.unkey.dev"
]
},
"status": {
"gte": 400,
"lt": 600,
"isNot": [
429
]
}
}
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
limit: 50,
cursor: 'MTc5MjAyMTg1MDEyMzpyZXFfNTY3OGVmZ2g',
filters: {
time: {gte: 1791936000000, lt: 1792022400000},
path: {startsWith: ['/v2/keys.'], notContains: ['verifyKey']},
method: {is: ['POST', 'PUT']},
requestId: {isNot: ['api.unkey.dev']},
status: {gte: 400, lt: 600, isNot: [429]}
}
})
};
fetch('https://api.unkey.com/v2/logs.listApiRequests', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.unkey.com/v2/logs.listApiRequests",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'limit' => 50,
'cursor' => 'MTc5MjAyMTg1MDEyMzpyZXFfNTY3OGVmZ2g',
'filters' => [
'time' => [
'gte' => 1791936000000,
'lt' => 1792022400000
],
'path' => [
'startsWith' => [
'/v2/keys.'
],
'notContains' => [
'verifyKey'
]
],
'method' => [
'is' => [
'POST',
'PUT'
]
],
'requestId' => [
'isNot' => [
'api.unkey.dev'
]
],
'status' => [
'gte' => 400,
'lt' => 600,
'isNot' => [
429
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.post("https://api.unkey.com/v2/logs.listApiRequests")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"limit\": 50,\n \"cursor\": \"MTc5MjAyMTg1MDEyMzpyZXFfNTY3OGVmZ2g\",\n \"filters\": {\n \"time\": {\n \"gte\": 1791936000000,\n \"lt\": 1792022400000\n },\n \"path\": {\n \"startsWith\": [\n \"/v2/keys.\"\n ],\n \"notContains\": [\n \"verifyKey\"\n ]\n },\n \"method\": {\n \"is\": [\n \"POST\",\n \"PUT\"\n ]\n },\n \"requestId\": {\n \"isNot\": [\n \"api.unkey.dev\"\n ]\n },\n \"status\": {\n \"gte\": 400,\n \"lt\": 600,\n \"isNot\": [\n 429\n ]\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.unkey.com/v2/logs.listApiRequests")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"limit\": 50,\n \"cursor\": \"MTc5MjAyMTg1MDEyMzpyZXFfNTY3OGVmZ2g\",\n \"filters\": {\n \"time\": {\n \"gte\": 1791936000000,\n \"lt\": 1792022400000\n },\n \"path\": {\n \"startsWith\": [\n \"/v2/keys.\"\n ],\n \"notContains\": [\n \"verifyKey\"\n ]\n },\n \"method\": {\n \"is\": [\n \"POST\",\n \"PUT\"\n ]\n },\n \"requestId\": {\n \"isNot\": [\n \"api.unkey.dev\"\n ]\n },\n \"status\": {\n \"gte\": 400,\n \"lt\": 600,\n \"isNot\": [\n 429\n ]\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"data": [],
"meta": {
"requestId": "req_1234abcd"
},
"pagination": {
"hasMore": false
}
}