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
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.124.0"
".": "0.125.0"
}
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## [0.125.0](https://github.com/kernel/kernel-node-sdk/compare/v0.124.0...v0.125.0) (2026-10-13)


### Features

* chore(stlc): seal custom-code tracking files ([635766d](https://github.com/kernel/kernel-node-sdk/commit/635766db0f0e9d2dada9f134403533b97c41e7b2))

## [0.124.0](https://github.com/kernel/kernel-node-sdk/compare/v0.123.0...v0.124.0) (2026-10-13)


Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@onkernel/sdk",
"version": "0.124.0",
"version": "0.125.0",
"description": "The official TypeScript library for the Kernel API",
"author": "Kernel <>",
"types": "dist/index.d.ts",
Expand Down
78 changes: 76 additions & 2 deletions src/resources/api-keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import { path } from '../internal/utils/path';
*/
export class APIKeys extends APIResource {
/**
* Create a new API key within the authenticated organization.
* Create a new API key. API keys may be scoped by project and may include a
* policy.
*
* @example
* ```ts
Expand Down Expand Up @@ -156,6 +157,12 @@ export interface APIKey {
* project name is unavailable.
*/
project_name: string | null;

/**
* Permissions granted to a scoped API key. Absent for an ordinary key, which keeps
* unrestricted access within its organization or project.
*/
policy?: APIKey.Policy | null;
}

export namespace APIKey {
Expand All @@ -175,6 +182,32 @@ export namespace APIKey {
*/
name: string | null;
}

/**
* Permissions granted to a scoped API key. Absent for an ordinary key, which keeps
* unrestricted access within its organization or project.
*/
export interface Policy {
/**
* Allow statements. Every action and resource not listed is denied.
*/
statements: Array<Policy.Statement>;
}

export namespace Policy {
export interface Statement {
/**
* Permitted action, such as browsers:use or vaults:read.
*/
action: string;

/**
* Resource the action applies to, in the format projects/{project_id}/{kind}/{id}.
* Wildcards are supported.
*/
resource: string;
}
}
}

/**
Expand All @@ -194,16 +227,57 @@ export interface APIKeyCreateParams {
name: string;

/**
* Number of days until expiry, up to 3650. Use null for never.
* Number of days until expiry, up to 3650. Use null for never. Cannot be combined
* with expires_at.
*/
days_to_expire?: number | null;

/**
* Exact expiry time. Must be in the future and no later than the issuing
* credential's own expiry. Cannot be combined with days_to_expire.
*/
expires_at?: string | null;

/**
* Issue a scoped key that may only perform the listed actions on the listed
* resources.
*/
policy?: APIKeyCreateParams.Policy;

/**
* Unique project identifier
*/
project_id?: string | null;
}

export namespace APIKeyCreateParams {
/**
* Issue a scoped key that may only perform the listed actions on the listed
* resources.
*/
export interface Policy {
/**
* Allow statements. Every action and resource not listed is denied.
*/
statements: Array<Policy.Statement>;
}

export namespace Policy {
export interface Statement {
/**
* Permitted action, such as browsers:use or vaults:read.
*/
action: string;

/**
* Resource the action applies to, in the format projects/{project_id}/{kind}/{id}.
* Wildcards are supported.
*/
resource: string;
}
}
}

export interface APIKeyRetrieveParams {
/**
* When true, return the API key even if it has been deleted (soft-deleted), for
Expand Down
2 changes: 1 addition & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const VERSION = '0.124.0'; // x-release-please-version
export const VERSION = '0.125.0'; // x-release-please-version
4 changes: 4 additions & 0 deletions tests/api-resources/api-keys.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ describe('resource apiKeys', () => {
const response = await client.apiKeys.create({
name: 'staging',
days_to_expire: 30,
expires_at: '2025-01-15T09:00:00Z',
policy: {
statements: [{ action: 'browsers:use', resource: 'projects/proj_abc123/browsers/br_abc123' }],
},
project_id: 'proj_abc123',
});
});
Expand Down
Loading