Create Subscription
curl --request POST \
--url https://api.atlas.co/functions/v1/subscriptions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"customer": "<string>",
"items": [
{
"price": "<string>",
"quantity": 1
}
],
"trial_period_days": 123,
"trial_end": 123,
"billing_cycle_anchor": 123,
"cancel_at_period_end": true,
"days_until_due": 123,
"default_payment_method": "<string>",
"metadata": {}
}
'import requests
url = "https://api.atlas.co/functions/v1/subscriptions"
payload = {
"customer": "<string>",
"items": [
{
"price": "<string>",
"quantity": 1
}
],
"trial_period_days": 123,
"trial_end": 123,
"billing_cycle_anchor": 123,
"cancel_at_period_end": True,
"days_until_due": 123,
"default_payment_method": "<string>",
"metadata": {}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
customer: '<string>',
items: [{price: '<string>', quantity: 1}],
trial_period_days: 123,
trial_end: 123,
billing_cycle_anchor: 123,
cancel_at_period_end: true,
days_until_due: 123,
default_payment_method: '<string>',
metadata: {}
})
};
fetch('https://api.atlas.co/functions/v1/subscriptions', 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.atlas.co/functions/v1/subscriptions",
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([
'customer' => '<string>',
'items' => [
[
'price' => '<string>',
'quantity' => 1
]
],
'trial_period_days' => 123,
'trial_end' => 123,
'billing_cycle_anchor' => 123,
'cancel_at_period_end' => true,
'days_until_due' => 123,
'default_payment_method' => '<string>',
'metadata' => [
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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.atlas.co/functions/v1/subscriptions"
payload := strings.NewReader("{\n \"customer\": \"<string>\",\n \"items\": [\n {\n \"price\": \"<string>\",\n \"quantity\": 1\n }\n ],\n \"trial_period_days\": 123,\n \"trial_end\": 123,\n \"billing_cycle_anchor\": 123,\n \"cancel_at_period_end\": true,\n \"days_until_due\": 123,\n \"default_payment_method\": \"<string>\",\n \"metadata\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
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.atlas.co/functions/v1/subscriptions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"customer\": \"<string>\",\n \"items\": [\n {\n \"price\": \"<string>\",\n \"quantity\": 1\n }\n ],\n \"trial_period_days\": 123,\n \"trial_end\": 123,\n \"billing_cycle_anchor\": 123,\n \"cancel_at_period_end\": true,\n \"days_until_due\": 123,\n \"default_payment_method\": \"<string>\",\n \"metadata\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.atlas.co/functions/v1/subscriptions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"customer\": \"<string>\",\n \"items\": [\n {\n \"price\": \"<string>\",\n \"quantity\": 1\n }\n ],\n \"trial_period_days\": 123,\n \"trial_end\": 123,\n \"billing_cycle_anchor\": 123,\n \"cancel_at_period_end\": true,\n \"days_until_due\": 123,\n \"default_payment_method\": \"<string>\",\n \"metadata\": {}\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"object": "subscription",
"customer": "<string>",
"current_period_start": 123,
"current_period_end": 123,
"trial_start": 123,
"trial_end": 123,
"cancel_at_period_end": true,
"canceled_at": 123,
"ended_at": 123,
"collection_method": "<string>",
"days_until_due": 123,
"default_payment_method": "<string>",
"items": {
"object": "list",
"data": [
{
"id": "<string>",
"object": "subscription_item",
"price": {
"id": "<string>",
"product": "<string>",
"unit_amount": 123,
"currency": "<string>",
"recurring": {
"interval": "<string>",
"interval_count": 123
}
},
"quantity": 123,
"created": 123
}
]
},
"latest_invoice": "<string>",
"metadata": {},
"created": 123
}{
"error": {
"code": "<string>",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}Subscriptions
Create Subscription
POST
/
subscriptions
Create Subscription
curl --request POST \
--url https://api.atlas.co/functions/v1/subscriptions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"customer": "<string>",
"items": [
{
"price": "<string>",
"quantity": 1
}
],
"trial_period_days": 123,
"trial_end": 123,
"billing_cycle_anchor": 123,
"cancel_at_period_end": true,
"days_until_due": 123,
"default_payment_method": "<string>",
"metadata": {}
}
'import requests
url = "https://api.atlas.co/functions/v1/subscriptions"
payload = {
"customer": "<string>",
"items": [
{
"price": "<string>",
"quantity": 1
}
],
"trial_period_days": 123,
"trial_end": 123,
"billing_cycle_anchor": 123,
"cancel_at_period_end": True,
"days_until_due": 123,
"default_payment_method": "<string>",
"metadata": {}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
customer: '<string>',
items: [{price: '<string>', quantity: 1}],
trial_period_days: 123,
trial_end: 123,
billing_cycle_anchor: 123,
cancel_at_period_end: true,
days_until_due: 123,
default_payment_method: '<string>',
metadata: {}
})
};
fetch('https://api.atlas.co/functions/v1/subscriptions', 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.atlas.co/functions/v1/subscriptions",
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([
'customer' => '<string>',
'items' => [
[
'price' => '<string>',
'quantity' => 1
]
],
'trial_period_days' => 123,
'trial_end' => 123,
'billing_cycle_anchor' => 123,
'cancel_at_period_end' => true,
'days_until_due' => 123,
'default_payment_method' => '<string>',
'metadata' => [
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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.atlas.co/functions/v1/subscriptions"
payload := strings.NewReader("{\n \"customer\": \"<string>\",\n \"items\": [\n {\n \"price\": \"<string>\",\n \"quantity\": 1\n }\n ],\n \"trial_period_days\": 123,\n \"trial_end\": 123,\n \"billing_cycle_anchor\": 123,\n \"cancel_at_period_end\": true,\n \"days_until_due\": 123,\n \"default_payment_method\": \"<string>\",\n \"metadata\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
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.atlas.co/functions/v1/subscriptions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"customer\": \"<string>\",\n \"items\": [\n {\n \"price\": \"<string>\",\n \"quantity\": 1\n }\n ],\n \"trial_period_days\": 123,\n \"trial_end\": 123,\n \"billing_cycle_anchor\": 123,\n \"cancel_at_period_end\": true,\n \"days_until_due\": 123,\n \"default_payment_method\": \"<string>\",\n \"metadata\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.atlas.co/functions/v1/subscriptions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"customer\": \"<string>\",\n \"items\": [\n {\n \"price\": \"<string>\",\n \"quantity\": 1\n }\n ],\n \"trial_period_days\": 123,\n \"trial_end\": 123,\n \"billing_cycle_anchor\": 123,\n \"cancel_at_period_end\": true,\n \"days_until_due\": 123,\n \"default_payment_method\": \"<string>\",\n \"metadata\": {}\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"object": "subscription",
"customer": "<string>",
"current_period_start": 123,
"current_period_end": 123,
"trial_start": 123,
"trial_end": 123,
"cancel_at_period_end": true,
"canceled_at": 123,
"ended_at": 123,
"collection_method": "<string>",
"days_until_due": 123,
"default_payment_method": "<string>",
"items": {
"object": "list",
"data": [
{
"id": "<string>",
"object": "subscription_item",
"price": {
"id": "<string>",
"product": "<string>",
"unit_amount": 123,
"currency": "<string>",
"recurring": {
"interval": "<string>",
"interval_count": 123
}
},
"quantity": 123,
"created": 123
}
]
},
"latest_invoice": "<string>",
"metadata": {},
"created": 123
}{
"error": {
"code": "<string>",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}Authorizations
API key (sk_test_* or sk_live_*)
Body
application/json
Show child attributes
Show child attributes
Available options:
charge_automatically, send_invoice Show child attributes
Show child attributes
Response
Subscription created
Available options:
subscription Available options:
trialing, active, past_due, paused, canceled, unpaid Show child attributes
Show child attributes
Show child attributes
Show child attributes
⌘I