Skip to main content
POST
/
external
/
subscriptions
Create subscription
curl --request POST \
  --url https://platform.runonatlas.com/external/subscriptions \
  --header 'Content-Type: application/json' \
  --header 'x-api-key: <api-key>' \
  --data '
{
  "startDate": "2021-01-01T00:00:00.000Z",
  "autoChargeInvoice": false,
  "autoSyncInvoice": true,
  "autoSendInvoice": true,
  "customerId": "atlas-internal-customer-id-123",
  "planId": "atlas-internal-plan-id-123",
  "currency": "USD",
  "endDate": "2021-12-31T00:00:00.000Z",
  "netTerms": "net30",
  "allowCustomerChanges": true,
  "paymentGateway": "Stripe",
  "invoiceGenerationStartDate": "2021-01-01T00:00:00.000Z"
}
'
import requests

url = "https://platform.runonatlas.com/external/subscriptions"

payload = {
"startDate": "2021-01-01T00:00:00.000Z",
"autoChargeInvoice": False,
"autoSyncInvoice": True,
"autoSendInvoice": True,
"customerId": "atlas-internal-customer-id-123",
"planId": "atlas-internal-plan-id-123",
"currency": "USD",
"endDate": "2021-12-31T00:00:00.000Z",
"netTerms": "net30",
"allowCustomerChanges": True,
"paymentGateway": "Stripe",
"invoiceGenerationStartDate": "2021-01-01T00:00:00.000Z"
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
startDate: '2021-01-01T00:00:00.000Z',
autoChargeInvoice: false,
autoSyncInvoice: true,
autoSendInvoice: true,
customerId: 'atlas-internal-customer-id-123',
planId: 'atlas-internal-plan-id-123',
currency: 'USD',
endDate: '2021-12-31T00:00:00.000Z',
netTerms: 'net30',
allowCustomerChanges: true,
paymentGateway: 'Stripe',
invoiceGenerationStartDate: '2021-01-01T00:00:00.000Z'
})
};

fetch('https://platform.runonatlas.com/external/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://platform.runonatlas.com/external/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([
'startDate' => '2021-01-01T00:00:00.000Z',
'autoChargeInvoice' => false,
'autoSyncInvoice' => true,
'autoSendInvoice' => true,
'customerId' => 'atlas-internal-customer-id-123',
'planId' => 'atlas-internal-plan-id-123',
'currency' => 'USD',
'endDate' => '2021-12-31T00:00:00.000Z',
'netTerms' => 'net30',
'allowCustomerChanges' => true,
'paymentGateway' => 'Stripe',
'invoiceGenerationStartDate' => '2021-01-01T00:00:00.000Z'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <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://platform.runonatlas.com/external/subscriptions"

payload := strings.NewReader("{\n \"startDate\": \"2021-01-01T00:00:00.000Z\",\n \"autoChargeInvoice\": false,\n \"autoSyncInvoice\": true,\n \"autoSendInvoice\": true,\n \"customerId\": \"atlas-internal-customer-id-123\",\n \"planId\": \"atlas-internal-plan-id-123\",\n \"currency\": \"USD\",\n \"endDate\": \"2021-12-31T00:00:00.000Z\",\n \"netTerms\": \"net30\",\n \"allowCustomerChanges\": true,\n \"paymentGateway\": \"Stripe\",\n \"invoiceGenerationStartDate\": \"2021-01-01T00:00:00.000Z\"\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))

}
HttpResponse<String> response = Unirest.post("https://platform.runonatlas.com/external/subscriptions")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"startDate\": \"2021-01-01T00:00:00.000Z\",\n \"autoChargeInvoice\": false,\n \"autoSyncInvoice\": true,\n \"autoSendInvoice\": true,\n \"customerId\": \"atlas-internal-customer-id-123\",\n \"planId\": \"atlas-internal-plan-id-123\",\n \"currency\": \"USD\",\n \"endDate\": \"2021-12-31T00:00:00.000Z\",\n \"netTerms\": \"net30\",\n \"allowCustomerChanges\": true,\n \"paymentGateway\": \"Stripe\",\n \"invoiceGenerationStartDate\": \"2021-01-01T00:00:00.000Z\"\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://platform.runonatlas.com/external/subscriptions")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"startDate\": \"2021-01-01T00:00:00.000Z\",\n \"autoChargeInvoice\": false,\n \"autoSyncInvoice\": true,\n \"autoSendInvoice\": true,\n \"customerId\": \"atlas-internal-customer-id-123\",\n \"planId\": \"atlas-internal-plan-id-123\",\n \"currency\": \"USD\",\n \"endDate\": \"2021-12-31T00:00:00.000Z\",\n \"netTerms\": \"net30\",\n \"allowCustomerChanges\": true,\n \"paymentGateway\": \"Stripe\",\n \"invoiceGenerationStartDate\": \"2021-01-01T00:00:00.000Z\"\n}"

