Skip to content

Identities

Manage mock identities for the Identity Provider — new in SDK v1.2.0. For what identities are and how they behave in the OAuth flow, see Clients & Identities.

Create a mock identity linked to one of your mailboxes.

identity = client.create_identity(
client_id="mc_EXAMPLECLIENTID",
mailbox_address="tricia@minutemail.cc",
username="tricia",
name="Tricia McMillan",
avatar_url="https://example.com/avatar.png",
email_verified=False, # Test the "unverified email" branch
claims={"roles": "admin"} # Custom claims merged into ID tokens
)
print(f"Identity: {identity['id']}")
ParameterTypeRequiredDescription
client_idstrOAuth client the identity belongs to
mailbox_addressstrOne of your active mailbox addresses
usernamestrDefaults to the local part of the mailbox address
namestrDisplay name; defaults to the username
avatar_urlstrPicture URL returned by userinfo
email_verifiedboolemail_verified claim in ID tokens and userinfo (default True)
claimsdictCustom string-to-string claims merged into ID tokens and userinfo (default {}) — custom-provider clients only; rejected with a 400 for google/github/apple/facebook clients

Reserved claim names (iss, sub, aud, exp, iat, nbf, jti, email, email_verified, name, preferred_username, picture, nonce, at_hash) and empty claim keys are rejected by the API with a 400.

{
"id": "ident_01JEXAMPLE",
"clientId": "mc_EXAMPLECLIENTID",
"mailboxAddress": "tricia@minutemail.cc",
"username": "tricia",
"name": "Tricia McMillan",
"avatarUrl": "https://example.com/avatar.png",
"isActive": True,
"emailVerified": False,
"claims": {"roles": "admin"}
}

Partially update an identity. Only the fields you pass are changed; client_id and mailbox_address are immutable.

identity = client.update_identity(
"ident_01JEXAMPLE",
name="Tricia McMillan",
email_verified=True,
claims={"roles": "admin", "tenant": "acme"}
)
ParameterTypeRequiredDescription
identity_idstrIdentity identifier
usernamestrNew username
namestrNew display name
avatar_urlstrNew picture URL
is_activeboolFalse deactivates the identity — it is then skipped by the consent screen
email_verifiedboolNew email-verification status
claimsdictReplaces the existing claims wholesale when provided — custom-provider clients only (rejected with a 400 for google/github/apple/facebook clients)

Returns the updated identity, in the same shape as Create Identity.

For the email-verification and custom-claims testing patterns, see Testing email verification and custom claims. Custom claims are a custom-provider feature — Provider Behavior explains the per-provider restrictions.