> For the complete documentation index, see [llms.txt](https://codemash.gitbook.io/codemash/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://codemash.gitbook.io/codemash/api-reference/database/collections/execute-aggregate.md).

# Execute Aggregate

Database.

**Collections** hold your records. Norbix generates a full CRUD + query API over each collection from its schema, with record-level ownership and triggers.

Handles the aggregate.

{% openapi src="/files/LFXChrE9wGFKCxqoL5A1" path="/{version}/database/collections/{collectionName}/aggregates/{aggregateId}/execute" method="post" %}
[norbix-api-swagger.json](https://712692422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHy372bqsaex2cqS3ikhL%2Fuploads%2Fgit-blob-b1d87ac242f296adb274a3238bdeaff152c54b4a%2Fnorbix-api-swagger.json?alt=media)
{% endopenapi %}

## Joined collections and refused stages

The caller needs `database:read` on the start collection **and** on every collection the pipeline joins (`$lookup`, `$graphLookup`, `$unionWith`, nested pipelines, `$facet`). The check runs on the pipeline that really runs, after the tokens are filled in.

| Error                    | When                                                                       |
| ------------------------ | -------------------------------------------------------------------------- |
| `CM-ERRORS-DATABASE-031` | the pipeline has `$out`, `$merge`, `$where`, `$function` or `$accumulator` |
| `CM-ERRORS-DATABASE-032` | a joined name is not a schema in the request's environment                 |
| `CM-ERRORS-DATABASE-033` | the caller cannot read a joined collection                                 |
| `CM-ERRORS-DATABASE-034` | a join into another database, or a joined name that is not a plain string  |

## In Cloud

Manage this visually in Cloud — see [Database](/codemash/cloud/database/collections.md).

## Use it from code

Every Norbix SDK exposes this endpoint as a method — see [Execute Aggregate](/codemash/sdks/database/collections/execute-aggregate.md) in the SDK reference, with examples in every language.
