const { result, error } = await unkey.keys.get({ keyId: "key_123" });

const { result, error } = await unkey.keys.get({ keyId: "key_123" });

if (error){
  // error will be undefined if the request was successful
}


// result
{
  keyId: "key_123",
  apiId: "api_123",
  remaining: 1024,
  expires: 1630540800000,
}

Request

keyId
string
required

The ID of the key you want to revoke.

Response

result
object
id
string
required

The id of the key

start
string
required

The first few characters of the key to visually identify it.

workspaceId
string
required

The id of the workspace that owns the key

apiId
string

The id of the api that this key is for

name
string

The name of the key, give keys a name to easily identify their purpose

ownerId
string

The id of the tenant associated with this key. Use whatever reference you have in your system to identify the tenant. When verifying the key, we will send this field back to you, so you know who is accessing your API.

meta
JSON

Any additional metadata you want to store with the key

createdAt
integer
required

The unix timestamp in milliseconds when the key was created

deletedAt
integer

The unix timestamp in milliseconds when the key was deleted. We don’t delete the key outright, you can restore it later.

expires
integer

The unix timestamp in milliseconds when the key will expire. If this field is null or undefined, the key is not expiring.

remaining
integer

The number of requests that can be made with this key before it becomes invalid. If this field is null or undefined, the key has no request limit.

refill
object

Unkey allows you to refill remaining verifications on a key on a regular interval.

ratelimit
object
required
const { result, error } = await unkey.keys.get({ keyId: "key_123" });

const { result, error } = await unkey.keys.get({ keyId: "key_123" });

if (error){
  // error will be undefined if the request was successful
}


// result
{
  keyId: "key_123",
  apiId: "api_123",
  remaining: 1024,
  expires: 1630540800000,
}