For clean Markdown of any page, append .md to the page URL. For a complete documentation index, see https://docs.prolifi.io/endpoints/subscriptions/llms.txt. For full documentation content, see https://docs.prolifi.io/endpoints/subscriptions/llms-full.txt.

# Create a subscription

POST https://api.prolifi.co/api/v1/public/subscriptions
Content-Type: application/json

Creates a new subscription linking a customer to a plan. The subscription is activated immediately.

The `billing_cycle` can be a UUID (billing cycle ID) or a name like `"monthly"` or `"yearly"` — it will be matched against the plan's available billing cycles.

If `country_id` is not provided, it is resolved from the customer's record.


Reference: https://docs.prolifi.io/endpoints/subscriptions/create-subscription

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: Prolifi Public API
  version: 1.0.0
paths:
  /subscriptions:
    post:
      operationId: create-subscription
      summary: Create a subscription
      description: >
        Creates a new subscription linking a customer to a plan. The
        subscription is activated immediately.


        The `billing_cycle` can be a UUID (billing cycle ID) or a name like
        `"monthly"` or `"yearly"` — it will be matched against the plan's
        available billing cycles.


        If `country_id` is not provided, it is resolved from the customer's
        record.
      tags:
        - subpackage_subscriptions
      parameters:
        - name: Authorization
          in: header
          description: >
            Use a secret key (`sk_test_*` or `sk_live_*`) for full read/write
            access, or a public key (`pk_test_*` or `pk_live_*`) for read-only
            access.
          required: true
          schema:
            type: string
      responses:
        '201':
          description: Subscription created successfully
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/Subscriptions_createSubscription_Response_201
        '401':
          description: Authentication failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: Permission denied
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '422':
          description: Validation failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateSubscriptionRequest'
servers:
  - url: https://api.prolifi.co/api/v1/public
  - url: https://sandbox.prolifi.co/api/v1/public
