API Authentication
  • 16 May 2023
  • Dark
    Light
  • PDF

API Authentication

  • Dark
    Light
  • PDF

Article Summary

API authentication is a process to access Dataloop platform APIs securely. There are three ways to connect Platform API.

  1. SDK M2M Login: Long-running SDK jobs require API authentication. M2M Login is recommended when:

    • To run commands on the platform without an internet connection.
    • To run API commands directly from an external system to Dataloop.

  2. The Dataloop Swagger UI: It allows to perform API requests, such as GET, POST, PUT, PATCH, and DELETE to different endpoints in the Dataloop backend services, such as projects, datasets, tasks, etc.
    To use the Swagger UI you will need to be logged in from another tab. Authentication will be completed with the logged in user.

  3. External System: Connect Dataloop API environment from an external system which requires a JWT token. Use the JWT for every HTTP request to the platform with bearer authentication.
    This method is recommended, if you prefer to use Postman or Insomnia API platforms.

Attaining API Credentials

  • Use your email ID and password to log in to the system. Use the registered email ID and password to get a valid JWT, and ensure the user is in your domain, i.e. machine1@myCompany.com.
  • For each machine user you create, ensure you use the password (not with the Google account) to log in once into the Dataloop platform.
  • You can sign up with a Google email ID.

Working With JWT

Once your API Credentials are set, use them to obtain a JWT for the Dataloop platform. The Dataloop API uses Auth authentication scheme, where each HTTP request has JWT attached to it via the Authorization header.

Basic Flow

  • Initiate an HTTP request using API Credentials to receive a JWT.
  • As long as the JWT is not expired, you can add it as a Bearer authorization header.

Generating a JWT

The request schema is as follows:

POST https://gate.dataloop.ai/token?default
Content-Type: application/json
Body

{
    "username": "<user name>",
    "password": "<user password>",
    "type": "user_credentials"
}

An example using Postman follows:

postman_jwt_request.PNG

Click Send and a response is displayed in the following format:

{
    "access_token": "...",
    "id_token": "...",
    "refresh_token": "...",
}

Use the id_token (JWT) from the response as your authorization JWT for future requests.

JWT Expiration

Once the JWT expires, request for a new JWT. Expiration period is 24 hours.
There are many tools and libraries to decode JWTs, for example, https://jwt.io/ allows interactive decoding.

A decoded JWT as follows:

{
  "name": "Name",
  "nickname": "Name",
  "picture": "https://example.com",
  "locale": "he",
  "updated_at": "2025-09-23T06:06:17.641Z",
  "email": "zaphod@dataloop.ai",
  "email_verified": true,
  "iss": "https://dataloop-development.auth0.com/",
  "sub": "google-oauth2|101916523885779176498",
  "aud": "I44w8",
  "iat": 1569218779,
  "exp": 1569283579,
}
Note:
  • To obtain the expiration date, decode the JWT. Also, extract the exp field to get your JWT for a lifetime.
  • Ensure you refresh your JWT before its expiry date.

API HTTP Request

The Dataloop API uses Auth authentication scheme, where each HTTP request has JWT attached to it via the Authorization header.

The following example uses JWT to make a request using Postman and obtain the details of a specific project.

  1. The GET request URL is https://gate.dataloop.ai/api/v1/projects/{id}.
  2. For authentication, select the Bearer Token and enter the Token that obtained.
  3. Select the "Get" method.
  4. Press "Send".
    postman_project_get.png