## Submit visitor data

`POST /v1/crm-forms/:id/results`

Submits CRM form field values on behalf of a visitor, as when the form is filled in on a website. The result is processed according to the form settings: it can create a lead or deal, trigger automation and send notifications to the responsible persons.

## Parameters

| Parameter | Type | Required | Description |
|----------|-----|:-----:|----------|
| `id` (path) | integer | yes | Form ID. List: [Form list](/docs/entities/crm-forms/list) |

## Request fields (body)

| Field | Type | Required | Description |
|------|-----|:-----:|----------|
| `fields` | object | yes | Non-empty object of values. Keys are form field names `fields[].name` from [Get a form](/docs/entities/crm-forms/get), for example `LEAD_NAME`, `LEAD_PHONE`. Fields of type `file` are not supported |
| `presets` | object | no | Preset values, passed unchanged |
| `fromUrl` | string | no | URL of the page where the form was filled in |

No other fields are accepted in the body. The set and values of fields are validated against the form settings.

## Examples

### curl — personal key

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/crm-forms/75/results" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"fields":{"LEAD_NAME":"Anna","LEAD_PHONE":"+12025550123"},"fromUrl":"https://example.com/contact"}'
```

### curl — OAuth application

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/crm-forms/75/results" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"fields":{"LEAD_NAME":"Anna","LEAD_PHONE":"+12025550123"},"fromUrl":"https://example.com/contact"}'
```

### JavaScript — personal key

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/crm-forms/75/results', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    fields: { LEAD_NAME: 'Anna', LEAD_PHONE: '+12025550123' },
    fromUrl: 'https://example.com/contact',
  }),
})

const { data } = await res.json()
console.log('Form result:', data.resultId)
```

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/crm-forms/75/results', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    fields: { LEAD_NAME: 'Anna', LEAD_PHONE: '+12025550123' },
    fromUrl: 'https://example.com/contact',
  }),
})

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

## Response fields

| Field | Type | Description |
|------|-----|----------|
| `success` | boolean | `true` when the result is saved |
| `data.resultId` | number | ID of the form submission result. This is not the ID of the created lead or deal |

## Response example

HTTP 201 — the result is saved:

```json
{
  "success": true,
  "data": {
    "resultId": 231
  }
}
```

## Error response example

404 — no form with this `id`:

```json
{
  "success": false,
  "error": {
    "code": "ENTITY_NOT_FOUND",
    "message": "Form not found."
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|----------|
| 400 | `MISSING_REQUIRED_FIELDS` | `fields` is not passed, is empty or is not an object, message "fields must be a non-empty object" |
| 400 | `INVALID_PARAMS` | `id` is not a positive integer, message "id must be a positive safe integer" |
| 400 | `INVALID_PARAMS` | The body is not a JSON object, message "Request body must be a JSON object" |
| 400 | `INVALID_PARAMS` | The body contains a field other than `fields`, `presets`, `fromUrl`, message "Only fields, presets and fromUrl are accepted" |
| 400 | `INVALID_PARAMS` | `presets` is not an object or `fromUrl` is not a string |
| 404 | `ENTITY_NOT_FOUND` | No form with this `id`, message "Form not found." |
| 422 | `BITRIX_ERROR` | Bitrix24 did not accept the result: the form is inactive ("Form is not active.") or a field of type `file` is passed. The Bitrix24 text comes in `message` and the original code in `b24Code` (`ERROR_CORE` for an inactive form) |
| 403 | Bitrix24 code | Bitrix24 denied access. `code` and `message` come from Bitrix24 unchanged |
| 409 | Bitrix24 code | Bitrix24 rejected the result because of the form or portal state. `code` and `message` come from Bitrix24 unchanged |
| 403 | `WRITE_BLOCKED_READONLY_KEY` | The key is read-only. Submitting requires a key with write access |
| 429 | `RATE_LIMITED` | The Bitrix24 request rate limit is exceeded |
| 502 | `BITRIX_RESPONSE_INVALID` | Bitrix24 did not return a result ID, message `Bitrix24 returned no result ID; do not retry blindly` |
| 502 | `BITRIX_UNAVAILABLE` | Bitrix24 is unavailable: it responded with a server error or the connection dropped |
| 503 | `BITRIX_TIMEOUT` | Bitrix24 accepted the request but did not respond within the allotted time |
| 401 | `MISSING_API_KEY` | The `X-Api-Key` header is not passed |
| 401 | `TOKEN_MISSING` | The API key has no configured Bitrix24 tokens |
| 403 | `SCOPE_DENIED` | The API key lacks the `crm` scope |

Full list of common API errors — [Errors](/docs/errors).

## Known specifics

- **Do not retry a submission blindly.** Each call saves a new result, and Vibecode does not retry the submission itself. After `502`, `503` or a dropped connection, the result may already be saved and may have triggered automation, so a repeated call creates a second result.
- **Unknown `fields` keys are not rejected.** A value with a name that does not exist in the form does not cause an error: the result is created and `201` is returned. Check the keys against the form's `fields[].name` before submitting.

## See also

- [Get a form](/docs/entities/crm-forms/get)
- [Form list](/docs/entities/crm-forms/list)
- [Activate a form](/docs/entities/crm-forms/activate)
- [Send a CRM form to a client](/docs/openlines/send-form)
- [Limits and optimization](/docs/optimization)
