πŸ””Webhook

The Webhook feature allows you to receive real-time HTTP POST notifications whenever trading events occur on your MetaCopier accounts. This enables you to build custom integrations, dashboards, alerting systems, or automated workflows.

Overview

When enabled, MetaCopier sends a JSON payload to your HTTPS endpoint whenever one of the subscribed events fires. You can configure authentication, delivery behavior, and payload content.

Supported Events

Event
Event type string
Description

POSITION_OPENED

position.opened

A new position was opened on the account

POSITION_CLOSED

position.closed

A position was closed on the account

HISTORY_UPDATED

history.updated

The trade history was updated

Setup

Account Level

  1. Navigate to your Account β†’ Features

  2. Click the + button and select Webhook

  3. Configure the webhook settings and save

Project Level

  1. Navigate to your Project β†’ Webhooks panel in the sidebar

  2. Fill in the configuration form and save

circle-info

At the project level, the webhook applies to all accounts in that project. Only one webhook can be configured per project.

Configuration

General

Setting
Description

Enable webhook

Toggle delivery on/off without losing the configuration

Endpoint URL

Your HTTPS endpoint (must start with https://)

Description

Optional label for your reference

Authentication

Method
Description

None

No authentication header is sent

HMAC-SHA256

A signature is computed over the payload and sent in the X-Webhook-Signature header

Bearer Token

Your token is sent as Authorization: Bearer <token>

HMAC-SHA256 Details

When HMAC-SHA256 is selected:

  • The signature is computed as HMAC-SHA256(secret, payload_body) and sent hex-encoded in the X-MetaCopier-Signature header.

  • If Include timestamp in signature is enabled, a X-MetaCopier-Timestamp header is sent (value in milliseconds) and the signature is computed over timestamp.payload_body for replay protection.

  • The secret must be at least 32 characters. You can use the Generate button to create a cryptographically secure key.

Delivery Configuration

Setting
Description
Range
Default

Max retries

Number of retry attempts on failure

0–5

3

Retry delay (ms)

Initial delay between retries (exponential backoff: delay Γ— 2^attempt)

500–30000

2000

Timeout (sec)

HTTP request timeout

5–60

30

Rate limit/min

Maximum deliveries per minute (0 = unlimited)

0–1000

60

Payload Options

Option
Description
Default

Include position details

Include symbol, volume, prices, profit in the payload

true

Include account metadata

Include broker name and login number

false

Custom Headers

You can add up to 10 custom HTTP headers that will be included with every webhook request. This is useful for routing, API keys in downstream systems, or correlation IDs.

circle-exclamation

Payload Format

All webhook payloads are sent as Content-Type: application/json with a POST request. Fields with null values are excluded from the JSON.

Example: Position Opened

Example: Position Closed

Example: History Updated

circle-info

When Include position details is disabled, the position field is omitted entirely.

When Include account metadata is disabled, the accountMetadata field is omitted.

Position Fields Reference

Field
Type
Description

id

string

Position ticket ID

symbol

string

Trading symbol (e.g. EURUSD)

orderType

string

Buy, Sell, BuyLimit, SellLimit, etc.

volume

number

Lot size

openPrice

number

Entry price

closePrice

number

Exit price (only on close events)

stopLoss

number

Stop loss price

takeProfit

number

Take profit price

openTime

string

ISO 8601 open timestamp

closeTime

string

ISO 8601 close timestamp (only on close events)

profit

number

Gross profit

netProfit

number

Profit after swap and commission

swap

number

Swap/rollover charges

commission

number

Trading commission

comment

string

Position comment

magicNumber

string

Magic number identifier

Headers Sent

Every webhook request includes these headers:

Header
Description

Content-Type

Always application/json

X-MetaCopier-Delivery-Attempt

The delivery attempt number (starts at 1)

X-MetaCopier-Timestamp

Unix timestamp in milliseconds (when HMAC with timestamp is enabled)

X-MetaCopier-Signature

HMAC-SHA256 hex signature (when HMAC auth is configured)

Authorization

Bearer <token> (when Bearer Token auth is configured)

Custom headers

Any custom headers you configured

Client-Side Implementation

Below are examples showing how to receive and verify webhook requests on your server.


C#


Java


TypeScript


Python


Go


Best Practices

  1. Always verify signatures - Never trust incoming webhooks without validating the HMAC signature.

  2. Check timestamp freshness - Reject requests with timestamps older than 5 minutes to prevent replay attacks.

  3. Respond quickly - Return a 200 OK as soon as possible. Process the event asynchronously if your logic is slow.

  4. Handle retries idempotently - The same event may be delivered multiple times. Use the position id and timestamp to deduplicate.

  5. Use HTTPS - MetaCopier only delivers webhooks to https:// endpoints.

  6. Monitor failures - If your endpoint returns errors consistently, check your server logs and ensure the endpoint is accessible.

Troubleshooting

Issue
Solution

Not receiving webhooks

Ensure the webhook is enabled and your endpoint returns 200

Signature verification fails

Check that your secret matches exactly and you're using UTF-8 encoding

Stale timestamp errors

Ensure your server clock is synchronized (NTP)

Rate limited

Increase the Rate limit/min setting or optimize your endpoint speed

Last updated