
## Create a payment

`POST /v1/payments`

Registers a new payment for an existing order. The request body is flat, without a `fields` wrapper.

## Request fields (body)

| Parameter | Type | Required | Description |
|----------|-----|:-----:|---------|
| `orderId` | number | yes | Order ID. Source: [`GET /v1/orders`](../orders/list.md) |
| `paySystemId` | number | yes | Payment system ID. Each Bitrix24 account has its own set of systems. Available IDs are returned by [GET /v1/pay-systems](/docs/entities/pay-systems/list) |
| `sum` | number | no | Payment amount. If omitted, Bitrix24 uses the outstanding order amount |
| `currency` | string | no | Payment currency. Inherited from the order: if the field is provided and differs from the order currency, the request is rejected with `409 CURRENCY_MISMATCH`. List: [`GET /v1/currencies`](/docs/entities/currencies) |
| `paid` | boolean | no | Whether the payment is marked as received. Defaults to `false` |
| `datePaid` | datetime | no | Date the payment was marked as received (in ISO 8601 format) |
| `dateBill` | datetime | no | Invoice issue date |
| `datePayBefore` | datetime | no | Payment due date. Responses return only the date — the time is always midnight in the Bitrix24 account time zone |
| `responsibleId` | number | no | Responsible employee. Source: [`GET /v1/users`](/docs/entities/users) |
| `comments` | string | no | Payment comment |
| `xmlId` | string | no | External ID (for example, the payment gateway transaction ID) |

## Examples

### curl — personal key

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/payments" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "orderId": 19,
    "paySystemId": 11,
    "sum": 1500,
    "currency": "USD",
    "paid": true,
    "comments": "Payment through a payment gateway",
    "xmlId": "txn_abc123"
  }'
```

### curl — OAuth application

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/payments" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "orderId": 19,
    "paySystemId": 11,
    "sum": 1500,
    "currency": "USD",
    "paid": true,
    "comments": "Payment through a payment gateway",
    "xmlId": "txn_abc123"
  }'
```

### JavaScript — personal key

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/payments', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    orderId: 19,
    paySystemId: 11,
    sum: 1500,
    currency: 'USD',
    paid: true,
    comments: 'Payment through a payment gateway',
    xmlId: 'txn_abc123',
  }),
})

const { success, data } = await res.json()
console.log('Payment ID:', data.id)
```

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/payments', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    orderId: 19,
    paySystemId: 11,
    sum: 1500,
    currency: 'USD',
    paid: true,
    comments: 'Payment through a payment gateway',
    xmlId: 'txn_abc123',
  }),
})

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

## Response fields

| Field | Type | Description |
|------|-----|---------|
| `success` | boolean | Always `true` on success |
| `data` | object | Created payment with all fields. Object structure — [Payment fields](./fields.md) |

## Response example

```json
{
  "success": true,
  "data": {
    "id": 217,
    "accountNumber": "98/2",
    "orderId": 19,
    "paySystemId": 11,
    "paySystemName": "Cash",
    "sum": 1500,
    "currency": "USD",
    "paid": true,
    "datePaid": "2026-05-13T11:50:24.000Z",
    "dateBill": "2026-05-13T11:50:24.000Z",
    "responsibleId": 1,
    "comments": "Payment through a payment gateway",
    "xmlId": "txn_abc123",
    "isReturn": "N",
    "marked": false
  }
}
```

## Error response example

409 — the payment currency does not match the order currency:

```json
{
  "success": false,
  "error": {
    "code": "CURRENCY_MISMATCH",
    "message": "Payment currency \"USD\" does not match order 19, which is in \"EUR\"."
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|---------|
| 409 | `CURRENCY_MISMATCH` | The provided `currency` does not match the currency of order `orderId` |
| 422 | `BITRIX_ERROR` | Required fields are missing — the message lists them (`Required fields: orderId, paySystemId`) |
| 422 | `BITRIX_ERROR` | The `orderId` or `paySystemId` does not exist |
| 403 | `SCOPE_DENIED` | The API key does not have the `sale` scope |
| 401 | `TOKEN_MISSING` | The API key has no configured tokens |

For the full list of common API errors, see [Errors](/docs/errors).

## Known specifics

**The currency comes from the order.** The payment is stored in the order currency. If the provided currency does not match the order currency, the request is rejected with `409 CURRENCY_MISMATCH`. To inherit the order currency, omit the `currency` field. The order currency is returned by [`GET /v1/orders/:id`](../orders/get.md).

**The payment number is generated automatically.** Bitrix24 assigns the `accountNumber` field on creation in the `<orderAccount>/<seq>` format (for example, `19/1`), and it cannot be provided in the request.

**Multiple payments per order.** An order can have several payments — for example, a partial advance payment and a balance payment on delivery. Each is registered with a separate `POST /v1/payments` using the same `orderId` and different `paySystemId` or `sum` values.

**The order status is not updated automatically.** After a payment is registered, the order status (`orders.payed`, `orders.statusId`) remains unchanged — update it with a separate [`PATCH /v1/orders/:id`](../orders/update.md) call.

## See also

- [Payment fields](./fields.md)
- [List payments](./list.md)
- [Get a payment](./get.md)
- [Update a payment](./update.md)
- [Update an order](../orders/update.md)
- [Batch](/docs/batch)
- [Limits and optimization](/docs/optimization)
