Skip to main content
POST
/
v1
/
stores
/
{store}
/
subscription-plans
/
{plan}
/
subscriptions
Create subscription
curl --request POST \
  --url https://api.confiopagos.com/v1/stores/{store}/subscription-plans/{plan}/subscriptions \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "buyer": {
    "email": "buyer@example.com",
    "phoneNumber": "+573215786325",
    "firstName": "Santiago",
    "lastName": "García"
  },
  "firstChargeAmountCents": 3000000,
  "redirectUri": "https://example.com/subscription-status"
}
'
import requests

url = "https://api.confiopagos.com/v1/stores/{store}/subscription-plans/{plan}/subscriptions"

payload = {
"buyer": {
"email": "buyer@example.com",
"phoneNumber": "+573215786325",
"firstName": "Santiago",
"lastName": "García"
},
"firstChargeAmountCents": 3000000,
"redirectUri": "https://example.com/subscription-status"
}
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({
buyer: {
email: 'buyer@example.com',
phoneNumber: '+573215786325',
firstName: 'Santiago',
lastName: 'García'
},
firstChargeAmountCents: 3000000,
redirectUri: 'https://example.com/subscription-status'
})
};

fetch('https://api.confiopagos.com/v1/stores/{store}/subscription-plans/{plan}/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.confiopagos.com/v1/stores/{store}/subscription-plans/{plan}/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([
'buyer' => [
'email' => 'buyer@example.com',
'phoneNumber' => '+573215786325',
'firstName' => 'Santiago',
'lastName' => 'García'
],
'firstChargeAmountCents' => 3000000,
'redirectUri' => 'https://example.com/subscription-status'
]),
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.confiopagos.com/v1/stores/{store}/subscription-plans/{plan}/subscriptions"

payload := strings.NewReader("{\n \"buyer\": {\n \"email\": \"buyer@example.com\",\n \"phoneNumber\": \"+573215786325\",\n \"firstName\": \"Santiago\",\n \"lastName\": \"García\"\n },\n \"firstChargeAmountCents\": 3000000,\n \"redirectUri\": \"https://example.com/subscription-status\"\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.confiopagos.com/v1/stores/{store}/subscription-plans/{plan}/subscriptions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"buyer\": {\n \"email\": \"buyer@example.com\",\n \"phoneNumber\": \"+573215786325\",\n \"firstName\": \"Santiago\",\n \"lastName\": \"García\"\n },\n \"firstChargeAmountCents\": 3000000,\n \"redirectUri\": \"https://example.com/subscription-status\"\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.confiopagos.com/v1/stores/{store}/subscription-plans/{plan}/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 \"buyer\": {\n \"email\": \"buyer@example.com\",\n \"phoneNumber\": \"+573215786325\",\n \"firstName\": \"Santiago\",\n \"lastName\": \"García\"\n },\n \"firstChargeAmountCents\": 3000000,\n \"redirectUri\": \"https://example.com/subscription-status\"\n}"

response = http.request(request)
puts response.read_body
{
  "name": "stores/01JNRRDZDPH40DB2YRW329BFXM/subscription-plans/01JNRVWWHH68E76V3TMFFT6GHJ/subscriptions/01JNRVWWHH68E76V3TMFFT6GHJ",
  "status": "PENDING_ACCEPTANCE",
  "buyer": {
    "email": "buyer@example.com",
    "phoneNumber": "+573215786325",
    "firstName": "Santiago",
    "lastName": "García"
  },
  "createTime": "2024-01-15T10:30:00Z",
  "firstChargeAmountCents": 3000000,
  "redirectUri": "https://example.com/subscription-status",
  "acceptanceUrl": "https://checkout.confiopagos.com/s/abc123token",
  "acceptanceTokenExpiresAt": "2024-01-22T10:30:00Z",
  "currentPeriodStart": "2024-01-15T10:30:00Z",
  "currentPeriodEnd": "2024-02-15T10:30:00Z",
  "nextBillingTime": "2024-02-15T10:30:00Z"
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

store
string
required
Example:

"01G65Z755AFWAKHE12NY0CQ9FH"

plan
string
required
Example:

"01JNRVWWHH68E76V3TMFFT6GHJ"

Body

application/json
buyer
object
required
firstChargeAmountCents
number

Optional first charge amount in cents (only for the first charge)

Required range: x >= 0
Example:

3000000

redirectUri
string<uri>

Optional redirect URI after subscription payment

Example:

"https://example.com/subscription-status"

Response

200 - application/json

Successfully created subscription.

name
string
required

Subscription's resource name

Example:

"stores/01JNRRDZDPH40DB2YRW329BFXM/subscription-plans/01JNRVWWHH68E76V3TMFFT6GHJ/subscriptions/01JNRVWWHH68E76V3TMFFT6GHJ"

status
enum<string>
required

Subscription status

Available options:
PENDING_ACCEPTANCE,
ACTIVE,
TRIALING,
PAST_DUE,
CANCELED,
SUSPENDED
Example:

"PENDING_ACCEPTANCE"

buyer
object
required

Buyer information

createTime
string
required

Creation timestamp

Example:

"2024-01-15T10:30:00Z"

firstChargeAmountCents
number

Optional first charge amount in cents (only for the first charge)

Example:

3000000

redirectUri
string<uri>

Optional redirect URI after subscription payment

Example:

"https://example.com/subscription-status"

acceptanceUrl
string

URL for buyer to accept the subscription (only available when status is PENDING_ACCEPTANCE)

Example:

"https://checkout.confiopagos.com/s/abc123token"

acceptanceTokenExpiresAt
string

Expiration time of the acceptance token

Example:

"2024-01-22T10:30:00Z"

currentPeriodStart
string

Start of current billing period

Example:

"2024-01-15T10:30:00Z"

currentPeriodEnd
string

End of current billing period

Example:

"2024-02-15T10:30:00Z"

nextBillingTime
string

Next billing date

Example:

"2024-02-15T10:30:00Z"