[{"data":1,"prerenderedAt":7},["ShallowReactive",2],{"docs-entities\u002Fcrm-payments\u002Fcreate":3,"docs-tabs-entities\u002Fcrm-payments\u002Fcreate":6},{"content":4,"lastmod":5},"\n## Create a CRM payment\n\n`POST \u002Fv1\u002Fcrm-payments`\n\nCreates an empty payment for a CRM item, such as a deal: no line items, a zero amount and no \"paid\" mark.\n\nProducts are added to the payment in the next step, as [payment line items](\u002Fdocs\u002Fentities\u002Fcrm-payments\u002Fproducts-add). Fields are passed flat at the JSON root, without a `fields` wrapper.\n\n## Request fields (body)\n\n| Field | Type | Required | Description |\n|------|-----|:-----:|---------|\n| `entityTypeId` | number | yes | CRM item type. For a deal, `2` |\n| `entityId` | number | yes | CRM item ID. For a deal, the ID from [`GET \u002Fv1\u002Fdeals`](\u002Fdocs\u002Fentities\u002Fdeals\u002Flist) |\n| `paySystemId` | number | no | Payment system ID, a non-negative integer. List: [`GET \u002Fv1\u002Fpay-systems`](\u002Fdocs\u002Fentities\u002Fpay-systems\u002Flist). If omitted or `0`, a payment system is assigned automatically and its ID is returned in the response |\n\nThe amount and the paid mark cannot be set at creation.\n\n## Examples\n\n### curl — personal key\n\n```bash\ncurl -X POST \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fcrm-payments\" \\\n  -H \"X-Api-Key: YOUR_API_KEY\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{ \"entityTypeId\": 2, \"entityId\": 8761, \"paySystemId\": 1 }'\n```\n\n### curl — OAuth application\n\n```bash\ncurl -X POST \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fcrm-payments\" \\\n  -H \"X-Api-Key: YOUR_APP_KEY\" \\\n  -H \"Authorization: Bearer USER_SESSION_TOKEN\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{ \"entityTypeId\": 2, \"entityId\": 8761, \"paySystemId\": 1 }'\n```\n\n### JavaScript — personal key\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fcrm-payments', {\n  method: 'POST',\n  headers: {\n    'X-Api-Key': 'YOUR_API_KEY',\n    'Content-Type': 'application\u002Fjson',\n  },\n  body: JSON.stringify({ entityTypeId: 2, entityId: 8761, paySystemId: 1 }),\n})\n\nconst { data } = await res.json()\nconsole.log('Payment ID:', data.id, 'number:', data.accountNumber)\n```\n\n### JavaScript — OAuth application\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fcrm-payments', {\n  method: 'POST',\n  headers: {\n    'X-Api-Key': 'YOUR_APP_KEY',\n    'Authorization': 'Bearer USER_SESSION_TOKEN',\n    'Content-Type': 'application\u002Fjson',\n  },\n  body: JSON.stringify({ entityTypeId: 2, entityId: 8761, paySystemId: 1 }),\n})\n\nconst { data } = await res.json()\n```\n\n## Response fields\n\nThe HTTP status of a successful response is `201`.\n\n| Field | Type | Description |\n|------|-----|---------|\n| `success` | boolean | `true` on success |\n| `data.id` | number | ID of the created payment |\n| `data.accountNumber` | string | Payment number: the linked order number and the payment's sequence number separated by `\u002F`, for example `1029\u002F2` |\n| `data.paid` | string | Paid mark, `N` for a new payment |\n| `data.datePaid` | null | `null` for a new payment |\n| `data.empPaidId` | null | `null` for a new payment |\n| `data.paySystemId` | number | Payment system ID, either the one passed or the one assigned automatically. List: [`GET \u002Fv1\u002Fpay-systems`](\u002Fdocs\u002Fentities\u002Fpay-systems\u002Flist) |\n| `data.sum` | number | Payment amount, `0` for a new payment |\n| `data.currency` | string | Currency code. List: [`GET \u002Fv1\u002Fcurrencies`](\u002Fdocs\u002Fentities\u002Fcurrencies\u002Flist) |\n| `data.paySystemName` | string | Payment system name |\n| `meta.readbackUnavailable` | boolean | Returned only with the value `true` when the payment was created but could not be read back. In that case `data` contains only `id`. Do not create it again. Fetch the payment by this `id` instead |\n\n## Response example\n\n```json\n{\n  \"success\": true,\n  \"data\": {\n    \"id\": 565,\n    \"accountNumber\": \"1029\u002F2\",\n    \"paid\": \"N\",\n    \"datePaid\": null,\n    \"empPaidId\": null,\n    \"paySystemId\": 1,\n    \"sum\": 0,\n    \"currency\": \"USD\",\n    \"paySystemName\": \"Bank transfer (Companies)\"\n  }\n}\n```\n\n## Error response example\n\n400 — `paySystemId` is negative or not an integer:\n\n```json\n{\n  \"success\": false,\n  \"error\": {\n    \"code\": \"INVALID_PARAMS\",\n    \"message\": \"paySystemId must be a non-negative integer.\"\n  }\n}\n```\n\n## Errors\n\n| HTTP | Code | Description |\n|------|-----|---------|\n| 400 | `MISSING_REQUIRED_FIELDS` | `entityTypeId` or `entityId` is missing, or the value is not a positive integer |\n| 400 | `READONLY_FIELD` | The body contains a field other than `entityTypeId`, `entityId` and `paySystemId` |\n| 400 | `INVALID_PARAMS` | `paySystemId` is negative or not an integer |\n| 404 | `ENTITY_NOT_FOUND` | No CRM item with this `entityTypeId` and `entityId` exists |\n| 422 | `BITRIX_NO_EFFECT` | The payment was not created, for example because no payment system with this `paySystemId` exists. No new payment appears on the item |\n| 422 | `BITRIX_ERROR` | CRM items of this type have no payments, for example a lead with `entityTypeId` equal to `1`. The message says that payment creation is unavailable for this entity |\n| 422 | `BITRIX_ERROR` | Bitrix24 rejected the request. The reason is in `error.message` |\n| 403 | `BITRIX_ACCESS_DENIED` | The key's user has no access to the CRM item or the payment in Bitrix24 |\n| 403 | `WRITE_BLOCKED_READONLY_KEY` | The key is not allowed to write |\n| 403 | `SCOPE_DENIED` | The API key does not have the `crm` scope |\n| 401 | `TOKEN_MISSING` | The API key has no configured tokens |\n| 401 | `MISSING_API_KEY` | `X-Api-Key` is missing |\n\nFull list of common API errors: [Errors](\u002Fdocs\u002Ferrors).\n\n## See also\n\n- [Add a line item to a payment](\u002Fdocs\u002Fentities\u002Fcrm-payments\u002Fproducts-add)\n- [Available product rows](\u002Fdocs\u002Fentities\u002Fcrm-payments\u002Favailable-products)\n- [List CRM payments](\u002Fdocs\u002Fentities\u002Fcrm-payments\u002Flist)\n- [Mark a payment as paid](\u002Fdocs\u002Fentities\u002Fcrm-payments\u002Fpay)\n- [Pay systems](\u002Fdocs\u002Fentities\u002Fpay-systems)\n- [CRM payments](\u002Fdocs\u002Fentities\u002Fcrm-payments)\n","2026-10-05",{},1794739356623]