# `OpenPayments.Types.Subject`
[🔗](https://github.com/interledger/open-payments-elixir/blob/v1.0.0/lib/open_payments/types/subject.ex#L1)

Subject information requested or returned by an authorization server.

The pinned schema requires `sub_ids` to contain exactly one typed
`SubjectIdentifier`. Missing, null, empty and multi-entry arrays are invalid.
Additional JSON fields are retained in `extensions`. The wire name remains
`sub_ids`; no camel-case alias is substituted.

Inspection omits subject values and extensions; explicit map/JSON exports
contain them. This data codec makes no requests and does not verify identity.
Validate manually constructed or modified structs with `validate/1`;
`to_map/1` converts shape without validating it.

# `t`

```elixir
@type t() :: %OpenPayments.Types.Subject{
  extensions: %{optional(String.t()) =&gt; term()},
  sub_ids: [OpenPayments.Types.SubjectIdentifier.t()]
}
```

# `from_map`

```elixir
@spec from_map(map()) :: {:ok, t()} | {:error, OpenPayments.Error.t()}
```

Decodes a subject object and its single identifier without resolving it.

# `to_map`

```elixir
@spec to_map(t()) :: map()
```

Converts to protocol fields, including subject identifiers, without validating.

# `validate`

```elixir
@spec validate(t()) :: :ok | {:error, OpenPayments.Error.t()}
```

Revalidates the single typed subject identifier and root extension fields.

---

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