> This page is for Developer Documentation.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.benchling.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.benchling.com/_mcp/server.

# Create a template DNA alignment

POST https://{tenant_name}.benchling.com/api/v2/dna-alignments:create-template-alignment
Content-Type: application/json

Create a template DNA alignment

Reference: https://docs.benchling.com/docs/api/v2/benchling-api/dna-alignments/create-dna-template-alignment

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Request

### Body (application/json)

This endpoint expects a DnaTemplateAlignmentCreate.

- `algorithm` (enum, required)
  - Allowed values: `mafft`, `clustalo`
- `files` (list of DnaAlignmentBaseFilesItems, required)
- `templateSequenceId` (string, required)
- `clustaloOptions` (ClustaloOptions, optional) — Options to pass to the ClustalO algorithm, only applicable for ClustalO.
- `mafftOptions` (MafftOptions, optional) — Options to pass to the MAFFT algorithm, only applicable for MAFFT.
- `name` (string, optional)
- `shouldDisableCircularSequenceRotation` (boolean, optional, default: false) — Whether to disable circular sequence rotation.

## Response

### 202

This endpoint launches a [long-running task](#/Tasks/getTask) and returns the Task ID of the launched task. When successful, the task returns the [DNA Alignment](#/DNA%20Alignments/getDNAAlignment) resource that was created.

- `taskId` (string, optional)

## Types

### DnaAlignmentBaseFilesItems

### ClustaloOptions

Options to pass to the ClustalO algorithm, only applicable for ClustalO.

- `maxGuidetreeIterations` (integer, optional, default: -1) — Max guide tree iterations within combined iterations. Use -1 for no max (all iterations will include guide tree iterations).
- `maxHmmIterations` (integer, optional, default: -1) — Max HMM iterations within combined iterations. Use -1 for no max (all iterations will include HMM iterations).
- `mbedGuideTree` (boolean, optional, default: true) — Whether mBed-like clustering guide tree should be used (faster to use it).
- `mbedIteration` (boolean, optional, default: true) — Whether mBed-like clustering iteration should be used (faster to use it).
- `numCombinedIterations` (integer, optional, default: 0) — Number of (combined guide-tree/HMM) iterations.

### MafftOptions

Options to pass to the MAFFT algorithm, only applicable for MAFFT.

- `adjustDirection` (enum, optional, default: fast) — Adjust direction: * `fast`: Enabled, quickly. * `accurate`: Enabled, accurately (slow). * `disabled`: Disabled, fastest.
  - Allowed values: `fast`, `accurate`, `disabled`
- `gapExtensionPenalty` (double, optional, default: 0) — Gap extension penalty.
- `gapOpenPenalty` (double, optional, default: 1.53) — Gap open penalty.
- `maxIterations` (integer, optional, default: 0) — Max refinement iterations. Not applicable for auto strategy, as it will be selected automatically.
- `retree` (integer, optional, default: 2) — Tree rebuilding. Only used for 6-mer strategy.
- `strategy` (enum, optional, default: auto) — MAFFT Strategy: * `auto`: Pick a strategy automatically based on the count and size of inputs. * `sixmer`: Use 6-mer distance for constructing the guide tree. * `localpair`: Compute local pairwise alignments using Smith-Waterman for constructing the guide tree and iterative refinement. * `globalpair`: Compute global pairwise alignments using Needleman-Wunsch for constructing the guide tree and iterative refinement.
  - Allowed values: `auto`, `sixmer`, `localpair`, `globalpair`

### DnaAlignmentBaseFilesItems0

- `sequenceId` (string, optional)

### DnaTemplateAlignmentFile

- `data` (string, optional)
- `name` (string, optional)

## Examples

**Request**

```json
{
  "algorithm": "mafft",
  "files": [
    {}
  ],
  "templateSequenceId": "seq_rXqq0IHU"
}
```

**Response**

```json
{
  "taskId": "string"
}
```

**SDK Code**

```python
import requests

url = "https://{tenant_name}.benchling.com/api/v2/dna-alignments:create-template-alignment"

payload = {
    "algorithm": "mafft",
    "files": [{}],
    "templateSequenceId": "seq_rXqq0IHU"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://{tenant_name}.benchling.com/api/v2/dna-alignments:create-template-alignment';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"algorithm":"mafft","files":[{}],"templateSequenceId":"seq_rXqq0IHU"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```