> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://dev.admoji.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://dev.admoji.com/_mcp/server.

# Import subscription

POST https://openapi.admoji.com/api/v2/open/subscriptions
Content-Type: application/json

Import an active subscription into the CRM. Idempotent by `ExternalSubscriptionId`. If both `VaultToken` and `ProcessorId` are provided, a payment method is created and linked.


Reference: https://dev.admoji.com/api-reference/admoji-crm-api/subscriptions/import-subscription

## Authentication

- `Authorization` header (required) — Format: `ApiKey <your_key>`

## Servers

- `https://openapi.admoji.com` (Live, default)
- `https://openapi.staging.admoji.com` (Test)

## Request

### Headers

- `Idempotency-Key` (string, required) — UUID to prevent duplicate POST operations

### Body (application/json)

This endpoint expects an object.

- `CustomerId` (integer, required)
- `ProductId` (integer, required)
- `Amount` (double, required)
- `BillingIntervalDays` (integer, required) — Days between charges
- `NextChargeDate` (datetime, required)
- `SiteId` (integer, optional)
- `TotalCycles` (integer, optional, default: 0) — Total charges to run. 0 = unlimited
- `ProcessorId` (integer, optional)
- `VaultToken` (string, optional) — Gateway vault token (NMI CustomerVaultID, Stripe cus_xxx, etc.)
- `ExternalSubscriptionId` (string, optional) — External subscription ID for idempotency

## Response

### 200

Subscription imported

- `Status` (integer, optional)
- `SubscriptionId` (integer, optional)

## Examples

**Request**

```json
{
  "CustomerId": 8563080,
  "ProductId": 11622,
  "Amount": 29.99,
  "BillingIntervalDays": 30,
  "NextChargeDate": "2026-06-15T00:00:00Z",
  "TotalCycles": 0,
  "ProcessorId": 1234,
  "VaultToken": "cus_ABC123xyz",
  "ExternalSubscriptionId": "WC-5678"
}
```

**Response**

```json
{
  "Status": 0,
  "SubscriptionId": 961111
}
```

**SDK Code**

```python Subscriptions_importSubscription_example
import requests

url = "https://openapi.admoji.com/api/v2/open/subscriptions"

payload = {
    "CustomerId": 8563080,
    "ProductId": 11622,
    "Amount": 29.99,
    "BillingIntervalDays": 30,
    "NextChargeDate": "2026-06-15T00:00:00Z",
    "TotalCycles": 0,
    "ProcessorId": 1234,
    "VaultToken": "cus_ABC123xyz",
    "ExternalSubscriptionId": "WC-5678"
}
headers = {
    "Idempotency-Key": "Idempotency-Key",
    "Authorization": "<apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Subscriptions_importSubscription_example
const url = 'https://openapi.admoji.com/api/v2/open/subscriptions';
const options = {
  method: 'POST',
  headers: {
    'Idempotency-Key': 'Idempotency-Key',
    Authorization: '<apiKey>',
    'Content-Type': 'application/json'
  },
  body: '{"CustomerId":8563080,"ProductId":11622,"Amount":29.99,"BillingIntervalDays":30,"NextChargeDate":"2026-06-15T00:00:00Z","TotalCycles":0,"ProcessorId":1234,"VaultToken":"cus_ABC123xyz","ExternalSubscriptionId":"WC-5678"}'
};

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

```go Subscriptions_importSubscription_example
package main

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

func main() {

	url := "https://openapi.admoji.com/api/v2/open/subscriptions"

	payload := strings.NewReader("{\n  \"CustomerId\": 8563080,\n  \"ProductId\": 11622,\n  \"Amount\": 29.99,\n  \"BillingIntervalDays\": 30,\n  \"NextChargeDate\": \"2026-06-15T00:00:00Z\",\n  \"TotalCycles\": 0,\n  \"ProcessorId\": 1234,\n  \"VaultToken\": \"cus_ABC123xyz\",\n  \"ExternalSubscriptionId\": \"WC-5678\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Idempotency-Key", "Idempotency-Key")
	req.Header.Add("Authorization", "<apiKey>")
	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 Subscriptions_importSubscription_example
require 'uri'
require 'net/http'

url = URI("https://openapi.admoji.com/api/v2/open/subscriptions")

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

request = Net::HTTP::Post.new(url)
request["Idempotency-Key"] = 'Idempotency-Key'
request["Authorization"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"CustomerId\": 8563080,\n  \"ProductId\": 11622,\n  \"Amount\": 29.99,\n  \"BillingIntervalDays\": 30,\n  \"NextChargeDate\": \"2026-06-15T00:00:00Z\",\n  \"TotalCycles\": 0,\n  \"ProcessorId\": 1234,\n  \"VaultToken\": \"cus_ABC123xyz\",\n  \"ExternalSubscriptionId\": \"WC-5678\"\n}"

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

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

HttpResponse<String> response = Unirest.post("https://openapi.admoji.com/api/v2/open/subscriptions")
  .header("Idempotency-Key", "Idempotency-Key")
  .header("Authorization", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"CustomerId\": 8563080,\n  \"ProductId\": 11622,\n  \"Amount\": 29.99,\n  \"BillingIntervalDays\": 30,\n  \"NextChargeDate\": \"2026-06-15T00:00:00Z\",\n  \"TotalCycles\": 0,\n  \"ProcessorId\": 1234,\n  \"VaultToken\": \"cus_ABC123xyz\",\n  \"ExternalSubscriptionId\": \"WC-5678\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://openapi.admoji.com/api/v2/open/subscriptions', [
  'body' => '{
  "CustomerId": 8563080,
  "ProductId": 11622,
  "Amount": 29.99,
  "BillingIntervalDays": 30,
  "NextChargeDate": "2026-06-15T00:00:00Z",
  "TotalCycles": 0,
  "ProcessorId": 1234,
  "VaultToken": "cus_ABC123xyz",
  "ExternalSubscriptionId": "WC-5678"
}',
  'headers' => [
    'Authorization' => '<apiKey>',
    'Content-Type' => 'application/json',
    'Idempotency-Key' => 'Idempotency-Key',
  ],
]);

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

```csharp Subscriptions_importSubscription_example
using RestSharp;

var client = new RestClient("https://openapi.admoji.com/api/v2/open/subscriptions");
var request = new RestRequest(Method.POST);
request.AddHeader("Idempotency-Key", "Idempotency-Key");
request.AddHeader("Authorization", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"CustomerId\": 8563080,\n  \"ProductId\": 11622,\n  \"Amount\": 29.99,\n  \"BillingIntervalDays\": 30,\n  \"NextChargeDate\": \"2026-06-15T00:00:00Z\",\n  \"TotalCycles\": 0,\n  \"ProcessorId\": 1234,\n  \"VaultToken\": \"cus_ABC123xyz\",\n  \"ExternalSubscriptionId\": \"WC-5678\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Subscriptions_importSubscription_example
import Foundation

let headers = [
  "Idempotency-Key": "Idempotency-Key",
  "Authorization": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "CustomerId": 8563080,
  "ProductId": 11622,
  "Amount": 29.99,
  "BillingIntervalDays": 30,
  "NextChargeDate": "2026-06-15T00:00:00Z",
  "TotalCycles": 0,
  "ProcessorId": 1234,
  "VaultToken": "cus_ABC123xyz",
  "ExternalSubscriptionId": "WC-5678"
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://openapi.admoji.com/api/v2/open/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()
```