Packages

ory_client

1.22.55
1.22.63 1.22.62 1.22.61 1.22.60 1.22.59 1.22.58 1.22.57 1.22.56 1.22.55 1.22.54 1.22.53 1.22.52 1.22.51 1.22.50 1.22.49 1.22.48 1.22.47 1.22.46 1.22.45 1.22.44 1.22.43 1.22.42 1.22.41 1.22.40 1.22.39 1.22.38 1.22.37 1.22.36 1.22.35 1.22.34 1.22.33 1.22.32 1.22.28 1.22.27 1.22.26 1.22.25 1.22.24 1.22.23 1.22.22 1.22.21 1.22.16 1.22.15 1.22.14 1.22.13 1.22.12 1.22.11 1.22.10 1.22.9 1.22.8 1.22.7 1.22.6 1.22.5 1.22.4 1.22.3 1.22.2 1.22.1 1.22.0 1.21.6 1.21.5 1.21.4 1.21.3 1.21.2 1.21.1 1.21.0 1.20.23 1.20.22 1.20.11 1.20.10 1.20.9 1.20.8 1.20.7 1.20.6 1.20.5 1.20.4 1.20.3 1.20.2 1.20.1 1.20.0 1.19.0 1.18.5 1.18.4 1.17.2 1.17.1 1.16.10 1.6.2 1.6.1 1.5.2 1.5.1 1.5.0 1.4.9 1.4.8 1.4.7 1.4.6 1.4.5 1.4.4 1.4.3 1.4.2 1.4.1 1.4.0 1.3.0 1.2.17 1.2.16 1.2.15 1.2.14 1.2.11 1.2.10 1.2.9 1.2.8 1.2.7 1.2.6 1.2.5 1.2.4 1.2.3 1.2.2 1.2.1 1.2.0 1.1.51 1.1.50 1.1.49 1.1.48 1.1.47 1.1.46 1.1.45 1.1.44 1.1.41 1.1.40 1.1.39 1.1.39-alpha.0 1.1.38 1.1.37 1.1.36 1.1.35 1.1.34 1.1.33 1.1.32 1.1.31 1.1.30 1.1.29 1.1.28 1.1.27 1.1.26 1.1.25 1.1.24 1.1.23 1.1.22 1.1.21 1.1.20 1.1.19 1.1.18 1.1.17 1.1.7 1.1.5 1.1.4 1.1.3 1.1.2 1.1.1 1.1.0 1.0.2 1.0.1 1.0.0 1.0.0-alpha.0 0.2.0-alpha.60 0.2.0-alpha.48 0.2.0-alpha.47 0.2.0-alpha.46 0.2.0-alpha.45 0.2.0-alpha.44 0.2.0-alpha.43 0.2.0-alpha.42 0.2.0-alpha.41 0.2.0-alpha.40 0.2.0-alpha.39 0.2.0-alpha.38 0.2.0-alpha.37 0.2.0-alpha.36 0.2.0-alpha.35 0.2.0-alpha.34 0.2.0-alpha.33 0.2.0-alpha.32 0.2.0-alpha.31 0.2.0-alpha.30 0.2.0-alpha.29 0.2.0-alpha.28 0.2.0-alpha.27 0.2.0-alpha.26 0.2.0-alpha.25 0.2.0-alpha.24 0.2.0-alpha.23 0.2.0-alpha.22 0.2.0-alpha.21 0.2.0-alpha.20 0.2.0-alpha.19 0.2.0-alpha.18 0.2.0-alpha.16 0.2.0-alpha.15 0.2.0-alpha.14 0.2.0-alpha.4 0.2.0-alpha.2 0.1.0-alpha.12 0.1.0-alpha.11 0.1.0-alpha.10 0.1.0-alpha.9 0.1.0-alpha.8 0.1.0-alpha.7 0.1.0-alpha.6 0.1.0-alpha.5 0.1.0-alpha.4 0.1.0-alpha.3 0.1.0-alpha.2 0.1.0-alpha.1 0.0.1-alpha.189 0.0.1-alpha.188 0.0.1-alpha.187

OpenAPI API client for Ory Network, Ory's web-scale API for identity and access control.

Current section

Files

Jump to
ory_client lib ory api identity.ex
Raw

lib/ory/api/identity.ex

