# Custom validity rules

When creating an order, validity and expiry rules that are associated with the product being purchased will be inherited by the cards created as part of that order.

However, if you want to override these validity or expiry rules, you can pass in `validity_rules` and `expiry_config` variables as part of the OrderItemInput object.

| Validity Rule Type           | ID | Format                           | Description                                                                  |
| ---------------------------- | -- | -------------------------------- | ---------------------------------------------------------------------------- |
| Valid From                   | 1  | UTC date in `Y-m-d H:i:s` format | The date the purchase is valid from                                          |
| Valid Until                  | 2  | UTC date in `Y-m-d H:i:s` format | The date the purchase is valid until                                         |
| Valid Seconds After Purchase | 3  | Integer                          | The number of seconds after the purchase has been made that it is valid from |

To use the `validity_rules`  follow the example below:

```
 "validity_rules": [
     {
          "validity_rule_type_id": 1,
          "rule": "2021-08-14 00:08:00"
     }      
]
```

| Field                           | Format                                  | Description                                                                                    |
| ------------------------------- | --------------------------------------- | ---------------------------------------------------------------------------------------------- |
| `seconds_valid_for`             | Integer / NULL                          | The number of seconds after purchase that it will expire. NULL sets to never.                  |
| `send_expiry_alert_days_before` | UTC date in `Y-m-d H:i:s` format / NULL | The number of days before expiry a notification will be sent to the owner. NULL sets to never. |
| `hard_expire_at`                | UTC date in `Y-m-d H:i:s` format / NULL | The specific time the purchase should expire. NULL sets to never.                              |

To use the `expiry_config` follow the example below:

```
"expiry_config": {
    "hard_expire_at": "2021-08-14 22:59:59"
 }
```

### Update a card

If you want to update a card with a new validity ruleset or a new expiry config you can use the `updateCard` mutation.
