@@ -12,7 +12,8 @@ import { path } from '../internal/utils/path';
1212 */
1313export class APIKeys extends APIResource {
1414 /**
15- * Create a new API key within the authenticated organization.
15+ * Create a new API key. API keys may be scoped by project and may include a
16+ * policy.
1617 *
1718 * @example
1819 * ```ts
@@ -156,6 +157,12 @@ export interface APIKey {
156157 * project name is unavailable.
157158 */
158159 project_name : string | null ;
160+
161+ /**
162+ * Permissions granted to a scoped API key. Absent for an ordinary key, which keeps
163+ * unrestricted access within its organization or project.
164+ */
165+ policy ?: APIKey . Policy | null ;
159166}
160167
161168export namespace APIKey {
@@ -175,6 +182,32 @@ export namespace APIKey {
175182 */
176183 name : string | null ;
177184 }
185+
186+ /**
187+ * Permissions granted to a scoped API key. Absent for an ordinary key, which keeps
188+ * unrestricted access within its organization or project.
189+ */
190+ export interface Policy {
191+ /**
192+ * Allow statements. Every action and resource not listed is denied.
193+ */
194+ statements : Array < Policy . Statement > ;
195+ }
196+
197+ export namespace Policy {
198+ export interface Statement {
199+ /**
200+ * Permitted action, such as browsers:use or vaults:read.
201+ */
202+ action : string ;
203+
204+ /**
205+ * Resource the action applies to, in the format projects/{project_id}/{kind}/{id}.
206+ * Wildcards are supported.
207+ */
208+ resource : string ;
209+ }
210+ }
178211}
179212
180213/**
@@ -194,16 +227,57 @@ export interface APIKeyCreateParams {
194227 name : string ;
195228
196229 /**
197- * Number of days until expiry, up to 3650. Use null for never.
230+ * Number of days until expiry, up to 3650. Use null for never. Cannot be combined
231+ * with expires_at.
198232 */
199233 days_to_expire ?: number | null ;
200234
235+ /**
236+ * Exact expiry time. Must be in the future and no later than the issuing
237+ * credential's own expiry. Cannot be combined with days_to_expire.
238+ */
239+ expires_at ?: string | null ;
240+
241+ /**
242+ * Issue a scoped key that may only perform the listed actions on the listed
243+ * resources.
244+ */
245+ policy ?: APIKeyCreateParams . Policy ;
246+
201247 /**
202248 * Unique project identifier
203249 */
204250 project_id ?: string | null ;
205251}
206252
253+ export namespace APIKeyCreateParams {
254+ /**
255+ * Issue a scoped key that may only perform the listed actions on the listed
256+ * resources.
257+ */
258+ export interface Policy {
259+ /**
260+ * Allow statements. Every action and resource not listed is denied.
261+ */
262+ statements : Array < Policy . Statement > ;
263+ }
264+
265+ export namespace Policy {
266+ export interface Statement {
267+ /**
268+ * Permitted action, such as browsers:use or vaults:read.
269+ */
270+ action : string ;
271+
272+ /**
273+ * Resource the action applies to, in the format projects/{project_id}/{kind}/{id}.
274+ * Wildcards are supported.
275+ */
276+ resource : string ;
277+ }
278+ }
279+ }
280+
207281export interface APIKeyRetrieveParams {
208282 /**
209283 * When true, return the API key even if it has been deleted (soft-deleted), for
0 commit comments