Create key
Generates a new API key for the calling organization. Pass the resulting
key as a Bearer token on every Buckt request.
Body parameters
| Name | Type | Default | Description |
|---|---|---|---|
| namerequired | string | — | Human-readable label for the key. 1–100 characters. |
| permissionsrequired | string[] | — | One or more scopes from: `buckets:read`, `buckets:write`, `buckets:delete`, `files:read`, `files:write`, `files:delete`, `keys:read`, `keys:write`, `aws-accounts:read`, `aws-accounts:write`, `aws-accounts:delete`. |
| bucketIds | string[] | — | Restrict the key to specific buckets. When omitted, the key works against every bucket in the org. |
| expiresAt | string (ISO 8601) | — | When the key stops working. Omit for a non-expiring key. The SDK accepts a `Date` and converts it. |
Example request
import { Buckt } from "@buckt/sdk";
const client = new Buckt({ apiKey: process.env.BUCKT_API_KEY });
const { id, key } = await client.keys.create({
name: "Production uploader",
permissions: ["buckets:read", "files:read", "files:write"],
bucketIds: ["bkt_01H8XYZABCDEFGHJKMNPQRSTVW"],
expiresAt: new Date("2027-01-01"),
});
// Save `key` somewhere safe — it is only returned here.Responses
{
"data": {
"object": "api_key",
"id": "key_01J5UPLOADERXXXXXXXXXXXXXX",
"key": "bkt_xY9z8wQ7r6T5s4u3v2w1x0y_aBcDeFgHiJkLmNoPqRsTuVwXyZ"
},
"error": null,
"meta": null
}