components:
  schemas:
    CreateSubscriptionRequestMetadata:
      type: object
      properties: {}
      title: CreateSubscriptionRequestMetadata
    CreateSubscriptionRequest:
      type: object
      properties:
        customer_id:
          type: string
          format: uuid
          description: The customer to subscribe.
        plan_id:
          type: string
          format: uuid
          description: The plan to subscribe to.
        billing_cycle:
          type:
            - string
            - 'null'
          description: >-
            Billing cycle UUID or name (e.g., `"monthly"`, `"yearly"`). Defaults
            to the plan's first billing cycle.
        start_date:
          type:
            - string
            - 'null'
          format: date
          description: Subscription start date. Defaults to today.
        billing_date:
          type:
            - string
            - 'null'
          format: date
          description: First billing date. Defaults to start date.
        country_id:
          type:
            - string
            - 'null'
          format: uuid
          description: >-
            Country for tax and currency. Resolved from customer if not
            provided.
        pricing_scheme_id:
          type:
            - string
            - 'null'
          format: uuid
          description: Override the plan's default pricing scheme.
        payment_term_id:
          type:
            - string
            - 'null'
          format: uuid
        quantity:
          type:
            - integer
            - 'null'
          description: Seat count or quantity (for per-unit pricing).
        metadata:
          oneOf:
            - $ref: '#/components/schemas/CreateSubscriptionRequestMetadata'
            - type: 'null'
      required:
        - customer_id
        - plan_id
      title: CreateSubscriptionRequest
    SubscriptionStatus:
      type: string
      enum:
        - active
        - cancelled
        - paused
        - pending
        - expired
      title: SubscriptionStatus
    SubscriptionPricing:
      type: object
      properties:
        amount:
          type:
            - number
            - 'null'
          format: double
          description: Subscription amount in minor units.
        currency:
          type:
            - string
            - 'null'
          description: ISO 4217 currency code.
        pricing_scheme_id:
          type:
            - string
            - 'null'
          format: uuid
      title: SubscriptionPricing
    SubscriptionMetadata:
      type: object
      properties: {}
      title: SubscriptionMetadata
    Subscription:
      type: object
      properties:
        id:
          type: string
          format: uuid
          description: Unique identifier.
        customer_id:
          type: string
          format: uuid
        plan_id:
          type: string
          format: uuid
          description: The plan (product) this subscription is for.
        plan_name:
          type:
            - string
            - 'null'
        status:
          $ref: '#/components/schemas/SubscriptionStatus'
        billing_cycle:
          type:
            - string
            - 'null'
          description: Current billing cycle name (e.g., monthly, yearly).
        current_period_start:
          type:
            - string
            - 'null'
          format: date
        current_period_end:
          type:
            - string
            - 'null'
          format: date
        start_date:
          type:
            - string
            - 'null'
          format: date
        billing_date:
          type:
            - string
            - 'null'
          format: date
        cancel_at:
          type:
            - string
            - 'null'
          format: date-time
          description: When the subscription is scheduled to cancel.
        canceled_at:
          type:
            - string
            - 'null'
          format: date-time
          description: When the subscription was cancelled.
        pause_start:
          type:
            - string
            - 'null'
          format: date-time
        pause_end:
          type:
            - string
            - 'null'
          format: date-time
        pricing:
          $ref: '#/components/schemas/SubscriptionPricing'
        metadata:
          oneOf:
            - $ref: '#/components/schemas/SubscriptionMetadata'
            - type: 'null'
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
      title: Subscription
    Subscriptions_createSubscription_Response_201:
      type: object
      properties:
        data:
          $ref: '#/components/schemas/Subscription'
      title: Subscriptions_createSubscription_Response_201
    ErrorResponseErrorType:
      type: string
      enum:
        - authentication_error
        - permission_error
        - validation_error
        - not_found
        - invalid_request
        - rate_limit_error
        - ip_restricted
        - conflict
        - api_error
      description: Machine-readable error type.
      title: ErrorResponseErrorType
    ErrorResponseErrorErrorsItems:
      type: object
      properties:
        field:
          type: string
          description: The field that failed validation.
        message:
          type: string
          description: The validation error message.
      title: ErrorResponseErrorErrorsItems
    ErrorResponseError:
      type: object
      properties:
        type:
          $ref: '#/components/schemas/ErrorResponseErrorType'
          description: Machine-readable error type.
        message:
          type: string
          description: Human-readable error description.
        errors:
          type: array
          items:
            $ref: '#/components/schemas/ErrorResponseErrorErrorsItems'
          description: >-
            Field-level validation errors (only present for `validation_error`
            type).
      required:
        - type
        - message
      title: ErrorResponseError
    ErrorResponse:
      type: object
      properties:
        error:
          $ref: '#/components/schemas/ErrorResponseError'
      title: ErrorResponse
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: >
        Use a secret key (`sk_test_*` or `sk_live_*`) for full read/write
        access, or a public key (`pk_test_*` or `pk_live_*`) for read-only
        access.

```

## SDK Code Examples

```python Create with start date and quantity
import requests

url = "https://api.prolifi.co/api/v1/public/subscriptions"

payload = {
    "customer_id": "d290f1ee-6c54-4b01-90e6-d701748f0851",
    "plan_id": "a1b2c3d4-5678-90ab-cdef-1234567890ab",
    "billing_cycle": "yearly",
    "start_date": "2026-04-01",
    "quantity": 5
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Create with start date and quantity
const url = 'https://api.prolifi.co/api/v1/public/subscriptions';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"customer_id":"d290f1ee-6c54-4b01-90e6-d701748f0851","plan_id":"a1b2c3d4-5678-90ab-cdef-1234567890ab","billing_cycle":"yearly","start_date":"2026-04-01","quantity":5}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Create with start date and quantity
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.prolifi.co/api/v1/public/subscriptions"

	payload := strings.NewReader("{\n  \"customer_id\": \"d290f1ee-6c54-4b01-90e6-d701748f0851\",\n  \"plan_id\": \"a1b2c3d4-5678-90ab-cdef-1234567890ab\",\n  \"billing_cycle\": \"yearly\",\n  \"start_date\": \"2026-04-01\",\n  \"quantity\": 5\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(res)
	fmt.Println(string(body))

}
```

```ruby Create with start date and quantity
require 'uri'
require 'net/http'

