---
name: "X-Up-Events"
area: "API"
kind: "HTTP header"
parent: "up.protocol module"
url: "https://unpoly.com/api/X-Up-Events"
---
<nav aria-label="Unpoly docs">[All docs](https://unpoly.com/index.md) · [up.protocol module](https://unpoly.com/api/up.protocol.md)</nav>

# X-Up-Events

The server may set this response header to [emit events](https://unpoly.com/api/up.emit.md) with the requested [fragment update](https://unpoly.com/api/up-follow.md).

The header value is a [relaxed JSON](https://unpoly.com/api/relaxed-json.md) array. Each element in the array is an object representing an event to be emitted on the `document`.

The object property `{ "type" }` defines the event's [type](https://developer.mozilla.org/en-US/docs/Web/API/Event/type). Other properties become properties of the emitted event object.

> #### Important
>
> HTTP headers [may only contain US-ASCII (7-bit) characters](https://www.rfc-editor.org/rfc/rfc7230#section-3.2.4). If you have higher code points in a JSON value, you may [encode those characters using Unicode escape sequences](https://makandracards.com/makandra/536174-http-headers-can-only-transport-us-ascii-characters-safely).

## Example {#example}

```http
Content-Type: text/html
X-Up-Events: [{ type: 'user:created', id: 5012 }, { type: 'signup:completed' }]
...

<html>
  ...
</html>
```

## Emitting an event on a layer {#emitting-an-event-on-a-layer}

Instead of emitting an event on the `document`, the server may also choose to [emit the event on the layer being updated](https://unpoly.com/api/up.layer.emit.md). To do so, add a property `{ layer: 'current' }` to the JSON object of an event:

```http
Content-Type: text/html
X-Up-Events: [{ type: 'user:created', name: 'foobar', layer: 'current' }]
...

<html>
  ...
</html>
```

