Actualizar un Webhook
Endpoint
PUT https://api.verifik.co/v2/webhooks/{id}
Método para actualizar un webhook existente. Para que el servicio funcione, se requiere el parámetro _id, que se genera cuando un webhook se crea correctamente.
Encabezados
| Nombre | Valor |
|---|---|
| Content-Type | application/json |
| Authorization | Bearer <token> |
Parámetros de Ruta
id
Tipo: string
Requerido: Sí
El identificador único del webhook a actualizar.
Parámetros de Cuerpo
name
Tipo: string
Requerido: No
El nuevo nombre que quieres que tenga este webhook.
url
Tipo: string
Requerido: No
Puedes actualizar la URL a donde quieres recibir las llamadas POST.
description
Tipo: string
Requerido: No
La nueva descripción que quieres que tenga este webhook.
link
Tipo: array
Requerido: No
Arreglo de projectFlows que quieres vincular a este webhook.
unlink
Tipo: array
Requerido: No
Arreglo de projectFlows que quieres desvincular de este webhook.
Ejemplo de Solicitud
- Node.js
- Python
- PHP
- Go
import axios from 'axios';
const options = {
method: 'PUT',
url: 'https://api.verifik.co/v2/webhooks/66de320d6a5c6ef0e02d4223',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer <your_token>'
},
data: {
url: 'https://sandbox.verifik.co/v2/webhooks/logs',
name: 'Updated webhook name',
description: 'Updated description'
}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
import http.client
import json
conn = http.client.HTTPSConnection("api.verifik.co")
payload = json.dumps({
"url": "https://sandbox.verifik.co/v2/webhooks/logs",
"name": "Updated webhook name",
"description": "Updated description"
})
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer <your_token>'
}
conn.request("PUT", "/v2/webhooks/66de320d6a5c6ef0e02d4223", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
<?php
$client = new \GuzzleHttp\Client();
$response = $client->request('PUT', 'https://api.verifik.co/v2/webhooks/66de320d6a5c6ef0e02d4223', [
'headers' => [
'Content-Type': 'application/json',
'Authorization' => 'Bearer <your_token>',
],
'json' => [
'url' => 'https://sandbox.verifik.co/v2/webhooks/logs',
'name' => 'Updated webhook name',
'description' => 'Updated description'
]
]);
echo $response->getBody();
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
)
func main() {
url := "https://api.verifik.co/v2/webhooks/66de320d6a5c6ef0e02d4223"
payload := map[string]interface{}{
"url": "https://sandbox.verifik.co/v2/webhooks/logs",
"name": "Updated webhook name",
"description": "Updated description",
}
jsonData, _ := json.Marshal(payload)
req, _ := http.NewRequest("PUT", url, bytes.NewBuffer(jsonData))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer <your_token>")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
Ejemplo de Respuesta
- 200 OK
- Error
{
"data": {
"_id": "66de320d6a5c6ef0e02d4223",
"client": "613375a1eab2fe08527f81e2",
"projectFlow": [],
"isActive": true,
"name": "Updated webhook name",
"url": "https://sandbox.verifik.co/v2/webhooks/logs",
"notification": {
"success": false,
"fail": true,
"_id": "66de320d6a5c6ef0e02d4222"
},
"updatedAt": "2024-09-08T23:23:57.678Z",
"createdAt": "2024-09-08T23:23:57.678Z",
"__v": 0
}
}
{
"code": "NotFound",
"message": "Record not found."
}
Características
- Actualizaciones flexibles: Actualiza cualquier campo del webhook de forma independiente
- Gestión de flujos de proyecto: Vincula o desvincula flujos de proyecto de los webhooks
- Actualizaciones parciales: Solo envía los campos que quieres cambiar
- Múltiples lenguajes de programación: Soporte para JavaScript, Python, PHP y Go
- Manejo de errores: Respuestas 404 apropiadas para webhooks no existentes