url = URI("https://api.prolifi.co/api/v1/public/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_id\": \"d290f1ee-6c54-4b01-90e6-d701748f0851\",\n  \"plan_id\": \"a1b2c3d4-5678-90ab-cdef-1234567890ab\",\n  \"billing_cycle\": \"yearly\",\n  \"start_date\": \"2026-04-01\",\n  \"quantity\": 5\n}"

response = http.request(request)
puts response.read_body
```

```java Create with start date and quantity
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.prolifi.co/api/v1/public/subscriptions")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"customer_id\": \"d290f1ee-6c54-4b01-90e6-d701748f0851\",\n  \"plan_id\": \"a1b2c3d4-5678-90ab-cdef-1234567890ab\",\n  \"billing_cycle\": \"yearly\",\n  \"start_date\": \"2026-04-01\",\n  \"quantity\": 5\n}")
  .asString();
```

```php Create with start date and quantity
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.prolifi.co/api/v1/public/subscriptions', [
  'body' => '{
  "customer_id": "d290f1ee-6c54-4b01-90e6-d701748f0851",
  "plan_id": "a1b2c3d4-5678-90ab-cdef-1234567890ab",
  "billing_cycle": "yearly",
  "start_date": "2026-04-01",
  "quantity": 5
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Create with start date and quantity
using RestSharp;

var client = new RestClient("https://api.prolifi.co/api/v1/public/subscriptions");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"customer_id\": \"d290f1ee-6c54-4b01-90e6-d701748f0851\",\n  \"plan_id\": \"a1b2c3d4-5678-90ab-cdef-1234567890ab\",\n  \"billing_cycle\": \"yearly\",\n  \"start_date\": \"2026-04-01\",\n  \"quantity\": 5\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Create with start date and quantity
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "customer_id": "d290f1ee-6c54-4b01-90e6-d701748f0851",
  "plan_id": "a1b2c3d4-5678-90ab-cdef-1234567890ab",
  "billing_cycle": "yearly",
  "start_date": "2026-04-01",
  "quantity": 5
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.prolifi.co/api/v1/public/subscriptions")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

```python
import requests

url = "https://api.prolifi.co/api/v1/public/subscriptions"

payload = {
    "customer_id": "d290f1ee-6c54-4b01-90e6-d701748f0851",
    "plan_id": "a1b2c3d4-5678-90ab-cdef-1234567890ab",
    "billing_cycle": "monthly"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript
const url = 'https://api.prolifi.co/api/v1/public/subscriptions';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"customer_id":"d290f1ee-6c54-4b01-90e6-d701748f0851","plan_id":"a1b2c3d4-5678-90ab-cdef-1234567890ab","billing_cycle":"monthly"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.prolifi.co/api/v1/public/subscriptions"

	payload := strings.NewReader("{\n  \"customer_id\": \"d290f1ee-6c54-4b01-90e6-d701748f0851\",\n  \"plan_id\": \"a1b2c3d4-5678-90ab-cdef-1234567890ab\",\n  \"billing_cycle\": \"monthly\"\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(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.prolifi.co/api/v1/public/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_id\": \"d290f1ee-6c54-4b01-90e6-d701748f0851\",\n  \"plan_id\": \"a1b2c3d4-5678-90ab-cdef-1234567890ab\",\n  \"billing_cycle\": \"monthly\"\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.prolifi.co/api/v1/public/subscriptions")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"customer_id\": \"d290f1ee-6c54-4b01-90e6-d701748f0851\",\n  \"plan_id\": \"a1b2c3d4-5678-90ab-cdef-1234567890ab\",\n  \"billing_cycle\": \"monthly\"\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.prolifi.co/api/v1/public/subscriptions', [
  'body' => '{
  "customer_id": "d290f1ee-6c54-4b01-90e6-d701748f0851",
  "plan_id": "a1b2c3d4-5678-90ab-cdef-1234567890ab",
  "billing_cycle": "monthly"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.prolifi.co/api/v1/public/subscriptions");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"customer_id\": \"d290f1ee-6c54-4b01-90e6-d701748f0851\",\n  \"plan_id\": \"a1b2c3d4-5678-90ab-cdef-1234567890ab\",\n  \"billing_cycle\": \"monthly\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "customer_id": "d290f1ee-6c54-4b01-90e6-d701748f0851",
  "plan_id": "a1b2c3d4-5678-90ab-cdef-1234567890ab",
  "billing_cycle": "monthly"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.prolifi.co/api/v1/public/subscriptions")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```