# Account Statements

Account Statements are generated monthly for every active Account. You can access the statement’s data via the API or retrieve a PDF with its details via its associated File.

## Events

Your application can listen to [webhooks](/content/documentation/api/events/index.html) about this resource. All of the events about Account Statements will have the category "account_statement.created".

### The Account Statement object

```json
{
  "account_id": "account_in71c4amph0vgo2qllky",
  "created_at": "2020-01-31T23:59:59Z",
  "ending_balance": 100,
  "file_id": "file_makxrc67oh9l6sg7w9yc",
  "id": "account_statement_lkc03a4skm2k7f38vj15",
  "loan": null,
  "starting_balance": 0,
  "statement_period_end": "2020-01-31T23:59:59Z",
  "statement_period_start": "2020-01-31T23:59:59Z",
  "type": "account_statement"
}
```

#### Attributes
- **account_id**: string - The identifier for the Account this Account Statement belongs to.

- **created_at**: string - The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) time at which the Account Statement was created.

- **ending_balance**: integer - The Account’s balance at the end of its statement period.

- **file_id**: string - The identifier of the File containing a PDF of the statement.

- **id**: string - The Account Statement identifier.

- **loan**: dictionary - Nullable - The loan balances.
  - **starting_balance**: integer - The Account’s balance at the start of its statement period.
  - **statement_period_end**: string - The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) time representing the end of the period the Account Statement covers.
  - **statement_period_start**: string - The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) time representing the start of the period the Account Statement covers.
  - **type**: string - A constant representing the object’s type. For this resource it will always be `account_statement`.

## List Account Statements

### Example Request (cURL)

```bash
curl \ 
  --url "${INCREASE_URL}/account_statements?account_id=account_in71c4amph0vgo2qllky" \ 
  -H "Authorization: Bearer ${INCREASE_API_KEY}"
```

### Example Request (Python)

```python
import Increase from 'increase';

client = new Increase({
    apiKey: process.env['INCREASE_API_KEY'], // This is the default and can be omitted
});

// Automatically fetches more pages as needed.
for await (const accountStatement of client.accountStatements.list()) {
  console.log(accountStatement.id);
}
```

### Example Request (PHP)

```php
require "increase";

$increase = Increase::Client.new(
    api_key: ENV["INCREASE_API_KEY"] // This is the default and can be omitted
);

$page = increase.account_statements.list;

print(page);
```

## Retrieve an Account Statement

### Example Request (cURL)

```bash
curl \ 
  --url "${INCREASE_URL}/account_statements/account_statement_lkc03a4skm2k7f38vj15" \ 
  -H "Authorization: Bearer ${INCREASE_API_KEY}"
```

### Example Request (Python)

```python
client = Increase(
    api_key=os.environ.get("INCREASE_API_KEY"),  # This is the default and can be omitted
)
account_statement = client.account_statements.retrieve(
    "account_statement_lkc03a4skm2k7f38vj15",
)
print(account_statement.id)
```

## Sandbox: Create an Account Statement

### Example Request (cURL)

```bash
curl -X "POST" \ 
  --url "${INCREASE_URL}/simulations/account_statements" \ 
  -H "Authorization: Bearer ${INCREASE_API_KEY}" \ 
  -H "Content-Type: application/json" \ 
  -d $'{
    "account_id": "account_in71c4amph0vgo2qllky"
  }'
```

### Example Request (Python)

```python
account_statement = await client.simulations.accountStatements.create({
  account_id: 'account_in71c4amph0vgo2qllky',
});
console.log(account_statement.id);
```
