Créer un abonnement
curl --request POST \
--url https://api.example.com/v1/billing/subscriptionsimport requests
url = "https://api.example.com/v1/billing/subscriptions"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.example.com/v1/billing/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.example.com/v1/billing/subscriptions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/v1/billing/subscriptions"
req, _ := http.NewRequest("POST", url, nil)
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.example.com/v1/billing/subscriptions")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/billing/subscriptions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_bodyAbonnements
Créer un abonnement
Identité sans téléphone, essai explicite et checkout
POST
/
v1
/
billing
/
subscriptions
Créer un abonnement
curl --request POST \
--url https://api.example.com/v1/billing/subscriptionsimport requests
url = "https://api.example.com/v1/billing/subscriptions"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.example.com/v1/billing/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.example.com/v1/billing/subscriptions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/v1/billing/subscriptions"
req, _ := http.NewRequest("POST", url, nil)
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.example.com/v1/billing/subscriptions")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/billing/subscriptions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_bodyPOST /v1/billing/subscriptions/with-payment crée un abonnement et le premier
lien de paiement. POST /v1/billing/subscriptions prépare seulement le calendrier.
Voir le guide Billing bilingue pour les périodes payées et les essais explicites.
| Champ | Requis | Description |
|---|---|---|
plan_id | Oui | Plan actif dans l’application et le mode de la clé |
customer_id, customer_external_ref, customer_email, customer_phone | Au moins un | Téléphone facultatif |
customer_name | Non | Nom du client |
trial_end | Non | Fin d’essai ISO UTC future ; checkout sans facture/lien pendant l’essai |
start_date | Non | Première échéance ; création simple uniquement |
external_ref | Non | Référence stable de checkout ; avec customer_external_ref, sans ID/téléphone |
redirect_url, metadata | Non | Checkout uniquement |
const result = await api.subscriptions.createWithPayment({
plan_id: 'PLAN_ID', customer_external_ref: 'test_user_PLACEHOLDER',
external_ref: 'test_checkout_PLACEHOLDER', idempotency_key: 'test_checkout_PLACEHOLDER',
});
// result.invoice et result.payment_link peuvent être null.
idempotency_key est un en-tête, pas un champ JSON. Consultez les
garanties de rejeu dans le guide. Les deux créations exposent trial_end,
current_period_start/end et next_billing_date. Sans essai ni paiement : INCOMPLETE.
Une création d’essai conserve ACTIVE avec trial_end ; son GET canonique est
TRIALING. ACTIVE canonique signifie une période payée courante.
Erreurs : 400 validation/plan inactif, 404 plan absent ou hors périmètre, 409 conflit.