> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://docs.runpayments.io/reference/terminal-api/terminals/connect-terminal/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.runpayments.io/_mcp/server. # Connect a terminal session POST https://javelin.runpayments.io/api/terminal/{device_id}/connect Content-Type: application/json Manually connects a terminal session. The `read-card` and `charge-card` endpoints connect automatically if no session is active, so use this endpoint to pre-connect a terminal or force a reconnect. Reference: https://docs.runpayments.io/reference/terminal-api/terminals/connect-terminal ## Authentication - `Authorization` header (bearer token, required) — Use a Payments API key as the bearer token: `Authorization: Bearer `. Get a fresh key from [Refresh API Keys](/reference/authentication/refresh-api-keys). ## Request ### Path parameters - `device_id` (string, required) — Hardware Serial Number (HSN) of the terminal, provided by your Integration Delivery lead. ### Query parameters - `mid` (string, optional) — Merchant ID. Required when your bearer token is an ISV token acting on behalf of a merchant. If the `mid` can't be resolved to an authorized account, the request returns `400`. ### Body (application/json) This endpoint expects an object. - `force` (boolean, optional, default: false) — Force a reconnect even if a session is already active. ## Response ### 200 Terminal connected - `device_id` (string, required) — Hardware Serial Number of the connected terminal. - `connected` (boolean, required) — Connection status. `true` on success. - `session_key` (string, required) — Session token for subsequent terminal operations. ## Errors ### 401 Unauthorized Error Unauthorized - `errors` (list of string, optional) — Error messages. ### 404 Not Found Error Terminal not found on this account. - `error` (string, optional) — Error message. ### 409 Conflict Error The terminal already has an active session. Resend with `force` set to `true` to reconnect. - `error` (string, optional) — Error message. ### 429 Too Many Requests Error Rate limit exceeded. All Terminal API endpoints share a per-credential rate limit. - `any` ## Examples **Request** ```json {} ``` **Response** ```json { "device_id": "HSN123456789", "connected": true, "session_key": "sess_9f8e7d6c5b4a3210" } ``` **SDK Code** ```python import requests url = "https://javelin.runpayments.io/api/terminal/HSN123456789/connect" payload = {} headers = { "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript const url = 'https://javelin.runpayments.io/api/terminal/HSN123456789/connect'; const options = { method: 'POST', headers: {Authorization: 'Bearer ', 'Content-Type': 'application/json'}, body: '{}' }; 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://javelin.runpayments.io/api/terminal/HSN123456789/connect" payload := strings.NewReader("{}") 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://javelin.runpayments.io/api/terminal/HSN123456789/connect") 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 = "{}" 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://javelin.runpayments.io/api/terminal/HSN123456789/connect") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{}") .asString(); ``` ```php request('POST', 'https://javelin.runpayments.io/api/terminal/HSN123456789/connect', [ 'body' => '{}', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("https://javelin.runpayments.io/api/terminal/HSN123456789/connect"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = [ "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://javelin.runpayments.io/api/terminal/HSN123456789/connect")! 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() ```