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

A complete grant initiation request with typed client, access, interaction and
subject data.

A client identity is required. The pinned `anyOf` contract allows an access-token
request, or a subject request with interaction, or both. Subject information
alongside an access-token request does not itself require interaction.
Directed JWK identity cannot be combined with an explicit `interact` field,
following the specification's non-interactive restriction.

Omitted optional fields become nil; explicit JSON nulls are rejected.
Additional JSON fields are retained in `extensions` at the root and nested
access-token-request level. Known wire names and nested string/object forms are
preserved. All nested models and access entries are revalidated by `validate/1`.

Inspection omits payload values. Explicit map/JSON exports contain nonces,
subject identifiers and any card data. This type does not fetch keys, match a
directed JWK to a configured signing key, sign or send a request, or verify a
callback. `to_map/1` converts shape without validating it.

# `t`

```elixir
@type t() :: %OpenPayments.Types.GrantRequest{
  access_token: OpenPayments.Types.AccessTokenRequest.t() | nil,
  client: OpenPayments.Types.GrantClient.t(),
  extensions: %{optional(String.t()) =&gt; term()},
  interact: OpenPayments.Types.InteractionRequest.t() | nil,
  subject: OpenPayments.Types.Subject.t() | nil
}
```

# `from_map`

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

Decodes a complete grant request and validates its nested models and variant.

# `to_map`

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

Converts to a complete protocol request, including sensitive fields, without validating.

# `validate`

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

Revalidates typed nested fields, request variants and extension rules.

---

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