# Create a subscription

See https://docs.simpay.pl/payment/blik-recurrent for more information.

Endpoint: POST /payment/{serviceId}/blik/subscriptions
Version: 1.0.0
Security: bearerAuth

## Security:

  - `bearerAuth` (unknown)
    http bearer scopes: payment.transactions

## Path parameters:

  - `serviceId` (string, required)

## Header parameters:

  - `x-sim-flow-submerchant` (string)
    **Applies only to SimPay Flow integrators.** If you do not use SimPay Flow - skip this header.
Indicates the submerchant on whose behalf the request is made. The value is the submerchant ID (`flsm_...`)
or its `customId` assigned during registration (max. 36 characters).
**When is the header required?**
When `serviceId` in the path is an Online Payments service **linked to your active Flow service**
(the parent service, visible as `paymentService` in `GET /flow/{flowServiceId}`).
In that case every request to `/payment/{serviceId}/...` must include this header - without it you will receive
`422` with the `SIMPAY_FLOW_VALIDATION_ERROR` code.
For regular Online Payments services (not linked to Flow) the header is ignored.
**How does it work?**
- In the path you always pass the
`serviceId`
 of the
**parent service**
 (linked to the Flow service), not the submerchant's service.
- The request is executed in the context of the submerchant's Online Payments service - transactions, refunds, channels, subscriptions

and BLIK aliases belong to the given submerchant, and funds go to its wallet.
- Submerchant Online Payments services cannot be used directly - passing their ID as
`serviceId`

returns
`422`
 (
`VALIDATION_ERROR`
).

**Possible errors:**
- `422`

`SIMPAY_FLOW_VALIDATION_ERROR`
 - missing header for a service linked to Flow or an invalid value,
- `404`

`FLOW_SUBMERCHANT_NOT_FOUND`
 - the submerchant does not exist within this Flow service,
- `403`

`FLOW_SUBMERCHANT_NOT_ACTIVE`
 - the submerchant has not completed onboarding or is not active,
- `400`

`FLOW_SUBMERCHANT_PAYMENT_SERVICE_NOT_FOUND`
 /
`FLOW_SUBMERCHANT_PAYMENT_SERVICE_NOT_ACTIVE`
 - the submerchant's Online Payments service does not exist or is not active.

**Example:** `x-sim-flow-submerchant: flsm_aaaabbbb` or `x-sim-flow-submerchant: user-123`

## Request fields (application/json):

  - `transactionId` (string, required)
    Transaction ID

  - `ticket` (object, required)
    BLIK code object
    Example: {"T6":"462755"}

  - `ticket.T6` (string, required)
    6-digit BLIK code

  - `alias` (object, required)
    BLIK alias information
    Example: {"value":"AAABBCC","type":"PAYID","label":"Payment for premium plan in aaa service"}

  - `alias.value` (string, required)
    Alias value (e.g., subscription ID)

  - `alias.type` (string, required)
    Alias type (for subscriptions - PAYID)
    Enum: "PAYID"

  - `alias.label` (string)
    Label visible in the payer's banking app

  - `options` (any, required)

  - `options.model` (string, required)
    Enum: "A"

  - `options.expiresAt` (string, required)
    Alias expiration date, max +10 years

  - `options.frequency` (string, required)
    Subscription frequency

  - `options.amountLimitPerTransaction` (number, required)
    Transaction amount limit per single transaction

  - `options.initiationDate` (string, required)
    Date of the first allowed recurring payment

  - `options.amountLimitTotal` (number, required)
    Total subscription amount limit

  - `options.transactionsCountLimit` (number)
    Quantity limit of recurring payments under one alias

  - `options.model` (string, required)
    Enum: "O"

  - `options.model` (string, required)
    Enum: "M"

  - `descriptions` (object)
    Additional descriptions passed to the payer's bank

  - `descriptions.line1` (string)
    Line no. 1

  - `descriptions.line2` (string)
    Line no. 2

  - `descriptions.line3` (string)
    Line no. 3

## Request examples:

  - `Model A` (unknown)

  - `Model O` (unknown)

  - `Model M` (unknown)

## Response 201:

  - `201` (unknown)
    Subscription and alias created

## Response 201 fields (application/json):

  - `success` (boolean, required)
    Request status

  - `data` (object, required)
    Example: {"subscriptionId":"019970c6-3d3e-708c-9313-5f89e251e2c0","aliasId":"019970c6-3ce8-71e7-8214-20fd635532fb"}

  - `data.subscriptionId` (string, required)
    Subscription ID

  - `data.aliasId` (string, required)
    Alias ID

## Response 400:

  - `400` (unknown)
    Invalid BLIK code or similar error

## Response 400 fields (application/json):

  - `success` (boolean, required)
    Request status

  - `errorCode` (string, required)
    Error code

  - `message` (string, required)
    Error message

## Response 401:

  - `401` (unknown)
    Unauthorized

## Response 401 fields (application/json):

  - `feedbackUrl` (string)
    URL for reporting API problems (`POST /feedback`). Returned for authenticated API keys.
    Example: https://api.simpay.pl/feedback

  - `success` (boolean, required)
    Request status

  - `errorCode` (string, required)
    Error status code
    Enum: "UNAUTHORIZED"

## Response 403:

  - `403` (unknown)
    Forbidden

## Response 403 fields (application/json):

  - `feedbackUrl` (string)
    URL for reporting API problems (`POST /feedback`). Returned for authenticated API keys.
    Example: https://api.simpay.pl/feedback

  - `success` (boolean, required)
    Request status

  - `errorCode` (string, required)
    Error status code
    Enum: "INVALID_ABILITY_PROVIDED", "IP_ADDRESS_NOT_WHITELISTED"

## Response 404:

  - `404` (unknown)
    NotFound

## Response 404 fields (application/json):

  - `success` (boolean, required)
    Request status

  - `errorCode` (string, required)
    Error status code
    Enum: "SERVICE_NOT_FOUND", "TRANSACTION_NOT_FOUND", "ROUTE_NOT_FOUND"

## Response 409:

  - `409` (unknown)
    Alias already exists

## Response 409 fields (application/json):

  - `success` (boolean, required)
    Request status

  - `errorCode` (string, required)
    Error code

  - `message` (string, required)
    Error message

## Response 422:

  - `422` (unknown)
    Unprocessable Content

## Response 422 fields (application/json):

  - `feedbackUrl` (string)
    URL for reporting API problems (`POST /feedback`). Returned for authenticated API keys.
    Example: https://api.simpay.pl/feedback

  - `success` (boolean, required)
    Request status

  - `errorCode` (string, required)
    Error status code
    Enum: "VALIDATION_ERROR"

  - `errors` (object, required)

  - `errors.amount` (array)

