curl --request POST \
--url https://api.ternswap.xyz/v1/quote/{id}/fulfill \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"fulfillment": "0x8f3b2c1d0e9f8a7b6c5d4e3f2a1b0c9d8e7f6a5b4c3d2e1f0a9b8c7d6e5f4a3b"
}
'import requests
url = "https://api.ternswap.xyz/v1/quote/{id}/fulfill"
payload = { "fulfillment": "0x8f3b2c1d0e9f8a7b6c5d4e3f2a1b0c9d8e7f6a5b4c3d2e1f0a9b8c7d6e5f4a3b" }
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
fulfillment: '0x8f3b2c1d0e9f8a7b6c5d4e3f2a1b0c9d8e7f6a5b4c3d2e1f0a9b8c7d6e5f4a3b'
})
};
fetch('https://api.ternswap.xyz/v1/quote/{id}/fulfill', 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://api.ternswap.xyz/v1/quote/{id}/fulfill",
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([
'fulfillment' => '0x8f3b2c1d0e9f8a7b6c5d4e3f2a1b0c9d8e7f6a5b4c3d2e1f0a9b8c7d6e5f4a3b'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$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://api.ternswap.xyz/v1/quote/{id}/fulfill"
payload := strings.NewReader("{\n \"fulfillment\": \"0x8f3b2c1d0e9f8a7b6c5d4e3f2a1b0c9d8e7f6a5b4c3d2e1f0a9b8c7d6e5f4a3b\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
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://api.ternswap.xyz/v1/quote/{id}/fulfill")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"fulfillment\": \"0x8f3b2c1d0e9f8a7b6c5d4e3f2a1b0c9d8e7f6a5b4c3d2e1f0a9b8c7d6e5f4a3b\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ternswap.xyz/v1/quote/{id}/fulfill")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"fulfillment\": \"0x8f3b2c1d0e9f8a7b6c5d4e3f2a1b0c9d8e7f6a5b4c3d2e1f0a9b8c7d6e5f4a3b\"\n}"
response = http.request(request)
puts response.read_body{
"id": "q_01JB8Z5W3F6V9Q2X4K7M1N0P8R",
"status": "in_progress"
}{
"code": "invalid_request",
"detail": "<string>",
"status": 1,
"title": "<string>",
"type": "<string>"
}{
"code": "invalid_request",
"detail": "<string>",
"status": 1,
"title": "<string>",
"type": "<string>"
}{
"code": "invalid_request",
"detail": "<string>",
"status": 1,
"title": "<string>",
"type": "<string>"
}{
"code": "invalid_request",
"detail": "<string>",
"status": 1,
"title": "<string>",
"type": "<string>"
}{
"code": "invalid_request",
"detail": "<string>",
"status": 1,
"title": "<string>",
"type": "<string>"
}{
"code": "invalid_request",
"detail": "<string>",
"status": 1,
"title": "<string>",
"type": "<string>"
}Reveal the fulfillment
Reveals the 32-byte fulfillment whose SHA-256 is the quote’s executionCondition, once the solver has locked the
destination funds. The relayer then claims them for the recipient. Check the destination escrows on chain before
revealing: once revealed, the fulfillment is public.
curl --request POST \
--url https://api.ternswap.xyz/v1/quote/{id}/fulfill \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"fulfillment": "0x8f3b2c1d0e9f8a7b6c5d4e3f2a1b0c9d8e7f6a5b4c3d2e1f0a9b8c7d6e5f4a3b"
}
'import requests
url = "https://api.ternswap.xyz/v1/quote/{id}/fulfill"
payload = { "fulfillment": "0x8f3b2c1d0e9f8a7b6c5d4e3f2a1b0c9d8e7f6a5b4c3d2e1f0a9b8c7d6e5f4a3b" }
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
fulfillment: '0x8f3b2c1d0e9f8a7b6c5d4e3f2a1b0c9d8e7f6a5b4c3d2e1f0a9b8c7d6e5f4a3b'
})
};
fetch('https://api.ternswap.xyz/v1/quote/{id}/fulfill', 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://api.ternswap.xyz/v1/quote/{id}/fulfill",
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([
'fulfillment' => '0x8f3b2c1d0e9f8a7b6c5d4e3f2a1b0c9d8e7f6a5b4c3d2e1f0a9b8c7d6e5f4a3b'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$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://api.ternswap.xyz/v1/quote/{id}/fulfill"
payload := strings.NewReader("{\n \"fulfillment\": \"0x8f3b2c1d0e9f8a7b6c5d4e3f2a1b0c9d8e7f6a5b4c3d2e1f0a9b8c7d6e5f4a3b\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
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://api.ternswap.xyz/v1/quote/{id}/fulfill")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"fulfillment\": \"0x8f3b2c1d0e9f8a7b6c5d4e3f2a1b0c9d8e7f6a5b4c3d2e1f0a9b8c7d6e5f4a3b\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ternswap.xyz/v1/quote/{id}/fulfill")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"fulfillment\": \"0x8f3b2c1d0e9f8a7b6c5d4e3f2a1b0c9d8e7f6a5b4c3d2e1f0a9b8c7d6e5f4a3b\"\n}"
response = http.request(request)
puts response.read_body{
"id": "q_01JB8Z5W3F6V9Q2X4K7M1N0P8R",
"status": "in_progress"
}{
"code": "invalid_request",
"detail": "<string>",
"status": 1,
"title": "<string>",
"type": "<string>"
}{
"code": "invalid_request",
"detail": "<string>",
"status": 1,
"title": "<string>",
"type": "<string>"
}{
"code": "invalid_request",
"detail": "<string>",
"status": 1,
"title": "<string>",
"type": "<string>"
}{
"code": "invalid_request",
"detail": "<string>",
"status": 1,
"title": "<string>",
"type": "<string>"
}{
"code": "invalid_request",
"detail": "<string>",
"status": 1,
"title": "<string>",
"type": "<string>"
}{
"code": "invalid_request",
"detail": "<string>",
"status": 1,
"title": "<string>",
"type": "<string>"
}Authorizations
A partner's API key. Optional: without it a request is anonymous. An invalid key is 401 unauthorized.
Headers
Repeats with the same key and body get the first response; 1 to 255 visible ASCII characters
Path Parameters
The quote's ID
Body
The body of POST /v1/quote/{id}/fulfill: the fulfillment whose SHA-256 is the quote's execution condition. Reveal
it only after checking the destination escrows on chain (spec section 9.4). Debug never prints it.
32 bytes in hex.
"0x0101010101010101010101010101010101010101010101010101010101010101"
Response
The relayer submits the fulfill; follow the quote's status
202 Accepted from POST /v1/quote/{id}/fulfill: the relayer will submit the fulfill. Follow the quote with
GET /v1/quote/{id}.