Skip to content

Click in-app to access the full platform documentation for your version of DataRobot.

API tokens (deprecated)

Warning

/predApi/v1.0/api_token/ endpoint in Prediction API is deprecated.

In the UI, use the API Key Management. In the DataRobot API use:

  • POST /api/v2/api_token/ to create a new API token.
  • GET /api/v2/api_token/ to retrieve an existing API token.

If you need help using the DataRobot API routes to create or retrieve tokens, contact your DataRobot representative or Support.

DataRobot automatically assigns your account an API key. The following examples illustrate using the deprecated method. When using the legacy method, note:

  • Be sure to replace example.orm.datarobot.com with the name of your dedicated prediction instance. If you do not know whether you have a dedicated prediction instance, or it's address, contact your DataRobot representative or DataRobot Support.
  • Only Managed AI Cloud users need to supply a datarobot-key to authenticate.

!!! info “Availability information” Cloud users require a datarobot-key (not a token) to authenticate, which you can find on the Predictions > Prediction API tab or by contacting your DataRobot representative.

Retrieve token via GET

You can make a GET request to the predApi/v1.0/api_token endpoint with your username and password. This returns the same token as was returned in response to the original POST request.

On-premise example:

$ curl -X GET
"https://example.orm.datarobot.com/predApi/v1.0/api_token" -u john@example.com

{"api_token": "wKx7N68uqTns-v8xd9WJKXf9w5e0duo-"}

Managed AI Cloud example:

$ curl -H "datarobot-key: xxxx" -X GET
"https://example.orm.datarobot.com/predApi/v1.0/api_token" -u john@example.com

{"api_token": "wKx7N68uqTns-v8xd9WJKXf9w5e0duo-"}

Replace an API token

There are cases when you need to change (create a new) API token (for example, if your token has been compromised). Note that each account has a single token attached to it which is used for both the Prediction API and the DataRobot API. This request will invalidate the previous token and any automation using it will need to be updated. To change your token, make a POST request to the api/v2/api_token/ endpoint with your username and password. For example:

On-premise example:

$ curl -X POST
"https://example.orm.datarobot.com/predApi/v1.0/api_token" -u john@example.com

{"api_token": "wKx7N68uqTns-v8xd9WJKXf9w5e0duo-"}

Managed AI Cloud example:

$ curl -H "Content-Type: application/json" -X POST
"https://example.orm.datarobot.com/api/v2/api_token/"
-d '{"username": "john@example.com", "password": "thisIsAPassword"}'

{"api_token": "wKx7N68uqTns-v8xd9WJKXf9w5e0duo-"}

2FA

If two-factor authentication is enabled for you account, you'll need to provide a second factor in the HTTP request. When using predApi/v1.0 you can either use header X-DataRobot-totpCode to submit a TOTP code (the one generated by an authenticator app) or X-DataRobot-recoveryCode to submit a recovery code. For api/v2 you'll need to submit the corresponding value in JSON payload as totpCode or recoveryCode.

The following example uses TOTP code 000000. You'll need to replace it with the value generated by your authenticator app.

On-premise example:

$ curl -H "X-DataRobot-totpCode: 000000" -X GET
"https://example.orm.datarobot.com/predApi/v1.0/api_token" -u john@example.com
-H "X-DataRobot-totpCode: 000000"

{"api_token": "wKx7N68uqTns-v8xd9WJKXf9w5e0duo-"}

Managed AI Cloud example (retrieve):

$ curl -H "datarobot-key: xxxx" -H "X-DataRobot-totpCode: 000000" -X GET
"https://example.orm.datarobot.com/predApi/v1.0/api_token" -u john@example.com

{"api_token": "wKx7N68uqTns-v8xd9WJKXf9w5e0duo-"}

Managed AI Cloud example (replace):

$ curl -H "Content-Type: application/json" -X POST
"https://example.orm.datarobot.com/api/v2/api_token/"
-d '{"username": "john@example.com", "password": "thisIsAPassword", "totpCode": "000000"}

{"api_token": "wKx7N68uqTns-v8xd9WJKXf9w5e0duo-"}

Updated October 26, 2021
Back to top