# `Ash.Resource.Interface`
[🔗](https://github.com/ash-project/ash/blob/v3.23.1/lib/ash/resource/interface.ex#L5)

Represents a function in a resource's code interface

See the functions defined in this module for specifications of the options
that each type of code interface function supports in its options list.

# `t`

```elixir
@type t() :: %Ash.Resource.Interface{
  __spark_metadata__: Spark.Dsl.Entity.spark_meta(),
  action: term(),
  args: term(),
  custom_inputs: term(),
  default_options: term(),
  exclude_inputs: term(),
  get?: term(),
  get_by: term(),
  get_by_identity: term(),
  name: term(),
  not_found_error?: term(),
  require_reference?: term()
}
```

# `calculate_opts`

Options supported by code interfaces for calculations

## Options

* `:actor` (`t:term/0`) - The actor for handling `^actor/1` templates, supplied to calculation context.

* `:scope` (`t:term/0`) - A value that implements the `Ash.Scope.ToOpts` protocol. Will overwrite any actor, tenant or context provided. See `Ash.Context` for more.

* `:tenant` (value that implements the `Ash.ToTenant` protocol) - The tenant, supplied to calculation context.

* `:context` (`t:map/0`) - Context to set on the calculation input.

* `:authorize?` (`t:boolean/0`) - Whether or not the request is being authorized, provided to calculation context. The default value is `true`.

* `:tracer` (one or a list of module that adopts `Ash.Tracer`) - A tracer, provided to the calculation context.

* `:data_layer?` (`t:boolean/0`) - Set to `true` to require that the value be computed within the data layer. Only works for calculations that define an expression.

* `:reuse_values?` (`t:boolean/0`) - Set to `true` to reuse existing values on any provided record. Only necessary if providing a record as the basis for calculation. The default value is `false`.

# `create_opts`

Options supported by code interfaces for create actions

## Options

* `:upsert?` (`t:boolean/0`) - If a conflict is found based on the primary key, the record is updated in the database (requires upsert support) The default value is `false`.

* `:return_skipped_upsert?` (`t:boolean/0`) - If `true`, and a record was *not* upserted because its filter prevented the upsert, the original record (which was *not* upserted) will be returned. The default value is `false`.

* `:upsert_identity` (`t:atom/0`) - The identity to use when detecting conflicts for `upsert?`, e.g. `upsert_identity: :full_name`. By default, the primary key is used. Has no effect if `upsert?: true` is not provided

* `:upsert_fields` - The fields to upsert. If not set, the action's upsert_fields is used, and if that is not set, then any fields not being set to defaults are written.

* `:upsert_condition` (`t:term/0`) - An expression to check if the record should be updated when there's a conflict.

* `:touch_update_defaults?` (`t:boolean/0`) - Whether or not to apply update defaults (like `updated_at` timestamps) on upsert. Only relevant when `upsert?: true` is set. Set to `false` to skip touching update_default fields when an upsert results in an update. The default value is `true`.

* `:timeout` (`t:timeout/0`) - A positive integer, or `:infinity`. If none is provided, the timeout configured on the domain is used.

* `:tracer` (one or a list of module that adopts `Ash.Tracer`) - A tracer that implements the `Ash.Tracer` behaviour. See that module for more.

* `:action` (`t:term/0`) - The action to use, either an Action struct or the name of the action

* `:authorize?` - If an actor option is provided (even if it is `nil`), authorization happens automatically. If not, this flag can be used to authorize with no user.

* `:context` (`t:map/0`) - Context to set on the query, changeset, or input

* `:tenant` (value that implements the `Ash.ToTenant` protocol) - A tenant to set on the query or changeset

* `:actor` (`t:term/0`) - If an actor is provided, it will be used in conjunction with the authorizers of a resource to authorize access

* `:scope` (`t:term/0`) - A value that implements the `Ash.Scope.ToOpts` protocol, for passing around actor/tenant/context in a single value. See `Ash.Scope.ToOpts` for more.

* `:return_notifications?` (`t:boolean/0`) - Use this if you're running ash actions in your own transaction and you want to manually handle sending notifications.  
  If a transaction is ongoing, and this is false, notifications will be discarded, otherwise
  the return value is `{:ok, result, notifications}` (or `{:ok, notifications}`)  
  To send notifications later, use `Ash.Notifier.notify(notifications)`. It sends any notifications
  that can be sent, and returns the rest. The default value is `false`.

* `:rollback_on_error?` (`t:boolean/0`) - Whether or not to rollback the transaction on error, if the resource is in a transaction.  
  If the action has `transaction? false` this option has no effect. If an error is returned from the
  data layer and the resource is in a transaction, the transaction is always rolled back, regardless. The default value is `true`.

* `:notification_metadata` (`t:term/0`) - Metadata to be merged into the metadata field for all notifications sent from this operation. The default value is `%{}`.

* `:skip_unknown_inputs` - A list of inputs that, if provided, will be ignored if they are not recognized by the action. Use `:*` to indicate all unknown keys.

* `:load` (`t:term/0`) - A load statement to add onto the changeset

* `:changeset` (`t:term/0`) - A changeset to seed the action with.

* `:bulk_options` (`t:keyword/0`) - Options passed to `Ash.bulk_create`, if a list or stream of inputs is provided.

  * `:select` (list of `t:atom/0`) - A select statement to apply to records. Ignored if `return_records?` is not true.

  * `:after_action` (function of arity 2) - An after_action hook to be added to each processed changeset

  * `:transform_changeset` (function of arity 1) - A function that takes and returns a changeset, applied to each changeset after it is built but before validation. Used internally by managed relationships to set foreign keys and context.

  * `:read_action` (`t:atom/0`) - The action to use when building the read query.

  * `:assume_casted?` (`t:boolean/0`) - Whether or not to cast attributes and arguments as input. This is an optimization for cases where the input is already casted and/or not in need of casting The default value is `false`.

  * `:select` (list of `t:atom/0`) - A select statement to apply to records. Ignored if `return_records?` is not true.

  * `:authorize_query_with` - If set to `:error`, instead of filtering unauthorized query results, unauthorized query results will raise an appropriate forbidden error. Uses `authorize_with` if not set.

  * `:authorize_changeset_with` - If set to `:error`, instead of filtering unauthorized changes, unauthorized changes will raise an appropriate forbidden error. Uses `authorize_with` if not set.

  * `:authorize_with` - If set to `:error`, instead of filtering unauthorized query results, unauthorized query results will raise an appropriate forbidden error. The default value is `:filter`.

  * `:private_arguments` (`t:map/0`) - Private argument values to set on each changeset before validations and changes are run. The default value is `%{}`.

  * `:sorted?` (`t:boolean/0`) - Whether or not to sort results by their input position, in cases where `return_records?: true` was provided. The default value is `false`.

  * `:return_records?` (`t:boolean/0`) - Whether or not to return all of the records that were inserted. Defaults to false to account for large inserts. The default value is `false`.

  * `:return_errors?` (`t:boolean/0`) - Whether to return all errors that occur during the operation. Defaults to the value of `:bulk_actions_default_to_errors?` in your config, or `false` if not set. Returning all errors may be expensive for large inserts. The default value is `true`.

  * `:batch_size` (`t:pos_integer/0`) - The number of records to include in each batch. Defaults to the `default_limit`
    or `max_page_size` of the action, or 100.

  * `:return_stream?` (`t:boolean/0`) - If set to `true`, instead of an `Ash.BulkResult`, a mixed stream is returned.

    Potential elements:

    `{:notification, notification}` - if `return_notifications?` is set to `true`
    `{:ok, record}` - if `return_records?` is set to `true`
    `{:error, error}` - an error that occurred. May be changeset or an individual error.

    The default value is `false`.

  * `:return_nothing?` (`t:boolean/0`) - Mutes warnings about returning nothing.

    Only relevant if `return_stream?` is set to `true` and all other
    `return_*?` options are set to `false`.

    The default value is `false`.

  * `:stop_on_error?` (`t:boolean/0`) - If true, the first encountered error will stop the action and be returned. Otherwise, errors
    will be skipped. The default value is `true`.

  * `:notify?` (`t:boolean/0`) - Whether or not to generate any notifications. If this is set to `true` then the data layer must return
    the results from each batch. This may be intensive for large bulk actions.

    Notifications will be automatically sent unless `return_notifications?` is set to `true`.

    The default value is `false`.

  * `:transaction` - Whether or not to wrap the entire execution in a transaction, each batch, or not at all.

    Keep in mind:

    `before_transaction` and `after_transaction` hooks attached to changesets will have to be run
    *inside* the transaction if you choose `transaction: :all`.

    The default value is `:batch`.

  * `:max_concurrency` (`t:non_neg_integer/0`) - If set to a value greater than 0, up to that many tasks will be started to run batches asynchronously The default value is `0`.

* `:private_arguments` (`t:map/0`) - Private argument values to set before validations and changes. The default value is `%{}`.

# `destroy_opts`

Options supported by code interfaces for destroy actions

## Options

* `:return_destroyed?` (`t:boolean/0`) - If true, the destroyed record is included in the return result, e.g `{:ok, destroyed}` or `{:ok, destroyed, notifications}` The default value is `false`.

* `:timeout` (`t:timeout/0`) - A positive integer, or `:infinity`. If none is provided, the timeout configured on the domain is used.

* `:tracer` (one or a list of module that adopts `Ash.Tracer`) - A tracer that implements the `Ash.Tracer` behaviour. See that module for more.

* `:action` (`t:term/0`) - The action to use, either an Action struct or the name of the action

* `:authorize?` - If an actor option is provided (even if it is `nil`), authorization happens automatically. If not, this flag can be used to authorize with no user.

* `:context` (`t:map/0`) - Context to set on the query, changeset, or input

* `:tenant` (value that implements the `Ash.ToTenant` protocol) - A tenant to set on the query or changeset

* `:actor` (`t:term/0`) - If an actor is provided, it will be used in conjunction with the authorizers of a resource to authorize access

* `:scope` (`t:term/0`) - A value that implements the `Ash.Scope.ToOpts` protocol, for passing around actor/tenant/context in a single value. See `Ash.Scope.ToOpts` for more.

* `:return_notifications?` (`t:boolean/0`) - Use this if you're running ash actions in your own transaction and you want to manually handle sending notifications.  
  If a transaction is ongoing, and this is false, notifications will be discarded, otherwise
  the return value is `{:ok, result, notifications}` (or `{:ok, notifications}`)  
  To send notifications later, use `Ash.Notifier.notify(notifications)`. It sends any notifications
  that can be sent, and returns the rest. The default value is `false`.

* `:rollback_on_error?` (`t:boolean/0`) - Whether or not to rollback the transaction on error, if the resource is in a transaction.  
  If the action has `transaction? false` this option has no effect. If an error is returned from the
  data layer and the resource is in a transaction, the transaction is always rolled back, regardless. The default value is `true`.

* `:notification_metadata` (`t:term/0`) - Metadata to be merged into the metadata field for all notifications sent from this operation. The default value is `%{}`.

* `:skip_unknown_inputs` - A list of inputs that, if provided, will be ignored if they are not recognized by the action. Use `:*` to indicate all unknown keys.

* `:load` (`t:term/0`) - A load statement to add onto the changeset

* `:bulk_options` (`t:keyword/0`) - Options passed to `Ash.bulk_destroy`, if a query, list, or stream of inputs is provided.

  * `:stream_batch_size` (`t:integer/0`) - Batch size to use if provided a query and the query must be streamed

  * `:allow_stream_with` - The 'worst' strategy allowed to be used to fetch records if the `:stream` strategy is chosen. See the `Ash.stream!/2` docs for more. The default value is `:keyset`.

  * `:authorize_query?` (`t:boolean/0`) - If a query is given, determines whether or not authorization is run on that query. The default value is `true`.

  * `:strategy` - The strategy or strategies to enable. :stream is used in all cases if the data layer does not support atomics. The default value is `:atomic`.

  * `:filter` (`t:term/0`) - A filter to apply to records. This is also applied to a stream of inputs.

  * `:transform_changeset` (function of arity 1) - A function that takes and returns a changeset, applied to each changeset after it is built but before validation. Used internally by managed relationships to set foreign keys and context.

  * `:allow_stream_with` - The 'worst' strategy allowed to be used to fetch records. See `Ash.stream!/2` docs for more. The default value is `:keyset`.

  * `:stream_with` - The specific strategy to use to fetch records. See `Ash.stream!/2` docs for more.

  * `:max_concurrency` (`t:non_neg_integer/0`) - The maximum number of processes allowed to be started for parallel loading of relationships and calculations. Defaults to `System.schedulers_online() * 2`

  * `:lock` (`t:term/0`) - A lock statement to add onto the query

  * `:return_query?` (`t:boolean/0`) - If `true`, the query that was ultimately used is returned as a third tuple element.

    The query goes through many potential changes during a request, potentially adding
    authorization filters, or replacing relationships for other data layers with their
    corresponding ids. This option can be used to get the true query that was sent to
    the data layer.

    The default value is `false`.

  * `:reuse_values?` (`t:boolean/0`) - Whether calculations are allowed to reuse values that have already been loaded, or must refetch them from the data layer. The default value is `false`.

  * `:strict?` (`t:boolean/0`) - If set to true, only specified attributes will be loaded when passing
      a list of fields to fetch on a relationship, which allows for more
      optimized data-fetching.

      See `Ash.Query.load/2`.

    The default value is `false`.

  * `:authorize_with` - If set to `:error`, instead of applying authorization filters as a filter, any records not matching the authorization filter will cause an error to be returned. The default value is `:filter`.

  * `:read_action` (`t:atom/0`) - The action to use when building the read query.

  * `:assume_casted?` (`t:boolean/0`) - Whether or not to cast attributes and arguments as input. This is an optimization for cases where the input is already casted and/or not in need of casting The default value is `false`.

  * `:select` (list of `t:atom/0`) - A select statement to apply to records. Ignored if `return_records?` is not true.

  * `:authorize_query_with` - If set to `:error`, instead of filtering unauthorized query results, unauthorized query results will raise an appropriate forbidden error. Uses `authorize_with` if not set.

  * `:authorize_changeset_with` - If set to `:error`, instead of filtering unauthorized changes, unauthorized changes will raise an appropriate forbidden error. Uses `authorize_with` if not set.

  * `:authorize_with` - If set to `:error`, instead of filtering unauthorized query results, unauthorized query results will raise an appropriate forbidden error. The default value is `:filter`.

  * `:private_arguments` (`t:map/0`) - Private argument values to set on each changeset before validations and changes are run. The default value is `%{}`.

  * `:sorted?` (`t:boolean/0`) - Whether or not to sort results by their input position, in cases where `return_records?: true` was provided. The default value is `false`.

  * `:return_records?` (`t:boolean/0`) - Whether or not to return all of the records that were inserted. Defaults to false to account for large inserts. The default value is `false`.

  * `:return_errors?` (`t:boolean/0`) - Whether to return all errors that occur during the operation. Defaults to the value of `:bulk_actions_default_to_errors?` in your config, or `false` if not set. Returning all errors may be expensive for large inserts. The default value is `true`.

  * `:batch_size` (`t:pos_integer/0`) - The number of records to include in each batch. Defaults to the `default_limit`
    or `max_page_size` of the action, or 100.

  * `:return_stream?` (`t:boolean/0`) - If set to `true`, instead of an `Ash.BulkResult`, a mixed stream is returned.

    Potential elements:

    `{:notification, notification}` - if `return_notifications?` is set to `true`
    `{:ok, record}` - if `return_records?` is set to `true`
    `{:error, error}` - an error that occurred. May be changeset or an individual error.

    The default value is `false`.

  * `:return_nothing?` (`t:boolean/0`) - Mutes warnings about returning nothing.

    Only relevant if `return_stream?` is set to `true` and all other
    `return_*?` options are set to `false`.

    The default value is `false`.

  * `:stop_on_error?` (`t:boolean/0`) - If true, the first encountered error will stop the action and be returned. Otherwise, errors
    will be skipped. The default value is `true`.

  * `:notify?` (`t:boolean/0`) - Whether or not to generate any notifications. If this is set to `true` then the data layer must return
    the results from each batch. This may be intensive for large bulk actions.

    Notifications will be automatically sent unless `return_notifications?` is set to `true`.

    The default value is `false`.

  * `:transaction` - Whether or not to wrap the entire execution in a transaction, each batch, or not at all.

    Keep in mind:

    `before_transaction` and `after_transaction` hooks attached to changesets will have to be run
    *inside* the transaction if you choose `transaction: :all`.

    The default value is `:batch`.

  * `:max_concurrency` (`t:non_neg_integer/0`) - If set to a value greater than 0, up to that many tasks will be started to run batches asynchronously The default value is `0`.

* `:private_arguments` (`t:map/0`) - Private argument values to set before validations and changes. The default value is `%{}`.

# `generic_action_opts`

Options supported by code interfaces for generic actions

## Options

* `:actor` (`t:term/0`) - The actor for handling `^actor/1` templates, supplied to calculation context.

* `:scope` (`t:term/0`) - A value that implements the `Ash.Scope.ToOpts` protocol. Will overwrite any actor, tenant or context provided. See `Ash.Context` for more.

* `:tenant` (value that implements the `Ash.ToTenant` protocol) - The tenant, supplied to calculation context.

* `:authorize?` (`t:boolean/0`) - Whether or not the request should be authorized.

* `:tracer` (one or a list of module that adopts `Ash.Tracer`) - A tracer, provided to the calculation context.

* `:context` (`t:map/0`) - Context to set on the action input

* `:skip_unknown_inputs` - A list of inputs that, if provided, will be ignored if they are not recognized by the action. Use `:*` to indicate all unknown keys.

* `:load` (`t:term/0`) - A load statement to apply on the resulting records after the action is invoked.

* `:private_arguments` (`t:map/0`) - Private argument values to set before validations and changes. The default value is `%{}`.

# `get_opts`

Options supported by code interfaces for read actions with `get?` or `get_by` set.

## Options

* `:page` - Pagination options, see `Ash.read/2` for more.

* `:load` (`t:term/0`) - A load statement to add onto the query

* `:max_concurrency` (`t:non_neg_integer/0`) - The maximum number of processes allowed to be started for parallel loading of relationships and calculations. Defaults to `System.schedulers_online() * 2`

* `:lock` (`t:term/0`) - A lock statement to add onto the query

* `:return_query?` (`t:boolean/0`) - If `true`, the query that was ultimately used is returned as a third tuple element.  
  The query goes through many potential changes during a request, potentially adding
  authorization filters, or replacing relationships for other data layers with their
  corresponding ids. This option can be used to get the true query that was sent to
  the data layer. The default value is `false`.

* `:skip_unknown_inputs` - A list of inputs that, if provided, will be ignored if they are not recognized by the action. Use `:*` to indicate all unknown keys.

* `:reuse_values?` (`t:boolean/0`) - Whether calculations are allowed to reuse values that have already been loaded, or must refetch them from the data layer. The default value is `false`.

* `:strict?` (`t:boolean/0`) - If set to true, only specified attributes will be loaded when passing
    a list of fields to fetch on a relationship, which allows for more
    optimized data-fetching.  
    See `Ash.Query.load/2`. The default value is `false`.

* `:authorize_with` - If set to `:error`, instead of applying authorization filters as a filter, any records not matching the authorization filter will cause an error to be returned. Valid values are :filter, :error The default value is `:filter`.

* `:timeout` (`t:timeout/0`) - A positive integer, or `:infinity`. If none is provided, the timeout configured on the domain is used.

* `:tracer` (one or a list of module that adopts `Ash.Tracer`) - A tracer that implements the `Ash.Tracer` behaviour. See that module for more.

* `:action` (`t:term/0`) - The action to use, either an Action struct or the name of the action

* `:authorize?` - If an actor option is provided (even if it is `nil`), authorization happens automatically. If not, this flag can be used to authorize with no user.

* `:context` (`t:map/0`) - Context to set on the query, changeset, or input

* `:tenant` (value that implements the `Ash.ToTenant` protocol) - A tenant to set on the query or changeset

* `:actor` (`t:term/0`) - If an actor is provided, it will be used in conjunction with the authorizers of a resource to authorize access

* `:scope` (`t:term/0`) - A value that implements the `Ash.Scope.ToOpts` protocol, for passing around actor/tenant/context in a single value. See `Ash.Scope.ToOpts` for more.

* `:query` - A query to seed the action with.

* `:not_found_error?` (`t:boolean/0`) - Whether or not to return or raise a `NotFound` error or to return `nil` when a get? action/interface is called.

* `:stream?` (`t:boolean/0`) - If true, a stream of the results will be returned The default value is `false`.

* `:stream_options` (`t:keyword/0`) - Options passed to `Ash.stream!`, if `stream?: true` is given

  * `:batch_size` (`t:integer/0`) - How many records to request in each query run. Defaults to the pagination limits on the resource, or 250.

  * `:allow_stream_with` - The 'worst' strategy allowed to be used to fetch records. See `Ash.stream!/2` docs for more. The default value is `:keyset`.

  * `:stream_with` - The specific strategy to use to fetch records. See `Ash.stream!/2` docs for more.

# `read_opts`

Options supported by code interfaces for read actions

## Options

* `:page` - Pagination options, see `Ash.read/2` for more.

* `:load` (`t:term/0`) - A load statement to add onto the query

* `:max_concurrency` (`t:non_neg_integer/0`) - The maximum number of processes allowed to be started for parallel loading of relationships and calculations. Defaults to `System.schedulers_online() * 2`

* `:lock` (`t:term/0`) - A lock statement to add onto the query

* `:return_query?` (`t:boolean/0`) - If `true`, the query that was ultimately used is returned as a third tuple element.  
  The query goes through many potential changes during a request, potentially adding
  authorization filters, or replacing relationships for other data layers with their
  corresponding ids. This option can be used to get the true query that was sent to
  the data layer. The default value is `false`.

* `:skip_unknown_inputs` - A list of inputs that, if provided, will be ignored if they are not recognized by the action. Use `:*` to indicate all unknown keys.

* `:reuse_values?` (`t:boolean/0`) - Whether calculations are allowed to reuse values that have already been loaded, or must refetch them from the data layer. The default value is `false`.

* `:strict?` (`t:boolean/0`) - If set to true, only specified attributes will be loaded when passing
    a list of fields to fetch on a relationship, which allows for more
    optimized data-fetching.  
    See `Ash.Query.load/2`. The default value is `false`.

* `:authorize_with` - If set to `:error`, instead of applying authorization filters as a filter, any records not matching the authorization filter will cause an error to be returned. Valid values are :filter, :error The default value is `:filter`.

* `:timeout` (`t:timeout/0`) - A positive integer, or `:infinity`. If none is provided, the timeout configured on the domain is used.

* `:tracer` (one or a list of module that adopts `Ash.Tracer`) - A tracer that implements the `Ash.Tracer` behaviour. See that module for more.

* `:action` (`t:term/0`) - The action to use, either an Action struct or the name of the action

* `:authorize?` - If an actor option is provided (even if it is `nil`), authorization happens automatically. If not, this flag can be used to authorize with no user.

* `:context` (`t:map/0`) - Context to set on the query, changeset, or input

* `:tenant` (value that implements the `Ash.ToTenant` protocol) - A tenant to set on the query or changeset

* `:actor` (`t:term/0`) - If an actor is provided, it will be used in conjunction with the authorizers of a resource to authorize access

* `:scope` (`t:term/0`) - A value that implements the `Ash.Scope.ToOpts` protocol, for passing around actor/tenant/context in a single value. See `Ash.Scope.ToOpts` for more.

* `:query` - A query to seed the action with.

* `:not_found_error?` (`t:boolean/0`) - Whether or not to return or raise a `NotFound` error or to return `nil` when a get? action/interface is called.

* `:stream?` (`t:boolean/0`) - If true, a stream of the results will be returned The default value is `false`.

* `:stream_options` (`t:keyword/0`) - Options passed to `Ash.stream!`, if `stream?: true` is given

  * `:batch_size` (`t:integer/0`) - How many records to request in each query run. Defaults to the pagination limits on the resource, or 250.

  * `:allow_stream_with` - The 'worst' strategy allowed to be used to fetch records. See `Ash.stream!/2` docs for more. The default value is `:keyset`.

  * `:stream_with` - The specific strategy to use to fetch records. See `Ash.stream!/2` docs for more.

# `update_opts`

Options supported by code interfaces for update actions

## Options

* `:params` (`t:map/0`) - Parameters to supply, ignored if the input is a changeset, only used when an identifier is given.

* `:atomic_upgrade?` (`t:boolean/0`) - If true the action will be done atomically if it can (and is configured to do so), ignoring the in memory transformations and validations. You should not generally need to disable this. The default value is `true`.

* `:timeout` (`t:timeout/0`) - A positive integer, or `:infinity`. If none is provided, the timeout configured on the domain is used.

* `:tracer` (one or a list of module that adopts `Ash.Tracer`) - A tracer that implements the `Ash.Tracer` behaviour. See that module for more.

* `:action` (`t:term/0`) - The action to use, either an Action struct or the name of the action

* `:authorize?` - If an actor option is provided (even if it is `nil`), authorization happens automatically. If not, this flag can be used to authorize with no user.

* `:context` (`t:map/0`) - Context to set on the query, changeset, or input

* `:tenant` (value that implements the `Ash.ToTenant` protocol) - A tenant to set on the query or changeset

* `:actor` (`t:term/0`) - If an actor is provided, it will be used in conjunction with the authorizers of a resource to authorize access

* `:scope` (`t:term/0`) - A value that implements the `Ash.Scope.ToOpts` protocol, for passing around actor/tenant/context in a single value. See `Ash.Scope.ToOpts` for more.

* `:return_notifications?` (`t:boolean/0`) - Use this if you're running ash actions in your own transaction and you want to manually handle sending notifications.  
  If a transaction is ongoing, and this is false, notifications will be discarded, otherwise
  the return value is `{:ok, result, notifications}` (or `{:ok, notifications}`)  
  To send notifications later, use `Ash.Notifier.notify(notifications)`. It sends any notifications
  that can be sent, and returns the rest. The default value is `false`.

* `:rollback_on_error?` (`t:boolean/0`) - Whether or not to rollback the transaction on error, if the resource is in a transaction.  
  If the action has `transaction? false` this option has no effect. If an error is returned from the
  data layer and the resource is in a transaction, the transaction is always rolled back, regardless. The default value is `true`.

* `:notification_metadata` (`t:term/0`) - Metadata to be merged into the metadata field for all notifications sent from this operation. The default value is `%{}`.

* `:skip_unknown_inputs` - A list of inputs that, if provided, will be ignored if they are not recognized by the action. Use `:*` to indicate all unknown keys.

* `:load` (`t:term/0`) - A load statement to add onto the changeset

* `:bulk_options` (`t:keyword/0`) - Options passed to `Ash.bulk_update`, if a query, list, or stream of inputs is provided.

  * `:atomic_update` (`t:map/0`) - A map of atomic updates to apply. See `Ash.Changeset.atomic_update/3` for more.

  * `:stream_batch_size` (`t:integer/0`) - Batch size to use if provided a query and the query must be streamed

  * `:allow_stream_with` - The 'worst' strategy allowed to be used to fetch records if the `:stream` strategy is chosen. See the `Ash.stream!/2` docs for more. The default value is `:keyset`.

  * `:authorize_query?` (`t:boolean/0`) - If a query is given, determines whether or not authorization is run on that query. The default value is `true`.

  * `:select` (list of `t:atom/0`) - A select statement to apply to records. Ignored if `return_records?` is not true.

  * `:filter` (`t:term/0`) - A filter to apply to records. This is also applied to a stream of inputs.

  * `:strategy` - The strategy or strategies to enable. :stream is used in all cases if the data layer does not support atomics. The default value is `[:atomic]`.

  * `:transform_changeset` (function of arity 1) - A function that takes and returns a changeset, applied to each changeset after it is built but before validation. Used internally by managed relationships to set foreign keys and context.

  * `:allow_stream_with` - The 'worst' strategy allowed to be used to fetch records. See `Ash.stream!/2` docs for more. The default value is `:keyset`.

  * `:stream_with` - The specific strategy to use to fetch records. See `Ash.stream!/2` docs for more.

  * `:max_concurrency` (`t:non_neg_integer/0`) - The maximum number of processes allowed to be started for parallel loading of relationships and calculations. Defaults to `System.schedulers_online() * 2`

  * `:lock` (`t:term/0`) - A lock statement to add onto the query

  * `:return_query?` (`t:boolean/0`) - If `true`, the query that was ultimately used is returned as a third tuple element.

    The query goes through many potential changes during a request, potentially adding
    authorization filters, or replacing relationships for other data layers with their
    corresponding ids. This option can be used to get the true query that was sent to
    the data layer.

    The default value is `false`.

  * `:reuse_values?` (`t:boolean/0`) - Whether calculations are allowed to reuse values that have already been loaded, or must refetch them from the data layer. The default value is `false`.

  * `:strict?` (`t:boolean/0`) - If set to true, only specified attributes will be loaded when passing
      a list of fields to fetch on a relationship, which allows for more
      optimized data-fetching.

      See `Ash.Query.load/2`.

    The default value is `false`.

  * `:authorize_with` - If set to `:error`, instead of applying authorization filters as a filter, any records not matching the authorization filter will cause an error to be returned. The default value is `:filter`.

  * `:read_action` (`t:atom/0`) - The action to use when building the read query.

  * `:assume_casted?` (`t:boolean/0`) - Whether or not to cast attributes and arguments as input. This is an optimization for cases where the input is already casted and/or not in need of casting The default value is `false`.

  * `:select` (list of `t:atom/0`) - A select statement to apply to records. Ignored if `return_records?` is not true.

  * `:authorize_query_with` - If set to `:error`, instead of filtering unauthorized query results, unauthorized query results will raise an appropriate forbidden error. Uses `authorize_with` if not set.

  * `:authorize_changeset_with` - If set to `:error`, instead of filtering unauthorized changes, unauthorized changes will raise an appropriate forbidden error. Uses `authorize_with` if not set.

  * `:authorize_with` - If set to `:error`, instead of filtering unauthorized query results, unauthorized query results will raise an appropriate forbidden error. The default value is `:filter`.

  * `:private_arguments` (`t:map/0`) - Private argument values to set on each changeset before validations and changes are run. The default value is `%{}`.

  * `:sorted?` (`t:boolean/0`) - Whether or not to sort results by their input position, in cases where `return_records?: true` was provided. The default value is `false`.

  * `:return_records?` (`t:boolean/0`) - Whether or not to return all of the records that were inserted. Defaults to false to account for large inserts. The default value is `false`.

  * `:return_errors?` (`t:boolean/0`) - Whether to return all errors that occur during the operation. Defaults to the value of `:bulk_actions_default_to_errors?` in your config, or `false` if not set. Returning all errors may be expensive for large inserts. The default value is `true`.

  * `:batch_size` (`t:pos_integer/0`) - The number of records to include in each batch. Defaults to the `default_limit`
    or `max_page_size` of the action, or 100.

  * `:return_stream?` (`t:boolean/0`) - If set to `true`, instead of an `Ash.BulkResult`, a mixed stream is returned.

    Potential elements:

    `{:notification, notification}` - if `return_notifications?` is set to `true`
    `{:ok, record}` - if `return_records?` is set to `true`
    `{:error, error}` - an error that occurred. May be changeset or an individual error.

    The default value is `false`.

  * `:return_nothing?` (`t:boolean/0`) - Mutes warnings about returning nothing.

    Only relevant if `return_stream?` is set to `true` and all other
    `return_*?` options are set to `false`.

    The default value is `false`.

  * `:stop_on_error?` (`t:boolean/0`) - If true, the first encountered error will stop the action and be returned. Otherwise, errors
    will be skipped. The default value is `true`.

  * `:notify?` (`t:boolean/0`) - Whether or not to generate any notifications. If this is set to `true` then the data layer must return
    the results from each batch. This may be intensive for large bulk actions.

    Notifications will be automatically sent unless `return_notifications?` is set to `true`.

    The default value is `false`.

  * `:transaction` - Whether or not to wrap the entire execution in a transaction, each batch, or not at all.

    Keep in mind:

    `before_transaction` and `after_transaction` hooks attached to changesets will have to be run
    *inside* the transaction if you choose `transaction: :all`.

    The default value is `:batch`.

  * `:max_concurrency` (`t:non_neg_integer/0`) - If set to a value greater than 0, up to that many tasks will be started to run batches asynchronously The default value is `0`.

* `:private_arguments` (`t:map/0`) - Private argument values to set before validations and changes. The default value is `%{}`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
