# Limits
> You can set limits at the Account, Account Number, or Card level. Limits applied to Accounts will apply to all Account Numbers and Cards in the Account. You can specify any number of Limits and they will all be applied to inbound debits and card authorizations. Volume and count Limits are designed to prevent unauthorized debits.

## The Limit object
### Example
```json
{
  "created_at": "2020-01-31T23:59:59Z",
  "id": "limit_fku42k0qtc8ulsuas38q",
  "idempotency_key": null,
  "interval": "month",
  "metric": "volume",
  "model_id": "account_number_v18nkfqm6afpsrvy82b2",
  "model_type": "account_number",
  "status": "active",
  "type": "limit",
  "value": 0
}
```
### Attributes
- `created_at` (string)
  The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time at which the limit was created.

- `id` (string)
  The Limit identifier.

- `idempotency_key` (string, nullable)
  The idempotency key you chose for this object. This value is unique across Increase and is used to ensure that a request is only processed once. Learn more about [idempotency](https://increase.com/documentation/idempotency-keys).

- `interval` (enum, nullable)
  The interval for the metric. This is required if `metric` is `count` or `volume`.
  Cases:
  * `transaction` (Enforce the limit per-transaction.)
  * `day` (Enforce the limit based on the previous 24 hour period.)
  * `week` (Enforce the limit based on the previous seven days.)
  * `month` (Enforce the limit based on the previous month, going back to the current day in the previous month, or as close as possible given month length differences.)
  * `year` (Enforce the limit based on the previous year.)
  * `all_time` (Enforce the limit for all time.)

- `metric` (enum)
  The metric for the Limit.
  Cases:
  * `count` (The maximum number of debits allowed.)
  * `volume` (The maximum volume of debits allowed in the minor unit of the model's currency.)

- `model_id` (string)
  The identifier of the Account Number, Account, or Card the Limit applies to.

- `model_type` (enum)
  The type of the model you wish to associate the Limit with.
  Cases:
  * `account` (Enforce the Limit for the entire account.)
  * `account_number` (Enforce the Limit for this specific route.)
  * `card` (Enforce the Limit for this specific card.)

- `status` (enum)
  The current status of the Limit.
  Cases:
  * `active` (Activate the limit.)
  * `inactive` (Disable the limit temporarily.)

- `type` (string)
  A constant representing the object's type. For this resource it will always be `limit`.

- `value` (integer)
  The value to evaluate the Limit against.

## List Limits
GET /limits

### Example
```curl
curl \
  --url "${INCREASE_URL}/limits?model_id=account_number_v18nkfqm6afpsrvy82b2&status=active" \
  -H "Authorization: Bearer ${INCREASE_API_KEY}"
```

### Query Parameters
- `cursor` (string, optional)
  Return the page of entries after this one.

- `limit` (integer, optional)
  Limit the size of the list that is returned. The default (and maximum) is 100 objects.

- `model_id` (string, optional)
  The model to retrieve limits for.

- `status` (string, optional)
  The status to retrieve limits for.

- `idempotency_key` (string, optional)
  Filter records to the one with the specified `idempotency_key` you chose for that object. This value is unique across Increase and is used to ensure that a request is only processed once. Learn more about [idempotency](https://increase.com/documentation/idempotency-keys).

### Returns a Limit List object:
```json
{
  "data": [
    {
      "created_at": "2020-01-31T23:59:59Z",
      "id": "limit_fku42k0qtc8ulsuas38q",
      "idempotency_key": null,
      "interval": "month",
      "metric": "volume",
      "model_id": "account_number_v18nkfqm6afpsrvy82b2",
      "model_type": "account_number",
      "status": "active",
      "type": "limit",
      "value": 0
    }
  ],
  "next_cursor": "v57w5d"
}
```

## Create a Limit
POST /limits

### Example
```curl
curl -X "POST" \
  --url "${INCREASE_URL}/limits" \
  -H "Authorization: Bearer ${INCREASE_API_KEY}" \
  -H "Content-Type: application/json" \
  -d $'{
    "interval": "month",
    "metric": "volume",
    "model_id": "account_in71c4amph0vgo2qllky",
    "value": 1234
  }'
```

### Body Parameters
- `interval` (enum, optional)
  The interval for the metric. Required if `metric` is `count` or `volume`.
  Cases:
  * `transaction` (Enforce the limit per-transaction.)
  * `day` (Enforce the limit based on the previous 24 hour period.)
  * `week` (Enforce the limit based on the previous seven days.)
  * `month` (Enforce the limit based on the previous month, going back to the current day in the previous month, or as close as possible given month length differences.)
  * `year` (Enforce the limit based on the previous year.)
  * `all_time` (Enforce the limit for all time.)

- `metric` (enum, required)
  The metric for the limit.
  Cases:
  * `count` (The maximum number of debits allowed.)
  * `volume` (The maximum volume of debits allowed in the minor unit of the model's currency.)

- `model_id` (string, required)
  The identifier of the Account or Account Number you wish to associate the limit with.

- `value` (integer, required)
  The value to test the limit against.

## Retrieve a Limit
GET /limits/{limit_id}

### Example
```curl
curl \
  --url "${INCREASE_URL}/limits/limit_fku42k0qtc8ulsuas38q" \
  -H "Authorization: Bearer ${INCREASE_API_KEY}"
```
### Path Parameters
- `limit_id` (string, required)
  The identifier of the Limit to retrieve.

## Update a Limit
PATCH /limits/{limit_id}

### Example
```curl
curl -X "PATCH" \
  --url "${INCREASE_URL}/limits/limit_fku42k0qtc8ulsuas38q" \
  -H "Authorization: Bearer ${INCREASE_API_KEY}" \
  -H "Content-Type: application/json" \
  -d $'{
    "status": "inactive"
  }'
```
### Path Parameters
- `limit_id` (string, required)
  The limit to update.

### Body Parameters
- `status` (enum, required)
  The status to update the limit with.
  Cases:
  * `active` (Activate the limit.)
  * `inactive` (Disable the limit temporarily.)