# `Attio.Attributes`
[🔗](https://github.com/sgerrand/ex_attio/blob/v0.2.0/lib/attio/attributes.ex#L1)

Functions for managing attributes on objects and lists.

Attributes are the typed properties that define the shape of records and list
entries. Both system-defined (e.g. `email_addresses` on people) and user-defined
attributes are accessible through these functions.

## Targets

Attributes belong to either an object or a list, identified by the `target`
parameter:

  * `:objects` – attributes on an object (e.g. `people`, `companies`)
  * `:lists` – attributes on a list

## Scopes

Requires `object_configuration:read` or `list_configuration:read` for reads,
and their `:read-write` counterparts for mutations.

# `target`

```elixir
@type target() :: :objects | :lists
```

# `create`

```elixir
@spec create(Attio.Client.t(), target(), String.t(), map()) ::
  {:ok, map()} | {:error, term()}
```

Creates an attribute on an object or list.

## Required attributes

  * `"api_slug"` - URL-safe identifier for the attribute.
  * `"title"` - Human-readable name.
  * `"type"` - Attribute type. One of: `"text"`, `"number"`, `"checkbox"`,
    `"currency"`, `"date"`, `"timestamp"`, `"rating"`, `"status"`, `"select"`,
    `"record-reference"`, `"actor-reference"`, `"location"`, `"domain"`,
    `"email-address"`, `"phone-number"`.

## Example

    Attio.Attributes.create(client, :objects, "people", %{
      "api_slug" => "linkedin_url",
      "title" => "LinkedIn URL",
      "type" => "text"
    })

# `delete`

```elixir
@spec delete(Attio.Client.t(), target(), String.t(), String.t()) ::
  {:ok, map()} | {:error, term()}
```

Deletes a custom attribute.

System-defined attributes cannot be deleted and will return a `403` error.

## Example

    Attio.Attributes.delete(client, :objects, "people", "linkedin_url")

# `get`

```elixir
@spec get(Attio.Client.t(), target(), String.t(), String.t()) ::
  {:ok, map()} | {:error, term()}
```

Gets a single attribute by its ID or slug.

## Example

    Attio.Attributes.get(client, :objects, "people", "email_addresses")

# `list`

```elixir
@spec list(Attio.Client.t(), target(), String.t(), keyword()) ::
  {:ok, map()} | {:error, term()}
```

Lists attributes on an object or list.

## Options

  * `:limit` - Maximum number of attributes to return.
  * `:offset` - Number of attributes to skip (offset-based pagination).

## Example

    Attio.Attributes.list(client, :objects, "people")

# `update`

```elixir
@spec update(Attio.Client.t(), target(), String.t(), String.t(), map()) ::
  {:ok, map()} | {:error, term()}
```

Updates an attribute's configuration.

Only the supplied fields are changed; others are left untouched.

## Example

    Attio.Attributes.update(client, :objects, "people", "linkedin_url", %{
      "title" => "LinkedIn Profile"
    })

---

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