API > Webhooks - Modificar Webhook

Webhooks - Modificar webhook

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

Permite modificar un webhook existente (URL, clave, solo errores, activo o eventos).

Disponible en pruebas y en producción. Usa el mismo entorno en el que se creó el webhook (api-test o api).

PARÁMETROS

url string obligatorio
URL a la que enviar el webhook
https://...
secret string obligatorio
Clave para la firma del webhook para validación del contenido. La firma se realiza mediante HMAC SHA256 y la firma se envía en base64 en el header X-Tbaiws-Hmac-Sha256
xajky22kjasy
solo_errores boolean opcional
Parámetro para enviar el webhook únicamente si se producen errores o si la factura es aceptada con errores o avisos
true
activo boolean opcional
Webhook activado. Permite apagar el webhook temporalmente
true
eventos array opcional
Eventos que se notifican a este webhook (ver eventos). Si no se envía, se conservan los que tenga
["cambio_estado", "spfe_envio"]


Método de cálculo de firma en 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
// Instalación: 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": ""
}
Ejemplo notificación 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":""}

Métodos TicketBAI / Verifactu

Documento representación

Métodos específicos para BATUZ BIZKAIA

SII (AEAT)

Clientes y productos (herramienta de facturación)

Otros métodos