# Create Mailgun API key Create Mailgun API key Endpoint: POST /v1/keys Version: 3.0.0 Security: basicAuth ## Request fields (multipart/form-data): - `domain_name` (string) Web domain to associate with the key, for keys of 'domain' kind - `kind` (string) Type of API key ('domain', 'user', or 'web'). Defaults to 'user' if not provided. Note: web keys are not subject to IP allowlisting and have a default/maximum validity period of 1 day. Enum: "domain", "user", "web" - `description` (string) Key description - `expiration` (integer) Key lifetime in seconds, must be greater than 0 if set - `role` (string, required) Key role ('admin', 'basic' [use in place of analyst], 'sending' [use with keys of domain kind], or 'developer') Enum: "admin", "basic", "sending", "developer" - `user_id` (string) API Key user's string user ID; should be provided for all keys of 'web' kind - `user_name` (string) API Key user's name - `email` (string) API Key user's email address; should be provided for all keys of 'web' kind ## Response 200 fields (application/json): - `message` (string, required) Response message - `key` (object, required) - `key.id` (string, required) The ID for the key - `key.description` (string, required) The description provided for the key upon its creation - `key.kind` (string, required) The type of the key which determines how it can be used Enum: "domain", "user", "web" - `key.role` (string, required) The role of the key which determines its scope in CRUD operations that have role-based access control Enum: "admin", "basic", "sending", "developer" - `key.created_at` (string, required) When the key was created in ISO 8601 date-time format without timezone offset (UTC time) Example: "2026-01-23T10:16:00" - `key.updated_at` (string, required) When the key was last updated in ISO 8601 date-time format without timezone offset (UTC time) Example: "2026-01-23T10:16:00" - `key.expires_at` (string) When the key will expire in ISO 8601 date-time format without timezone offset (UTC time) Example: "2026-01-23T10:16:00" - `key.disabled_reason` (string) The reason for the key's disablement if applicable - `key.is_disabled` (boolean, required) Whether or not the key is disabled from use - `key.domain_name` (any, required) - `key.requestor` (any, required) - `key.user_name` (any, required) - `key.secret` (string, required) The full API key secret in plain text returned only once upon key creation ## Response 403 fields (application/json): - `message` (string, required) Response message