> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://infonite.dev/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://infonite.dev/_mcp/server.

# Create or Update Webhooks

PATCH https://widgets.infonite.tech/api/flows/es-public-administration/v1/hooks/update
Content-Type: application/json

Create or update a webhook configuration for the Spain Public Administration flow.

Supported events:
- `es-public-administration:started`: Triggered when the customer starts the widget session.
- `es-public-administration:consent`: Triggered when the customer accepts and signs the consent form.
- `es-public-administration:partial`: Triggered when the customer is done and the widget closes while a source is still working in the background. Carries the data retrieved **so far** — same schema as `ended`, but **partial**. Delivered at most once per session, and the session stays open.
- `es-public-administration:ended`: Triggered when the flow session is completed and the results are **final**.

<Note title="Partial first, final always">
  If you subscribe to `es-public-administration:partial`, you may receive the same session twice: once with partial data when the customer leaves, and once with the complete data when the slow source answers. `ended` is the one that closes the session — it always fires, and it always carries the final version of the data.
</Note>

> **Console Dashboard:** Webhooks can also be configured manually via the **Infonite Console** (the customer dashboard) at https://www.infonite.tech/console/. These endpoints are provided for programmatic webhook management.

<llms-only>
Field-name and batch semantics (read carefully, this is a common LLM mistake):

- This endpoint takes **`events`** (plural), an **array** of event types. It does **not** take `event` (singular). The singular `event` field only ever appears in the response of the list endpoint (`GET /hooks/list`), where each stored webhook maps to exactly one event.
- `events` is a **convenience batch**: the operation is applied **once per event in the array**. Internally it creates/updates **one webhook per event**, because webhooks are stored one document per subscribed event.
- Correct shape: `{"events": ["es-public-administration:started", "es-public-administration:ended"], "enabled": true, "base_url": "https://example.com/my/hook"}`.
</llms-only>


Reference: https://infonite.dev/api-reference/spain-public-administration/spain-public-administration-api/webhooks-settings/flows-es-public-administration-v-1-hook-update

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: es-public-administration-v1-0-0-openapi
  version: 1.0.0
paths:
  /es-public-administration/v1/hooks/update:
    patch:
      operationId: flows:es-public-administration:v1:hook-update
      summary: Create or Update Webhooks
      description: >
        Create or update a webhook configuration for the Spain Public
        Administration flow.


        Supported events:

        - `es-public-administration:started`: Triggered when the customer starts
        the widget session.

        - `es-public-administration:consent`: Triggered when the customer
        accepts and signs the consent form.

        - `es-public-administration:partial`: Triggered when the customer is
        done and the widget closes while a source is still working in the
        background. Carries the data retrieved **so far** — same schema as
        `ended`, but **partial**. Delivered at most once per session, and the
        session stays open.

        - `es-public-administration:ended`: Triggered when the flow session is
        completed and the results are **final**.


        <Note title="Partial first, final always">
          If you subscribe to `es-public-administration:partial`, you may receive the same session twice: once with partial data when the customer leaves, and once with the complete data when the slow source answers. `ended` is the one that closes the session — it always fires, and it always carries the final version of the data.
        </Note>


        > **Console Dashboard:** Webhooks can also be configured manually via
        the **Infonite Console** (the customer dashboard) at
        https://www.infonite.tech/console/. These endpoints are provided for
        programmatic webhook management.


        <llms-only>

        Field-name and batch semantics (read carefully, this is a common LLM
        mistake):


        - This endpoint takes **`events`** (plural), an **array** of event
        types. It does **not** take `event` (singular). The singular `event`
        field only ever appears in the response of the list endpoint (`GET
        /hooks/list`), where each stored webhook maps to exactly one event.

        - `events` is a **convenience batch**: the operation is applied **once
        per event in the array**. Internally it creates/updates **one webhook
        per event**, because webhooks are stored one document per subscribed
        event.

        - Correct shape: `{"events": ["es-public-administration:started",
        "es-public-administration:ended"], "enabled": true, "base_url":
        "https://example.com/my/hook"}`.

        </llms-only>
      tags:
        - webhooksSettings
      parameters:
        - name: X-APP-SECRET
          in: header
          description: Application Secret
          required: true
          schema:
            type: string
      responses:
        '204':
          description: '**204 No Content**<br>Webhooks configurations updated successfully.'
          content:
            application/json:
              schema:
                type: object
                properties: {}
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Update'
servers:
  - url: https://widgets.infonite.tech/api/flows
    description: Production Server
  - url: https://widgets-dev.infonite.tech/api/flows
    description: Development Server
  - url: /api/flows
    description: Local Server
