Crear un Webhook
Endpoint
POST https://api.verifik.co/v2/webhooks
Esta API te permite crear un nuevo webhook dentro de tu cuenta. Puedes asociar un webhook con flujos de proyecto en este paso o cuando actualices el webhook.
Encabezados
| Nombre | Valor |
|---|---|
| Content-Type | application/json |
| Authorization | Bearer <token> |
Parámetros de Cuerpo
url
Tipo: string
Requerido: Sí
La URL donde enviaremos la información vía POST.
name
Tipo: string
Requerido: Sí
El nombre de tu webhook para identificarlo fácilmente.
isActive
Tipo: boolean
Requerido: Sí
Este booleano habilitará/deshabilitará el webhook cuando lo requieras.
description
Tipo: string
Requerido: No
Descripción para saber qué información estarás enviando allí.
link
Tipo: array
Requerido: No
Arreglo de projectFlows a los que quieres vincular este webhook.
Ejemplo de Solicitud
- Node.js
- Python
- PHP
- Go
import axios from 'axios';
const options = {
method: 'POST',
url: 'https://api.verifik.co/v2/webhooks',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer <your_token>'
},
data: {
url: 'https://sandbox.verifik.co/v2/webhooks/logs',
name: 'Postman sample',
isActive: true,
description: 'This is an example',
link: ['66df24f4c80823e06a348019']
}
};
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": "Postman sample",
"isActive": True,
"description": "This is an example",
"link": ["66df24f4c80823e06a348019"]
})
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer <your_token>'
}
conn.request("POST", "/v2/webhooks", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
<?php
$client = new \GuzzleHttp\Client();
$response = $client->request('POST', 'https://api.verifik.co/v2/webhooks', [
'headers' => [
'Content-Type' => 'application/json',
'Authorization' => 'Bearer <your_token>',
],
'json' => [
'url' => 'https://sandbox.verifik.co/v2/webhooks/logs',
'name' => 'Postman sample',
'isActive' => true,
'description' => 'This is an example',
'link' => ['66df24f4c80823e06a348019']
]
]);
echo $response->getBody();
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
)
func main() {
url := "https://api.verifik.co/v2/webhooks"
payload := map[string]interface{}{
"url": "https://sandbox.verifik.co/v2/webhooks/logs",
"name": "Postman sample",
"isActive": true,
"description": "This is an example",
"link": []string{"66df24f4c80823e06a348019"},
}
jsonData, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", 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": {
"client": "613375a1eab2fe08527f81e2",
"projectFlow": [
"66df24f4c80823e06a348019"
],
"isActive": true,
"name": "Postman sample",
"url": "https://sandbox.verifik.co/v2/webhooks/logs",
"notification": {
"success": false,
"fail": true,
"_id": "66df272bf82f3bfab17dea9a"
},
"_id": "66df272bf82f3bfab17dea9b",
"updatedAt": "2024-09-09T16:49:47.373Z",
"createdAt": "2024-09-09T16:49:47.373Z",
"__v": 0
}
}
{
"code": "MissingParameter",
"message": "missing url\n"
}
Características
- Integración con flujos de proyecto: Vincula webhooks a flujos de proyecto específicos
- Configuración flexible: Establece URLs, nombres y descripciones personalizadas
- Múltiples lenguajes de programación: Soporte para JavaScript, Python, PHP y Go
- Manejo de errores: Respuestas de error completas para diversos escenarios