createAPIToken()
createAPIToken(
request?:CreateAPITokenRequest):Promise<CreateAPITokenResponse>
Defined in: packages/core/src/index.ts:3237
Create a new API token for programmatic access
Parameters
| Parameter | Type | Description |
|---|---|---|
request? | CreateAPITokenRequest | Optional token configuration (name, expiry) |
Returns
Promise<CreateAPITokenResponse>
Created token response with the token value (only shown once)
Throws
401 - Not authenticated
Example
import { createAPIToken } from "@cpod/sdk";
const token = await createAPIToken({
name: "CI/CD Pipeline Token",
expires_in_days: 90,
});
// Save this token securely - it won't be shown again
console.log(`Token: ${token.token}`);