> You are reading the Docusign Developer Documentation. For clean Markdown of any page, append .md to the page URL.
>
> Documentation indexes by section:
> - APIs and SDKs: https://docusign.docs.buildwithfern.com/docs/llms.txt
> - Platform 101: https://docusign.docs.buildwithfern.com/platform/llms.txt
> - Extension Apps: https://docusign.docs.buildwithfern.com/extension-apps/llms.txt
> - Docusign CLI: https://docusign.docs.buildwithfern.com/docusign-cli/llms.txt
>
> Authentication (OAuth, JWT Grant, M2M): https://docusign.docs.buildwithfern.com/platform/auth
> Webhooks and Connect: https://docusign.docs.buildwithfern.com/platform/webhooks
>
> OpenAPI specifications: https://docusign.docs.buildwithfern.com/openapi.json
> MCP server: https://docusign.docs.buildwithfern.com/_mcp/server

# Lock template

POST https://demo.docusign.net/restapi/v2.1/accounts/{accountId}/templates/{templateId}/lock
Content-Type: application/json

This method locks the specified template and sets the time until
the lock expires to prevent other users or recipients from
changing the template.

The response to this request includes a `lockToken` parameter
that you must use in the `X-DocuSign-Edit` header for
every PUT method (typically a method that updates a template)
while the template is locked.

If you do not provide the `lockToken` when accessing
a locked template, you will get the following
error:

```json
{
   "errorCode": "EDIT_LOCK_NOT_LOCK_OWNER",
   "message": "The user is not the owner of the lock. The template is locked by another user or in another application"
}
```

### The X-DocuSign-Edit header

The `X-DocuSign-Edit` header looks like this
and can be specified in either JSON or XML.

**JSON**

```json
{
  "LockToken": "token-from-response",
  "LockDurationInSeconds": "600"
}
```

**XML**

```xml
<DocuSignEdit>
  <LockToken>token-from-response</LockToken>
  <LockDurationInSeconds>600</LockDurationInSeconds>
</DocuSignEdit>
```

In the actual HTTP header, you would remove the linebreaks:

```text
X-DocuSign-Edit: {"LockToken": "token-from-response", "LockDurationInSeconds": "600" }
    or
X-DocuSign-Edit:<DocuSignEdit><LockToken>token-from-response</LockToken><LockDurationInSeconds>600</LockDurationInSeconds></DocuSignEdit>
```

### Related topics

* [Common API Tasks: Locking and unlocking envelopes](https://www.docusign.com/blog/dsdev-common-api-tasks-locking-and-unlocking-envelopes)

Reference: https://developers.docusign.com/docs/esign-rest-api/reference/templates/templatelocks/create

## Authentication

- `Authorization` header (required) (prefixed with ` Bearer  `) — OAuth 2.0 access token (JWT or auth-code grant). Sent as `Authorization: Bearer <token>` on every request except `GET /v2.1` and `GET /service_information`, which are public discovery endpoints.

## Servers

- `https://demo.docusign.net/restapi` (Demo, default)
- `https://www.docusign.net/restapi` (Production)

## Request

### Path parameters

- `accountId` (string, required) — The external account number (int) or account ID Guid.
- `templateId` (string, required) — The ID of the template.

### Body (application/json)

This endpoint expects a lockRequest.

- `lockDurationInSeconds` (string, optional) — The configured value is not used; the timeout is hardcoded to 600 seconds. To use a different timeout, implement a custom timer and explicitly control locking and unlocking.
- `lockedByApp` (string, optional) — A friendly name of the application used to lock the envelope. Will be used in error messages to the user when lock conflicts occur.
- `lockType` (string, optional) — The type of lock. Currently `edit` is the only supported type.
- `templatePassword` (string, optional) — The [password for the template](https://support.docusign.com/s/document-item?bundleId=xry1643227563338&topicId=xwo1578456395432.html). If you are using a lock for a template that has a password or an envelope that is based on a template that has a password, you must enter the `templatePassword` to save the changes.
- `useScratchPad` (string, optional) — When **true,** a scratchpad is used to edit information.

## Response

### 201

Successful response.

- `errorDetails` (errorDetails, optional) — This object describes errors that occur. It is only valid for responses, and ignored in requests.
- `lockDurationInSeconds` (string, optional) — The number of seconds to lock the envelope for editing. This value must be greater than `0` seconds.
- `lockedByApp` (string, optional) — The human-readable name of the application that is locking the envelope or template. This value displays to the user in error messages when lock conflicts occur.
- `lockedByUser` (userInfo, optional)
- `lockedUntilDateTime` (string, optional) — The date and time that the lock expires.
- `lockToken` (string, optional) — A unique identifier provided to the owner of the lock. You must use this token with subsequent calls to prove ownership of the lock.
- `lockType` (string, optional) — The type of lock. Currently `edit` is the only supported type.
- `useScratchPad` (string, optional) — When **true,** a scratchpad is used to edit information.

## Errors

### 400 Bad Request Error

Error encountered.

- `errorCode` (string, optional) — The code associated with the error condition.
- `message` (string, optional) — A brief message describing the error condition.

## Types

### errorDetails

This object describes errors that occur. It is only valid for responses, and ignored in requests.

- `errorCode` (string, optional) — The code associated with the error condition.
- `message` (string, optional) — A brief message describing the error condition.

### userInfo

- `accountId` (string, optional) — The account ID associated with the envelope.
- `accountName` (string, optional) — The name on the account.
- `activationAccessCode` (string, optional) — Access code provided to the user to activate the account.
- `email` (string, optional) — The user's email address.
- `errorDetails` (errorDetails, optional) — This object describes errors that occur. It is only valid for responses, and ignored in requests.
- `ipAddress` (string, optional)
- `loginStatus` (string, optional) — When **true,** indicates that the user is logged in. This is a read-only property.
- `membershipId` (string, optional) — The user's membership ID.
- `sendActivationEmail` (string, optional) — This field is no longer supported for most accounts. To create an eSignature user without sending an activation email, use the Admin API by following [these steps](/docs/admin-api/how-to/create-active-user/).
- `uri` (string, optional) — A URI containing the user ID.
- `userId` (string, optional) — The ID of the user to access.
- `userName` (string, optional) — The name of the user.
- `userStatus` (string, optional) — Status of the user's account. One of: - `ActivationRequired` - `ActivationSent` - `Active` - `Closed` - `Disabled`
- `userType` (string, optional) — The type of user, for example `CompanyUser`.

## Examples

**Request**

```json
{
  "lockDurationInSeconds": "sample string 1",
  "lockedByApp": "sample string 2",
  "lockType": "sample string 3",
  "templatePassword": "sample string 4",
  "useScratchPad": "sample string 5"
}
```

**Response**

```json
{
  "errorDetails": {
    "errorCode": "sample string 1",
    "message": "sample string 2"
  },
  "lockDurationInSeconds": "sample string 1",
  "lockedByApp": "sample string 2",
  "lockedByUser": {
    "accountId": "sample string 1",
    "accountName": "sample string 2",
    "activationAccessCode": "sample string 3",
    "email": "sample string 4",
    "ipAddress": "sample string 5",
    "loginStatus": "sample string 6",
    "membershipId": "sample string 7",
    "sendActivationEmail": "sample string 8",
    "uri": "sample string 9",
    "userId": "sample string 10",
    "userName": "sample string 11",
    "userStatus": "sample string 12",
    "userType": "sample string 13"
  },
  "lockedUntilDateTime": "sample string 3",
  "lockToken": "sample string 4",
  "lockType": "sample string 5",
  "useScratchPad": "sample string 6"
}
```