# Ledger::insert()

Insert a ledger row and return its ID.

```php
insert( int $user_id, string $points_type_key, string $action_key, int $amount, string $ref = '' ): int
```

## Parameters

- `$user_id` (int) User ID.
- `$points_type_key` (string) Type key.
- `$action_key` (string) Action key.
- `$amount` (int) Points (positive).
- `$ref` (string) Optional reference to what earned the points (for example `sk_post:34`), so they can be taken back later.

## Return

`int` Insert ID or 0.

## Changelog

| Version | Description |
| --- | --- |
| 1.4.0 | Updated |