components:
  schemas:
    EsPublicAdministrationV1FlowEventType:
      type: string
      enum:
        - es-public-administration:started
        - es-public-administration:consent
        - es-public-administration:partial
        - es-public-administration:ended
      description: >-
        Events raised during the Spain public administration experience.


        - `es-public-administration:started`: the user has opened the
        experience.

        - `es-public-administration:consent`: the user has granted consent to
        the experience.

        - `es-public-administration:partial`: the user is done, and the
        experience has closed, but one
          or more sources are still working. Some administrations do not answer in real time — the
          CIRBE report from the Banco de España is the usual case — so the session keeps running in the
          background instead of holding the user in front of a spinner. This event carries **everything
          retrieved so far**: the same payload as `ended`, only partial. The complete results arrive
          later, with `ended`.
        - `es-public-administration:ended`: the experience has ended and the
        results are final.
      title: EsPublicAdministrationV1FlowEventType
    Update:
      type: object
      properties:
        events:
          type: array
          items:
            $ref: '#/components/schemas/EsPublicAdministrationV1FlowEventType'
          description: >-
            The specific flow events type to register or update the webhook
            callback for.
        enabled:
          type: boolean
          default: false
          description: >-
            Set to true to activate the webhook callback, or false to keep it
            inactive.
        base_url:
          type: string
          description: >-
            The target URL where the webhook callbacks should be sent.

            > Note: Any query parameters in the URL will be stripped; dynamic
            query parameters should be defined in the flow session
            configuration.
      required:
        - events
        - base_url
      title: Update
    ValidationErrorLocItems:
      oneOf:
        - type: string
        - type: integer
      title: ValidationErrorLocItems
    ValidationErrorCtx:
      type: object
      properties: {}
      title: ValidationErrorCtx
    ValidationError:
      type: object
      properties:
        loc:
          type: array
          items:
            $ref: '#/components/schemas/ValidationErrorLocItems'
        msg:
          type: string
        type:
          type: string
        input:
          description: Any type
        ctx:
          $ref: '#/components/schemas/ValidationErrorCtx'
      required:
        - loc
        - msg
        - type
      title: ValidationError
    HTTPValidationError:
      type: object
      properties:
        detail:
          type: array
          items:
            $ref: '#/components/schemas/ValidationError'
      title: HTTPValidationError
  securitySchemes:
    Application-Secret:
      type: apiKey
      in: header
      name: X-APP-SECRET
      description: Application Secret

```

## Examples

### Subscribe to all events



**Request**

```json
{
  "events": [
    "es-public-administration:started",
    "es-public-administration:consent",
    "es-public-administration:partial",
    "es-public-administration:ended"
  ],
  "base_url": "https://client.example.com/webhooks/spain-public-administration",
  "enabled": true
}
```

**SDK Code**

```python Subscribe to all events
import requests

url = "https://widgets.infonite.tech/api/flows/es-public-administration/v1/hooks/update"

payload = {
    "events": ["es-public-administration:started", "es-public-administration:consent", "es-public-administration:partial", "es-public-administration:ended"],
    "base_url": "https://client.example.com/webhooks/spain-public-administration",
    "enabled": True
}
headers = {
    "X-APP-SECRET": "<apiKey>",
    "Content-Type": "application/json"
}

response = requests.patch(url, json=payload, headers=headers)

