# Give an API key access to only what it needs
URL: https://samva.dev/changelog/give-an-api-key-access-to-only-what-it-needs
> Create a restricted API key limited to the resources you pick, each at read or write. Every key is also capped by its owner's current role.
- Published: 2026-09-25
- Tags: api, dashboard

Create an API key that can only do what its job needs. A key for your checkout service can send email and read templates, and nothing else, so a leaked key has a small blast radius.

```ts sdk-typecheck-skip="Historical release excerpt; assumes the client and resources from the release context"
await samva.apiKeys.create({
  name: "Transactional sender",
  access: { mode: "restricted", resources: { messages: "write", templates: "read" } },
});
```

Every key is also capped by its owner's current role. Demote the owner and the key loses that access on the next request; remove the owner and the key stops working.

[Authentication](/docs/developers/authentication) lists the resources you can grant.

## Links

- [Authentication](/docs/developers/authentication)

## Related

- [Set your brand once and use it in every template](/changelog/set-your-brand-once-and-use-it-in-every-template)
- [Manage contact groups and attachments from the SDK](/changelog/manage-contact-groups-and-attachments-from-the-sdk)
- [All changelog entries](/changelog)
