# Создать подписку

## OpenAPI Specification

```yaml
openapi: 3.0.1
info:
  title: ''
  description: ''
  version: 1.0.0
paths:
  /transaction/process:
    post:
      summary: Создать подписку
      deprecated: false
      description: >-
        Подписка — это регулярное автосписание с плательщика через СБП. Вы один
        раз создаёте подписку и отправляете плательщика на нашу платёжную форму;
        дальше привязку, активацию и все списания делаем мы, а вам приходят
        callback'и. Баланс пополняется по каждому успешному списанию.


        Плательщик на платёжной форме вводит email, подтверждает привязку счёта
        в своём банке (СБП/НСПК) — подписка становится Active. Дальше мы
        автоматически списываем amount каждый период. Вам ничего вызывать не
        нужно.


        Денежная транзакция на этом шаге не создаётся — транзакции появляются
        позже, по каждому списанию.
      operationId: createSubscription
      tags:
        - Платежи/Рекуррентные СБП-подписки
        - Payments
      parameters:
        - name: X-MerchantId
          in: header
          description: ''
          required: true
          example: ''
          schema:
            type: string
        - name: X-Secret
          in: header
          description: ''
          required: true
          example: ''
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                paymentMethod:
                  type: integer
                  description: Всегда 6 (число, не строка)
                  x-apidog-mock: '6'
                paymentDetails:
                  type: object
                  properties:
                    amount:
                      type: integer
                      description: Сумма одного регулярного списания
                    currency:
                      type: string
                      x-apidog-mock: '"RUB"'
                      description: '"RUB"'
                    interval:
                      description: >-
                        Период списаний: 1 — день, 2 — неделя, 3 — месяц, 4 —
                        год
                      $ref: '#/components/schemas/SubscriptionInterval'
                    intervalCount:
                      type: integer
                      description: >-
                        Лимит зависит от interval: день до 31, неделя до 4,
                        месяц до 12, год до 3
                  required:
                    - amount
                    - currency
                    - interval
                    - intervalCount
                  x-apidog-orders:
                    - amount
                    - currency
                    - interval
                    - intervalCount
                  x-apidog-ignore-properties: []
                description:
                  type: string
                  description: >-
                    Показывается плательщику на платёжной форме и в
                    email-уведомлениях
              required:
                - paymentMethod
                - paymentDetails
                - description
              x-apidog-orders:
                - paymentMethod
                - paymentDetails
                - description
              x-apidog-ignore-properties: []
            examples:
              sub_qr:
                value:
                  paymentMethod: 6
                  paymentDetails:
                    amount: 500
                    currency: RUB
                    interval: 3
                    intervalCount: 1
                  description: Premium подписка
                summary: Подписка
      responses:
        '200':
          description: Успешно создано
          content:
            application/json:
              schema:
                type: object
                properties:
                  paymentMethod:
                    type: string
                  transactionId:
                    type: string
                    description: >-
                      transactionId здесь — это ID подписки (subscriptionId).
                      Сохраните его: по нему приходят callback'и и работают все
                      ручки ниже
                  redirect:
                    type: string
                    description: >-
                      Плательщика нужно отправить на redirect сразу: на
                      подтверждение привязки даётся 30 минут, после чего
                      подписка переходит в Failed.
                  status:
                    type: string
                  merchantId:
                    type: string
                required:
                  - paymentMethod
                  - transactionId
                  - redirect
                  - status
                  - merchantId
                x-apidog-orders:
                  - paymentMethod
                  - transactionId
                  - redirect
                  - status
                  - merchantId
                x-apidog-ignore-properties: []
              example:
                paymentMethod: Subscription
                transactionId: 11111111-1111-1111-1111-111111111111
                redirect: https://pay.platega.io/subscription/11111111-...
                status: PENDING
                merchantId: 22222222-2222-2222-2222-222222222222
          headers: {}
          x-apidog-name: ''
        '400':
          description: Ошибка валидации запроса
          headers: {}
          x-apidog-name: ''
        '401':
          description: Ошибка аутентификации (проверьте X-MerchantId / X-Secret)
          headers: {}
          x-apidog-name: ''
      security: []
      x-apidog-folder: Платежи/Рекуррентные СБП-подписки
      x-apidog-status: released
      x-run-in-apidog: https://app.apidog.com/web/project/1213537/apis/api-40029698-run
components:
  schemas:
    SubscriptionInterval:
      type: string
      description: Интервал оплаты подписки
      enum:
        - '1'
        - '2'
        - '3'
        - '4'
      x-apidog-enum:
        - value: '1'
          name: ''
          description: ''
        - value: '2'
          name: ''
          description: ''
        - value: '3'
          name: ''
          description: 30 дней
        - value: '4'
          name: ''
          description: ''
      x-apidog-folder: ''
  securitySchemes:
    MerchantIdAuth:
      type: apikey
      in: header
      name: X-MerchantId
      description: Ваш MerchantId (UUID)
    SecretAuth:
      type: apikey
      in: header
      name: X-Secret
      description: Ваш API ключ
    Combination:
      group:
        - id: 482006
        - id: 482007
      type: customize
    bearer:
      type: bearer
      scheme: bearer
servers: []
security: []

```
