POST/api-keys

Create an API key

Creates a new API key. Supply a name and choose whether the key has full access or is restricted to sending emails; a sending-only key can be limited to a specific domain. The response includes the key token, so store it securely when you create the key.

  • IdempotentThe SDK sends Idempotency-Key, so a retried request is only applied once.

3 body fields

API key configuration. Supply the required name; optionally set its permission and, for a sending-only key, a domain restriction.

namestringrequired
The API key name.
permissionstringoptional
The API key can have full access to Resend’s API or be only restricted to send emails. * full_access - Can create, delete, get, and update any resource. * sending_access - Can only send emails.
Allowed:full_accesssending_access
domain_idstringoptional
Restrict an API key to send emails only from a specific domain. Only used when the permission is sending_access.

1 status code
201Returns the new API key's ID and token.
idstringoptional
The ID of the API key.
tokenstringoptional
The token of the API key.

Error handling

name is required. permission, if provided, must be full_access or sending_access; domain_id is used only with sending_access.