# NOTE: This file is auto generated by OpenAPI Generator 7.12.0 (https://openapi-generator.tech).
# Do not edit this file manually.
defmodule Ory.Api.Identity do
@moduledoc """
API calls for all endpoints tagged `Identity`.
"""
alias Ory.Connection
import Ory.RequestBuilder
@doc """
Create multiple identities
Creates multiple [identities](https://www.ory.com/docs/kratos/concepts/identity-user-model). You can also use this endpoint to [import credentials](https://www.ory.com/docs/kratos/manage-identities/import-user-accounts-identities), including passwords, social sign-in settings, and multi-factor authentication methods. If the patch includes hashed passwords you can import up to 1,000 identities per request. If the patch includes at least one plaintext password you can import up to 200 identities per request. Avoid importing large batches with plaintext passwords. They can cause timeouts as the passwords need to be hashed before they are stored. If at least one identity is imported successfully, the response status is 200 OK. If all imports fail, the response is one of the following 4xx errors: 400 Bad Request: The request payload is invalid or improperly formatted. 409 Conflict: Duplicate identities or conflicting data were detected. If you get a 504 Gateway Timeout: Reduce the batch size Avoid duplicate identities Pre-hash passwords with BCrypt If the issue persists, contact support.
### Parameters
- `connection` (Ory.Connection): Connection to server
- `opts` (keyword): Optional parameters
- `:body` (PatchIdentitiesBody):
### Returns
- `{:ok, Ory.Model.BatchPatchIdentitiesResponse.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec batch_patch_identities(Tesla.Env.client, keyword()) :: {:ok, Ory.Model.ErrorGeneric.t} | {:ok, Ory.Model.BatchPatchIdentitiesResponse.t} | {:error, Tesla.Env.t}
def batch_patch_identities(connection, opts \\ []) do
optional_params = %{
:body => :body
}
request =
%{}
|> method(:patch)
|> url("/admin/identities")
|> add_optional_params(optional_params, opts)
|> ensure_body()
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, Ory.Model.BatchPatchIdentitiesResponse},
{400, Ory.Model.ErrorGeneric},
{409, Ory.Model.ErrorGeneric},
{:default, Ory.Model.ErrorGeneric}
])
end
@doc """
Create an Identity
Create an [identity](https://www.ory.com/docs/kratos/concepts/identity-user-model). This endpoint can also be used to [import credentials](https://www.ory.com/docs/kratos/manage-identities/import-user-accounts-identities) for instance passwords, social sign in configurations, or multifactor methods.
### Parameters
- `connection` (Ory.Connection): Connection to server
- `opts` (keyword): Optional parameters
- `:body` (CreateIdentityBody):
### Returns
- `{:ok, Ory.Model.Identity.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec create_identity(Tesla.Env.client, keyword()) :: {:ok, Ory.Model.ErrorGeneric.t} | {:ok, Ory.Model.Identity.t} | {:error, Tesla.Env.t}
def create_identity(connection, opts \\ []) do
optional_params = %{
:body => :body
}
request =
%{}
|> method(:post)
|> url("/admin/identities")
|> add_optional_params(optional_params, opts)
|> ensure_body()
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{201, Ory.Model.Identity},
{400, Ory.Model.ErrorGeneric},
{409, Ory.Model.ErrorGeneric},
{:default, Ory.Model.ErrorGeneric}
])
end
@doc """
Create a Recovery Code
This endpoint creates a recovery code which should be given to the user in order for them to recover (or activate) their account.
### Parameters
- `connection` (Ory.Connection): Connection to server
- `opts` (keyword): Optional parameters
- `:body` (CreateRecoveryCodeForIdentityBody):
### Returns
- `{:ok, Ory.Model.RecoveryCodeForIdentity.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec create_recovery_code_for_identity(Tesla.Env.client, keyword()) :: {:ok, Ory.Model.ErrorGeneric.t} | {:ok, Ory.Model.RecoveryCodeForIdentity.t} | {:error, Tesla.Env.t}
def create_recovery_code_for_identity(connection, opts \\ []) do
optional_params = %{
:body => :body
}
request =
%{}
|> method(:post)
|> url("/admin/recovery/code")
|> add_optional_params(optional_params, opts)
|> ensure_body()
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{201, Ory.Model.RecoveryCodeForIdentity},
{400, Ory.Model.ErrorGeneric},
{404, Ory.Model.ErrorGeneric},
{:default, Ory.Model.ErrorGeneric}
])
end
@doc """
Create a Recovery Link
This endpoint creates a recovery link which should be given to the user in order for them to recover (or activate) their account.
### Parameters
- `connection` (Ory.Connection): Connection to server
- `opts` (keyword): Optional parameters
- `:return_to` (String.t):
- `:body` (CreateRecoveryLinkForIdentityBody):
### Returns
- `{:ok, Ory.Model.RecoveryLinkForIdentity.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec create_recovery_link_for_identity(Tesla.Env.client, keyword()) :: {:ok, Ory.Model.ErrorGeneric.t} | {:ok, Ory.Model.RecoveryLinkForIdentity.t} | {:error, Tesla.Env.t}
def create_recovery_link_for_identity(connection, opts \\ []) do
optional_params = %{
:return_to => :query,
:body => :body
}
request =
%{}
|> method(:post)
|> url("/admin/recovery/link")
|> add_optional_params(optional_params, opts)
|> ensure_body()
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, Ory.Model.RecoveryLinkForIdentity},
{400, Ory.Model.ErrorGeneric},
{404, Ory.Model.ErrorGeneric},
{:default, Ory.Model.ErrorGeneric}
])
end
@doc """
Create a test OIDC login flow
Creates a dry-run OIDC test login flow pre-scoped to one provider. The returned flow carries a single-submit UI and a CSRF bearer token. No identity is persisted and no session is issued when the flow completes; the captured debug data is returned in the flow's test_context.
### Parameters
- `connection` (Ory.Connection): Connection to server
- `create_test_login_flow_body` (CreateTestLoginFlowBody):
- `opts` (keyword): Optional parameters
### Returns
- `{:ok, Ory.Model.LoginFlow.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec create_test_login_flow(Tesla.Env.client, Ory.Model.CreateTestLoginFlowBody.t, keyword()) :: {:ok, Ory.Model.ErrorGeneric.t} | {:ok, Ory.Model.LoginFlow.t} | {:error, Tesla.Env.t}
def create_test_login_flow(connection, create_test_login_flow_body, _opts \\ []) do
request =
%{}
|> method(:post)
|> url("/admin/test-login-flows")
|> add_param(:body, :body, create_test_login_flow_body)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{201, Ory.Model.LoginFlow},
{400, Ory.Model.ErrorGeneric},
{404, Ory.Model.ErrorGeneric},
{:default, Ory.Model.ErrorGeneric}
])
end
@doc """
Delete an Identity
Calling this endpoint irrecoverably and permanently deletes the [identity](https://www.ory.com/docs/kratos/concepts/identity-user-model) given its ID. This action can not be undone. This endpoint returns 204 when the identity was deleted or 404 if the identity was not found.
### Parameters
- `connection` (Ory.Connection): Connection to server
- `id` (String.t): ID is the identity's ID.
- `opts` (keyword): Optional parameters
### Returns
- `{:ok, nil}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec delete_identity(Tesla.Env.client, String.t, keyword()) :: {:ok, nil} | {:ok, Ory.Model.ErrorGeneric.t} | {:error, Tesla.Env.t}
def delete_identity(connection, id, _opts \\ []) do
request =
%{}
|> method(:delete)
|> url("/admin/identities/#{id}")
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{204, false},
{404, Ory.Model.ErrorGeneric},
{:default, Ory.Model.ErrorGeneric}
])
end
@doc """
Delete a credential for a specific identity
Delete an [identity](https://www.ory.com/docs/kratos/concepts/identity-user-model) credential by its type. You cannot delete passkeys or code auth credentials through this API.
### Parameters
- `connection` (Ory.Connection): Connection to server
- `id` (String.t): ID is the identity's ID.
- `type` (String.t): Type is the type of credentials to delete. password CredentialsTypePassword oidc CredentialsTypeOIDC totp CredentialsTypeTOTP lookup_secret CredentialsTypeLookup webauthn CredentialsTypeWebAuthn code CredentialsTypeCodeAuth passkey CredentialsTypePasskey profile CredentialsTypeProfile saml CredentialsTypeSAML deviceauthn CredentialsTypeDeviceAuthn identifier_first CredentialsTypeIdentifierFirst link_recovery CredentialsTypeRecoveryLink CredentialsTypeRecoveryLink is a special credential type linked to the link strategy (recovery flow). It is not used within the credentials object itself. code_recovery CredentialsTypeRecoveryCode
- `opts` (keyword): Optional parameters
- `:identifier` (String.t): Identifier is the identifier of the OIDC/SAML credential to delete. Find the identifier by calling the `GET /admin/identities/{id}?include_credential={oidc,saml}` endpoint.
### Returns
- `{:ok, nil}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec delete_identity_credentials(Tesla.Env.client, String.t, String.t, keyword()) :: {:ok, nil} | {:ok, Ory.Model.ErrorGeneric.t} | {:error, Tesla.Env.t}
def delete_identity_credentials(connection, id, type, opts \\ []) do
optional_params = %{
:identifier => :query
}
request =
%{}
|> method(:delete)
|> url("/admin/identities/#{id}/credentials/#{type}")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{204, false},
{404, Ory.Model.ErrorGeneric},
{:default, Ory.Model.ErrorGeneric}
])
end
@doc """
Delete & Invalidate an Identity's Sessions
Calling this endpoint irrecoverably and permanently deletes and invalidates all sessions that belong to the given Identity.
### Parameters
- `connection` (Ory.Connection): Connection to server
- `id` (String.t): ID is the identity's ID.
- `opts` (keyword): Optional parameters
### Returns
- `{:ok, nil}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec delete_identity_sessions(Tesla.Env.client, String.t, keyword()) :: {:ok, nil} | {:ok, Ory.Model.ErrorGeneric.t} | {:error, Tesla.Env.t}
def delete_identity_sessions(connection, id, _opts \\ []) do
request =
%{}
|> method(:delete)
|> url("/admin/identities/#{id}/sessions")
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{204, false},
{400, Ory.Model.ErrorGeneric},
{401, Ory.Model.ErrorGeneric},
{404, Ory.Model.ErrorGeneric},
{:default, Ory.Model.ErrorGeneric}
])
end
@doc """
Deactivate a Session
Calling this endpoint deactivates the specified session. Session data is not deleted.
### Parameters
- `connection` (Ory.Connection): Connection to server
- `id` (String.t): ID is the session's ID.
- `opts` (keyword): Optional parameters
### Returns
- `{:ok, nil}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec disable_session(Tesla.Env.client, String.t, keyword()) :: {:ok, nil} | {:ok, Ory.Model.ErrorGeneric.t} | {:error, Tesla.Env.t}
def disable_session(connection, id, _opts \\ []) do
request =
%{}
|> method(:delete)
|> url("/admin/sessions/#{id}")
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{204, false},
{400, Ory.Model.ErrorGeneric},
{401, Ory.Model.ErrorGeneric},
{:default, Ory.Model.ErrorGeneric}
])
end
@doc """
Extend a Session
Calling this endpoint extends the given session ID. If `session.earliest_possible_extend` is set it will only extend the session after the specified time has passed. This endpoint returns per default a 204 No Content response on success. Older Ory Network projects may return a 200 OK response with the session in the body. Returning the session as part of the response will be deprecated in the future and should not be relied upon. This endpoint ignores consecutive requests to extend the same session and returns a 404 error in those scenarios. This endpoint also returns 404 errors if the session does not exist. Retrieve the session ID from the `/sessions/whoami` endpoint / `toSession` SDK method.
### Parameters
- `connection` (Ory.Connection): Connection to server
- `id` (String.t): ID is the session's ID.
- `opts` (keyword): Optional parameters
### Returns
- `{:ok, Ory.Model.Session.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec extend_session(Tesla.Env.client, String.t, keyword()) :: {:ok, nil} | {:ok, Ory.Model.ErrorGeneric.t} | {:ok, Ory.Model.Session.t} | {:error, Tesla.Env.t}
def extend_session(connection, id, _opts \\ []) do
request =
%{}
|> method(:patch)
|> url("/admin/sessions/#{id}/extend")
|> ensure_body()
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, Ory.Model.Session},
{204, false},
{400, Ory.Model.ErrorGeneric},
{404, Ory.Model.ErrorGeneric},
{:default, Ory.Model.ErrorGeneric}
])
end
@doc """
Get an Identity
Return an [identity](https://www.ory.com/docs/kratos/concepts/identity-user-model) by its ID. You can optionally include credentials (e.g. social sign in connections) in the response by using the `include_credential` query parameter.
### Parameters
- `connection` (Ory.Connection): Connection to server
- `id` (String.t): ID must be set to the ID of identity you want to get
- `opts` (keyword): Optional parameters
- `:include_credential` ([String.t]): Include Credentials in Response Include any credential, for example `password` or `oidc`, in the response. When set to `oidc`, This will return the initial OAuth 2.0 Access Token, OAuth 2.0 Refresh Token, and the OpenID Connect ID Token if available.
### Returns
- `{:ok, Ory.Model.Identity.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec get_identity(Tesla.Env.client, String.t, keyword()) :: {:ok, Ory.Model.ErrorGeneric.t} | {:ok, Ory.Model.Identity.t} | {:error, Tesla.Env.t}
def get_identity(connection, id, opts \\ []) do
optional_params = %{
:include_credential => :query
}
request =
%{}
|> method(:get)
|> url("/admin/identities/#{id}")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, Ory.Model.Identity},
{404, Ory.Model.ErrorGeneric},
{:default, Ory.Model.ErrorGeneric}
])
end
@doc """
Get an Identity by its External ID
Return an [identity](https://www.ory.com/docs/kratos/concepts/identity-user-model) by its external ID. You can optionally include credentials (e.g. social sign in connections) in the response by using the `include_credential` query parameter.
### Parameters
- `connection` (Ory.Connection): Connection to server
- `external_id` (String.t): ExternalID must be set to the ID of identity you want to get
- `opts` (keyword): Optional parameters
- `:include_credential` ([String.t]): Include Credentials in Response Include any credential, for example `password` or `oidc`, in the response. When set to `oidc`, This will return the initial OAuth 2.0 Access Token, OAuth 2.0 Refresh Token, and the OpenID Connect ID Token if available.
### Returns
- `{:ok, Ory.Model.Identity.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec get_identity_by_external_id(Tesla.Env.client, String.t, keyword()) :: {:ok, Ory.Model.ErrorGeneric.t} | {:ok, Ory.Model.Identity.t} | {:error, Tesla.Env.t}
def get_identity_by_external_id(connection, external_id, opts \\ []) do
optional_params = %{
:include_credential => :query
}
request =
%{}
|> method(:get)
|> url("/admin/identities/by/external/#{external_id}")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, Ory.Model.Identity},
{404, Ory.Model.ErrorGeneric},
{:default, Ory.Model.ErrorGeneric}
])
end
@doc """
Get Identity JSON Schema
Return a specific identity schema.
### Parameters
- `connection` (Ory.Connection): Connection to server
- `id` (String.t): ID must be set to the ID of schema you want to get
- `opts` (keyword): Optional parameters
### Returns
- `{:ok, map()}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec get_identity_schema(Tesla.Env.client, String.t, keyword()) :: {:ok, map()} | {:ok, Ory.Model.ErrorGeneric.t} | {:error, Tesla.Env.t}
def get_identity_schema(connection, id, _opts \\ []) do
request =
%{}
|> method(:get)
|> url("/schemas/#{id}")
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, %{}},
{404, Ory.Model.ErrorGeneric},
{:default, Ory.Model.ErrorGeneric}
])
end
@doc """
Get Session
This endpoint is useful for: Getting a session object with all specified expandables that exist in an administrative context.
### Parameters
- `connection` (Ory.Connection): Connection to server
- `id` (String.t): ID is the session's ID.
- `opts` (keyword): Optional parameters
- `:expand` ([String.t]): ExpandOptions is a query parameter encoded list of all properties that must be expanded in the Session. Example - ?expand=Identity&expand=Devices If no value is provided, the expandable properties are skipped.
### Returns
- `{:ok, Ory.Model.Session.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec get_session(Tesla.Env.client, String.t, keyword()) :: {:ok, Ory.Model.ErrorGeneric.t} | {:ok, Ory.Model.Session.t} | {:error, Tesla.Env.t}
def get_session(connection, id, opts \\ []) do
optional_params = %{
:expand => :query
}
request =
%{}
|> method(:get)
|> url("/admin/sessions/#{id}")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, Ory.Model.Session},
{400, Ory.Model.ErrorGeneric},
{:default, Ory.Model.ErrorGeneric}
])
end
@doc """
List Identities
Lists all [identities](https://www.ory.com/docs/kratos/concepts/identity-user-model) in the system. Note: filters cannot be combined.
### Parameters
- `connection` (Ory.Connection): Connection to server
- `opts` (keyword): Optional parameters
- `:per_page` (integer()): Deprecated Items per Page DEPRECATED: Please use `page_token` instead. This parameter will be removed in the future. This is the number of items per page.
- `:page` (integer()): Deprecated Pagination Page DEPRECATED: Please use `page_token` instead. This parameter will be removed in the future. This value is currently an integer, but it is not sequential. The value is not the page number, but a reference. The next page can be any number and some numbers might return an empty list. For example, page 2 might not follow after page 1. And even if page 3 and 5 exist, but page 4 might not exist. The first page can be retrieved by omitting this parameter. Following page pointers will be returned in the `Link` header.
- `:page_size` (integer()): Page Size This is the number of items per page to return. For details on pagination please head over to the [pagination documentation](https://www.ory.com/docs/ecosystem/api-design#pagination).
- `:page_token` (String.t): Next Page Token The next page token. For details on pagination please head over to the [pagination documentation](https://www.ory.com/docs/ecosystem/api-design#pagination).
- `:consistency` (String.t): Read Consistency Level (preview) The read consistency level determines the consistency guarantee for reads: strong (slow): The read is guaranteed to return the most recent data committed at the start of the read. eventual (very fast): The result will return data that is about 4.8 seconds old. The default consistency guarantee can be changed in the Ory Network Console or using the Ory CLI with `ory patch project --replace '/previews/default_read_consistency_level=\"strong\"'`. Setting the default consistency level to `eventual` may cause regressions in the future as we add consistency controls to more APIs. Currently, the following APIs will be affected by this setting: `GET /admin/identities` This feature is in preview and only available in Ory Network. ConsistencyLevelUnset ConsistencyLevelUnset is the unset / default consistency level. strong ConsistencyLevelStrong ConsistencyLevelStrong is the strong consistency level. eventual ConsistencyLevelEventual ConsistencyLevelEventual is the eventual consistency level using follower read timestamps.
- `:ids` ([String.t]): Retrieve multiple identities by their IDs. This parameter has the following limitations: Duplicate or non-existent IDs are ignored. The order of returned IDs may be different from the request. This filter does not support pagination. You must implement your own pagination as the maximum number of items returned by this endpoint may not exceed a certain threshold (currently 500).
- `:credentials_identifier` (String.t): CredentialsIdentifier is the identifier (username, email) of the credentials to look up using exact match. Only one of CredentialsIdentifier and CredentialsIdentifierSimilar can be used.
- `:preview_credentials_identifier_similar` (String.t): This is an EXPERIMENTAL parameter that WILL CHANGE. Do NOT rely on consistent, deterministic behavior. THIS PARAMETER WILL BE REMOVED IN AN UPCOMING RELEASE WITHOUT ANY MIGRATION PATH. CredentialsIdentifierSimilar is the (partial) identifier (username, email) of the credentials to look up using similarity search. Only one of CredentialsIdentifier and CredentialsIdentifierSimilar can be used.
- `:include_credential` ([String.t]): Include Credentials in Response Include any credential, for example `password` or `oidc`, in the response. When set to `oidc`, This will return the initial OAuth 2.0 Access Token, OAuth 2.0 Refresh Token, and the OpenID Connect ID Token if available.
- `:organization_id` (String.t): List identities that belong to a specific organization.
### Returns
- `{:ok, [%Identity{}, ...]}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec list_identities(Tesla.Env.client, keyword()) :: {:ok, Ory.Model.ErrorGeneric.t} | {:ok, [Ory.Model.Identity.t]} | {:error, Tesla.Env.t}
def list_identities(connection, opts \\ []) do
optional_params = %{
:per_page => :query,
:page => :query,
:page_size => :query,
:page_token => :query,
:consistency => :query,
:ids => :query,
:credentials_identifier => :query,
:preview_credentials_identifier_similar => :query,
:include_credential => :query,
:organization_id => :query
}
request =
%{}
|> method(:get)
|> url("/admin/identities")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, Ory.Model.Identity},
{:default, Ory.Model.ErrorGeneric}
])
end
@doc """
Get all Identity Schemas
Returns a list of all identity schemas currently in use.
### Parameters
- `connection` (Ory.Connection): Connection to server
- `opts` (keyword): Optional parameters
- `:per_page` (integer()): Deprecated Items per Page DEPRECATED: Please use `page_token` instead. This parameter will be removed in the future. This is the number of items per page.
- `:page` (integer()): Deprecated Pagination Page DEPRECATED: Please use `page_token` instead. This parameter will be removed in the future. This value is currently an integer, but it is not sequential. The value is not the page number, but a reference. The next page can be any number and some numbers might return an empty list. For example, page 2 might not follow after page 1. And even if page 3 and 5 exist, but page 4 might not exist. The first page can be retrieved by omitting this parameter. Following page pointers will be returned in the `Link` header.
- `:page_size` (integer()): Page Size This is the number of items per page to return. For details on pagination please head over to the [pagination documentation](https://www.ory.com/docs/ecosystem/api-design#pagination).
- `:page_token` (String.t): Next Page Token The next page token. For details on pagination please head over to the [pagination documentation](https://www.ory.com/docs/ecosystem/api-design#pagination).
### Returns
- `{:ok, [%IdentitySchemaContainer{}, ...]}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec list_identity_schemas(Tesla.Env.client, keyword()) :: {:ok, [Ory.Model.IdentitySchemaContainer.t]} | {:ok, Ory.Model.ErrorGeneric.t} | {:error, Tesla.Env.t}
def list_identity_schemas(connection, opts \\ []) do
optional_params = %{
:per_page => :query,
:page => :query,
:page_size => :query,
:page_token => :query
}
request =
%{}
|> method(:get)
|> url("/schemas")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, Ory.Model.IdentitySchemaContainer},
{:default, Ory.Model.ErrorGeneric}
])
end
@doc """
List an Identity's Sessions
This endpoint returns all sessions that belong to the given Identity.
### Parameters
- `connection` (Ory.Connection): Connection to server
- `id` (String.t): ID is the identity's ID.
- `opts` (keyword): Optional parameters
- `:per_page` (integer()): Deprecated Items per Page DEPRECATED: Please use `page_token` instead. This parameter will be removed in the future. This is the number of items per page.
- `:page` (integer()): Deprecated Pagination Page DEPRECATED: Please use `page_token` instead. This parameter will be removed in the future. This value is currently an integer, but it is not sequential. The value is not the page number, but a reference. The next page can be any number and some numbers might return an empty list. For example, page 2 might not follow after page 1. And even if page 3 and 5 exist, but page 4 might not exist. The first page can be retrieved by omitting this parameter. Following page pointers will be returned in the `Link` header.
- `:page_size` (integer()): Page Size This is the number of items per page to return. For details on pagination please head over to the [pagination documentation](https://www.ory.com/docs/ecosystem/api-design#pagination).
- `:page_token` (String.t): Next Page Token The next page token. For details on pagination please head over to the [pagination documentation](https://www.ory.com/docs/ecosystem/api-design#pagination).
- `:active` (boolean()): Active is a boolean flag that filters out sessions based on the state. If no value is provided, all sessions are returned.
### Returns
- `{:ok, [%Session{}, ...]}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec list_identity_sessions(Tesla.Env.client, String.t, keyword()) :: {:ok, [Ory.Model.Session.t]} | {:ok, Ory.Model.ErrorGeneric.t} | {:error, Tesla.Env.t}
def list_identity_sessions(connection, id, opts \\ []) do
optional_params = %{
:per_page => :query,
:page => :query,
:page_size => :query,
:page_token => :query,
:active => :query
}
request =
%{}
|> method(:get)
|> url("/admin/identities/#{id}/sessions")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, Ory.Model.Session},
{400, Ory.Model.ErrorGeneric},
{404, Ory.Model.ErrorGeneric},
{:default, Ory.Model.ErrorGeneric}
])
end
@doc """
List All Sessions
Listing all sessions that exist.
### Parameters
- `connection` (Ory.Connection): Connection to server
- `opts` (keyword): Optional parameters
- `:page_size` (integer()): Items per Page This is the number of items per page to return. For details on pagination please head over to the [pagination documentation](https://www.ory.com/docs/ecosystem/api-design#pagination).
- `:page_token` (String.t): Next Page Token The next page token. For details on pagination please head over to the [pagination documentation](https://www.ory.com/docs/ecosystem/api-design#pagination).
- `:active` (boolean()): Active is a boolean flag that filters out sessions based on the state. If no value is provided, all sessions are returned.
- `:expand` ([String.t]): ExpandOptions is a query parameter encoded list of all properties that must be expanded in the Session. If no value is provided, the expandable properties are skipped.
### Returns
- `{:ok, [%Session{}, ...]}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec list_sessions(Tesla.Env.client, keyword()) :: {:ok, [Ory.Model.Session.t]} | {:ok, Ory.Model.ErrorGeneric.t} | {:error, Tesla.Env.t}
def list_sessions(connection, opts \\ []) do
optional_params = %{
:page_size => :query,
:page_token => :query,
:active => :query,
:expand => :query
}
request =
%{}
|> method(:get)
|> url("/admin/sessions")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, Ory.Model.Session},
{400, Ory.Model.ErrorGeneric},
{:default, Ory.Model.ErrorGeneric}
])
end
@doc """
Manage sessions in bulk
Disable or delete sessions for a list of identities or a list of sessions in a single call. The `action` field selects the operation: `disable` — deactivate matching sessions (sets `active = false`, preserves audit data). `delete` — permanently delete matching sessions. Exactly one of `identities` or `sessions` must be provided. To scope the operation to every session in the network, pass `identities: [\"*\"]`; the wildcard is not accepted in the `sessions` field. Up to 500 explicit IDs are accepted per call. All requests return `200 OK` with `{processed, more}`. `processed` reports how many rows the call affected; for `disable` it counts only sessions that were active before the call. `more` is `true` only when a wildcard request reached the per-call batch limit and additional rows may remain; callers drain the network by re-issuing the same request while `more` is `true`. Explicit-IDs requests always return `more: false`.
### Parameters
- `connection` (Ory.Connection): Connection to server
- `manage_sessions_body` (ManageSessionsBody):
- `opts` (keyword): Optional parameters
### Returns
- `{:ok, Ory.Model.ManageSessionsResponse.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec manage_sessions(Tesla.Env.client, Ory.Model.ManageSessionsBody.t, keyword()) :: {:ok, Ory.Model.ErrorGeneric.t} | {:ok, Ory.Model.ManageSessionsResponse.t} | {:error, Tesla.Env.t}
def manage_sessions(connection, manage_sessions_body, _opts \\ []) do
request =
%{}
|> method(:post)
|> url("/admin/sessions")
|> add_param(:body, :body, manage_sessions_body)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, Ory.Model.ManageSessionsResponse},
{400, Ory.Model.ErrorGeneric},
{401, Ory.Model.ErrorGeneric},
{:default, Ory.Model.ErrorGeneric}
])
end
@doc """
Patch an Identity
Partially updates an [identity's](https://www.ory.com/docs/kratos/concepts/identity-user-model) field using [JSON Patch](https://jsonpatch.com/). The fields `id`, `stateChangedAt` and `credentials` can not be updated using this method.
### Parameters
- `connection` (Ory.Connection): Connection to server
- `id` (String.t): ID must be set to the ID of identity you want to update
- `opts` (keyword): Optional parameters
- `:body` ([Ory.Model.JsonPatch.t]):
### Returns
- `{:ok, Ory.Model.Identity.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec patch_identity(Tesla.Env.client, String.t, keyword()) :: {:ok, Ory.Model.ErrorGeneric.t} | {:ok, Ory.Model.Identity.t} | {:error, Tesla.Env.t}
def patch_identity(connection, id, opts \\ []) do
optional_params = %{
:body => :body
}
request =
%{}
|> method(:patch)
|> url("/admin/identities/#{id}")
|> add_optional_params(optional_params, opts)
|> ensure_body()
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, Ory.Model.Identity},
{400, Ory.Model.ErrorGeneric},
{404, Ory.Model.ErrorGeneric},
{409, Ory.Model.ErrorGeneric},
{:default, Ory.Model.ErrorGeneric}
])
end
@doc """
Update an Identity
This endpoint updates an [identity](https://www.ory.com/docs/kratos/concepts/identity-user-model). The full identity payload (except credentials) is expected. It is possible to update the identity's credentials as well. Using this operation, credentials will not be overwritten but instead added to the list. For example, if a user has a social sign in connection set up, updating the credentials will keep the social sign in connection and add the new credentials to the list. This prevents accidentally overwriting credentials and locking out users. A complete view of all credential types is here: `password`: The existing password credential will be completely replaced with the new configuration. You can provide either a hashed password, a plaintext password (which will be hashed), or enable the password migration hook. `oidc`, `saml`: The existing OIDC and SAML credentials will be kept and the new credentials will be added to the list. `totp`: The existing TOTP credentials will be replaced with the new configuration. `lookup_secret`: The existing Lookup Secret codes will be kept and the new codes will be added to the list. `webauthn`, `passkey`: The existing credentials are preserved, new credentials are added, and credentials with matching IDs are updated with new values. If a new `user_handle` is provided, it's added to the identity's identifiers list while preserving previous user handles. `code`: To import code credentials, configure your identity schema to use one of the identity traits as an identifier source (`{\"ory.sh/kratos\":{\"code\":{\"identifier\":true\", \"via\":\"email\"}}}`).
### Parameters
- `connection` (Ory.Connection): Connection to server
- `id` (String.t): ID must be set to the ID of identity you want to update
- `opts` (keyword): Optional parameters
- `:body` (UpdateIdentityBody):
### Returns
- `{:ok, Ory.Model.Identity.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec update_identity(Tesla.Env.client, String.t, keyword()) :: {:ok, Ory.Model.ErrorGeneric.t} | {:ok, Ory.Model.Identity.t} | {:error, Tesla.Env.t}
def update_identity(connection, id, opts \\ []) do
optional_params = %{
:body => :body
}
request =
%{}
|> method(:put)
|> url("/admin/identities/#{id}")
|> add_optional_params(optional_params, opts)
|> ensure_body()
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, Ory.Model.Identity},
{400, Ory.Model.ErrorGeneric},
{404, Ory.Model.ErrorGeneric},
{409, Ory.Model.ErrorGeneric},
{:default, Ory.Model.ErrorGeneric}
])
end
end