Skip to main content
POST
/
v1
/
swap-event
Record a swap event
curl --request POST \
  --url https://api.hypermid.io/v1/swap-event \
  --header 'Content-Type: application/json' \
  --header 'X-API-Key: <api-key>' \
  --data '
{
  "status": "pending",
  "provider": "<string>",
  "from_chain": "<string>",
  "from_token": "<string>",
  "to_chain": "<string>",
  "to_token": "<string>",
  "amount_usd": 123,
  "fee_usd": 123,
  "tx_hash": "<string>",
  "wallet_hash": "<string>",
  "from_amount": "<string>",
  "to_amount": "<string>",
  "duration_seconds": 123,
  "error_message": "<string>"
}
'
{
  "data": {
    "eventId": "evt_abc123",
    "received": true
  },
  "error": null,
  "meta": {
    "requestId": "c9f0a1b2-c3d4-5678-2345-789012345678",
    "timestamp": 1711234587,
    "rateLimit": {
      "limit": 2000,
      "remaining": 1971,
      "reset": 1711234627
    }
  }
}
Submits a swap lifecycle event to Hypermid for analytics and tracking purposes. Use this to report when users interact with your swap UI or when swap steps are completed.
event
string
required
The event type. Possible values: quote_requested, quote_received, swap_started, swap_signed, swap_completed, swap_failed, swap_cancelled.
transactionId
string
The transaction ID or quote ID associated with this event.
fromChain
number
Source chain ID.
toChain
number
Destination chain ID.
fromToken
string
Source token address.
toToken
string
Destination token address.
fromAmount
string
Amount being swapped.
txHash
string
Transaction hash (for signed/completed/failed events).
metadata
object
Additional metadata to attach to the event.
{
  "data": {
    "eventId": "evt_abc123",
    "received": true
  },
  "error": null,
  "meta": {
    "requestId": "c9f0a1b2-c3d4-5678-2345-789012345678",
    "timestamp": 1711234587,
    "rateLimit": {
      "limit": 2000,
      "remaining": 1971,
      "reset": 1711234627
    }
  }
}
await client.submitSwapEvent({
  event: "swap_completed",
  transactionId: "txn_abc123",
  fromChain: 1,
  toChain: 42161,
  fromToken: "0x0000000000000000000000000000000000000000",
  toToken: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
  fromAmount: "1000000000000000000",
  txHash: "0xCompletedTxHash",
  metadata: {
    userAgent: "MyDeFiApp/1.0",
    sessionId: "sess_xyz",
  },
});
Submitting swap events improves your analytics in the Partner Dashboard and helps Hypermid optimize route selection for your users.

Authorizations

X-API-Key
string
header
required

Partner API key. Optional for public endpoints, required for /v1/partner/*.

Body

application/json
status
enum<string>
required
Available options:
pending,
completed,
failed
provider
string
from_chain
string
from_token
string
to_chain
string
to_token
string
amount_usd
number
fee_usd
number
tx_hash
string
wallet_hash
string
from_amount
string
to_amount
string
duration_seconds
integer
error_message
string

Response

Event recorded

data
object
required

Response payload (null on error)

error
object
required
meta
object
required