## Update a pay system

`PATCH /v1/pay-systems/:id`

Updates selected fields of a pay system. Send the fields directly in the JSON body, without a `fields` wrapper.

## Parameters

|Parameter|Type|Required|Description|
|---|---|---|---|
|`id` (path)|integer|yes|Positive integer ID of the pay system. Source: [`GET /v1/pay-systems`](/docs/entities/pay-systems/list).|

## Request body fields

|Field|Type|Required|Description|
|---|---|---|---|
|`name`|string|no|New pay system name. Must not be empty.|
|`personTypeId`|integer|no|Payer type ID from [`GET /v1/person-types`](/docs/entities/person-types/list). Must belong to the pay system's registry.|
|`bxRestHandler`|string|no|Handler code from the `code` field returned by [`GET /v1/pay-systems/handlers`](/docs/entities/pay-systems/handlers).|
|`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.|

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

## Examples

### curl — personal key

```bash
curl -X PATCH "https://vibecode.bitrix24.com/v1/pay-systems/41" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Business invoice payment"
  }'
```

### curl — OAuth application

```bash
curl -X PATCH "https://vibecode.bitrix24.com/v1/pay-systems/41" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Business invoice payment"
  }'
```

### JavaScript — personal key

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/pay-systems/41', {
  method: 'PATCH',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "name": "Business invoice payment"
  }),
})

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

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/pay-systems/41', {
  method: 'PATCH',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "name": "Business invoice payment"
  }),
})

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

## Response fields

HTTP 200. Returns the updated pay system.

|Field|Type|Description|
|---|---|---|
|`success`|boolean|Always `true` on success.|
|`data`|object|Updated 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": "Business 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`|`id` is not a positive integer, a field has an invalid type, or the logo has an invalid format.|
|400|`MISSING_REQUIRED_FIELDS`|The JSON body is empty 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 pay system was not found during the update or subsequent read.|
|403|`BITRIX_ACCESS_DENIED`|Insufficient permissions, a built-in pay system, or the OAuth application does not own the handler.|
|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)
- [Create a pay system](/docs/entities/pay-systems/create)
- [Delete a pay system](/docs/entities/pay-systems/delete)
- [Pay system handlers](/docs/entities/pay-systems/handlers)
- [Pay systems](/docs/entities/pay-systems)
