# `Attio.Client`
[🔗](https://github.com/sgerrand/ex_attio/blob/v0.3.6/lib/attio/client.ex#L1)

HTTP client for the Attio API.

Build a client once with `new/1` and pass it to resource functions:

    client = Attio.Client.new(api_key: System.fetch_env!("ATTIO_API_KEY"))
    {:ok, response} = Attio.Records.list(client, "people")

## Options for `new/1`

  * `:api_key` - Required. Your Attio API key (used as a Bearer token).
  * `:base_url` - Optional. Defaults to `https://api.attio.com`.

Any additional keyword options are forwarded to `Req.new/1`, which allows
test-time injection of a plug adapter:

    client = Attio.Client.new(api_key: "test", plug: {Req.Test, __MODULE__})

# `list_response`

```elixir
@type list_response() :: {:ok, [map()]} | {:error, Attio.Error.t() | Exception.t()}
```

Return value of a paginated collection request that buffers every page into a
list. Same error shapes as `t:response/0`.

# `response`

```elixir
@type response() :: {:ok, map()} | {:error, Attio.Error.t() | Exception.t()}
```

Return value of a single-resource request: the decoded JSON body on success,
or an error. API errors are `Attio.Error`; transport failures are the
underlying exception (e.g. `Req.TransportError`).

# `t`

```elixir
@type t() :: %Attio.Client{req: Req.Request.t()}
```

# `new`

```elixir
@spec new(keyword()) :: t()
```

Creates a new client.

Raises `KeyError` if `:api_key` is not provided, or `ArgumentError` if it is
not a non-empty string.

---

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