API > Webhooks - Update webhook

Webhooks - Update webhook

PUT  https://{entorno}.ticketbaiws.eus/webhooks/{codigo_webhook}/

Updates an existing webhook (URL, secret, errors only, enabled or events).

Available in the test and production environments. Use the same environment the webhook was created in (api-test or api).

PARAMETERS

url string required
URL the webhook is sent to
https://...
secret string required
Secret key used to sign the webhook so its content can be validated. The signature is computed with HMAC SHA256 and sent base64-encoded in the X-Tbaiws-Hmac-Sha256 header
xajky22kjasy
solo_errores boolean optional
Send the webhook only when there are errors or when the invoice is accepted with errors or warnings
true
activo boolean optional
Webhook enabled. Lets you switch the webhook off temporarily
true
eventos array optional
Events notified to this webhook (see events). If not sent, the current ones are kept
["cambio_estado", "spfe_envio"]


How to compute the signature in PHP:
$calculated_hmac = base64_encode(hash_hmac('sha256', $request_body , $secret, true));

PUT https://{entorno}.ticketbaiws.eus/webhooks/{codigo_webhook}/
$ curl --request PUT \
     --url https://api-test.ticketbaiws.eus/webhooks/6904a3501884e/ \
     --header 'Accept: application/json' \
     --header 'Content-Type: application/json' \
     --header 'Token: xxx' \
     --header 'Nif: 00000014Z'
	 --data '
{
    "url": "https://www.berein.com/",
    "secret": "xajky22kjasy",
    "solo_errores" : true,
    "activo": true,
    "eventos": ["cambio_estado", "spfe_envio", "spfe_recibida"]
}'
$ composer require ticketbaiws/ticketbaiws-php
<?php
// Installation: composer require ticketbaiws/ticketbaiws-php
require 'vendor/autoload.php';

$tbai = new \TicketbaiWS\Client('xxx', '00000014Z', ['entorno' => 'test']);

$r = $tbai->modificarWebhook('6904a3501884e', [
    'url'          => 'https://www.berein.com/',
    'secret'       => 'xajky22kjasy',
    'solo_errores' => true,
    'activo'       => true,
    'eventos'      => ['cambio_estado', 'spfe_envio', 'spfe_recibida'],
]);

if ($r->isError()) {
    echo $r->getMessageText();
} else {
    print_r($r->getData());
}
$ python -m pip install requests
import requests

url = "https://api-test.ticketbaiws.eus/webhooks/6904a3501884e/"
payload = {
    "url": "https://www.berein.com/",
    "secret": "xajky22kjasy",
    "solo_errores" : true,
    "activo": true,
    "eventos": ["cambio_estado", "spfe_envio", "spfe_recibida"]
}

headers = {"Accept": "application/json", "Token" : "xxx", "Nif" : "00000014Z"}
response = requests.request("PUT", url, json=payload, headers=headers)

print(response.text)
CURL *hnd = curl_easy_init();

curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "PUT");
curl_easy_setopt(hnd, CURLOPT_URL, "https://api-test.ticketbaiws.eus/webhooks/6904a3501884e/");

struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Accept: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, '{"url": "https://www.berein.com/","secret": "xajky22kjasy","solo_errores" : true,"activo": true,"eventos": ["cambio_estado","spfe_envio","spfe_recibida"]}');

CURLcode ret = curl_easy_perform(hnd);
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, '{"url": "https://www.berein.com/","secret": "xajky22kjasy","solo_errores" : true,"activo": true,"eventos": ["cambio_estado","spfe_envio","spfe_recibida"]}');

Request request = new Request.Builder()
  .url("https://api-test.ticketbaiws.eus/webhooks/6904a3501884e/")
  .put(body)
  .addHeader("Accept", "application/json")
  .addHeader("Token", "xxx")
  .addHeader("Nif", "00000014Z")
  .build();
  
Response response = client.newCall(request).execute();
{ } Response JSON
HTTP/1.1 200 OK
{
    "result": "OK",
    "return": {
        "codigo": "6904a3501874e",
        "url": "https://www.berein.com/",
        "entorno": "test",
        "secret": "xajky22kjasy",
        "solo_errores": true,
        "activo": true,
        "fecha_creado": "2025-10-31T12:53:52+01:00",
        "fecha_modificado": "2025-11-03T10:16:15+01:00",
        "eventos": ["cambio_estado", "spfe_envio", "spfe_recibida"]
    },
    "msg": ""
}
Example notification JSON
Headers:
array (
 'X-Tbaiws-Hmac-Sha256' => 'Hl+X3FT/r5yH3wsgaku46votvTpUPSLPeDNCiCj+syM=',
 'X-Tbaiws-Topic' => 'cambio_estado',
 'X-Tbaiws-Environment' => 'real',
 'X-Tbaiws-Id' => '6904a3501884e',
 'User-Agent' => 'TbaiWS Hook',
 'Content-Type' => 'application/json',
 'Content-Length' => '168',
 'Connection' => 'close'
)

Payload:
{"codigo_webhook":"6904a3501884e","nif":"B123456789","evento":"cambio_estado","serie":"5","numero":"500593135","fecha_emision":"03\/11\/2025","estado":"OK","avisos":""}

TicketBAI / Verifactu methods

Representation document

BATUZ BIZKAIA specific methods

SII (AEAT)

Customers and products (invoicing tool)

Other methods