> 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/expire-market-data-subscription/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://partner.ninjatrader.com/_mcp/server. # Expire Market Data Subscription POST https://live.tradovateapi.com/v1/user/expiremarketdatasubscription Content-Type: application/json ### Expire market data subscriptions for users.**Available to:** Organization administrators**Environments:** Live**[Rate Limit](/overview/core-concepts/rate-limits):** No endpoint-specific limitImmediately archive and expire up to 100 market data subscriptions in a single request. Include every subscription in the `marketDataSubscriptionIds` array rather than calling the endpoint once per subscription. The IDs are primary keys from the `marketDataSubscriptions` database table, returned when subscriptions are created with endpoints like [`addMarketDataSubscription`](/api/rest-api-endpoints/users/add-market-data-subscription).Before expiring anything, the endpoint checks that every ID is accessible to your organization. If any ID is inaccessible (because it doesn't exist or belongs to a user outside your organization), the whole request fails and nothing is expired (`errorCode: UsersNotInOrganization`), so validate your IDs before calling. An already-expired but still accessible ID is treated as valid and counted as a success. Partial success (where some IDs expire and others don't) happens only when a backend error interrupts processing after the access check passes (`errorCode: InternalError`).A failed request still returns a response body, so don't rely on the absence of an error. Check `ok` along with the `successfulSubscriptionIdExpiries` and `failedSubscriptionIdExpiries` arrays to confirm what was actually expired.**Common Failure Scenarios**- One or more IDs don't exist or belong to a user outside your organization. The entire request fails and no subscriptions are expired. - More than 100 IDs are included in a single request. Input validation rejects the request before any subscription is expired. - A backend error interrupts processing. Some IDs may be expired and others not.If you expire a subscription by mistake, create a new one for the user with [`addMarketDataSubscription`](/api/rest-api-endpoints/users/add-market-data-subscription).**Error Messages**| `errorText` | Trigger | | ----------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `"some marketDataSubscriptions were inaccessible to an admin of this organization"` | One or more IDs don't exist or belong to a user outside your organization (`errorCode: UsersNotInOrganization`). Nothing is expired. | | `"some marketDataSubscriptions failed to be expired"` | A backend error prevented one or more accessible IDs from being expired (`errorCode: InternalError`); check the arrays to see which succeeded. Other backend failures return `InternalError` with a different message, and nothing is expired. |The `errorCode` schema also lists `TooManySubscriptions`, but the endpoint doesn't currently return it. A request with more than 100 IDs is rejected by validation first, with the error `"Market Data Subscription Ids should be no longer than 100"`. Reference: https://partner.ninjatrader.com/connect/api/rest-api-endpoints/users/expire-market-data-subscription ## 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 an ExpireMarketDataSubscription. - `marketDataSubscriptionIds` (list of long, required) ## Response ### 200 ExpireMarketDataSubscriptionResponse - `ok` (boolean, required) - `failedSubscriptionIdExpiries` (list of long, required) - `successfulSubscriptionIdExpiries` (list of long, required) - `errorText` (string, optional) — Non-empty if the request failed - `errorCode` (enum, optional) — InternalError, TooManySubscriptions, UsersNotInOrganization - Allowed values: `InternalError`, `TooManySubscriptions`, `UsersNotInOrganization` ## Examples ### All subscriptions expired **Request** ```json { "marketDataSubscriptionIds": [ 1023456789, 1023456790, 1023456791 ] } ``` **Response** ```json { "ok": true, "failedSubscriptionIdExpiries": [], "successfulSubscriptionIdExpiries": [ 1023456789, 1023456790, 1023456791 ] } ``` **SDK Code** ```python All subscriptions expired import requests url = "https://live.tradovateapi.com/v1/user/expiremarketdatasubscription" payload = { "marketDataSubscriptionIds": [1023456789, 1023456790, 1023456791] } headers = { "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript All subscriptions expired const url = 'https://live.tradovateapi.com/v1/user/expiremarketdatasubscription'; const options = { method: 'POST', headers: {Authorization: 'Bearer ', 'Content-Type': 'application/json'}, body: '{"marketDataSubscriptionIds":[1023456789,1023456790,1023456791]}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go All subscriptions expired package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://live.tradovateapi.com/v1/user/expiremarketdatasubscription" payload := strings.NewReader("{\n \"marketDataSubscriptionIds\": [\n 1023456789,\n 1023456790,\n 1023456791\n ]\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 All subscriptions expired require 'uri' require 'net/http' url = URI("https://live.tradovateapi.com/v1/user/expiremarketdatasubscription") 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 \"marketDataSubscriptionIds\": [\n 1023456789,\n 1023456790,\n 1023456791\n ]\n}" response = http.request(request) puts response.read_body ``` ```java All subscriptions expired import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://live.tradovateapi.com/v1/user/expiremarketdatasubscription") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"marketDataSubscriptionIds\": [\n 1023456789,\n 1023456790,\n 1023456791\n ]\n}") .asString(); ``` ```php All subscriptions expired request('POST', 'https://live.tradovateapi.com/v1/user/expiremarketdatasubscription', [ 'body' => '{ "marketDataSubscriptionIds": [ 1023456789, 1023456790, 1023456791 ] }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp All subscriptions expired using RestSharp; var client = new RestClient("https://live.tradovateapi.com/v1/user/expiremarketdatasubscription"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"marketDataSubscriptionIds\": [\n 1023456789,\n 1023456790,\n 1023456791\n ]\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift All subscriptions expired import Foundation let headers = [ "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = ["marketDataSubscriptionIds": [1023456789, 1023456790, 1023456791]] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://live.tradovateapi.com/v1/user/expiremarketdatasubscription")! 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() ``` ### One inaccessible ID fails the whole batch **Request** ```json { "marketDataSubscriptionIds": [ 1023456789, 1023456790, 9999999999 ] } ``` **Response** ```json { "ok": false, "failedSubscriptionIdExpiries": [ 9999999999 ], "successfulSubscriptionIdExpiries": [], "errorText": "some marketDataSubscriptions were inaccessible to an admin of this organization", "errorCode": "UsersNotInOrganization" } ``` **SDK Code** ```python One inaccessible ID fails the whole batch import requests url = "https://live.tradovateapi.com/v1/user/expiremarketdatasubscription" payload = { "marketDataSubscriptionIds": [1023456789, 1023456790, 9999999999] } headers = { "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript One inaccessible ID fails the whole batch const url = 'https://live.tradovateapi.com/v1/user/expiremarketdatasubscription'; const options = { method: 'POST', headers: {Authorization: 'Bearer ', 'Content-Type': 'application/json'}, body: '{"marketDataSubscriptionIds":[1023456789,1023456790,9999999999]}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go One inaccessible ID fails the whole batch package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://live.tradovateapi.com/v1/user/expiremarketdatasubscription" payload := strings.NewReader("{\n \"marketDataSubscriptionIds\": [\n 1023456789,\n 1023456790,\n 9999999999\n ]\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 One inaccessible ID fails the whole batch require 'uri' require 'net/http' url = URI("https://live.tradovateapi.com/v1/user/expiremarketdatasubscription") 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 \"marketDataSubscriptionIds\": [\n 1023456789,\n 1023456790,\n 9999999999\n ]\n}" response = http.request(request) puts response.read_body ``` ```java One inaccessible ID fails the whole batch import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://live.tradovateapi.com/v1/user/expiremarketdatasubscription") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"marketDataSubscriptionIds\": [\n 1023456789,\n 1023456790,\n 9999999999\n ]\n}") .asString(); ``` ```php One inaccessible ID fails the whole batch request('POST', 'https://live.tradovateapi.com/v1/user/expiremarketdatasubscription', [ 'body' => '{ "marketDataSubscriptionIds": [ 1023456789, 1023456790, 9999999999 ] }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp One inaccessible ID fails the whole batch using RestSharp; var client = new RestClient("https://live.tradovateapi.com/v1/user/expiremarketdatasubscription"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"marketDataSubscriptionIds\": [\n 1023456789,\n 1023456790,\n 9999999999\n ]\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift One inaccessible ID fails the whole batch import Foundation let headers = [ "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = ["marketDataSubscriptionIds": [1023456789, 1023456790, 9999999999]] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://live.tradovateapi.com/v1/user/expiremarketdatasubscription")! 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() ```