Create a subscription

The method allows you to connect a subscription

Create a subscription

post
Header parameters
x-api-public-keystringOptional

Public API-key

x-api-signaturestringOptional

Signing the request body with a private API-key

Content-typestringOptional

Request content type

Example: application/json
Body

Subscription request body

merchantIdstringRequired

Merchant ID in the system

Example: 3ef22c52-c364-4acd-941d-5940f647a4f1
billingLinkIdstringRequired

Payment link identifier (coins will be debited from the linked address)

Example: c7358087-4e45-44b7-8de2-427621f2eaf4
titlestringRequired

Subscription name

Example: Premium
descriptionstringOptional

Subscription Description

Example: Premium subscription. With premium subscription u can use premium functions
spendIntervalintegerRequired

Write-off period in minutes. For convenience, you can specify: -1 - daily write-off; -2 - weekly write-off; -3 - monthly write-off;

Example: -1
currencystringRequired

Payment currency. You can specify a fiat currency or any other, the amount will be automatically converted to the currency of the payment link

Example: USD
amountstringRequired

Payment amount in the specified currency

Example: 7.99
webhookUrlstringOptional

Subscription charge notification URL

Example: https://merchant.domain/webhooks/subscription
Responses
200Success
application/json
post
POST /api-gateway/recurrents/create-subscription HTTP/1.1
Host: ocp.onchainpay.io
Content-Type: application/json
Accept: */*
Content-Length: 333

{
  "merchantId": "3ef22c52-c364-4acd-941d-5940f647a4f1",
  "billingLinkId": "c7358087-4e45-44b7-8de2-427621f2eaf4",
  "title": "Premium",
  "description": "Premium subscription. With premium subscription u can use premium functions",
  "spendInterval": "-1",
  "currency": "USD",
  "amount": "7.99",
  "webhookUrl": "https://merchant.domain/webhooks/subscription"
}
200Success
{
  "success": true,
  "response": {
    "id": "0b619a42-c48c-48ba-bd7d-21645eca9c68",
    "merchantId": "3ef22c52-c364-4acd-941d-5940f647a4f1",
    "billingLinkId": "c7358087-4e45-44b7-8de2-427621f2eaf4",
    "title": "Premium",
    "description": "Premium subscription. With premium subscription u can use premium functions",
    "spendInterval": "-1",
    "status": "PENDING",
    "message": null,
    "currency": "USD",
    "amount": "7.99",
    "webhookUrl": "https://merchant.domain/webhooks/subscription",
    "createdAt": "2025-06-09T11:38:26.574Z",
    "updatedAt": "2025-06-09T11:38:26.574Z"
  }
}

Last updated