Create Stripe Checkout session for credit purchase
curl --request POST \
--url https://api.platform.dakota.xyz/self-serve/credits/purchase \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"tier_price_cents": 10000
}
'const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({tier_price_cents: 10000})
};
fetch('https://api.platform.dakota.xyz/self-serve/credits/purchase', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.platform.dakota.xyz/self-serve/credits/purchase"
payload = { "tier_price_cents": 10000 }
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.platform.dakota.xyz/self-serve/credits/purchase"
payload := strings.NewReader("{\n \"tier_price_cents\": 10000\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))
}{
"checkout_url": "https://checkout.stripe.com/c/pay/cs_test_a1b2c3"
}{
"type": "https://docs.dakota.xyz/api-reference/errors#invalid-request",
"title": "Invalid Request",
"status": 400,
"detail": "tier_price_cents must be a valid credit tier"
}{
"type": "https://docs.dakota.xyz/api-reference/errors#authentication-error",
"title": "Authentication Required",
"status": 401,
"detail": "Missing or invalid authentication credentials."
}{
"type": "https://docs.dakota.xyz/api-reference/errors#forbidden",
"title": "Forbidden",
"status": 403,
"detail": "Credit management is only available for self-serve customers."
}{
"type": "https://docs.dakota.xyz/api-reference/errors#service-unavailable",
"title": "Service Unavailable",
"status": 503,
"detail": "Stripe checkout is not configured"
}Self Serve
Create Stripe Checkout session for credit purchase
Creates a Stripe Checkout session for a valid prepaid credit tier for the authenticated self-serve client.
POST
/
self-serve
/
credits
/
purchase
Create Stripe Checkout session for credit purchase
curl --request POST \
--url https://api.platform.dakota.xyz/self-serve/credits/purchase \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"tier_price_cents": 10000
}
'const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({tier_price_cents: 10000})
};
fetch('https://api.platform.dakota.xyz/self-serve/credits/purchase', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.platform.dakota.xyz/self-serve/credits/purchase"
payload = { "tier_price_cents": 10000 }
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.platform.dakota.xyz/self-serve/credits/purchase"
payload := strings.NewReader("{\n \"tier_price_cents\": 10000\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))
}{
"checkout_url": "https://checkout.stripe.com/c/pay/cs_test_a1b2c3"
}{
"type": "https://docs.dakota.xyz/api-reference/errors#invalid-request",
"title": "Invalid Request",
"status": 400,
"detail": "tier_price_cents must be a valid credit tier"
}{
"type": "https://docs.dakota.xyz/api-reference/errors#authentication-error",
"title": "Authentication Required",
"status": 401,
"detail": "Missing or invalid authentication credentials."
}{
"type": "https://docs.dakota.xyz/api-reference/errors#forbidden",
"title": "Forbidden",
"status": 403,
"detail": "Credit management is only available for self-serve customers."
}{
"type": "https://docs.dakota.xyz/api-reference/errors#service-unavailable",
"title": "Service Unavailable",
"status": 503,
"detail": "Stripe checkout is not configured"
}Was this page helpful?
āI

