# Send a document from a template

> Available starting with the **sign 26.1300.0** module. On older self-hosted installations the method may be unavailable: the platform returns `422 METHOD_NOT_YET_AVAILABLE` with `error.release`.

`POST /v1/sign-b2e/templates/send`

Creates a document from an available template and sends it to an employee. Requires permission to add, read and edit documents, and access to the template. Sending has legal consequences.

**Scopes:** `sign.b2e`, `crm`.

## Request body fields

| Parameter | Type | Required | Description |
|---|---|---|---|
| `templateUid` | string | yes | Template ID from the [list of templates](./list-templates.md). |
| `signerUserId` | integer \| string | yes | ID of an active employee or candidate from the [list of users](/docs/entities/users). |
| `responsibleUserId` | integer \| string \| null | no | ID of an active responsible person from the [list of users](/docs/entities/users). Defaults to the key owner; null is allowed. |
| `externalSettings` | object \| null | no | External system settings; null is allowed when sending from a template. |
| `externalSettings.externalId` | string | no | Document ID in the external system, up to 255 characters. |
| `externalSettings.externalDateCreate` | string | no | Creation date in the external system in ISO 8601 format. Sending from a template requires ATOM format with a numeric time zone offset. |

## Examples

### curl — personal key

```bash
curl -X POST 'https://vibecode.bitrix24.com/v1/sign-b2e/templates/send' \
  -H 'X-Api-Key: YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{"templateUid": "DUMMY_TEMPLATE_UID", "signerUserId": 7}'
```

### curl — OAuth application

```bash
curl -X POST 'https://vibecode.bitrix24.com/v1/sign-b2e/templates/send' \
  -H 'X-Api-Key: YOUR_APP_KEY' \
  -H 'Authorization: Bearer USER_SESSION_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"templateUid": "DUMMY_TEMPLATE_UID", "signerUserId": 7}'
```

### JavaScript — personal key

```javascript
const response = await fetch('https://vibecode.bitrix24.com/v1/sign-b2e/templates/send', {
  "method": "POST",
  "headers": {
    "X-Api-Key": "YOUR_API_KEY",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({"templateUid": "DUMMY_TEMPLATE_UID", "signerUserId": 7})
});
const result = await response.json();
if (!response.ok || !result.success) throw new Error(result.error?.message);
console.log(result.data);
```

### JavaScript — OAuth application

```javascript
const response = await fetch('https://vibecode.bitrix24.com/v1/sign-b2e/templates/send', {
  "method": "POST",
  "headers": {
    "X-Api-Key": "YOUR_APP_KEY",
    "Authorization": "Bearer USER_SESSION_TOKEN",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({"templateUid": "DUMMY_TEMPLATE_UID", "signerUserId": 7})
});
const result = await response.json();
if (!response.ok || !result.success) throw new Error(result.error?.message);
console.log(result.data);
```

## Response fields

| Field | Type | Description |
|---|---|---|
| `success` | boolean | Whether the request succeeded. |
| `data` | object | Operation data. |
| `data.uid` | string | Document UID. |
| `data.state` | object | Object state. |
| `data.state.code` | string | Machine-readable code. |
| `data.state.name` | string | Localized signing state name. |
| `data.members` | array | Document members. |
| `data.members[].uid` | string | Signing member UID. |
| `data.members[].role` | string | Member role. |
| `data.members[].state` | object | Object state. |
| `data.members[].state.code` | string | Machine-readable code. |
| `data.members[].state.name` | string | Localized signing state name. |
| `data.members[].user` | object | The member's user. |
| `data.members[].party` | integer | The member's signing party number. |
| `data.members[].user.employeeCode` | string \| null | HCM Link employee code; null for a regular user. |
| `data.members[].user.employeeId` | integer \| null | Numeric HCM Link employee ID; null for a regular user. |
| `data.members[].user.userId` | integer \| null | User ID. |
| `meta.redacted` | array<string> | Present when credentials are hidden; contains the paths of the replaced values. |

## Response example

Shape of a successful response; the data depends on the Bitrix24 account and the request.

```json
{
  "success": true,
  "data": {
    "uid": "DUMMY_DOCUMENT_UID",
    "state": {
      "code": "ready",
      "name": "Ready"
    },
    "members": []
  }
}
```

## Error response example

403 — the key lacks a required scope:

```json
{
  "success": false,
  "error": {
    "code": "SCOPE_DENIED",
    "message": "This endpoint requires 'sign.b2e' scope"
  }
}
```

## Errors

| HTTP | Code | Reason |
|---|---|---|
| 400 | `INVALID_PARAMS` | Invalid request shape: types, required fields or an unknown query string parameter. |
| 401 | `TOKEN_MISSING` | No credentials for the Bitrix24 connection. |
| 403 | `SCOPE_DENIED` | One of the required scopes is not granted. |
| 422 | `BITRIX_ERROR` | Bitrix24 rejected the operation; the code is in error.b24Code, the text in error.message. |
| 403 | `WRITE_BLOCKED_READONLY_KEY` | The key is read-only. |
| 422 | `METHOD_NOT_YET_AVAILABLE` | The method is not yet available on the Bitrix24 account; the release is in error.release. |

[Common API errors](/docs/errors).

## Known specifics

Bitrix24 checks user permissions, HR e-signature availability, business rules, page sizes and field contents. Values are passed through without local correction. Response text is JSON-encoded; credential-bearing links are hidden.

The operation is not retried automatically. If the outcome is unknown, check the state in the Bitrix24 account first; resending can create another document.

The Idempotency-Key header is passed to Bitrix24 without generating a new value. It does not enable automatic retries. externalSettings.externalDateCreate requires strict ATOM format with a numeric time zone offset.

## See also

- [Employee signatures](/docs/sign-b2e)
- [API errors](/docs/errors)
