Payments
Create subscription
Create a Stripe subscription for recurring billing. Requires a valid price ID from your Stripe account. Optionally pass submitter email and metadata.
POST
/
api
/
payments
/
subscribe
Create subscription
curl --request POST \
--url https://spitshake.io/api/payments/subscribe \
--header 'Content-Type: application/json' \
--header 'X-Auth-Token: <api-key>' \
--data '
{
"price_id": "price_1abc123",
"email": "jsmith@example.com",
"metadata": {}
}
'import requests
url = "https://spitshake.io/api/payments/subscribe"
payload = {
"price_id": "price_1abc123",
"email": "jsmith@example.com",
"metadata": {}
}
headers = {
"X-Auth-Token": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-Auth-Token': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({price_id: 'price_1abc123', email: 'jsmith@example.com', metadata: {}})
};
fetch('https://spitshake.io/api/payments/subscribe', 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://spitshake.io/api/payments/subscribe",
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([
'price_id' => 'price_1abc123',
'email' => 'jsmith@example.com',
'metadata' => [
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Auth-Token: <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://spitshake.io/api/payments/subscribe"
payload := strings.NewReader("{\n \"price_id\": \"price_1abc123\",\n \"email\": \"jsmith@example.com\",\n \"metadata\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Auth-Token", "<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://spitshake.io/api/payments/subscribe")
.header("X-Auth-Token", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"price_id\": \"price_1abc123\",\n \"email\": \"jsmith@example.com\",\n \"metadata\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://spitshake.io/api/payments/subscribe")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Auth-Token"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"price_id\": \"price_1abc123\",\n \"email\": \"jsmith@example.com\",\n \"metadata\": {}\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"status": "active",
"customer": "<string>",
"current_period_start": 123,
"current_period_end": 123,
"latest_invoice": "<string>",
"client_secret": "<string>"
}Authorizations
ApiTokenSessionCookie
API token generated at Settings > API
Body
application/json
Response
Subscription created
Stripe subscription ID
Subscription status
Available options:
active, incomplete, incomplete_expired, trialing, past_due, canceled, unpaid, paused Stripe customer ID
Unix timestamp of current billing period start
Unix timestamp of current billing period end
Latest Stripe invoice ID
Client secret for completing payment if required
⌘I
Create subscription
curl --request POST \
--url https://spitshake.io/api/payments/subscribe \
--header 'Content-Type: application/json' \
--header 'X-Auth-Token: <api-key>' \
--data '
{
"price_id": "price_1abc123",
"email": "jsmith@example.com",
"metadata": {}
}
'import requests
url = "https://spitshake.io/api/payments/subscribe"
payload = {
"price_id": "price_1abc123",
"email": "jsmith@example.com",
"metadata": {}
}
headers = {
"X-Auth-Token": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-Auth-Token': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({price_id: 'price_1abc123', email: 'jsmith@example.com', metadata: {}})
};
fetch('https://spitshake.io/api/payments/subscribe', 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://spitshake.io/api/payments/subscribe",
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([
'price_id' => 'price_1abc123',
'email' => 'jsmith@example.com',
'metadata' => [
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Auth-Token: <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://spitshake.io/api/payments/subscribe"
payload := strings.NewReader("{\n \"price_id\": \"price_1abc123\",\n \"email\": \"jsmith@example.com\",\n \"metadata\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Auth-Token", "<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://spitshake.io/api/payments/subscribe")
.header("X-Auth-Token", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"price_id\": \"price_1abc123\",\n \"email\": \"jsmith@example.com\",\n \"metadata\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://spitshake.io/api/payments/subscribe")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Auth-Token"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"price_id\": \"price_1abc123\",\n \"email\": \"jsmith@example.com\",\n \"metadata\": {}\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"status": "active",
"customer": "<string>",
"current_period_start": 123,
"current_period_end": 123,
"latest_invoice": "<string>",
"client_secret": "<string>"
}
