# `Twilio.Usage.Triggers`

API calls: `create`, `delete`, `list`, `retrieve`, `update`.

# `create`

```elixir
@spec create(map() | keyword(), keyword()) ::
  {:ok, Twilio.Schemas.UsageTrigger.t()} | {:error, Infusion.Runtime.Error.t()}
```

Create a new UsageTrigger

`POST /2010-04-01/Accounts/{AccountSid}/Usage/Triggers.json`

`{AccountSid}` in the path is the `:account_sid` setting; pass `account_sid: "..."` as an option to use another.

## Parameters

  * `callback_method` - The HTTP method we should use to call `callback_url`. Can be: `GET` or `POST` and the default is `POST`.
  * `callback_url` (required) - The URL we should call using `callback_method` when the trigger fires.
  * `friendly_name` - A descriptive string that you create to describe the resource. It can be up to 64 characters long.
  * `recurring`
  * `trigger_by`
  * `trigger_value` (required) - The usage value at which the trigger should fire. For convenience, you can use an offset value such as `+30` to specify a trigger_value that is 30 units more than the current usage value. Be sure to urlencode a `+` as `%2B`.
  * `usage_category` (required) - The usage category that the trigger should watch. Use one of the supported [usage categories](https://www.twilio.com/docs/usage/api/usage-record#usage-categories) for this value.

# `create!`

```elixir
@spec create!(map() | keyword(), keyword()) :: Twilio.Schemas.UsageTrigger.t()
```

Like `create/2`, but returns the result or raises `Infusion.Runtime.Error`.

# `delete`

```elixir
@spec delete(String.t(), keyword()) ::
  {:ok, nil} | {:error, Infusion.Runtime.Error.t()}
```

`DELETE /2010-04-01/Accounts/{AccountSid}/Usage/Triggers/{Sid}.json`

## Path parameters

  * `sid` (required) - The Twilio-provided string that uniquely identifies the UsageTrigger resource to delete.

`{AccountSid}` in the path is the `:account_sid` setting; pass `account_sid: "..."` as an option to use another.

# `delete!`

```elixir
@spec delete!(String.t(), keyword()) :: nil
```

Like `delete/2`, but returns the result or raises `Infusion.Runtime.Error`.

# `list`

```elixir
@spec list(map() | keyword(), keyword()) ::
  {:ok, Twilio.Schemas.UsageTriggersListResponse.t()}
  | {:error, Infusion.Runtime.Error.t()}
```

Retrieve a list of usage-triggers belonging to the account used to make the request

`GET /2010-04-01/Accounts/{AccountSid}/Usage/Triggers.json`

`{AccountSid}` in the path is the `:account_sid` setting; pass `account_sid: "..."` as an option to use another.

## Parameters

  * `recurring` - The frequency of recurring UsageTriggers to read. Can be: `daily`, `monthly`, or `yearly` to read recurring UsageTriggers. An empty value or a value of `alltime` reads non-recurring UsageTriggers.
  * `trigger_by` - The trigger field of the UsageTriggers to read. Can be: `count`, `usage`, or `price` as described in the [UsageRecords documentation](https://www.twilio.com/docs/usage/api/usage-record#usage-count-price).
  * `usage_category` - The usage category of the UsageTriggers to read. Must be a supported [usage categories](https://www.twilio.com/docs/usage/api/usage-record#usage-categories).
  * `page_size` - How many resources to return in each list page. The default is 50, and the maximum is 1000.
  * `page` - The page index. This value is simply for client state.
  * `page_token` - The page token. This is provided by the API.

To read every item across all pages, use `list_all`.

# `list!`

```elixir
@spec list!(map() | keyword(), keyword()) ::
  Twilio.Schemas.UsageTriggersListResponse.t()
```

Like `list/2`, but returns the result or raises `Infusion.Runtime.Error`.

# `list_all`

```elixir
@spec list_all(map() | keyword(), keyword()) ::
  {:ok, Enumerable.t()} | {:error, Infusion.Runtime.Error.t()}
```

Like `list/2`, but returns every item, from every page: a lazy stream of `Twilio.Schemas.UsageTrigger.t()` that fetches pages as it is read.

The first page is fetched right away, so its errors are returned; a later page that fails raises `Infusion.Runtime.Error`. Stopping early (`Enum.take/2`) fetches no more pages.

# `list_all!`

```elixir
@spec list_all!(map() | keyword(), keyword()) :: Enumerable.t()
```

Like `list_all/2`, but returns the stream or raises `Infusion.Runtime.Error`.

# `retrieve`

```elixir
@spec retrieve(String.t(), keyword()) ::
  {:ok, Twilio.Schemas.UsageTrigger.t()} | {:error, Infusion.Runtime.Error.t()}
```

Fetch and instance of a usage-trigger

`GET /2010-04-01/Accounts/{AccountSid}/Usage/Triggers/{Sid}.json`

## Path parameters

  * `sid` (required) - The Twilio-provided string that uniquely identifies the UsageTrigger resource to fetch.

`{AccountSid}` in the path is the `:account_sid` setting; pass `account_sid: "..."` as an option to use another.

# `retrieve!`

```elixir
@spec retrieve!(String.t(), keyword()) :: Twilio.Schemas.UsageTrigger.t()
```

Like `retrieve/2`, but returns the result or raises `Infusion.Runtime.Error`.

# `update`

```elixir
@spec update(String.t(), map() | keyword(), keyword()) ::
  {:ok, Twilio.Schemas.UsageTrigger.t()} | {:error, Infusion.Runtime.Error.t()}
```

Update an instance of a usage trigger

`POST /2010-04-01/Accounts/{AccountSid}/Usage/Triggers/{Sid}.json`

## Path parameters

  * `sid` (required) - The Twilio-provided string that uniquely identifies the UsageTrigger resource to update.

`{AccountSid}` in the path is the `:account_sid` setting; pass `account_sid: "..."` as an option to use another.

## Parameters

  * `callback_method` - The HTTP method we should use to call `callback_url`. Can be: `GET` or `POST` and the default is `POST`.
  * `callback_url` - The URL we should call using `callback_method` when the trigger fires.
  * `friendly_name` - A descriptive string that you create to describe the resource. It can be up to 64 characters long.

# `update!`

```elixir
@spec update!(String.t(), map() | keyword(), keyword()) ::
  Twilio.Schemas.UsageTrigger.t()
```

Like `update/3`, but returns the result or raises `Infusion.Runtime.Error`.

---

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