Skip to main content
Shell
#!/usr/bin/env bash
set -euo pipefail

# This example assumes that you already have a working and verified
# customer. If not, please follow the `Full flow from Customer Creation to Autoramp`
# example up until the customer id

# User your customer id
customer_id="..."


# This script requires the installation of:
#   - jq (https://stedolan.github.io/jq/)
#   - uuidgen (https://www.gnu.org/software/coreutils/uuidgen)

# Your API Key
API_KEY=''

# The IRON API Base URL. Currently set to sandbox.
BASE_URL="https://api.sandbox.iron.xyz/api"

# Helper to generate idempotency keys (requires uuidgen installation)
gen_key(){ uuidgen || echo "key-$RANDOM"; }

echo "Creating autoramp (EUR → USDC)..."
IDEMPOTENCY_KEY=$(gen_key)
autoramp_resp=$(curl -sSf \
  -X POST "$BASE_URL/autoramps" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $API_KEY" \
  -H "Idempotency-Key: $IDEMPOTENCY_KEY" \
  -d '{
    "customer_id":"'"$customer_id"'",
    "name":"EUR to USDC Ramp",
    "source_is_third_party": true,
    "source_currencies":[{"type":"Fiat","code":"EUR"}],
    "destination_currency":{"type":"Crypto","blockchain":"Solana","token":"USDC"},
    "recipient_account":{"type":"Crypto","chain":"Solana","address":"'"$wallet_address"'"}
  }')
autoramp_id=$(echo "$autoramp_resp" | jq -r '.id')
This only works on sandbox
Shell
echo "Creating a mock 42 EUR transaction for this autoramp"
mock_response=$(curl -sSf -X POST "$BASE_URL/sandbox/transaction" \
     -H "Content-Type: application/json" \
     -H "Idempotency-Key: $IDEMPOTENCY_KEY" \
	   -H "X-API-Key: $API_KEY" \
     -d '{
  "amount": "1111",
  "initial_state": "Completed",
  "autoramp_id": "'"$autoramp_id"'"
}')
echo "$mock_response"
transaction_id=$(echo "$mock_response" | jq -r '.id')
Shell
echo "Listing transactions for autoramp $autoramp_id..."
curl -sSf \
  -X GET "$BASE_URL/autoramp-transactions?autoramp_id=$autoramp_id" \
  -H "X-API-Key: $API_KEY" \
| jq .
On Sandbox, you can change the transaction state to one of:
  • “Pending”
  • “Completed”
  • “Failed”
In order to test the different states
Shell
# You can also update the `initial_state` to test different phases
# This one will set it to failed
curl -sSf -X POST "$BASE_URL/sandbox/transaction/$transaction_id/state" \
     -H "Content-Type: application/json" \
     -H "Idempotency-Key: $IDEMPOTENCY_KEY" \
	   -H "X-API-Key: $API_KEY" \
     -d '{
  "state": "Failed",
}'
#!/usr/bin/env bash
set -euo pipefail

# This example assumes that you already have a working and verified
# customer. If not, please follow the `Full flow from Customer Creation to Autoramp`
# example up until the customer id

# User your customer id
customer_id="..."


# This script requires the installation of:
#   - jq (https://stedolan.github.io/jq/)
#   - uuidgen (https://www.gnu.org/software/coreutils/uuidgen)

# Your API Key
API_KEY=''

# The IRON API Base URL. Currently set to sandbox.
BASE_URL="https://api.sandbox.iron.xyz/api"

# Helper to generate idempotency keys (requires uuidgen installation)
gen_key(){ uuidgen || echo "key-$RANDOM"; }

echo "Creating autoramp (EUR → USDC)..."
IDEMPOTENCY_KEY=$(gen_key)
autoramp_resp=$(curl -sSf \
  -X POST "$BASE_URL/autoramps" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $API_KEY" \
  -H "Idempotency-Key: $IDEMPOTENCY_KEY" \
  -d '{
    "customer_id":"'"$customer_id"'",
    "name":"EUR to USDC Ramp",
    "source_is_third_party": true,
    "source_currencies":[{"type":"Fiat","code":"EUR"}],
    "destination_currency":{"type":"Crypto","blockchain":"Solana","token":"USDC"},
    "recipient_account":{"type":"Crypto","chain":"Solana","address":"'"$wallet_address"'"}
  }')
autoramp_id=$(echo "$autoramp_resp" | jq -r '.id')

echo "Creating a mock 42 EUR transaction for this autoramp"
mock_response=$(curl -sSf -X POST "$BASE_URL/sandbox/transaction" \
     -H "Content-Type: application/json" \
     -H "Idempotency-Key: $IDEMPOTENCY_KEY" \
	   -H "X-API-Key: $API_KEY" \
     -d '{
  "amount": "1111",
  "initial_state": "Completed",
  "autoramp_id": "'"$autoramp_id"'"
}')
echo "$mock_response"
transaction_id=$(echo "$mock_response" | jq -r '.id')

# Print the transaction
echo "Listing transactions for autoramp $autoramp_id..."
curl -sSf \
  -X GET "$BASE_URL/autoramp-transactions?autoramp_id=$autoramp_id" \
  -H "X-API-Key: $API_KEY" \
| jq .

# You can also update the `initial_state` to test different phases
# This one will set it to failed
curl -sSf -X POST "$BASE_URL/sandbox/transaction/$transaction_id/state" \
     -H "Content-Type: application/json" \
     -H "Idempotency-Key: $IDEMPOTENCY_KEY" \
	   -H "X-API-Key: $API_KEY" \
     -d '{
  "state": "Failed",
}'

# Print the transaction again
echo "Listing transactions for autoramp $autoramp_id..."
curl -sSf \
  -X GET "$BASE_URL/autoramp-transactions?autoramp_id=$autoramp_id" \
  -H "X-API-Key: $API_KEY" \
| jq .
{"success":true}