> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.redpincompany.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.redpincompany.com/_mcp/server.

# Create a webhook

POST https://sandbox.currenciesdirect.com/v1/webhooks
Content-Type: application/json

Subscribe to real-time status updates for customers, virtual accounts, and payments. When you create a webhook, you'll receive JSON notifications at your specified endpoint whenever status changes occur.

Each affiliate can configure only one webhook endpoint. If you register the same event type with a different endpoint, the existing webhook configuration will be updated with the new endpoint details.

**Webhook Payload Mapping:**
- If you subscribe to **CUSTOMER STATUS**, your webhook will receive the payload described in the [`customer_status_updated`](/api-reference/webhooks/customers/webhook-customer-status-updated) event.
- If you subscribe to **VBAN STATUS**, your webhook will receive the payload described in the [`virtual_account_status_updated`](/api-reference/webhooks/virtual-accounts/webhook-virtual-account-status-updated) event.
- If you subscribe to **PAYMENT STATUS**, your webhook will receive the payload described in the [`payment_status_updated`](/api-reference/webhooks/payments/webhook-payment-status-updated) event.
- If you subscribe to **THIRD PARTY CUSTOMER STATUS**, your webhook will receive the payload described in the [`third_party_customer_status_updated`](/api-reference/webhooks/third-party-customers/webhook-third-party-customer-status-updated) event.

For details of the payload structure, refer to the respective webhook event definition linked above.

**Authentication:** [Bearer token required](/api-guide/getting-started/authentication#oauth-20-authentication)      


Reference: https://docs.redpincompany.com/api-reference/customers/api-integration/webhooks/create-webhook

## Authentication

- `Authorization` header (bearer token, required) — OAuth 2.0 Bearer token authentication. This API uses OAuth 2.0 Client Credentials flow. Please refer to the [Authentication](/api-guide/getting-started/authentication#oauth-20-authentication) section for detailed information on how to obtain and use your OAuth credentials.

## Servers

- `https://sandbox.currenciesdirect.com` (Sandbox, default)
- `https://api.redpincompany.com` (Production)

## Request

### Body (application/json)

This endpoint expects a SubscribeWebhookRequest.

- `endpoint` (string, required) — The HTTPS URL where webhook notifications will be sent. Must be a publicly accessible endpoint that can receive POST requests.
- `event_type` (enum, required) — The type of event to subscribe to.
  - Allowed values: `CUSTOMER STATUS`, `VBAN STATUS`, `PAYMENT STATUS`, `THIRD PARTY CUSTOMER STATUS`

## Response

### 200

Webhook created successfully

- `id` (integer, required) — Unique subscription ID for this webhook subscription.

## Errors

### 400 Bad Request Error

Bad request - invalid parameters

- `code` (string, required)
- `description` (string, required) — Human-readable error description
- `type` (enum, optional) — Category or type of the error. - `VALIDATION_ERROR`: Error due to invalid input data or format - `AUTHORIZATION_ERROR`: Error related to insufficient permissions - `SYSTEM_ERROR`: Internal system or server errors - `RESOURCE_ERROR`: Error related to resource availability - `BUSINESS_ERROR`: Error related to business logic violations - `DATA_ERROR`: Error related to data inconsistencies or duplication
  - Allowed values: `VALIDATION_ERROR`, `AUTHORIZATION_ERROR`, `SYSTEM_ERROR`, `RESOURCE_ERROR`, `BUSINESS_ERROR`, `DATA_ERROR`
- `field` (string, optional)
- `details` (map from string to any, optional) — Additional details about the error
- `timestamp` (datetime, optional)

### 401 Unauthorized Error

Unauthorized - invalid authorization header

- `code` (string, required)
- `description` (string, required) — Human-readable error description
- `type` (enum, optional) — Category or type of the error. - `VALIDATION_ERROR`: Error due to invalid input data or format - `AUTHORIZATION_ERROR`: Error related to insufficient permissions - `SYSTEM_ERROR`: Internal system or server errors - `RESOURCE_ERROR`: Error related to resource availability - `BUSINESS_ERROR`: Error related to business logic violations - `DATA_ERROR`: Error related to data inconsistencies or duplication
  - Allowed values: `VALIDATION_ERROR`, `AUTHORIZATION_ERROR`, `SYSTEM_ERROR`, `RESOURCE_ERROR`, `BUSINESS_ERROR`, `DATA_ERROR`
- `field` (string, optional)
- `details` (map from string to any, optional) — Additional details about the error
- `timestamp` (datetime, optional)

## Examples

**Request**

```json
{
  "endpoint": "https://webhooks.merchantapp.com/notify/payment-status",
  "event_type": "PAYMENT STATUS"
}
```

**Response**

```json
{
  "id": 10234
}
```

**SDK Code**

```python
import requests

url = "https://sandbox.currenciesdirect.com/v1/webhooks"

payload = {
    "endpoint": "https://webhooks.merchantapp.com/notify/payment-status",
    "event_type": "PAYMENT STATUS"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript
const url = 'https://sandbox.currenciesdirect.com/v1/webhooks';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"endpoint":"https://webhooks.merchantapp.com/notify/payment-status","event_type":"PAYMENT STATUS"}'
};

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

```go
package main

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

func main() {

	url := "https://sandbox.currenciesdirect.com/v1/webhooks"

	payload := strings.NewReader("{\n  \"endpoint\": \"https://webhooks.merchantapp.com/notify/payment-status\",\n  \"event_type\": \"PAYMENT STATUS\"\n}")

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

	req.Header.Add("Authorization", "Bearer <token>")
	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
require 'uri'
require 'net/http'

url = URI("https://sandbox.currenciesdirect.com/v1/webhooks")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"endpoint\": \"https://webhooks.merchantapp.com/notify/payment-status\",\n  \"event_type\": \"PAYMENT STATUS\"\n}"

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

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://sandbox.currenciesdirect.com/v1/webhooks")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"endpoint\": \"https://webhooks.merchantapp.com/notify/payment-status\",\n  \"event_type\": \"PAYMENT STATUS\"\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://sandbox.currenciesdirect.com/v1/webhooks', [
  'body' => '{
  "endpoint": "https://webhooks.merchantapp.com/notify/payment-status",
  "event_type": "PAYMENT STATUS"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://sandbox.currenciesdirect.com/v1/webhooks");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"endpoint\": \"https://webhooks.merchantapp.com/notify/payment-status\",\n  \"event_type\": \"PAYMENT STATUS\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "endpoint": "https://webhooks.merchantapp.com/notify/payment-status",
  "event_type": "PAYMENT STATUS"
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://sandbox.currenciesdirect.com/v1/webhooks")! 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()
```