> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.sqril.io/llms.txt.
> For full documentation content, see https://docs.sqril.io/llms-full.txt.

# Webhook Notification - Transaction Failed

POST https://api.sqril.com/webhooks/transactions
Content-Type: application/json

Example webhook notification sent by SQRIL when a transaction is finalized as failed.

**When it is sent:**

- After provider processing marks the transaction failed.
    
- Sent to all active webhook configs whose event filter matches `transaction.failed`.
    

**Payload notes:**

- Required fields: `tx_id`, `status` (`FAILED`).
    
- Optional fields: `error_message`, `sender`, `recipient`, and fee fields (if present).
    
- `error_message` describes why the transaction failed.
    

**Headers:**

- `Content-Type: application/json`
    
- `User-Agent: SQRIL-Webhook/`
    
- `X-SQRIL-Signature` only when a webhook secret is configured.

Reference: https://docs.sqril.io/sqril-saa-s-api/account-webhook-notifications/webhook-notification-transaction-failed

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: collection
  version: 1.0.0
paths:
  /webhooks/transactions:
    post:
      operationId: webhook-notification-transaction-failed
      summary: Webhook Notification - Transaction Failed
      description: >-
        Example webhook notification sent by SQRIL when a transaction is
        finalized as failed.


        **When it is sent:**


        - After provider processing marks the transaction failed.
            
        - Sent to all active webhook configs whose event filter matches
        `transaction.failed`.
            

        **Payload notes:**


        - Required fields: `tx_id`, `status` (`FAILED`).
            
        - Optional fields: `error_message`, `sender`, `recipient`, and fee
        fields (if present).
            
        - `error_message` describes why the transaction failed.
            

        **Headers:**


        - `Content-Type: application/json`
            
        - `User-Agent: SQRIL-Webhook/`
            
        - `X-SQRIL-Signature` only when a webhook secret is configured.
      tags:
        - subpackage_accountWebhookNotifications
      parameters:
        - name: X-SQRIL-Signature
          in: header
          description: >-
            HMAC-SHA256 signature of the webhook payload (base64). Included only
            when webhook secret is configured.
          required: false
          schema:
            type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/Account Webhook Notifications_Webhook
                  Notification - Transaction Failed_Response_200
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                tx_id:
                  type: string
                status:
                  type: string
                error_message:
                  type: string
                sender:
                  $ref: >-
                    #/components/schemas/WebhooksTransactionsPostRequestBodyContentApplicationJsonSchemaSender
                recipient:
                  $ref: >-
                    #/components/schemas/WebhooksTransactionsPostRequestBodyContentApplicationJsonSchemaRecipient
              required:
                - tx_id
                - status
                - error_message
                - sender
                - recipient
servers:
  - url: https://api.sqril.com
  - url: https://your-app.com
components:
  schemas:
    WebhooksTransactionsPostRequestBodyContentApplicationJsonSchemaSender:
      type: object
      properties:
        name_first:
          type: string
        name_last:
          type: string
        country:
          type: string
        ic_number:
          type: string
        ic_type:
          type: string
        phone:
          type: string
        email:
          type: string
          format: email
      required:
        - name_first
        - name_last
        - country
        - ic_number
        - ic_type
        - phone
        - email
      title: WebhooksTransactionsPostRequestBodyContentApplicationJsonSchemaSender
    WebhooksTransactionsPostRequestBodyContentApplicationJsonSchemaRecipient:
      type: object
      properties:
        name_first:
          type: string
        name_last:
          type: string
        country:
          type: string
        account_no:
          type: string
        bank_code:
          type: string
        bank_name:
          type: string
      required:
        - name_first
        - name_last
        - country
        - account_no
        - bank_code
        - bank_name
      title: WebhooksTransactionsPostRequestBodyContentApplicationJsonSchemaRecipient
    Account Webhook Notifications_Webhook Notification - Transaction Failed_Response_200:
      type: object
      properties:
        received:
          type: boolean
        message:
          type: string
      required:
        - received
        - message
      title: >-
        Account Webhook Notifications_Webhook Notification - Transaction
        Failed_Response_200

