Short Grant Code
Mint a single-use code that signs one of your users into a NinjaTrader-hosted page.
Available to: Trader users of a configured NT Connect partner organization
Environments: Live. The endpoint is not blocked on Demo, but partner mode depends on a partner configuration, and those are provisioned on Live.
Rate Limit: No endpoint-specific time penalty. Partner-mode requests are limited per partner organization: 1,000 requests per hour by default, measured over a sliding window.
Use this endpoint when a user is already signed in to your application and you want to send their browser to a NinjaTrader-hosted URL (the trader dashboard, an account page, a funding page) without a second login.
Your backend calls this endpoint with the partner access token it already holds for that user (minted with the urn:ietf:params:oauth:grant-type:jwt-bearer grant on oAuthToken). NinjaTrader returns a short-lived, single-use code. You then redirect the user’s browser to the NinjaTrader application with that code attached, and exchangeShortGrantCode redeems it on arrival.
The partner access token never leaves your backend. Only the short code travels through the browser.
The handoff runs in three steps:
- Your backend posts to
/auth/shortgrantcodewith the partner access token. - NinjaTrader returns
codeandexpires_in. - Your backend redirects the user’s browser to the NinjaTrader application with the code attached, and the application redeems it.
errorText field in the response body to determine whether the request succeeded or failed.Partner Mode and expectedClientIp
expectedClientIp is what selects partner mode, and it is the field that makes the flow work end to end. Send the end user’s IP address as resolved by your own load-balancer-aware logic. The code is then bound to that address and redemption is rejected from anywhere else.
expectedClientIp does not return an error. The request silently falls back to the non-partner path, which binds the code to your backend’s IP address instead of the user’s, so the redirect fails at redemption with "Access denied from another IP". Always send it.In partner mode the caller must be a trader user belonging to an organization that has an enabled, non-archived partner configuration. Organization administrators and non-trader accounts are rejected.
Code Lifetime
ttl is a request, not a guarantee. The server clamps it to the per-environment maximum (30 seconds in production), and the response’s expires_in carries the value actually stored. Omitting ttl, or sending a value of zero or less, gives 15 seconds.
Mint the code at the moment you are ready to redirect, not in advance. Only one code exists per user at a time: minting a second code invalidates the first.
Response Fields
The response is an OAuthGrantResponse. Two fields matter for this flow:
code: the single-use code. Attach it to the NinjaTrader URL you redirect the user to.expires_in: the code’s lifetime in seconds, after clamping. Note the underscore: the JSON key isexpires_in, notexpiresIn.
The idToken field is never populated by this endpoint.
Sample Call
Common Failure Scenarios
expectedClientIpis omitted, so the code is bound to your backend’s address instead of the user’s.expectedClientIpis not a valid IPv4 or IPv6 address, or exceeds 64 characters. Both are request-validation failures, so they returnHTTP 400with a field-violation body rather than theHTTP 200shape below.- The caller’s organization has no partner configuration, or that configuration is disabled or archived.
- The caller is an organization administrator or a non-trader account.
- The access token is missing or expired (returns
HTTP 401, plain-text body). - The organization exceeded its hourly quota (returns
HTTP 429, plain-text body). - The code was minted too early and expired before the user’s browser reached NinjaTrader.
Error Messages
Authentication
Bearer authentication of the form Bearer <token>, where token is your auth token.
Request
Response
Non-empty if the request failed