const { result, error } = await unkey.keys.create({
apiId: "api_123",
prefix: "xyz",
byteLength: 16,
externalId: "user_1234",
meta: {
hello: "world",
},
expires: 1686941966471,
ratelimit: {
async: true,
duration: 1000,
limit: 10,
},
remaining: 1000,
environment: "test",
name: "My Key",
permissions: ["email.test"],
roles: ["domain.manager"],
refill: {
interval: "monthly",
amount: 100,
refillDay: 15,
},
enabled: true,
});
if (error) {
// handle potential network or bad request error
// a link to our docs will be in the `error.docs` field
console.error(error.message);
return;
}
console.log(result)