> ## Documentation Index
> Fetch the complete documentation index at: https://docs.isofold.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Query Completion Webhook

> Webhook triggered when a query completes execution.

Isofold can send a webhook to your system after each query completes execution.

This is useful for:

* Tracking per-query savings
* Auditing rewritten queries
* Updating internal cost dashboards

***

## Trigger

The webhook fires after:

* A query is received via `/query`
* It is rewritten (if possible)
* It has finished executing

***

## Payload

```json theme={null}
{
  "query": "SELECT * FROM users",
  "trace_id": "abc123",
  "savings": 0.18,
  "duration_ms": 114
}
```

### Fields

| Field         | Type   | Description                              |
| ------------- | ------ | ---------------------------------------- |
| `query`       | string | The original query submitted             |
| `trace_id`    | string | The unique identifier for this query run |
| `savings`     | number | Estimated USD savings from optimization  |
| `duration_ms` | number | Time taken to execute the query          |

***

## Setup

To enable this webhook:

1. Go to the **Team Settings** in the Isofold Dashboard
2. Add your webhook endpoint URL
3. Optionally include an HMAC signing secret

Webhook retries on failure with exponential backoff.

***

## Security

* Webhooks include an `X-Isofold-Signature` header
* You can verify integrity with your shared secret using HMAC-SHA256

```bash theme={null}
X-Isofold-Signature: t=1699987200,v1=abc123...
```

***

Want to listen for failed or skipped queries too? Contact [support@isofold.com](mailto:support@isofold.com).


## OpenAPI

````yaml WEBHOOK /query/completed
openapi: 3.1.0
info:
  title: Isofold API
  description: >-
    Programmatic interface for sending queries, estimating cost, and verifying
    outputs using Isofold.
  version: 1.0.0
servers:
  - url: https://api.isofold.com
security:
  - bearerAuth: []
paths: {}
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````