Skip to main content

Prerequisites

  • Payward Services API credentials (see the Authentication guide).
  • A verified user with at least one account and sufficient balance in the source asset.
  • Examples target https://api.services.payward.com and read credentials from the PWS_API_KEY and PWS_API_SECRET environment variables.

Workflow

1

Create a price trigger swap

Submit the swap with its trigger condition.POST /v1/accounts/{account_id}/price-trigger-swaps
2

Monitor or cancel

Track status, list active swaps, or cancel one that hasn’t fired yet.
  • GET /v1/accounts/{account_id}/price-trigger-swaps
  • GET /v1/accounts/{account_id}/price-trigger-swaps/{price_trigger_swap_id}
  • POST /v1/accounts/{account_id}/price-trigger-swaps/{price_trigger_swap_id}/cancel

Trigger conditions

The when block specifies the price to monitor and the threshold that fires the trade. Set the base and quote AssetRef pair, then exactly one of drops_to or rises_to: The threshold is a base/quote rate as a decimal string. For example, with base.symbol = BTC and quote.symbol = USD, drops_to: "50000.00" means “fire when 1 BTC trades at 50,000 USD or below”. Examples:
  • Buy the Dip: “Buy BTC when BTC/USD drops to 50,000” — set base.symbol to BTC, quote.symbol to USD, and drops_to to "50000.00". Pair with a trade whose from is USD and to is BTC.
  • Stop the Loss: “Sell BTC when BTC/USD drops to 50,000” — same when block, but with trade.from set to BTC and trade.to set to USD.
  • Join the Rally: “Buy BTC when BTC/USD rises to 80,000” — same pair, replace drops_to with rises_to: "80000.00". Trade goes USD → BTC.
  • Take the Profit: “Sell BTC when BTC/USD rises to 80,000” — same when block as Join the Rally, but with trade.from set to BTC and trade.to set to USD.

Execution behavior

Price trigger swaps are not guaranteed to execute at exactly the threshold price. The threshold is a trigger, not a limit price. The execution price can move beyond the threshold, but only ever in the direction that fired the trigger — it never crosses back to the other side of the threshold:
  • Buy the Dip / Stop the Loss (drops_to): The swap triggers when the market price drops to or below drops_to. The execution price may be lower than the threshold, but never higher.
  • Join the Rally / Take the Profit (rises_to): The swap triggers when the market price rises to or above rises_to. The execution price may be higher than the threshold, but never lower.
For swaps where the execution price is higher than the market price and the user is spending the client’s reserve fiat currency, an error will be returned at creation. Because the execution price may be higher than the threshold, the final spend amount is unbounded upward — this prevents a situation where a user creates a swap that could spend more fiat than the client has approved.

Authentication setup

Authenticated endpoints require an HMAC-SHA512 request signature in the API-Sign header and a monotonically increasing nonce in the API-Nonce header. The helper below derives the signature from the URL path, request body, and nonce. See the Authentication guide for the full algorithm.

Step 1: create a price trigger swap

Submit the swap with trade, when, and an optional external_reference. The external_reference is a free-form string for client-side correlation — it’s echoed back on reads and webhook events but is not interpreted by Payward. The response returns only the new swap’s id; fetch GET /v1/accounts/{account_id}/price-trigger-swaps/{price_trigger_swap_id} to read the full resource. Set the amount on exactly one of trade.from or trade.to to indicate which side of the trade is fixed. Setting both or neither returns 400 Bad Request.

Response example

The response also carries a Location header pointing at the new resource (e.g. /v1/accounts/NL00KRAK0123456789/price-trigger-swaps/swap_01J0M7C0Z9F8YX3GQH8E).

Step 2: monitor swaps

Get a single swap

Response example

When status is completed, the response also includes trade.fees and trade.rate reflecting what was realised at execution time.

List swaps

Filter by status using the statuses query parameter (repeat for multiple values, or omit to include any status). Use page_token and page_size (default 20, max 100) for pagination — next_page_token is omitted on the final page.

Swap statuses

A cancelled swap is always user-initiated and carries no extra reason. When status is failed, the response includes a failure_reason field explaining why it was terminated. The value is one of:

Step 3: cancel a swap

Cancel an active swap that hasn’t triggered yet. The body is empty. Swaps in completed, cancelled, or failed status are terminal and return 409 Conflict with code: price_trigger_swap_not_cancellable.

Webhook events

Portfolio transactions

Executed price trigger swaps appear in the List Portfolio Transactions endpoint. Filter by transaction type:

API reference