# Functions `projection` breaking change

**Version:** v2025-08-06

**Published:** August 6, 2025

## Why we're making the change

⚠️ Previously, we accepted GROQ projections in function event definitions that were not wrapped in curly braces (`{}`). Behind the scenes, we would transparently wrap your projection with curly braces. 

📣 In order to better support the full GROQ specification, as of now, if you wish to receive an object as a projection in your function invocation, you are required to wrap your projection in curly braces.

## Before

❌ Previously, you could provide the following projection that expressed "give me an object with `_id` and `type` properties":

```json
{
  "on": ["publish"],
  "filter": "_type == 'post'",
  "projection": "_id, type"
}
```

Now, trying to create or update a function with the above `projection` will yield an error like:

`Failed to manage function subscription: Failed to validate document change event rule: projection is invalid: parse error at position 3: unable to parse entire expression"`

## After

✅ Instead, wrap the `projection` with curly braces:

```json
{
  "on": ["publish"],
  "filter": "_type == 'post'",
  "projection": "{_id, type}"
}
```

This explicitly says that you want an object.

## Existing functions

If you have an existing function deployed to Sanity, we've migrated the deployed code to the new syntax. Your function will continue to work as it has without any intervention. 

**Prior to your next deployment**, you will need to update any projections to use the new syntax. In short, wrap your projection in curly braces as shown above and then deploy the changes.

