Webhooks Setup

Receive real-time notifications when events occur in your Techsolut account. Webhooks allow your application to stay in sync with our platform without constantly polling the API.

Webhook Overview

Webhooks are HTTP callbacks that notify your application when certain events occur in your Techsolut account. Rather than continuously polling for updates, your server is automatically notified when an event happens, making your applications more efficient and responsive.

Real-time

Receive instant notifications as soon as an event occurs, with no delay.

Efficient

Save resources by avoiding unnecessary polling requests to our API.

Flexible

Choose which events you're interested in and where to receive notifications.

Setup Guide

1
Create a webhook endpoint

First, create an HTTP endpoint on your server that will be ready to receive POST requests from Techsolut. This endpoint must be publicly accessible on the Internet.

Python (Flask)
from flask import Flask, request, jsonify
import hmac
import hashlib

app = Flask(__name__)

@app.route('/webhook/techsolut', methods=['POST'])
def techsolut_webhook():
    # Verify the webhook signature (see security section)
    signature = request.headers.get('X-Techsolut-Signature')
    if not verify_signature(request.data, signature, 'your_webhook_secret'):
        return jsonify({"error": "Invalid signature"}), 401
    
    # Process the webhook payload
    payload = request.json
    event_type = payload.get('event')
    
    # Handle different event types
    if event_type == 'model.trained':
        # Handle model training completion
        print(f"Model {payload['data']['model_id']} has been trained")
    elif event_type == 'detection.complete':
        # Handle detection completion
        print(f"Detection completed with {len(payload['data']['detections'])} objects found")
    
    # Return a 200 OK response to acknowledge receipt
    return jsonify({"status": "success"}), 200

def verify_signature(payload, signature, secret):
    # Compute HMAC using your webhook secret
    computed_signature = hmac.new(
        secret.encode(),
        payload,
        hashlib.sha256
    ).hexdigest()
    
    # Compare signatures
    return hmac.compare_digest(computed_signature, signature)

if __name__ == '__main__':
    app.run(debug=True)
2
Register the webhook

Once your endpoint is ready, you need to register it with Techsolut. You can do this via our API or from the dashboard.

curl
curl -X POST https://api.techsolut.fr/v1/webhooks \
     -H "Authorization: Bearer YOUR_API_KEY" \
     -H "Content-Type: application/json" \
     -d '{
       "url": "https://your-app.com/webhook/techsolut",
       "events": ["model.trained", "detection.complete", "classification.complete"],
       "description": "Production webhook for detection and model events"
     }'
Response
{
  "id": "whk_123456789abcdef",
  "url": "https://your-app.com/webhook/techsolut",
  "events": ["model.trained", "detection.complete", "classification.complete"],
  "description": "Production webhook for detection and model events",
  "created_at": "2025-04-21T15:32:10Z",
  "secret": "whsec_abcdefghijklmnopqrstuvwxyz123456"
}

Important: Store the returned secret value securely. It's needed to verify webhook authenticity and will never be shown again.

3
Test the webhook

You can send a test event to verify that your setup is working correctly.

curl
curl -X POST https://api.techsolut.fr/v1/webhooks/whk_123456789abcdef/test \
     -H "Authorization: Bearer YOUR_API_KEY"

This will send a test event to your endpoint. Check your server logs to confirm receipt.

Security

To ensure the webhooks you receive are genuinely from Techsolut and haven't been tampered with in transit, we include a signature with each request. You should verify this signature before processing the webhook.

Signature Validation

Each webhook request includes an X-Techsolut-Signature header which is an HMAC SHA-256 of the request body, signed with your webhook secret.

Python
import hmac
import hashlib

def verify_webhook_signature(payload, signature_header, secret):
    """
    Verify that the webhook request came from Techsolut
    
    Args:
        payload (bytes): Raw request body
        signature_header (str): Value of X-Techsolut-Signature header
        secret (str): Your webhook secret
        
    Returns:
        bool: True if signature is valid
    """
    computed_signature = hmac.new(
        secret.encode('utf-8'),
        payload,
        hashlib.sha256
    ).hexdigest()
    
    # Use constant-time comparison to prevent timing attacks
    return hmac.compare_digest(computed_signature, signature_header)
Example Request
POST /webhook/techsolut HTTP/1.1
Host: your-app.com
X-Techsolut-Signature: 9e0e12f7b7casef8af3b3058c8d24bb698411429ce4c9143db136e2a942b1c39
Content-Type: application/json
Content-Length: 246

{
  "id": "evt_123456789",
  "event": "detection.complete",
  "created_at": "2025-04-21T15:32:10Z",
  "data": {
    "request_id": "req_abcdef123",
    "detections": [
      {"class": "person", "confidence": 0.95, "box": {"x1": 100, "y1": 200, "x2": 300, "y2": 500}}
    ]
  }
}
Security Best Practices
  • Store the secret securely - Don't hardcode it in your application.
  • Use HTTPS - Ensure your webhook endpoint is only accessible via HTTPS.
  • Always validate the signature - Never process a webhook without verifying its signature.
  • Process idempotently - Design your handler to safely deal with duplicate webhook deliveries.
  • Use timeouts - Add a freshness check to reject webhooks that are too old.

