---
title: "How do I specify time restrictions for a policy?"
slug: "how-do-i-specify-an-expiry-date-or-a-rolling-validity-date-for-a-policy"
updated: 2024-11-20T10:58:39Z
published: 2024-11-20T10:58:39Z
canonical: "support.lusid.com/how-do-i-specify-an-expiry-date-or-a-rolling-validity-date-for-a-policy"
---

> ## Documentation Index
> Fetch the complete documentation index at: https://support.lusid.com/llms.txt
> Use this file to discover all available pages before exploring further.

# How do I specify time restrictions for a policy?

You can specify:

- Validity dates for a [feature or data policy](/v1/docs/what-are-a-policy-and-a-policy-collection). Outside these dates, access to features or data is denied.
- Time restrictions on the data controlled by a data policy, including rolling restrictions relative to points in time such as ‘now’ or ‘first business day of the month’.

## Specifying validity dates for a feature or data policy

You can specify **Policy validity** dates when you create a policy in the LUSID web app:

![](https://cdn.document360.io/d575ad81-c0ed-4980-bbd1-d59ac5c3de82/Images/Documentation/image(270).png)

If you do not specify a **Last day**, a policy expires on 31 December 9999 (that is, effectively never).

Note these restrictions are recorded in the JSON document using the `when` object:

```json
"when": {  
  "activate": "2024-10-17T00:00:00.0000000+00:00",  
  "deactivate": "2027-01-01T00:00:00.0000000+00:00"  
}
```

## Specifying time restrictions for data in a data policy

You can specify **Time Restrictions** on the LUSID data controlled by a data policy. You can use this feature to restrict access to the latest data, or conversely to only allow access to the latest data.

Consider the following examples for a policy designed for a portfolio manager to restrict the ability to upsert transactions to a portfolio. Without time restrictions, a portfolio manager can upsert a transaction with a transaction date of ‘now’, at any point in the past after the creation date of the portfolio, and at any point in the future.

### Example 1: Disallow backdated transactions

- Allow: Transactions with a transaction date of ‘now’ or later.
- Disallow: Transactions with a transaction date before ‘now’.

![](https://cdn.document360.io/d575ad81-c0ed-4980-bbd1-d59ac5c3de82/Images/Documentation/PolicyTimeRestrictionsExample1.png) ![](https://cdn.document360.io/d575ad81-c0ed-4980-bbd1-d59ac5c3de82/Images/Documentation/image(356).png)

Note these restrictions are recorded in the JSON document using the `for` object:

```json
"for": [ 
   { 
      "effectiveDateRelative": { 
         "date": "Now", 
         "adjustment": 0, 
         "unit": "Minute", 
         "relativeToDateTime": "AfterOrOn" 
      } 
   } 
]
```

### Example 2: Disallow future-dated transactions

- Allow: Transactions with a transaction date of ‘now’ or earlier.
- Disallow: Transactions with a transaction date after ‘now’.

![](https://cdn.document360.io/d575ad81-c0ed-4980-bbd1-d59ac5c3de82/Images/Documentation/PolicyTimeRestrictionsExample2.png)

![](https://cdn.document360.io/d575ad81-c0ed-4980-bbd1-d59ac5c3de82/Images/Documentation/image(358).png)

### Example 3: Disallow backdated transactions more than 10 days old

- Allow: Transactions with a transaction date of 10 days ago or later.
- Disallow: Transactions with a transaction date more than 10 days old.

![](https://cdn.document360.io/d575ad81-c0ed-4980-bbd1-d59ac5c3de82/Images/Documentation/PolicyTimeRestrictionsExample3.png)

Note the **Adjustment Quantity** is negative:

![](https://cdn.document360.io/d575ad81-c0ed-4980-bbd1-d59ac5c3de82/Images/Documentation/image(359).png)

### Example 4: Disallow future-dated transactions more than 10 days ahead

- Allow: Transactions with a transaction date of 10 days ahead or earlier.
- Disallow: Transactions with a transaction date more than 10 days ahead.

![](https://cdn.document360.io/d575ad81-c0ed-4980-bbd1-d59ac5c3de82/Images/Documentation/PolicyTimeRestrictionsExample4 (1).png)

![](https://cdn.document360.io/d575ad81-c0ed-4980-bbd1-d59ac5c3de82/Images/Documentation/image(360).png)

### Example 5: Disallow future-dated transactions, and backdated ones more than 10 days old

- Allow: Transactions with a transaction date of 10 days ago or later, up to ‘now’.
- Disallow: Transactions with a transaction date more than 10 days ago, and all future-dated transactions.

![](https://cdn.document360.io/d575ad81-c0ed-4980-bbd1-d59ac5c3de82/Images/Documentation/PolicyTimeRestrictionsExample5.png)

Note two time restrictions are required:

![](https://cdn.document360.io/d575ad81-c0ed-4980-bbd1-d59ac5c3de82/Images/Documentation/image(361).png)

### Retrieving time-restricted transactions

Note that whenever a user makes an API request to get a set of transactions, a ‘from’ and ‘to’ date are specified. By default, the ‘from’ date is the date the portfolio was created, and the ‘to’ date is the datetime of the API request. A user can override this to return a more limited set of transactions using the `fromTransactionDate` and `toTransactionDate `parameters, for example:

```json
curl -X GET https://<domain>.lusid.com/api/api/transactionportfolios/<scope>/<code>/transactions?fromTransactionDate=2021-07-01&toTransactionDate=2021-07-10   
```

Note that if any part of the period requested falls outside the allowed time restrictions of a policy, then no transactions are returned, even those nominally within the date. For example, imagine the following scenario:

- **Policy**: Allow access to portfolio data recorded 7 or more days ago
- **Date of API request**: 10 August 2021
- **XYZ transaction recorded**: 2 August 2021

Nominally, the XYZ transaction is 8 days old, and the portfolio manager is entitled to see it. But whether they actually do or not depends on the ‘from’ and ‘to’ dates in their API request:

| **API request** | **Transaction returned?** | **Explanation** |
| --- | --- | --- |
| From: 2 July 2021 To: 2 August 2021 | YES | Period requested falls wholly within the validity date of the policy |
| From: 2 July 2021 To: 3 August 2021 | NO (403 Forbidden) | Period requested falls partly outside (by one day) the validity date of the policy |
