<@U04UQ68083H> How do you remove a phone AND code ...
# ory-copilot
c
@chilly-king-10285 How do you remove a phone AND code auth credential from an identity?
b
A message from kapa.ai
To remove a phone and code auth credential from an identity in Ory, you need to use the Admin API endpoint for deleting credentials. The relevant endpoint is:
Copy code
DELETE /admin/identities/{id}/credentials/{type}
- To remove the code auth credential (which is typically used for "Log in via email or SMS" with a one-time code), set
{type}
to
code
. - If the phone number is used as an identifier for another credential type (such as
password
or
code
), you may need to remove that credential type as well, depending on your schema and how the phone is used. Important: You cannot delete code auth credentials through this API. The documentation explicitly states: > You cannot delete passkeys or code auth credentials through this API. [Delete Identity Credentials API](https://www.ory.sh/docs/reference/api#tag/identity/operation/deleteIdentityCredentials) So, while you can remove other credential types (like
password
,
totp
,
lookup_secret
, etc.), you cannot remove the
code
credential via the API at this time. Summary: - You can remove most credential types (including those using phone as an identifier) with the API. - You cannot remove the
code
credential (code auth) via the API. If you need to remove a phone identifier from another credential (e.g.,
password
), you can use:
Copy code
DELETE /admin/identities/{id}/credentials/password
But for
code
credentials, removal is not currently supported via the API. For more details, see the official documentation: [Delete Identity Credentials API](https://www.ory.sh/docs/reference/api#tag/identity/operation/deleteIdentityCredentials)
c
@chilly-king-10285 how to remove an SMS phone identifier from credential
b
A message from kapa.ai
To remove an SMS phone identifier from a credential in Ory, you need to delete the credential type (such as
password
or
code
) that uses the phone number as an identifier. This is done using the Admin API:
Copy code
DELETE /admin/identities/{id}/credentials/{type}
-
{id}
is the identity's ID. -
{type}
is the credential type (e.g.,
password
,
code
). However, according to the documentation, you cannot delete code auth credentials (the "code" type, used for SMS one-time codes) through this API. You can only delete other credential types, such as
password
,
totp
, etc. If the phone number is used as an identifier for the
password
credential, you can remove it with:
Copy code
DELETE /admin/identities/{id}/credentials/password
But if the phone number is only used for the
code
credential, there is currently no supported API method to remove it directly via the Admin APIĀ [Delete Identity Credentials API](https://www.ory.sh/docs/reference/api#tag/identity/operation/deleteIdentityCredentials). Summary: - You can remove a phone identifier by deleting the credential type (e.g.,
password
) that uses it, except for the
code
credential. - Removing an SMS phone identifier from the
code
credential is not supported via the API at this time. If you need to update the identifiers for a credential, you may need to update the identity's schema or traits and then update the identity, but the knowledge sources do not provide explicit instructions for this scenario.