print(response.json())
```

```javascript Subscribe to all events
const url = 'https://widgets.infonite.tech/api/flows/es-public-administration/v1/hooks/update';
const options = {
  method: 'PATCH',
  headers: {'X-APP-SECRET': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"events":["es-public-administration:started","es-public-administration:consent","es-public-administration:partial","es-public-administration:ended"],"base_url":"https://client.example.com/webhooks/spain-public-administration","enabled":true}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Subscribe to all events
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://widgets.infonite.tech/api/flows/es-public-administration/v1/hooks/update"

	payload := strings.NewReader("{\n  \"events\": [\n    \"es-public-administration:started\",\n    \"es-public-administration:consent\",\n    \"es-public-administration:partial\",\n    \"es-public-administration:ended\"\n  ],\n  \"base_url\": \"https://client.example.com/webhooks/spain-public-administration\",\n  \"enabled\": true\n}")

	req, _ := http.NewRequest("PATCH", url, payload)

	req.Header.Add("X-APP-SECRET", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Subscribe to all events
require 'uri'
require 'net/http'

url = URI("https://widgets.infonite.tech/api/flows/es-public-administration/v1/hooks/update")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Patch.new(url)
request["X-APP-SECRET"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"events\": [\n    \"es-public-administration:started\",\n    \"es-public-administration:consent\",\n    \"es-public-administration:partial\",\n    \"es-public-administration:ended\"\n  ],\n  \"base_url\": \"https://client.example.com/webhooks/spain-public-administration\",\n  \"enabled\": true\n}"

response = http.request(request)
puts response.read_body
```

```java Subscribe to all events
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.patch("https://widgets.infonite.tech/api/flows/es-public-administration/v1/hooks/update")
  .header("X-APP-SECRET", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"events\": [\n    \"es-public-administration:started\",\n    \"es-public-administration:consent\",\n    \"es-public-administration:partial\",\n    \"es-public-administration:ended\"\n  ],\n  \"base_url\": \"https://client.example.com/webhooks/spain-public-administration\",\n  \"enabled\": true\n}")
  .asString();
```

```php Subscribe to all events
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://widgets.infonite.tech/api/flows/es-public-administration/v1/hooks/update', [
  'body' => '{
  "events": [
    "es-public-administration:started",
    "es-public-administration:consent",
    "es-public-administration:partial",
    "es-public-administration:ended"
  ],
  "base_url": "https://client.example.com/webhooks/spain-public-administration",
  "enabled": true
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'X-APP-SECRET' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp Subscribe to all events
using RestSharp;

var client = new RestClient("https://widgets.infonite.tech/api/flows/es-public-administration/v1/hooks/update");
var request = new RestRequest(Method.PATCH);
request.AddHeader("X-APP-SECRET", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"events\": [\n    \"es-public-administration:started\",\n    \"es-public-administration:consent\",\n    \"es-public-administration:partial\",\n    \"es-public-administration:ended\"\n  ],\n  \"base_url\": \"https://client.example.com/webhooks/spain-public-administration\",\n  \"enabled\": true\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Subscribe to all events
import Foundation

let headers = [
  "X-APP-SECRET": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "events": ["es-public-administration:started", "es-public-administration:consent", "es-public-administration:partial", "es-public-administration:ended"],
  "base_url": "https://client.example.com/webhooks/spain-public-administration",
  "enabled": true
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://widgets.infonite.tech/api/flows/es-public-administration/v1/hooks/update")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PATCH"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Subscribe to two events



**Request**

```json
{
  "events": [
    "es-public-administration:consent",
    "es-public-administration:ended"
  ],
  "base_url": "https://client.example.com/webhooks/spain-public-administration",
  "enabled": true
}
```

**SDK Code**

```python Subscribe to two events
import requests

url = "https://widgets.infonite.tech/api/flows/es-public-administration/v1/hooks/update"

payload = {
    "events": ["es-public-administration:consent", "es-public-administration:ended"],
    "base_url": "https://client.example.com/webhooks/spain-public-administration",
    "enabled": True
}
headers = {
    "X-APP-SECRET": "<apiKey>",
    "Content-Type": "application/json"
}

response = requests.patch(url, json=payload, headers=headers)

print(response.json())
```

```javascript Subscribe to two events
const url = 'https://widgets.infonite.tech/api/flows/es-public-administration/v1/hooks/update';
const options = {
  method: 'PATCH',
  headers: {'X-APP-SECRET': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"events":["es-public-administration:consent","es-public-administration:ended"],"base_url":"https://client.example.com/webhooks/spain-public-administration","enabled":true}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Subscribe to two events
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://widgets.infonite.tech/api/flows/es-public-administration/v1/hooks/update"

	payload := strings.NewReader("{\n  \"events\": [\n    \"es-public-administration:consent\",\n    \"es-public-administration:ended\"\n  ],\n  \"base_url\": \"https://client.example.com/webhooks/spain-public-administration\",\n  \"enabled\": true\n}")

	req, _ := http.NewRequest("PATCH", url, payload)

	req.Header.Add("X-APP-SECRET", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Subscribe to two events
require 'uri'
require 'net/http'

url = URI("https://widgets.infonite.tech/api/flows/es-public-administration/v1/hooks/update")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Patch.new(url)
request["X-APP-SECRET"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"events\": [\n    \"es-public-administration:consent\",\n    \"es-public-administration:ended\"\n  ],\n  \"base_url\": \"https://client.example.com/webhooks/spain-public-administration\",\n  \"enabled\": true\n}"

response = http.request(request)
puts response.read_body
```

```java Subscribe to two events
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.patch("https://widgets.infonite.tech/api/flows/es-public-administration/v1/hooks/update")
  .header("X-APP-SECRET", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"events\": [\n    \"es-public-administration:consent\",\n    \"es-public-administration:ended\"\n  ],\n  \"base_url\": \"https://client.example.com/webhooks/spain-public-administration\",\n  \"enabled\": true\n}")
  .asString();
```

```php Subscribe to two events
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://widgets.infonite.tech/api/flows/es-public-administration/v1/hooks/update', [
  'body' => '{
  "events": [
    "es-public-administration:consent",
    "es-public-administration:ended"
  ],
  "base_url": "https://client.example.com/webhooks/spain-public-administration",
  "enabled": true
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'X-APP-SECRET' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp Subscribe to two events
using RestSharp;

var client = new RestClient("https://widgets.infonite.tech/api/flows/es-public-administration/v1/hooks/update");
var request = new RestRequest(Method.PATCH);
request.AddHeader("X-APP-SECRET", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"events\": [\n    \"es-public-administration:consent\",\n    \"es-public-administration:ended\"\n  ],\n  \"base_url\": \"https://client.example.com/webhooks/spain-public-administration\",\n  \"enabled\": true\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Subscribe to two events
import Foundation

let headers = [
  "X-APP-SECRET": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "events": ["es-public-administration:consent", "es-public-administration:ended"],
  "base_url": "https://client.example.com/webhooks/spain-public-administration",
  "enabled": true
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://widgets.infonite.tech/api/flows/es-public-administration/v1/hooks/update")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PATCH"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```