Simplifyd Cloud
SmailAPI ReferenceAPI KeysCreate API Key

Create API Key

Generate a new API key for the account.

POST /api/v1/keys

Generates a new API key. The full key value is returned only once in this response — store it immediately. Authenticate with a JWT.

Request body

FieldTypeRequiredDescription
namestringYesHuman-readable label for the key
scopesstring[]NoPermission scopes (e.g. ["send"])

Response

Returns 200 OK:

FieldTypeDescription
keystringFull API key — shown only once
api_key.idstringUnique key ID
api_key.namestringKey label
api_key.key_prefixstringFirst few characters of the key
api_key.scopesstring[]Permission scopes
api_key.created_atstringISO 8601 timestamp
api_key.revoked_atstring | nullSet when the key is revoked
warningstringReminder to store the key securely
{
  "key": "sk_live_abc123xyz...",
  "api_key": {
    "id": "key_01hx...",
    "name": "Production",
    "key_prefix": "sk_live_abc",
    "scopes": ["send"],
    "created_at": "2024-01-15T10:00:00Z",
    "revoked_at": null
  },
  "warning": "Store this key securely. It will not be shown again."
}

Code examples

curl https://api.smail.dev/api/v1/keys \
  -H "Authorization: Bearer eyJ..." \
  -H "Content-Type: application/json" \
  -d '{"name": "Production", "scopes": ["send"]}'
const result = await smail.keys.create({
  name: "Production",
  scopes: ["send"],
});
// Store result.key immediately!
console.log("API key:", result.key);
result, err := client.Keys.Create(ctx, smail.CreateAPIKeyRequest{
    Name:   "Production",
    Scopes: []string{"send"},
})
// Store result.Key immediately!
fmt.Println("API key:", result.Key)

Error responses

StatusErrorDescription
401unauthorizedMissing or invalid JWT