curl --request POST \
--url https://perp-api.phoenix.trade/v1/ix/swap \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"assetIn": "sol",
"assetOut": "sol",
"authority": "string"
}
'import requests
url = "https://perp-api.phoenix.trade/v1/ix/swap"
payload = {
"assetIn": "sol",
"assetOut": "sol",
"authority": "string"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({assetIn: 'sol', assetOut: 'sol', authority: 'string'})
};
fetch('https://perp-api.phoenix.trade/v1/ix/swap', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://perp-api.phoenix.trade/v1/ix/swap",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'assetIn' => 'sol',
'assetOut' => 'sol',
'authority' => 'string'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://perp-api.phoenix.trade/v1/ix/swap"
payload := strings.NewReader("{\n \"assetIn\": \"sol\",\n \"assetOut\": \"sol\",\n \"authority\": \"string\"\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(string(body))
}HttpResponse<String> response = Unirest.post("https://perp-api.phoenix.trade/v1/ix/swap")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"assetIn\": \"sol\",\n \"assetOut\": \"sol\",\n \"authority\": \"string\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://perp-api.phoenix.trade/v1/ix/swap")
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 \"assetIn\": \"sol\",\n \"assetOut\": \"sol\",\n \"authority\": \"string\"\n}"
response = http.request(request)
puts response.read_body{
"addressLookupTableAddresses": [
"<string>"
],
"amountInAtoms": 1,
"blockhash": "<string>",
"computeUnitLimit": 1,
"contextSlot": 1,
"expectedAmountOutAtoms": 1,
"instructions": [
{
"data": [
1
],
"keys": [
{
"isSigner": true,
"isWritable": true,
"pubkey": "<string>"
}
],
"programId": "<string>"
}
],
"lastValidBlockHeight": 1,
"minAmountOutAtoms": 1,
"priceImpactBps": 1,
"swapNativeAmountInAtoms": 1,
"transaction": "<string>",
"transactionVersion": 1,
"venue": "<string>",
"attestationExpiresAt": 123,
"sponsorshipAttestation": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}Build spot collateral swap transaction
Builds an unsigned swap transaction for a trader account. User callers must authenticate as the wallet named by authority; service accounts with the route scope may build for any authority.
curl --request POST \
--url https://perp-api.phoenix.trade/v1/ix/swap \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"assetIn": "sol",
"assetOut": "sol",
"authority": "string"
}
'import requests
url = "https://perp-api.phoenix.trade/v1/ix/swap"
payload = {
"assetIn": "sol",
"assetOut": "sol",
"authority": "string"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({assetIn: 'sol', assetOut: 'sol', authority: 'string'})
};
fetch('https://perp-api.phoenix.trade/v1/ix/swap', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://perp-api.phoenix.trade/v1/ix/swap",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'assetIn' => 'sol',
'assetOut' => 'sol',
'authority' => 'string'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://perp-api.phoenix.trade/v1/ix/swap"
payload := strings.NewReader("{\n \"assetIn\": \"sol\",\n \"assetOut\": \"sol\",\n \"authority\": \"string\"\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(string(body))
}HttpResponse<String> response = Unirest.post("https://perp-api.phoenix.trade/v1/ix/swap")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"assetIn\": \"sol\",\n \"assetOut\": \"sol\",\n \"authority\": \"string\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://perp-api.phoenix.trade/v1/ix/swap")
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 \"assetIn\": \"sol\",\n \"assetOut\": \"sol\",\n \"authority\": \"string\"\n}"
response = http.request(request)
puts response.read_body{
"addressLookupTableAddresses": [
"<string>"
],
"amountInAtoms": 1,
"blockhash": "<string>",
"computeUnitLimit": 1,
"contextSlot": 1,
"expectedAmountOutAtoms": 1,
"instructions": [
{
"data": [
1
],
"keys": [
{
"isSigner": true,
"isWritable": true,
"pubkey": "<string>"
}
],
"programId": "<string>"
}
],
"lastValidBlockHeight": 1,
"minAmountOutAtoms": 1,
"priceImpactBps": 1,
"swapNativeAmountInAtoms": 1,
"transaction": "<string>",
"transactionVersion": 1,
"venue": "<string>",
"attestationExpiresAt": 123,
"sponsorshipAttestation": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}Authorizations
Body
JSON request payload for post.v1.ix.swap.
Request payload for /v1/ix/swap.
Venue configuration (venue list, base URLs, API keys, shared lookup tables, slippage bounds) is server-side; the request only selects what to swap and how to quote it.
Priority fee (compute unit price) in micro-lamports. A v0
transaction carries it as a compute-budget instruction; a v1
transaction carries ceil(price * compute_unit_limit / 1e6) lamports
in its message config. Sponsored swaps must set fees here rather than
recompiling the message, since the sponsorship attestation covers the
exact compiled bytes.
x >= 0Transaction format to compile: 0 (default) for a v0 message with
address lookup tables, 1 for a v1 message (SIMD-0385) that inlines
every address and carries the compute budget in its config instead of
compute-budget instructions. Other values are rejected.
x >= 0Response
Successful response
Response payload for /v1/ix/swap.
Carries the same plan twice: a compiled unsigned transaction for clients that sign and send as-is, and the instruction/lookup-table breakdown for clients that compile their own message (own blockhash, fee payer, and safety instructions).
Provenance attestation over the compiled message, for the
sponsorship server. Present only when the server has an attestation
key configured. Issued for the swapper (position_authority when
provided, else authority). Sign transaction verbatim and pass this
through to POST /v1/sponsorship/transaction; any recompilation
invalidates it.