Webhook Code Examples

To ensure the integrity and authenticity of the webhooks sent from Trust Swiftly, we sign every request sent to your endpoint. By verifying this signature, you can confirm that the webhook was sent by Trust Swiftly and that its payload has not been tampered with during transmission.

The signature is an HMAC-SHA256 hash, generated using your unique webhook signing secret and the raw request body. This signature is passed in the Signature HTTP header with each request.

Below are code examples demonstrating how to properly verify the webhook signature in several common languages and frameworks. It is crucial to use a secure, constant-time comparison method to prevent timing attacks.

  • PHP (Procedural)

  • PHP (Laravel)

  • JavaScript (Express.js)

  • Python (Flask)


Example Payload (verification.completed)

The new webhook format encapsulates the main payload within data and relationships objects. All custom business logic should now access data through these keys.

{
  "id": "4e057b68-0d5f-40ad-b84a-a4d878b738fd",
  "type": "verification.completed",
  "subject": "verification",
  "spec_version": "2025-10-08",
  "occurred_at": "2025-10-08T23:55:09+00:00",
  "resource_id": 1,
  "relationships": {
    "user_id": 172,
    "user_uuid": "0199c63f-a1d4-7400-bc22-8cdfaad82084"
  },
  "data": {
    "verification_id": 1,
    "verification_name": "Email verification",
    "email": "[email protected]",
    "user_status": "Active",
    "order_id": null,
    "ip": "172.19.0.7",
    "ip_country": "US",
    "reference_id": "5122",
    "last_activity": "2025-10-08T23:54:50+00:00",
    "verifications": [
      {
        "id": 1,
        "name": "Email",
        "status": {
          "value": 2,
          "friendly": "Complete"
        },
        "attributes": {
          "email": "[email protected]",
          "paypal_email": "[email protected]",
          "paypal_email_verified": 0
        },
        "start_time": "2025-10-08 23:54:43",
        "completion_time": "2025-10-08 23:55(0 h 0 m 26 s)",
        "completed_at": "2025-10-08 23:55"
      },
      {
        "id": 3,
        "name": "Document / ID",
        "status": {
          "value": 0,
          "friendly": "Assigned"
        },
        "attributes": {
          "verify_documents": [],
          "workflow": "ID + Selfie"
        }
      }
    ]
  }
}

PHP (Procedural) Example


PHP (Laravel) Example


JavaScript (Express.js) Example


Python (Flask) Example

Last updated