Skip to main content

Method

func (s *ApiKeysSvcImpl) Create(params *CreateApiKeyRequest) (CreateApiKeyResponse, error)
func (s *ApiKeysSvcImpl) CreateWithContext(ctx context.Context, params *CreateApiKeyRequest) (CreateApiKeyResponse, error)

Parameters

params
*CreateApiKeyRequest
required
The API key creation parameters
Name
string
required
The name of the API key
Permission
string
The permission level for the API key
DomainId
string
Optional domain ID to scope the API key to a specific domain

Response

Id
string
The unique identifier of the created API key
Token
string
The API key token. Store this securely - it’s only shown once.

Example

client := resend.NewClient("re_123456789")

params := &resend.CreateApiKeyRequest{
    Name:       "Production API Key",
    Permission: "full_access",
}

apiKey, err := client.ApiKeys.Create(params)
if err != nil {
    panic(err)
}

fmt.Println("API Key ID:", apiKey.Id)
fmt.Println("Token:", apiKey.Token)

Build docs developers (and LLMs) love