> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://partner.ninjatrader.com/connect/api/rest-api-endpoints/users/create-account-lockout/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://partner.ninjatrader.com/_mcp/server. # Create Account Lockout POST https://demo.tradovateapi.com/v1/user/createaccountlockout Content-Type: application/json ### Lock an account for a specified duration. **Available to:** All authenticated users (own account only) **Environments:** Demo **[Rate Limit](/overview/core-concepts/rate-limits):** No endpoint-specific limit Traders can voluntarily lock themselves out of trading on a specific account for a set period. This helps traders protect their progress, whether that means locking in a winning day or stepping away before losses deepen. * **Traders can't cancel their own lockouts.** Once activated, the lockout stays in effect until it expires or an organization administrator manually unlocks it. * **Account-level lockout.** Only the specified account is locked. Other accounts belonging to the same user are not affected. * **Closes positions and blocks orders.** When a trader activates a lockout, open positions on the account are liquidated and new orders are rejected until the lockout expires. **Common Failure Scenarios** * The caller doesn't own the account (organization administrators can't create lockouts) * The user's organization doesn't have the Tradovate Prop entitlement * The account already has an active lockout * The account doesn't exist * The `durationMinutes` value is 0 All responses return `HTTP 200`. Errors are indicated by `ok: false` and an `errorText` field in the response body. **Error Messages** | `errorText` | Trigger | | -------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | | `"Unauthorized: only the eval user may initiate a trading lockout. Org admins and super admins not permitted to create lockouts"` | The caller is not the account owner | | `"Account {id} already has an active lockout for user {userId}. New lockout requests are not permitted until the existing lockout expires."` | The account already has an active lockout | | `"Account not found."` | The `accountId` doesn't match an existing account | | `"Tradovate Prop required"` | The user's organization doesn't have the required Tradovate Prop entitlement | | `"durationMinutes must be greater than 0"` | The `durationMinutes` value is 0 | **Related Endpoints** * Use [`accountLockoutStatus`](/api/rest-api-endpoints/users/account-lockout-status) to check whether accounts are currently locked * Use [`expireAccountLockout`](/api/rest-api-endpoints/users/expire-account-lockout) to unlock a single account early (organization administrators only) * Use [`expireAllAccountLockouts`](/api/rest-api-endpoints/users/expire-all-account-lockouts) to unlock all accounts for a user (organization administrators only) Reference: https://partner.ninjatrader.com/connect/api/rest-api-endpoints/users/create-account-lockout ## Authentication - `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer `, where token is your auth token. ## Request ### Body (application/json) This endpoint expects a CreateAccountLockout. - `accountId` (long, required) - `durationMinutes` (integer, required) ## Response ### 200 AccountLockoutResponse - `errorText` (string, optional) — Non-empty if the request failed - `ok` (boolean, optional) ## Examples **Request** ```json { "accountId": 1, "durationMinutes": 1 } ``` **Response** ```json { "errorText": "string", "ok": true } ``` **SDK Code** ```python import requests url = "https://demo.tradovateapi.com/v1/user/createaccountlockout" payload = { "accountId": 1, "durationMinutes": 1 } headers = { "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript const url = 'https://demo.tradovateapi.com/v1/user/createaccountlockout'; const options = { method: 'POST', headers: {Authorization: 'Bearer ', 'Content-Type': 'application/json'}, body: '{"accountId":1,"durationMinutes":1}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://demo.tradovateapi.com/v1/user/createaccountlockout" payload := strings.NewReader("{\n \"accountId\": 1,\n \"durationMinutes\": 1\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby require 'uri' require 'net/http' url = URI("https://demo.tradovateapi.com/v1/user/createaccountlockout") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"accountId\": 1,\n \"durationMinutes\": 1\n}" response = http.request(request) puts response.read_body ``` ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://demo.tradovateapi.com/v1/user/createaccountlockout") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"accountId\": 1,\n \"durationMinutes\": 1\n}") .asString(); ``` ```php request('POST', 'https://demo.tradovateapi.com/v1/user/createaccountlockout', [ 'body' => '{ "accountId": 1, "durationMinutes": 1 }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("https://demo.tradovateapi.com/v1/user/createaccountlockout"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"accountId\": 1,\n \"durationMinutes\": 1\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = [ "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "accountId": 1, "durationMinutes": 1 ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://demo.tradovateapi.com/v1/user/createaccountlockout")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ```