# `Ash.ToTenant`
[🔗](https://github.com/ash-project/ash/blob/v3.17.0/lib/ash/to_tenant.ex#L5)

Converts a value to a tenant.

To add this to a resource, implement the protocol like so:

```elixir
defmodule MyApp.Organization do
  use Ash.Resource, ...

  ...

  defimpl Ash.ToTenant do
    def to_tenant(%{id: id}, _resource), do: "org_#{id}"
  end
end
```

What this should do is entirely dependent on how you've set up your tenants. This example assumes
that you want the tenant to be `org_#{organization_id}`, but it could also be something like
`organization.schema`.

# `t`

```elixir
@type t() :: term()
```

# `to_tenant`

```elixir
@spec to_tenant(t(), Ash.Resource.t()) :: term()
```

---

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