# Execution model

When a webhook hits your integration's endpoint, Studio runs your JavaScript with the details of that request available to it. Your code inspects the request and **returns a message object**, which Studio delivers as a push notification.

```
HTTP request ─► your code reads it ─► your code returns a message ─► JustPush delivers it
```

## The incoming request

Your code receives the incoming webhook as a `request` object with these parts:

| Property          | Description                                               |
| ----------------- | --------------------------------------------------------- |
| `request.method`  | The HTTP method — `GET`, `POST`, `PUT`, or `DELETE`.      |
| `request.headers` | The request headers as a key/value object.                |
| `request.body`    | The parsed request body (JSON, when the payload is JSON). |
| `request.query`   | Query-string parameters from the URL, if any.             |

## Returning a message

To send a notification, **return a message object**. At minimum it needs a `title`:

```javascript
return {
    title: "Build passed",
    message: "main is green ✅",
    topic: "CI"
}
```

The full set of fields you can return — priority, sound, images, buttons, and more — is documented in [The message object](/introduction/justpush-studio/writing-code/the-message-object.md) and the [Message schema](/introduction/justpush-studio/reference/message-schema.md).

## Not every request needs a notification

If a request shouldn't produce a notification (for example, a webhook event you don't care about), simply **don't return a message**:

```javascript
if (request.body.event !== "deployment.finished") {
    return // ignore everything else — no push sent
}

return {
    title: "Deployment finished",
    message: request.body.environment
}
```

## Debugging a run

Use `console.log(...)` anywhere in your code. The output is captured per request and shown in the **Console** tab of [Request history](/introduction/justpush-studio/testing-and-monitoring/request-history.md). See [Logging & debugging](/introduction/justpush-studio/writing-code/logging-and-debugging.md).

> **Next:** [The message object](/introduction/justpush-studio/writing-code/the-message-object.md) — every field you can return.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.justpush.io/introduction/justpush-studio/writing-code/execution-model.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
