Skip to content
Hermesmail
Docs pages

Create an API key

POST /api-keys

Creates a new API key for the authenticated team and returns its identifier and secret token once. The raw token is not stored after creation and cannot be retrieved again. Set permission to full_access for team-wide management or sending_access for sending only, and optionally pass domain_id to restrict a sending key to one domain.

Authentication

Send a full access API key as a bearer token in the Authorization header. A sending access key is refused.

Request body

A JSON object.

Field Type Required Details
name string Yes
permission string No One of full_access, sending_access.
domain_id string No Format uuid. Matches ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$.

Response

Status 201, a JSON object.

Field Type Details
object api_key
id string Format uuid. Matches ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$.
token string

Headers: x-request-id, ratelimit-limit, ratelimit-remaining, ratelimit-reset.

Errors

Each error answers with the status below and a JSON body naming the error. Every error has its own entry.

Status Names
400 validation_error
401 missing_api_key, validation_error, restricted_api_key
403 validation_error, restricted_api_key, suspended_api_key, terms_acceptance_required
404 not_found
413 validation_error
415 validation_error
422 validation_error, missing_required_field
429 rate_limit_exceeded

Error headers: x-request-id, ratelimit-limit, ratelimit-remaining, ratelimit-reset, retry-after.

Samples

cURL

curl -X POST 'https://api.hermesmail.app/api-keys' \
  -H "Authorization: Bearer $HERMESMAIL_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "Production sending",
  "permission": "sending_access"
}'

Node

import { Resend } from 'resend';

const resend = new Resend(process.env.HERMESMAIL_API_KEY, { baseUrl: 'https://api.hermesmail.app' });

const { data, error } = await resend.apiKeys.create({
  "name": "Production sending",
  "permission": "sending_access"
});

Python

import os
import resend

resend.api_key = os.environ["HERMESMAIL_API_KEY"]
resend.api_url = "https://api.hermesmail.app"

result = resend.ApiKeys.create({
  "name": "Production sending",
  "permission": "sending_access"
})

PHP

<?php
// Set RESEND_BASE_URL="https://api.hermesmail.app" in the environment.
$resend = Resend::client(getenv("HERMESMAIL_API_KEY"));

$result = $resend->apiKeys->create([
  "name" => "Production sending",
  "permission" => "sending_access"
]);

Go

package main

import (
	"net/url"
	"os"

	"github.com/resend/resend-go/v4"
)

func main() {
	client := resend.NewClient(os.Getenv("HERMESMAIL_API_KEY"))
	baseURL, _ := url.Parse("https://api.hermesmail.app/")
	client.BaseURL = baseURL

	_, err := client.ApiKeys.Create(&resend.CreateApiKeyRequest{
		Name: "Production sending",
		Permission: "sending_access",
	})
	_ = err
}

Ruby

# Set RESEND_BASE_URL="https://api.hermesmail.app/" before require "resend".
require "resend"

Resend.api_key = ENV.fetch("HERMESMAIL_API_KEY")

result = Resend::ApiKeys.create({
  "name" => "Production sending",
  "permission" => "sending_access"
})