response = http.request(request)
puts response.read_body
{
  "createdAt": "2021-01-01T00:00:00.000Z",
  "id": "atlas-internal-subscription-id-123",
  "startDate": "2021-01-01T00:00:00.000Z",
  "status": "active",
  "updatedAt": "2021-01-01T00:00:00.000Z",
  "allowCustomerChanges": true,
  "autoChargeInvoice": false,
  "autoSyncInvoice": true,
  "autoSendInvoice": true,
  "paymentGateway": "Stripe",
  "isTrial": false,
  "customerId": "atlas-internal-customer-id-123",
  "planId": "atlas-internal-plan-id-123",
  "merchantId": "atlas-internal-merchant-id-123",
  "billingCadence": "monthly",
  "currency": "USD",
  "endDate": "2021-12-31T00:00:00.000Z",
  "netTerms": "net30",
  "chargeForUsageBasedPricesDuringTrial": false
}

Authorizations

x-api-key
string
header
required

You can obtain this key from the Atlas dashboard. It must be of type secret

Body

application/json
startDate
required

The start date of the subscription

Example:

"2021-01-01T00:00:00.000Z"

autoChargeInvoice
boolean
required

Whether to automatically charge invoices for this subscription to the associated payment gateway. Requires a valid Stripe connection. Only compatible with a Stripe payment gateway.

Example:

false

autoSyncInvoice
boolean
required

Whether to automatically sync invoices for this subscription to the associated payment gateway.

Example:

true

autoSendInvoice
boolean
required

Whether to automatically send invoices for this subscription from the associated payment gateway to the customers email address.

Example:

true

customerId
string
required

The Atlas customer ID

Minimum string length: 1
Example:

"atlas-internal-customer-id-123"

planId
string
required

The Atlas plan ID

Minimum string length: 1
Example:

"atlas-internal-plan-id-123"

currency
enum<string> | null

The currency for this subscription

Available options:
USD
Example:

"USD"

endDate

The end date of the subscription

Example:

"2021-12-31T00:00:00.000Z"

netTerms
enum<string> | null

The net terms for this subscription; applies only if autoChargeInvoice is false. Determines the number of days after the invoice is issued before the payment is due.

Available options:
uponReceipt,
net30,
net60,
net90
Example:

"net30"

allowCustomerChanges
boolean
default:true

Whether the customer can change the subscription, for example by cancelling it or creating another.

Example:

true

paymentGateway
enum<string> | null

The selected payment gateway for this subscription

Available options:
Stripe,
QuickBooks,
Xero
Example:

"Stripe"

invoiceGenerationStartDate

The date from which invoices should be generated. If ommitted, invoices will be generated from the subscription startDate. If set, no invoices will be generated until this date.

Example:

"2021-01-01T00:00:00.000Z"

Response

The subscription that has been created.

createdAt
string<date>
required

The date and time the subscription was created

Example:

"2021-01-01T00:00:00.000Z"

id
string
required

The Atlas subscription ID

Minimum string length: 1
Example:

"atlas-internal-subscription-id-123"

startDate
required

The start date of the subscription

Example:

"2021-01-01T00:00:00.000Z"

status
enum<string>
required

The status of the subscription

Available options:
draft,
pendingActivation,
active,
ended,
deleted
Example:

"active"

updatedAt
string<date>
required

The date and time the subscription was last updated

Example:

"2021-01-01T00:00:00.000Z"

allowCustomerChanges
boolean
required

Whether the customer can change the subscription, for example by cancelling it or creating another.

Example:

true

autoChargeInvoice
boolean
required

Whether to automatically charge invoices for this subscription to the associated payment gateway. Requires a valid Stripe connection. Only compatible with a Stripe payment gateway.

Example:

false

autoSyncInvoice
boolean
required

Whether to automatically sync invoices for this subscription to the associated payment gateway.

Example:

true

autoSendInvoice
boolean
required

Whether to automatically send invoices for this subscription from the associated payment gateway to the customers email address.

Example:

true

paymentGateway
enum<string> | null
required

The selected payment gateway for this subscription

Available options:
Stripe,
QuickBooks,
Xero
Example:

"Stripe"

isTrial
boolean
required

Whether this subscription is a trial subscription

Example:

false

customerId
string
required

The Atlas customer ID

Minimum string length: 1
Example:

"atlas-internal-customer-id-123"

planId
string
required

The Atlas plan ID

Minimum string length: 1
Example:

"atlas-internal-plan-id-123"

merchantId
string
required

The Atlas merchant ID

Minimum string length: 1
Example:

"atlas-internal-merchant-id-123"

billingCadence
enum<string> | null

The billing cadence for this subscription

Available options:
oneTime,
monthly,
quarterly,
annually
Example:

"monthly"

currency
enum<string> | null

The currency for this subscription

Available options:
USD
Example:

"USD"

endDate

The end date of the subscription

Example:

"2021-12-31T00:00:00.000Z"

netTerms
enum<string> | null

The net terms for this subscription; applies only if autoChargeInvoice is false. Determines the number of days after the invoice is issued before the payment is due.

Available options:
uponReceipt,
net30,
net60,
net90
Example:

"net30"

chargeForUsageBasedPricesDuringTrial
boolean | null

Whether to charge for usage-based prices during the trial period. Only applies if isTrial is true.

Example:

false