# Report results

> Report the outcome of commands a game server received from a poll, once per command and only from the server that received it.

After running the commands from a [poll](https://docs.bloxlytics.app/api/bridge/poll), the server reports what happened to each one. The person who ran the command sees the output or error in the dashboard straight away, and macros that were waiting on it carry on.

Each command accepts exactly one result, and only from the server it was delivered to. Anything else in the request is ignored, without an error.

## Headers

- `Content-Type` (string, header, required): `application/json`.

- `Authorization` (string, header, required): `Bearer ` followed by the project's bridge key, `bxb_…`.

- `X-Bloxlytics-Project` (string, header, required): The experience's Universe ID (`game.GameId`).

- `X-Bloxlytics-Timestamp` (string, header, required): The current Unix time in seconds, within 120 seconds of Bloxlytics' clock.

- `X-Bloxlytics-Nonce` (string, header, required): A new random value for this request, 16 to 64 characters from `A–Z a–z 0–9 - { }`.

## Body

- `protocol` (number, body, required): Must be `1`.

- `jobId` (string, body, required): The id of the server that ran the commands, up to 64 characters. Must be the `jobId` of the poll that delivered them.

- `results` (Result[], body, required): Up to 50 results. One poll returns at most 10 commands, so one request per poll is enough.  **Result**
  
  - `id` (string, body, required): The command's `id` from the poll, up to 64 characters.
  
  - `ok` (boolean, body, required): `true` if the command ran successfully, `false` if it was refused or failed.
  
  - `output` (string, body): What the command produced, up to 4,000 characters, for example Cmdr's replies and the command's return value. Send it when `ok` is `true`.
  
  - `error` (string, body): Why it failed or was refused, up to 4,000 characters, for example `Rejected by BeforeRun hook: …` or `Command expired before it reached the server.`. Send it when `ok` is `false`; if you leave it out, the error is recorded as `Command failed.`.
  
  - `durationMs` (number, body): How long the command took to run, in milliseconds, `0` or more. Rounded to a whole number.
  
  - `context` (string, body): How a Cmdr command ran: `player` when it ran as the issuer's own player in the server (`executorUserId`), `system` when it ran without a player. Shown with the execution in the command history.

Output and error strings longer than 4,000 characters fail the whole request with `400`. Cut them first, as the Luau bridge does.

## Response

`200 OK`.

- `accepted` (integer, required): How many results were recorded. A result is recorded only when all of these hold:
  
  - the command belongs to this project,
  - it was delivered by a poll from this same `jobId`, within the last 10 minutes,
  - it's still waiting for a result: no result has been recorded yet, and it hasn't been marked as timed out.  Results that don't qualify are skipped silently, so `accepted` can be lower than the number you sent. Nothing is gained by sending them again.

## What happens to a recorded result

- The command's status becomes **success** (`ok: true`) or **error** (`ok: false`), with its output or error, duration and run context, and the time it completed.
- If the command was a moderation action taken through the bridge, such as a kick, the action is marked as **confirmed** by the game server, or as **failed** with your error.
- Everyone watching the project in the dashboard is notified, so the result appears without a refresh.

If no result arrives, the command is marked as timed out (`The game server didn't respond in time.`), at the latest two minutes after it was delivered. A late result is then ignored. The Luau bridge doesn't retry this request.

**Request example**

```bash cURL
curl -X POST https://api.bloxlytics.app/v1/bridge/result \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer bxb_…" \
  -H "X-Bloxlytics-Project: <universe id>" \
  -H "X-Bloxlytics-Timestamp: $(date +%s)" \
  -H "X-Bloxlytics-Nonce: $(uuidgen)" \
  -d '{
    "protocol": 1,
    "jobId": "<job id>",
    "results": [
      { "id": "<execution id>", "ok": true, "output": "Gave 500 coins to <username>", "durationMs": 3, "context": "player" },
      { "id": "<execution id>", "ok": false, "error": "Player is not in this server.", "durationMs": 0 }
    ]
  }'
```

**Response example**

```json 200
{ "accepted": 2 }
```

```json 200 ignored
{ "accepted": 0 }
```

```json 400
{ "error": { "code": "invalid_payload", "message": "results: Too big: expected array to have <=50 items" } }
```

```json 401
{ "error": { "code": "unauthorized", "message": "Invalid project key." } }
```
