curl --request POST \
--url https://api.ionicfi.com/v1/spend/setup_sessions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: <idempotency-key>' \
--data '
{
"label": "<string>",
"return_url": "<string>"
}
'import requests
url = "https://api.ionicfi.com/v1/spend/setup_sessions"
payload = {
"label": "<string>",
"return_url": "<string>"
}
headers = {
"Idempotency-Key": "<idempotency-key>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'Idempotency-Key': '<idempotency-key>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({label: '<string>', return_url: '<string>'})
};
fetch('https://api.ionicfi.com/v1/spend/setup_sessions', 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.ionicfi.com/v1/spend/setup_sessions",
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([
'label' => '<string>',
'return_url' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"Idempotency-Key: <idempotency-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.ionicfi.com/v1/spend/setup_sessions"
payload := strings.NewReader("{\n \"label\": \"<string>\",\n \"return_url\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Idempotency-Key", "<idempotency-key>")
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://api.ionicfi.com/v1/spend/setup_sessions")
.header("Idempotency-Key", "<idempotency-key>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"label\": \"<string>\",\n \"return_url\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ionicfi.com/v1/spend/setup_sessions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Idempotency-Key"] = '<idempotency-key>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"label\": \"<string>\",\n \"return_url\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"object": "spend.setup_session",
"account_id": "<string>",
"livemode": true,
"status": "pending",
"url": "<string>",
"card_id": "<string>",
"created": 1,
"expires_at": 1
}{
"id": "<string>",
"object": "spend.setup_session",
"account_id": "<string>",
"livemode": true,
"status": "pending",
"url": "<string>",
"card_id": "<string>",
"created": 1,
"expires_at": 1
}{
"error": {
"code": "<string>",
"message": "<string>",
"retryable": true
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"retryable": true
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"retryable": true
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"retryable": true
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"retryable": true,
"spend_intent": {
"id": "<string>",
"object": "spend_intent",
"account_id": "<string>",
"agent_id": "<string>",
"livemode": true,
"version": 2,
"action": "payment",
"card_id": "<string>",
"purpose": "<string>",
"seller": {
"name": "<string>",
"checkout_url": "<string>"
},
"amount": 4503599627370495,
"currency": "<string>",
"billing_details": {
"name": "<string>",
"address": {
"line1": "<string>",
"city": "<string>",
"postal_code": "<string>",
"country": "<string>",
"line2": "<string>",
"state": "<string>"
},
"email": "[email protected]"
},
"reference": "<string>",
"status": "pending_approval",
"allowed_hosts": [
"<string>"
],
"approval_url": "<string>",
"return_url": "<string>",
"created": 1,
"approval_expires_at": 1,
"approved_at": 1,
"claimed_at": 1,
"canceled_at": 1,
"claim_expires_at": 1,
"credential_expires_at": 1,
"claim_replay_available": true,
"credential_exposure": "none",
"claim_within_seconds": 300,
"approvals": [
{
"authority": "owner",
"status": "pending",
"over_limit": true,
"decided_at": 1
}
],
"limit_breaches": [
{
"authority": "owner",
"limit_id": "<string>",
"rule": {
"type": "max_amount",
"window": "1h"
},
"limit": 4503599627370496,
"usage": 4503599627370495,
"requested": 4503599627370495,
"on_breach": "hold"
}
],
"blocked_at": 1
}
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"retryable": true,
"spend_intent": {
"id": "<string>",
"object": "spend_intent",
"account_id": "<string>",
"agent_id": "<string>",
"livemode": true,
"version": 2,
"action": "payment",
"card_id": "<string>",
"purpose": "<string>",
"seller": {
"name": "<string>",
"checkout_url": "<string>"
},
"amount": 4503599627370495,
"currency": "<string>",
"billing_details": {
"name": "<string>",
"address": {
"line1": "<string>",
"city": "<string>",
"postal_code": "<string>",
"country": "<string>",
"line2": "<string>",
"state": "<string>"
},
"email": "[email protected]"
},
"reference": "<string>",
"status": "pending_approval",
"allowed_hosts": [
"<string>"
],
"approval_url": "<string>",
"return_url": "<string>",
"created": 1,
"approval_expires_at": 1,
"approved_at": 1,
"claimed_at": 1,
"canceled_at": 1,
"claim_expires_at": 1,
"credential_expires_at": 1,
"claim_replay_available": true,
"credential_exposure": "none",
"claim_within_seconds": 300,
"approvals": [
{
"authority": "owner",
"status": "pending",
"over_limit": true,
"decided_at": 1
}
],
"limit_breaches": [
{
"authority": "owner",
"limit_id": "<string>",
"rule": {
"type": "max_amount",
"window": "1h"
},
"limit": 4503599627370496,
"usage": 4503599627370495,
"requested": 4503599627370495,
"on_breach": "hold"
}
],
"blocked_at": 1
}
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"retryable": true
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"retryable": true
}
}Create a setup session
Creates a hosted page where a business owner adds a card for agent purchases. Send the owner to the returned url. The session expires after 30 minutes.
Completing setup saves the card but gives no agent access to it. The owner grants access to an agent separately.
Call this from your server with a secret key that has spend:write. A platform acting for a connected business also sends Ionic-Account. Agent keys can’t create setup sessions.
A return_url must use one of the business’s registered web origins or, for a platform, one of the platform’s approved origins. Otherwise the request fails with 400 invalid_return_url. Retrying a pending creation can return a new url; earlier links keep working until the session completes or expires.
curl --request POST \
--url https://api.ionicfi.com/v1/spend/setup_sessions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: <idempotency-key>' \
--data '
{
"label": "<string>",
"return_url": "<string>"
}
'import requests
url = "https://api.ionicfi.com/v1/spend/setup_sessions"
payload = {
"label": "<string>",
"return_url": "<string>"
}
headers = {
"Idempotency-Key": "<idempotency-key>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'Idempotency-Key': '<idempotency-key>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({label: '<string>', return_url: '<string>'})
};
fetch('https://api.ionicfi.com/v1/spend/setup_sessions', 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.ionicfi.com/v1/spend/setup_sessions",
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([
'label' => '<string>',
'return_url' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"Idempotency-Key: <idempotency-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.ionicfi.com/v1/spend/setup_sessions"
payload := strings.NewReader("{\n \"label\": \"<string>\",\n \"return_url\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Idempotency-Key", "<idempotency-key>")
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://api.ionicfi.com/v1/spend/setup_sessions")
.header("Idempotency-Key", "<idempotency-key>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"label\": \"<string>\",\n \"return_url\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ionicfi.com/v1/spend/setup_sessions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Idempotency-Key"] = '<idempotency-key>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"label\": \"<string>\",\n \"return_url\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"object": "spend.setup_session",
"account_id": "<string>",
"livemode": true,
"status": "pending",
"url": "<string>",
"card_id": "<string>",
"created": 1,
"expires_at": 1
}{
"id": "<string>",
"object": "spend.setup_session",
"account_id": "<string>",
"livemode": true,
"status": "pending",
"url": "<string>",
"card_id": "<string>",
"created": 1,
"expires_at": 1
}{
"error": {
"code": "<string>",
"message": "<string>",
"retryable": true
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"retryable": true
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"retryable": true
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"retryable": true
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"retryable": true,
"spend_intent": {
"id": "<string>",
"object": "spend_intent",
"account_id": "<string>",
"agent_id": "<string>",
"livemode": true,
"version": 2,
"action": "payment",
"card_id": "<string>",
"purpose": "<string>",
"seller": {
"name": "<string>",
"checkout_url": "<string>"
},
"amount": 4503599627370495,
"currency": "<string>",
"billing_details": {
"name": "<string>",
"address": {
"line1": "<string>",
"city": "<string>",
"postal_code": "<string>",
"country": "<string>",
"line2": "<string>",
"state": "<string>"
},
"email": "[email protected]"
},
"reference": "<string>",
"status": "pending_approval",
"allowed_hosts": [
"<string>"
],
"approval_url": "<string>",
"return_url": "<string>",
"created": 1,
"approval_expires_at": 1,
"approved_at": 1,
"claimed_at": 1,
"canceled_at": 1,
"claim_expires_at": 1,
"credential_expires_at": 1,
"claim_replay_available": true,
"credential_exposure": "none",
"claim_within_seconds": 300,
"approvals": [
{
"authority": "owner",
"status": "pending",
"over_limit": true,
"decided_at": 1
}
],
"limit_breaches": [
{
"authority": "owner",
"limit_id": "<string>",
"rule": {
"type": "max_amount",
"window": "1h"
},
"limit": 4503599627370496,
"usage": 4503599627370495,
"requested": 4503599627370495,
"on_breach": "hold"
}
],
"blocked_at": 1
}
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"retryable": true,
"spend_intent": {
"id": "<string>",
"object": "spend_intent",
"account_id": "<string>",
"agent_id": "<string>",
"livemode": true,
"version": 2,
"action": "payment",
"card_id": "<string>",
"purpose": "<string>",
"seller": {
"name": "<string>",
"checkout_url": "<string>"
},
"amount": 4503599627370495,
"currency": "<string>",
"billing_details": {
"name": "<string>",
"address": {
"line1": "<string>",
"city": "<string>",
"postal_code": "<string>",
"country": "<string>",
"line2": "<string>",
"state": "<string>"
},
"email": "[email protected]"
},
"reference": "<string>",
"status": "pending_approval",
"allowed_hosts": [
"<string>"
],
"approval_url": "<string>",
"return_url": "<string>",
"created": 1,
"approval_expires_at": 1,
"approved_at": 1,
"claimed_at": 1,
"canceled_at": 1,
"claim_expires_at": 1,
"credential_expires_at": 1,
"claim_replay_available": true,
"credential_exposure": "none",
"claim_within_seconds": 300,
"approvals": [
{
"authority": "owner",
"status": "pending",
"over_limit": true,
"decided_at": 1
}
],
"limit_breaches": [
{
"authority": "owner",
"limit_id": "<string>",
"rule": {
"type": "max_amount",
"window": "1h"
},
"limit": 4503599627370496,
"usage": 4503599627370495,
"requested": 4503599627370495,
"on_breach": "hold"
}
],
"blocked_at": 1
}
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"retryable": true
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"retryable": true
}
}Authorizations
Headers
Body
Absolute HTTPS URL; no userinfo, port, query, fragment or whitespace. Return destinations require registration where specified. Seller pre-registration is not required when the caller supplies allowed_hosts.
10 - 2048^https://[a-z0-9](?:[a-z0-9.-]*[a-z0-9])?(?:/[^\s?#]*)?$Response
Returned when you retry with the same Idempotency-Key. The body is the existing object.
Absolute HTTPS URL; no userinfo, port, query, fragment or whitespace. Return destinations require registration where specified. Seller pre-registration is not required when the caller supplies allowed_hosts.
10 - 2048^https://[a-z0-9](?:[a-z0-9.-]*[a-z0-9])?(?:/[^\s?#]*)?$
