## Create a pay system

`POST /v1/pay-systems`

Creates a pay system using a registered REST handler. Send the fields directly in the JSON body, without a `fields` wrapper.

## Request body fields

|Field|Type|Required|Description|
|---|---|---|---|
|`name`|string|yes|Pay system name. Must not be empty.|
|`personTypeId`|integer|yes|Payer type ID from [`GET /v1/person-types`](/docs/entities/person-types/list). Must belong to the registry specified in `entityRegistryType`.|
|`bxRestHandler`|string|yes|Handler code from the `code` field returned by [`GET /v1/pay-systems/handlers`](/docs/entities/pay-systems/handlers). The handler must already be registered.|
|`description`|string|no|Pay system description.|
|`active`|string|no|Activity flag: `Y` for active, `N` for inactive.|
|`newWindow`|string|no|Open the payment page in a new window: `Y` or `N`.|
|`xmlId`|string|no|External ID.|
|`logo`|array|no|Logo as `[filename, base64]`. Decoded file size must not exceed 2 MiB.|
|`settings`|object \| array|no|Handler settings with the original business keys. Each entry must be an object or array using `TYPE` and `VALUE`.|
|`entityRegistryType`|string|no|Registry: `ORDER`, `CRM_INVOICE` or `CRM_QUOTE`. Use `ORDER` for orders.|

Send a nonempty JSON object. Fields outside the table are rejected.

## Examples

### curl — personal key

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/pay-systems" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Invoice payment",
    "personTypeId": 5,
    "bxRestHandler": "my_payment_handler",
    "entityRegistryType": "ORDER",
    "active": "N",
    "xmlId": "invoice-20261014"
  }'
```

### curl — OAuth application

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/pay-systems" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Invoice payment",
    "personTypeId": 5,
    "bxRestHandler": "my_payment_handler",
    "entityRegistryType": "ORDER",
    "active": "N",
    "xmlId": "invoice-20261014"
  }'
```

### JavaScript — personal key

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/pay-systems', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "name": "Invoice payment",
    "personTypeId": 5,
    "bxRestHandler": "my_payment_handler",
    "entityRegistryType": "ORDER",
    "active": "N",
    "xmlId": "invoice-20261014"
  }),
})

const { success, data } = await res.json()
```

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/pay-systems', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "name": "Invoice payment",
    "personTypeId": 5,
    "bxRestHandler": "my_payment_handler",
    "entityRegistryType": "ORDER",
    "active": "N",
    "xmlId": "invoice-20261014"
  }),
})

const { success, data } = await res.json()
```

## Response fields

HTTP 201. Returns the created pay system.

|Field|Type|Description|
|---|---|---|
|`success`|boolean|Always `true` on success.|
|`data`|object|Created pay system. Full field reference: [Pay system fields](/docs/entities/pay-systems/fields).|

## Response example

Main fields are shown. Full field reference: [Pay system fields](/docs/entities/pay-systems/fields).

```json
{
  "success": true,
  "data": {
    "id": 41,
    "name": "Invoice payment",
    "actionFile": "my_payment_handler",
    "newWindow": "N",
    "active": "N",
    "entityRegistryType": "ORDER",
    "personTypeId": 5,
    "xmlId": "invoice-20261014"
  }
}
```

## Error response example

400 — the request body contains the unsupported field `unexpected`:

```json
{
  "success": false,
  "error": {
    "code": "READONLY_FIELD",
    "message": "Field 'unexpected' is not writable for this operation"
  }
}
```

## Errors

|HTTP|Code|Description|
|---|---|---|
|400|`INVALID_PARAMS`|A field has an invalid type, the logo has an invalid format, or a settings entry is not an object or array.|
|400|`MISSING_REQUIRED_FIELDS`|The JSON body is empty, a required field is missing, or `name` is empty.|
|400|`READONLY_FIELD`|The body contains a field not supported by this operation.|
|413|`PAYLOAD_TOO_LARGE`|The decoded logo exceeds 2 MiB or the JSON body exceeds 3 MiB.|
|404|`ENTITY_NOT_FOUND`|The created pay system was not found during the subsequent read.|
|403|`BITRIX_ACCESS_DENIED`|Access to the create operation is denied.|
|422|`BITRIX_ERROR`|A business error occurred. Details are in `error.message`.|
|502|`BITRIX_RESPONSE_INVALID`|The response to the operation or subsequent read has an invalid structure.|
|403|`SCOPE_DENIED`|The API key lacks the `pay_system` scope.|
|403|`WRITE_BLOCKED_READONLY_KEY`|The key is restricted to read operations.|
|401|`TOKEN_MISSING`|The key has no configured Bitrix24 credentials.|

For common API errors, see [Error codes](/docs/errors).

## See also

- [List pay systems](/docs/entities/pay-systems/list)
- [Get a pay system](/docs/entities/pay-systems/get)
- [Update a pay system](/docs/entities/pay-systems/update)
- [Delete a pay system](/docs/entities/pay-systems/delete)
- [Pay system handlers](/docs/entities/pay-systems/handlers)
- [Pay systems](/docs/entities/pay-systems)
