Skip to content
CCPEDIAby Unity Nodes
Documentation/Canton Network Docs/Splice APIsValidator APIsWallet API (External)View on Canton Network Docs

POST /v0/wallet/buy-traffic-requests

POST
/
api
/
validator
/
v0
/
wallet
/
buy-traffic-requests
Try it
cURL
Python
JavaScript
PHP
Go
Java
Ruby
curl --request POST \
  --url 'https://example.com/api/validator/v0/wallet/buy-traffic-requests' \
  --header 'Authorization: Bearer $TOKEN' \
  --header 'Content-Type: application/json' \
  --data '{
  "receiving_validator_party_id": "<string>",
  "domain_id": "<string>",
  "traffic_amount": 123,
  "tracking_id": "<string>",
  "expires_at": 123
}'
import json
import requests

url = "https://example.com/api/validator/v0/wallet/buy-traffic-requests"
headers = {'Authorization': 'Bearer <token>', 'Content-Type': 'application/json'}
payload = json.loads(r'''{
  "receiving_validator_party_id": "<string>",
  "domain_id": "<string>",
  "traffic_amount": 123,
  "tracking_id": "<string>",
  "expires_at": 123
}''')
response = requests.request(
    "POST", url, headers=headers, json=payload
)

print(response.text)
const response = await fetch('https://example.com/api/validator/v0/wallet/buy-traffic-requests', {
  method: 'POST',
  headers: {
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
},
  body: JSON.stringify({
  "receiving_validator_party_id": "<string>",
  "domain_id": "<string>",
  "traffic_amount": 123,
  "tracking_id": "<string>",
  "expires_at": 123
}),
});

console.log(await response.text());
<?php
$curl = curl_init();

curl_setopt_array($curl, [
    CURLOPT_URL => 'https://example.com/api/validator/v0/wallet/buy-traffic-requests',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_POSTFIELDS => <<<'JSON'
{
  "receiving_validator_party_id": "<string>",
  "domain_id": "<string>",
  "traffic_amount": 123,
  "tracking_id": "<string>",
  "expires_at": 123
}
JSON,
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer <token>",
        "Content-Type: application/json"
    ],
]);

$response = curl_exec($curl);
echo $response;
package main

import (
  "bytes"
  "fmt"
  "io"
  "net/http"
)

func main() {
  req, _ := http.NewRequest("POST", "https://example.com/api/validator/v0/wallet/buy-traffic-requests", bytes.NewBufferString(`{
  "receiving_validator_party_id": "<string>",
  "domain_id": "<string>",
  "traffic_amount": 123,
  "tracking_id": "<string>",
  "expires_at": 123
}`))
  req.Header.Set("Authorization", "Bearer <token>")
  req.Header.Set("Content-Type", "application/json")
  response, _ := http.DefaultClient.Do(req)
  defer response.Body.Close()
  body, _ := io.ReadAll(response.Body)
  fmt.Println(string(body))
}
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

var request = HttpRequest.newBuilder()
    .uri(URI.create("https://example.com/api/validator/v0/wallet/buy-traffic-requests"))
    .header("Authorization", "Bearer <token>")
    .header("Content-Type", "application/json")
    .method("POST", HttpRequest.BodyPublishers.ofString("""
{
  "receiving_validator_party_id": "<string>",
  "domain_id": "<string>",
  "traffic_amount": 123,
  "tracking_id": "<string>",
  "expires_at": 123
}
"""))
    .build();
var response = HttpClient.newHttpClient().send(
    request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
require 'net/http'
require 'uri'

uri = URI('https://example.com/api/validator/v0/wallet/buy-traffic-requests')
request = Net::HTTP::Post.new(uri)
request['Authorization'] = 'Bearer <token>'
request['Content-Type'] = 'application/json'
request.body = <<~JSON
{
  "receiving_validator_party_id": "<string>",
  "domain_id": "<string>",
  "traffic_amount": 123,
  "tracking_id": "<string>",
  "expires_at": 123
}
JSON
response = Net::HTTP.start(uri.hostname, uri.port) do |http|
  http.request(request)
end
puts response.body
200
400
409
429
500
{
  "request_contract_id": "<string>"
}
{
  "error": "<string>"
}
{
  "error": "<string>"
}
{
  "error": "<string>"
}
{
  "error": "<string>"
}

Create a request to buy traffic. Note that this only creates the request to do so. Refer to the status endpoint to check if the request succeeded.

OpenAPI
cURL
Python
JavaScript
PHP
Go
Java
Ruby
curl --request POST \
  --url 'https://example.com/api/validator/v0/wallet/buy-traffic-requests' \
  --header 'Authorization: Bearer $TOKEN' \
  --header 'Content-Type: application/json' \
  --data '{
  "receiving_validator_party_id": "<string>",
  "domain_id": "<string>",
  "traffic_amount": 123,
  "tracking_id": "<string>",
  "expires_at": 123
}'
import json
import requests

url = "https://example.com/api/validator/v0/wallet/buy-traffic-requests"
headers = {'Authorization': 'Bearer <token>', 'Content-Type': 'application/json'}
payload = json.loads(r'''{
  "receiving_validator_party_id": "<string>",
  "domain_id": "<string>",
  "traffic_amount": 123,
  "tracking_id": "<string>",
  "expires_at": 123
}''')
response = requests.request(
    "POST", url, headers=headers, json=payload
)

