Create or resume a subscription purchase
curl --request POST \
--url https://app.flextell.ai/api/v1/billing/subscription/purchase \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'X-Tenant: <x-tenant>' \
--data '
{
"plan_code": "<string>",
"idempotency_key": "<string>",
"tenant": "<string>"
}
'import requests
url = "https://app.flextell.ai/api/v1/billing/subscription/purchase"
payload = {
"plan_code": "<string>",
"idempotency_key": "<string>",
"tenant": "<string>"
}
headers = {
"X-Tenant": "<x-tenant>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'X-Tenant': '<x-tenant>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({plan_code: '<string>', idempotency_key: '<string>', tenant: '<string>'})
};
fetch('https://app.flextell.ai/api/v1/billing/subscription/purchase', 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://app.flextell.ai/api/v1/billing/subscription/purchase",
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([
'plan_code' => '<string>',
'idempotency_key' => '<string>',
'tenant' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"X-Tenant: <x-tenant>"
],
]);
$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://app.flextell.ai/api/v1/billing/subscription/purchase"
payload := strings.NewReader("{\n \"plan_code\": \"<string>\",\n \"idempotency_key\": \"<string>\",\n \"tenant\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Tenant", "<x-tenant>")
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://app.flextell.ai/api/v1/billing/subscription/purchase")
.header("X-Tenant", "<x-tenant>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"plan_code\": \"<string>\",\n \"idempotency_key\": \"<string>\",\n \"tenant\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.flextell.ai/api/v1/billing/subscription/purchase")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Tenant"] = '<x-tenant>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"plan_code\": \"<string>\",\n \"idempotency_key\": \"<string>\",\n \"tenant\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"success": "<string>",
"data": {
"proforma_invoice": {
"id": 123,
"tenant_id": 123,
"number": "<string>",
"kind": "<string>",
"kind_label": "<string>",
"subscription_plan_code": "<string>",
"is_subscription_upgrade": true,
"subscription_activation_pending": true,
"subscription_upgrade_from_code": "<string>",
"subscription_upgrade_period_end": "<string>",
"status": "<string>",
"status_label": "<string>",
"currency": "<string>",
"gross_amount": "<string>",
"discount_amount": "<string>",
"net_amount": "<string>",
"tax_amount": "<string>",
"total_amount": "<string>",
"paid_amount": "<string>",
"outstanding_amount": "<string>",
"is_fully_paid": true,
"is_overdue": true,
"is_payable": "<string>",
"is_pending_purchase": true,
"purchase_expired": true,
"period_start": "<string>",
"period_end": "<string>",
"issue_date": "<string>",
"due_date": "<string>",
"approved_at": "2023-11-07T05:31:56Z",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"checkout": {
"can_pay": "<string>",
"can_cancel_purchase": "<string>",
"can_apply_discount": "<string>",
"can_complete_without_payment": "<string>",
"active_payment_id": 123,
"blocked_error_code": "<string>",
"blocked_message": "<string>"
},
"lines": [
{
"id": 123,
"billing_quota_package_id": 123,
"proforma_invoice_id": 123,
"source": "<string>",
"source_label": "<string>",
"billing_type": "<string>",
"billing_type_label": "<string>",
"description": "<string>",
"quantity": "<string>",
"unit": "<string>",
"unit_label": "<string>",
"unit_price": "<string>",
"gross_amount": "<string>",
"discount_allocated": "<string>",
"net_amount": "<string>",
"tax_rate": "<string>",
"tax_amount": "<string>",
"line_total": "<string>",
"period_start": "<string>",
"period_end": "<string>",
"sort_order": 123
}
],
"discount_applications": [
{
"status": "applied",
"id": 123,
"proforma_invoice_id": 123,
"usage_type": "<string>",
"usage_type_label": "<string>",
"applied_amount": "<string>",
"applied_at": "2023-11-07T05:31:56Z",
"proforma_invoice_number": "<string>",
"currency": "<string>",
"discount": {
"id": 123,
"code": "<string>",
"application_mode": "<string>",
"name": "<string>",
"discount_type": "<string>",
"discount_type_label": "<string>",
"value": "<string>"
}
}
],
"payments": [
{
"id": 123,
"proforma_invoice_id": 123,
"method": "<string>",
"method_label": "<string>",
"gateway": "<string>",
"status": "<string>",
"status_label": "<string>",
"failure_message": "<string>",
"amount": "<string>",
"refunded_amount": "<string>",
"currency": "<string>",
"masked_reference": "<string>",
"completed_at": "2023-11-07T05:31:56Z",
"created_at": "2023-11-07T05:31:56Z"
}
]
}
}
}{
"message": "<string>"
}{
"message": "<string>"
}{
"message": "<string>",
"errors": {}
}Billing
Create or resume a subscription purchase
POST
/
v1
/
billing
/
subscription
/
purchase
Create or resume a subscription purchase
curl --request POST \
--url https://app.flextell.ai/api/v1/billing/subscription/purchase \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'X-Tenant: <x-tenant>' \
--data '
{
"plan_code": "<string>",
"idempotency_key": "<string>",
"tenant": "<string>"
}
'import requests
url = "https://app.flextell.ai/api/v1/billing/subscription/purchase"
payload = {
"plan_code": "<string>",
"idempotency_key": "<string>",
"tenant": "<string>"
}
headers = {
"X-Tenant": "<x-tenant>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'X-Tenant': '<x-tenant>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({plan_code: '<string>', idempotency_key: '<string>', tenant: '<string>'})
};
fetch('https://app.flextell.ai/api/v1/billing/subscription/purchase', 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://app.flextell.ai/api/v1/billing/subscription/purchase",
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([
'plan_code' => '<string>',
'idempotency_key' => '<string>',
'tenant' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"X-Tenant: <x-tenant>"
],
]);
$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://app.flextell.ai/api/v1/billing/subscription/purchase"
payload := strings.NewReader("{\n \"plan_code\": \"<string>\",\n \"idempotency_key\": \"<string>\",\n \"tenant\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Tenant", "<x-tenant>")
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://app.flextell.ai/api/v1/billing/subscription/purchase")
.header("X-Tenant", "<x-tenant>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"plan_code\": \"<string>\",\n \"idempotency_key\": \"<string>\",\n \"tenant\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.flextell.ai/api/v1/billing/subscription/purchase")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Tenant"] = '<x-tenant>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"plan_code\": \"<string>\",\n \"idempotency_key\": \"<string>\",\n \"tenant\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"success": "<string>",
"data": {
"proforma_invoice": {
"id": 123,
"tenant_id": 123,
"number": "<string>",
"kind": "<string>",
"kind_label": "<string>",
"subscription_plan_code": "<string>",
"is_subscription_upgrade": true,
"subscription_activation_pending": true,
"subscription_upgrade_from_code": "<string>",
"subscription_upgrade_period_end": "<string>",
"status": "<string>",
"status_label": "<string>",
"currency": "<string>",
"gross_amount": "<string>",
"discount_amount": "<string>",
"net_amount": "<string>",
"tax_amount": "<string>",
"total_amount": "<string>",
"paid_amount": "<string>",
"outstanding_amount": "<string>",
"is_fully_paid": true,
"is_overdue": true,
"is_payable": "<string>",
"is_pending_purchase": true,
"purchase_expired": true,
"period_start": "<string>",
"period_end": "<string>",
"issue_date": "<string>",
"due_date": "<string>",
"approved_at": "2023-11-07T05:31:56Z",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"checkout": {
"can_pay": "<string>",
"can_cancel_purchase": "<string>",
"can_apply_discount": "<string>",
"can_complete_without_payment": "<string>",
"active_payment_id": 123,
"blocked_error_code": "<string>",
"blocked_message": "<string>"
},
"lines": [
{
"id": 123,
"billing_quota_package_id": 123,
"proforma_invoice_id": 123,
"source": "<string>",
"source_label": "<string>",
"billing_type": "<string>",
"billing_type_label": "<string>",
"description": "<string>",
"quantity": "<string>",
"unit": "<string>",
"unit_label": "<string>",
"unit_price": "<string>",
"gross_amount": "<string>",
"discount_allocated": "<string>",
"net_amount": "<string>",
"tax_rate": "<string>",
"tax_amount": "<string>",
"line_total": "<string>",
"period_start": "<string>",
"period_end": "<string>",
"sort_order": 123
}
],
"discount_applications": [
{
"status": "applied",
"id": 123,
"proforma_invoice_id": 123,
"usage_type": "<string>",
"usage_type_label": "<string>",
"applied_amount": "<string>",
"applied_at": "2023-11-07T05:31:56Z",
"proforma_invoice_number": "<string>",
"currency": "<string>",
"discount": {
"id": 123,
"code": "<string>",
"application_mode": "<string>",
"name": "<string>",
"discount_type": "<string>",
"discount_type_label": "<string>",
"value": "<string>"
}
}
],
"payments": [
{
"id": 123,
"proforma_invoice_id": 123,
"method": "<string>",
"method_label": "<string>",
"gateway": "<string>",
"status": "<string>",
"status_label": "<string>",
"failure_message": "<string>",
"amount": "<string>",
"refunded_amount": "<string>",
"currency": "<string>",
"masked_reference": "<string>",
"completed_at": "2023-11-07T05:31:56Z",
"created_at": "2023-11-07T05:31:56Z"
}
]
}
}
}{
"message": "<string>"
}{
"message": "<string>"
}{
"message": "<string>",
"errors": {}
}Yetkilendirmeler
oauth2bearer
The access token received from the authorization server in the OAuth 2.0 flow.
Başlıklar
Tenant identifier. Send the Tenant ID in the X-Tenant header to scope API requests to a specific tenant.
Gövde
application/json