# `LightningWeb.API.Codes`
[🔗](https://github.com/OpenFn/lightning/blob/main/lib/lightning_web/api/codes.ex#L1)

The API's codes: each response code with its status and fixed detail, and
every code an error entry may carry. Both lists are the API's contract.
Adding a code is compatible. Renaming or removing one, or moving it to another
status, is a breaking change.

# `code`

```elixir
@type code() ::
  :id_taken
  | :insufficient_scope
  | :being_edited
  | :scheduled_for_deletion
  | :invalid_request
  | :bad_request
  | :in_use
  | :concurrent_edit
  | :invalid_token
  | :not_implemented
  | :too_many_requests
  | :malformed
  | :content_too_large
  | :not_found
  | :not_acceptable
  | :service_unavailable
  | :invalid_header
  | :uri_too_long
  | :export_conflict
  | :exceeds_limit
  | :not_ready
  | :timeout
  | :forbidden
  | :invalid
  | :trigger_disabled
  | :internal
  | :unauthenticated
  | :request_timeout
  | :bad_gateway
  | :invalid_parameter
  | :too_many_runs
  | :ambiguous_name
  | :unsupported_media_type
```

A response code, one of the keys of the response list.

# `detail`

```elixir
@spec detail(code()) :: String.t()
```

# `entry_codes`

```elixir
@spec entry_codes() :: [atom()]
```

The codes the walker maps from Ecto's own options, and those Lightning sets
with `code:`.

# `for_exception`

```elixir
@spec for_exception(:error | :exit | :throw, term()) :: code()
```

The code a raise is answered with. Every exception a client can cause has a
4xx status (`Plug.Exception.status/1`) and is answered by it. Anything else
is `:internal`: a 500 means Lightning raised where it should not have.

# `for_limiter`

```elixir
@spec for_limiter(atom()) :: code()
```

The code a usage or rate limiter's refusal is answered with.
The limiter's text is copy for the app's pages, so it never reaches the
answer.

# `response_codes`

```elixir
@spec response_codes() :: [code()]
```

# `status`

```elixir
@spec status(code()) :: pos_integer()
```

# `statuses`

```elixir
@spec statuses(code()) :: [pos_integer()]
```

Every status `code` may answer with, its own first.

---

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