```

## SDK Code Examples

```python Account Webhook Notifications_Webhook Notification - Transaction Failed_example
import requests

url = "https://api.sqril.com/webhooks/transactions"

payload = {
    "tx_id": "tx_1234567890_abc123",
    "status": "FAILED",
    "error_message": "Transaction failed",
    "sender": {
        "name_first": "John",
        "name_last": "Doe",
        "country": "MY",
        "ic_number": "123456789012",
        "ic_type": "NIC",
        "phone": "+60123456789",
        "email": "john.doe@example.com"
    },
    "recipient": {
        "name_first": "Jane",
        "name_last": "Smith",
        "country": "ID",
        "account_no": "1234567890",
        "bank_code": "014",
        "bank_name": "Bank BCA"
    }
}
headers = {
    "X-SQRIL-Signature": "{{webhook_signature}}",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Account Webhook Notifications_Webhook Notification - Transaction Failed_example
const url = 'https://api.sqril.com/webhooks/transactions';
const options = {
  method: 'POST',
  headers: {
    'X-SQRIL-Signature': '{{webhook_signature}}',
    'Content-Type': 'application/json'
  },
  body: '{"tx_id":"tx_1234567890_abc123","status":"FAILED","error_message":"Transaction failed","sender":{"name_first":"John","name_last":"Doe","country":"MY","ic_number":"123456789012","ic_type":"NIC","phone":"+60123456789","email":"john.doe@example.com"},"recipient":{"name_first":"Jane","name_last":"Smith","country":"ID","account_no":"1234567890","bank_code":"014","bank_name":"Bank BCA"}}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Account Webhook Notifications_Webhook Notification - Transaction Failed_example
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.sqril.com/webhooks/transactions"

	payload := strings.NewReader("{\n  \"tx_id\": \"tx_1234567890_abc123\",\n  \"status\": \"FAILED\",\n  \"error_message\": \"Transaction failed\",\n  \"sender\": {\n    \"name_first\": \"John\",\n    \"name_last\": \"Doe\",\n    \"country\": \"MY\",\n    \"ic_number\": \"123456789012\",\n    \"ic_type\": \"NIC\",\n    \"phone\": \"+60123456789\",\n    \"email\": \"john.doe@example.com\"\n  },\n  \"recipient\": {\n    \"name_first\": \"Jane\",\n    \"name_last\": \"Smith\",\n    \"country\": \"ID\",\n    \"account_no\": \"1234567890\",\n    \"bank_code\": \"014\",\n    \"bank_name\": \"Bank BCA\"\n  }\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("X-SQRIL-Signature", "{{webhook_signature}}")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Account Webhook Notifications_Webhook Notification - Transaction Failed_example
require 'uri'
require 'net/http'

url = URI("https://api.sqril.com/webhooks/transactions")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["X-SQRIL-Signature"] = '{{webhook_signature}}'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"tx_id\": \"tx_1234567890_abc123\",\n  \"status\": \"FAILED\",\n  \"error_message\": \"Transaction failed\",\n  \"sender\": {\n    \"name_first\": \"John\",\n    \"name_last\": \"Doe\",\n    \"country\": \"MY\",\n    \"ic_number\": \"123456789012\",\n    \"ic_type\": \"NIC\",\n    \"phone\": \"+60123456789\",\n    \"email\": \"john.doe@example.com\"\n  },\n  \"recipient\": {\n    \"name_first\": \"Jane\",\n    \"name_last\": \"Smith\",\n    \"country\": \"ID\",\n    \"account_no\": \"1234567890\",\n    \"bank_code\": \"014\",\n    \"bank_name\": \"Bank BCA\"\n  }\n}"

response = http.request(request)
puts response.read_body
```

```java Account Webhook Notifications_Webhook Notification - Transaction Failed_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.sqril.com/webhooks/transactions")
  .header("X-SQRIL-Signature", "{{webhook_signature}}")
  .header("Content-Type", "application/json")
  .body("{\n  \"tx_id\": \"tx_1234567890_abc123\",\n  \"status\": \"FAILED\",\n  \"error_message\": \"Transaction failed\",\n  \"sender\": {\n    \"name_first\": \"John\",\n    \"name_last\": \"Doe\",\n    \"country\": \"MY\",\n    \"ic_number\": \"123456789012\",\n    \"ic_type\": \"NIC\",\n    \"phone\": \"+60123456789\",\n    \"email\": \"john.doe@example.com\"\n  },\n  \"recipient\": {\n    \"name_first\": \"Jane\",\n    \"name_last\": \"Smith\",\n    \"country\": \"ID\",\n    \"account_no\": \"1234567890\",\n    \"bank_code\": \"014\",\n    \"bank_name\": \"Bank BCA\"\n  }\n}")
  .asString();
```

```php Account Webhook Notifications_Webhook Notification - Transaction Failed_example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.sqril.com/webhooks/transactions', [
  'body' => '{
  "tx_id": "tx_1234567890_abc123",
  "status": "FAILED",
  "error_message": "Transaction failed",
  "sender": {
    "name_first": "John",
    "name_last": "Doe",
    "country": "MY",
    "ic_number": "123456789012",
    "ic_type": "NIC",
    "phone": "+60123456789",
    "email": "john.doe@example.com"
  },
  "recipient": {
    "name_first": "Jane",
    "name_last": "Smith",
    "country": "ID",
    "account_no": "1234567890",
    "bank_code": "014",
    "bank_name": "Bank BCA"
  }
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'X-SQRIL-Signature' => '{{webhook_signature}}',
  ],
]);

