Make a verified email address the user's primary address

POST /v1/users/{user_id}/emails/{email_id}:set-primary · permission users:write

Makes a verified address the user's primary address; the previous primary stays as a secondary address. An unverified address cannot become primary. If the address is already primary nothing is written and 200 is returned. The change is written to the management audit log as user.primary_email_changed with the API key as actor, and emits user.updated.

Request

Parameter In Required Description
user_id path yes User id, prefixed usr_.
email_id path yes Id of the email row (internal UUID, lowercase, hyphenated), as returned by GET /v1/users/{user_id}/emails.

The request takes no body (an empty body or {} is accepted).

Response

200 OK with the updated email row. Without the users:read_pii permission the address is masked (a***@e***.com).

{
  "id": "0191f0a0-3333-7444-8555-666666666666",
  "email": "ada@example.com",
  "verified": true,
  "primary": true,
  "created_at": "2026-01-15T09:30:00Z"
}

Errors

Every error is an application/problem+json body with a stable code.

HTTP code When
400 malformed_request, unknown_field The body is not valid JSON, or is neither empty nor {}.
409 primary_requires_verified The address is not verified.
404 not_found The user or the email row does not exist in this environment, the email does not belong to this user, or an id is malformed.
401 unauthenticated The API key is missing, invalid or revoked.
403 insufficient_permissions The key lacks the users:write permission.
429 rate_limited The rate limit was exceeded; honor Retry-After.
503 service_unavailable A dependency is temporarily unavailable; retry later.

Example

curl -X POST https://api.eu.keenauth.com/v1/users/usr_0a1b2c3d4e5f6g7h8j9k0m1n2p/emails/0191f0a0-3333-7444-8555-666666666666:set-primary \
  -H "Authorization: Bearer $KEENAUTH_SECRET_KEY"

Personal data

This endpoint carries personal data: end-user profile. Personal data in the KeenAuth APIs describes what is stored, how long it is kept and how it is deleted. Do not send special categories of personal data (health, biometric data, religion, political opinions, sexual orientation) in any field.