---
title: "Emit a data_event to the Rules Engine"
method: POST
path: "/api/data-access/emit"
tags: ["DataAccess"]
---

# Emit a data_event to the Rules Engine

`POST /api/data-access/emit`

## Request

- Base URL: `https://api.agentstack.tech` (the document declares no server; this is the origin it was published from)
- URL: `https://api.agentstack.tech/api/data-access/emit`
- Auth: one of:
  - API key in header `X-API-Key`
  - HTTP bearer

Fire a data_event trigger in the Rules Engine for the given resource + action.

Philosophy: Creation over Conflict — instead of hardcoding side-effects in
endpoint handlers, endpoints call this to let the Rules Engine react
declaratively (webhook, notify, masking, etc.).

Valid actions: `created`, `updated`, `deleted`, `read`.

Example use in an order-creation handler::

    await emit_data_event_internal(
        resource="orders",
        action="created",
        event_data=new_order,
        project_id=project_id,
        user_id=user_id,
    )

## Query parameters

- `project_id` integer, required: Project ID

## Headers

- `Idempotency-Key` string

## Request body

- EmitDataEventBody: Body for POST /emit
  - `resource` string, required: Resource name (e.g., 'orders')
  - `action` string, required: 'created' | 'updated' | 'deleted' | 'read'
  - `event_data` object: Payload to pass to triggered rules

## Response `200`

Rules Engine execution result

- unknown

## Other responses

- `400`: Bad Request
- `401`: Not authenticated
- `403`: Insufficient project access (read / admin / owner)
- `404`: Not Found
- `409`: Conflict
- `422`: Validation Error
- `429`: Too Many Requests
- `500`: Internal Server Error

---

[API](https://skmtc.dev/agentstack/apis/agentstack-core-api.md) · [All operations](https://skmtc.dev/agentstack/apis/agentstack-core-api/llms.txt) · [OpenAPI document](https://skmtc.dev/agentstack/apis/agentstack-core-api/revisions/8ecf3406e74a?raw)