echo $response->getBody();
```

```csharp Account Webhook Notifications_Webhook Notification - Transaction Failed_example
using RestSharp;

var client = new RestClient("https://api.sqril.com/webhooks/transactions");
var request = new RestRequest(Method.POST);
request.AddHeader("X-SQRIL-Signature", "{{webhook_signature}}");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"tx_id\": \"tx_1234567890_abc123\",\n  \"status\": \"FAILED\",\n  \"error_message\": \"Transaction failed\",\n  \"sender\": {\n    \"name_first\": \"John\",\n    \"name_last\": \"Doe\",\n    \"country\": \"MY\",\n    \"ic_number\": \"123456789012\",\n    \"ic_type\": \"NIC\",\n    \"phone\": \"+60123456789\",\n    \"email\": \"john.doe@example.com\"\n  },\n  \"recipient\": {\n    \"name_first\": \"Jane\",\n    \"name_last\": \"Smith\",\n    \"country\": \"ID\",\n    \"account_no\": \"1234567890\",\n    \"bank_code\": \"014\",\n    \"bank_name\": \"Bank BCA\"\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Account Webhook Notifications_Webhook Notification - Transaction Failed_example
import Foundation

let headers = [
  "X-SQRIL-Signature": "{{webhook_signature}}",
  "Content-Type": "application/json"
]
let parameters = [
  "tx_id": "tx_1234567890_abc123",
  "status": "FAILED",
  "error_message": "Transaction failed",
  "sender": [
    "name_first": "John",
    "name_last": "Doe",
    "country": "MY",
    "ic_number": "123456789012",
    "ic_type": "NIC",
    "phone": "+60123456789",
    "email": "john.doe@example.com"
  ],
  "recipient": [
    "name_first": "Jane",
    "name_last": "Smith",
    "country": "ID",
    "account_no": "1234567890",
    "bank_code": "014",
    "bank_name": "Bank BCA"
  ]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.sqril.com/webhooks/transactions")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```