# Support for code\_interface in embedded resources

**URL:** <https://forum.elixirforum.com/t/support-for-code-interface-in-embedded-resources/64479>\
**Category:** Questions\
**Tags:** embedded, ash\
**Created:** [June 23, 2024, 11:01pm UTC](https://forum.elixirforum.com/t/support-for-code-interface-in-embedded-resources/64479 "2024-06-23T23:01:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sezaru](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/sezaru/32/36113_2.png) [@sezaru](https://forum.elixirforum.com/u/sezaru)\
**Post date:** [June 23, 2024, 11:01pm UTC](https://forum.elixirforum.com/t/support-for-code-interface-in-embedded-resources/64479/1 "2024-06-23T23:01:45Z")

</div>

I’m upgrading Ash from 2 to 3. Before I had a create action with a code interface in my embedded resource like this:

```elixir
defmodule Coupon do
  @moduledoc false

  use Ash.Resource,
    data_layer: :embedded

  code_interface do
    define :new
  end
  ...
  actions do
    create :new, primary?: true
  end
end

```

I expect that a function `Coupon.new/1` will be created, but that doesn’t seem to be the case, did something changed regarding this from 2 to 3? I can’t find anything regarding this in the upgrade documentation.

---

<div class="post-metadata">

**Author:** ![zachdaniel](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/zachdaniel/32/31980_2.png) [@zachdaniel](https://forum.elixirforum.com/u/zachdaniel)\
**Post date:** [June 24, 2024, 12:34am UTC](https://forum.elixirforum.com/t/support-for-code-interface-in-embedded-resources/64479/2 "2024-06-24T00:34:18Z")

</div>

Interesting…I honestly hadn’t even considered having a code interface on an embedded resource. You’ll need to set the `domain` option inside the `code_interface` block:

```elixir
  code_interface do
    domain TheDomain.ToUse
    define :new
  end

```

If you don’t want to use an existing domain, you can do this:

```elixir
defmodule EmbedDomain do
  use Ash.Domain

  resources do
    allow_unregistered? true
  end
end

```