Event Types

Here are the different event types available for webhooks. You can subscribe to any combination of these events.

model.trained
Model Training Completed

Triggered when a custom model has completed its training process.

{
  "id": "evt_1234567890",
  "event": "model.trained",
  "created_at": "2025-04-21T15:32:10Z",
  "data": {
    "model_id": "mod_987654321",
    "name": "retail-product-detector",
    "status": "completed",
    "metrics": {
      "map": 0.892,
      "precision": 0.917,
      "recall": 0.885
    },
    "training_time": 3245,
    "project_id": "proj_456789123"
  }
}
detection.complete
Object Detection Completed

Triggered when an asynchronous object detection request is completed.

{
  "id": "evt_2345678901",
  "event": "detection.complete",
  "created_at": "2025-04-21T15:39:22Z",
  "data": {
    "request_id": "req_abcdef123",
    "model": "yolov8x",
    "image_id": "img_12345",
    "processing_time": 1.24,
    "detections": [
      {
        "class": "person",
        "confidence": 0.95,
        "box": {"x1": 100, "y1": 200, "x2": 300, "y2": 500}
      },
      {
        "class": "car",
        "confidence": 0.87,
        "box": {"x1": 450, "y1": 300, "x2": 650, "y2": 420}
      }
    ]
  }
}
classification.complete
Image Classification Completed

Triggered when an asynchronous image classification request is completed.

{
  "id": "evt_3456789012",
  "event": "classification.complete",
  "created_at": "2025-04-21T15:45:31Z",
  "data": {
    "request_id": "req_ghijkl456",
    "model": "resnet101",
    "image_id": "img_67890",
    "processing_time": 0.89,
    "classifications": [
      {
        "label": "golden retriever",
        "confidence": 0.92
      },
      {
        "label": "dog",
        "confidence": 0.88
      },
      {
        "label": "pet",
        "confidence": 0.76
      }
    ]
  }
}
project.updated
Project Updated

Triggered when a project is updated (data added, configuration changed, etc.).

{
  "id": "evt_4567890123",
  "event": "project.updated",
  "created_at": "2025-04-21T16:01:44Z",
  "data": {
    "project_id": "proj_456789123",
    "name": "Retail Product Detection",
    "update_type": "data_added",
    "updated_by": "user_123456",
    "items_added": 47,
    "current_items_count": 1253
  }
}

Managing Webhooks

List Webhooks
curl
curl -X GET https://api.techsolut.fr/v1/webhooks \
     -H "Authorization: Bearer YOUR_API_KEY"
Update a Webhook
curl
curl -X PATCH https://api.techsolut.fr/v1/webhooks/whk_123456789abcdef \
     -H "Authorization: Bearer YOUR_API_KEY" \
     -H "Content-Type: application/json" \
     -d '{
       "events": ["model.trained", "detection.complete", "project.updated"],
       "description": "Updated production webhook"
     }'
Delete a Webhook
curl
curl -X DELETE https://api.techsolut.fr/v1/webhooks/whk_123456789abcdef \
     -H "Authorization: Bearer YOUR_API_KEY"

Troubleshooting

  1. Check that your endpoint is publicly accessible on the Internet.
  2. Make sure your server responds properly with a 200 OK status code.
  3. Check the events you're subscribed to.
  4. Check the event logs in the Techsolut dashboard to see delivery attempts.
  1. Make sure you're using the correct webhook secret.
  2. Verify that you're correctly calculating the HMAC SHA-256.
  3. Make sure you're using the raw request body, not the parsed JSON.
  4. Check the encoding - the body and secret should be in UTF-8.

Webhooks may sometimes be delivered multiple times in case of failures or timeouts. Your webhook handler should be designed to be idempotent - that is, it can be executed multiple times without side effects.

Python
def handle_webhook(payload):
    # Extract event ID
    event_id = payload.get('id')
    
    # Check if we've already processed this event
    if already_processed(event_id):
        print(f"Event {event_id} already processed, skipping")
        return
    
    # Process the event
    process_event(payload)
    
    # Mark as processed
    mark_as_processed(event_id)
    
def already_processed(event_id):
    # Check your database or storage to see if this event has been processed
    # Return True if it has, False otherwise
    ...
    
def mark_as_processed(event_id):
    # Record that this event has been processed in your database or storage
    ...

Support

If you encounter any issues or have questions about webhooks, please don't hesitate to contact our support team.

Assistant IA Techsolut
Historique des conversations

Vous n'avez pas encore de conversations enregistrées.

Analyser une image

Glissez-déposez une image ici
ou cliquez pour choisir un fichier