print(response.text)
const response = await fetch('https://example.com/api/validator/v0/wallet/buy-traffic-requests', {
  method: 'POST',
  headers: {
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
},
  body: JSON.stringify({
  "receiving_validator_party_id": "<string>",
  "domain_id": "<string>",
  "traffic_amount": 123,
  "tracking_id": "<string>",
  "expires_at": 123
}),
});

console.log(await response.text());
<?php
$curl = curl_init();

curl_setopt_array($curl, [
    CURLOPT_URL => 'https://example.com/api/validator/v0/wallet/buy-traffic-requests',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_POSTFIELDS => <<<'JSON'
{
  "receiving_validator_party_id": "<string>",
  "domain_id": "<string>",
  "traffic_amount": 123,
  "tracking_id": "<string>",
  "expires_at": 123
}
JSON,
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer <token>",
        "Content-Type: application/json"
    ],
]);

$response = curl_exec($curl);
echo $response;
package main

import (
  "bytes"
  "fmt"
  "io"
  "net/http"
)

func main() {
  req, _ := http.NewRequest("POST", "https://example.com/api/validator/v0/wallet/buy-traffic-requests", bytes.NewBufferString(`{
  "receiving_validator_party_id": "<string>",
  "domain_id": "<string>",
  "traffic_amount": 123,
  "tracking_id": "<string>",
  "expires_at": 123
}`))
  req.Header.Set("Authorization", "Bearer <token>")
  req.Header.Set("Content-Type", "application/json")
  response, _ := http.DefaultClient.Do(req)
  defer response.Body.Close()
  body, _ := io.ReadAll(response.Body)
  fmt.Println(string(body))
}
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

var request = HttpRequest.newBuilder()
    .uri(URI.create("https://example.com/api/validator/v0/wallet/buy-traffic-requests"))
    .header("Authorization", "Bearer <token>")
    .header("Content-Type", "application/json")
    .method("POST", HttpRequest.BodyPublishers.ofString("""
{
  "receiving_validator_party_id": "<string>",
  "domain_id": "<string>",
  "traffic_amount": 123,
  "tracking_id": "<string>",
  "expires_at": 123
}
"""))
    .build();
var response = HttpClient.newHttpClient().send(
    request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
require 'net/http'
require 'uri'

uri = URI('https://example.com/api/validator/v0/wallet/buy-traffic-requests')
request = Net::HTTP::Post.new(uri)
request['Authorization'] = 'Bearer <token>'
request['Content-Type'] = 'application/json'
request.body = <<~JSON
{
  "receiving_validator_party_id": "<string>",
  "domain_id": "<string>",
  "traffic_amount": 123,
  "tracking_id": "<string>",
  "expires_at": 123
}
JSON
response = Net::HTTP.start(uri.hostname, uri.port) do |http|
  http.request(request)
end
puts response.body
200
400
409
429
500
{
  "request_contract_id": "<string>"
}
{
  "error": "<string>"
}
{
  "error": "<string>"
}
{
  "error": "<string>"
}
{
  "error": "<string>"
}

Authorizations

walletUserAuth

Authorization
string
required
HTTP bearer authentication. Send the token as Authorization: Bearer &lt;token&gt;. Bearer format: JWT. JWT token as described by the spliceAppBearerAuth security scheme. The subject of the token must be ledger API user of the user whose wallet the endpoint affects.

Body

application/json
receiving_validator_party_id
string
required
Traffic will be purchased for the validator hosting this party. If the party is hosted on multiple participants, the request will fail with 400 Bad Request.
domain_id
string
required
The domain to purchase traffic for.
traffic_amount
number
required
OpenAPI type: integer (int64).traffic to purchase in bytes.
tracking_id
string
required
Tracking id to support exactly once submission. Once submitted, all succeessive calls with the same tracking id will get rejected with a 409 or 429 status code unless the command fails and the traffic did not get purchased. Clients should create a fresh tracking id when they try to send a new request to buy traffic. If that command submission fails with a retryable error or the application crashed and got restarted, successive command submissions must reuse the same tracking id to ensure they don’t purchase traffic multiple times.
expires_at
number
required
OpenAPI type: integer (int64).Expiry time of the request to buy traffic as unix timestamp in microseconds. If the request does not succeed before this time, the wallet automation will reject and expire it. Note that this time is compared against the ledger effective time of the Daml transaction accepting or expiring an offer, and can skew from the wall clock time measured on the caller’s machine. See https://docs.daml.com/concepts/time.html for how ledger effective time is bound to the record time of a transaction on a domain.

Responses

200

Request to buy traffic got created
application/json
request_contract_id
string
required

400

Request was invalid, adjust parameters
application/json
error
string
required

409

A request to buy traffic with the same tracking id has been created. Check the status endpoint for the current status.
application/json
error
string
required

429

A request to buy traffic with the same tracking id is currently being processed. Check the status endpoint and resubmit if it returns 404.
application/json
error
string
required

500

Internal server error that requires operator investigation. Retrying for a small number of times with exponential back-off MAY work.
application/json
error
string
required